Author Topic: USB game controllers and mice  (Read 7046 times)

0 Members and 1 Guest are viewing this topic.

Offline Duke

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.118
  • Country: dk
    • spinpoint.org
  • Liked: 1198
  • Likes Given: 874
USB game controllers and mice
« on: 01:30, 02 February 19 »

Had a bit of encouragement to work on my dust collecting USB to joyport board project, in bad need of a proper mouse for my Atari ST and Amiga (oups).
CPC is first of course, here is a quick video of the first testing with a USB gamepad:


https://youtu.be/CpNEHrwhOzg

Will add HID mouse driver next and hope to do a fairly generic hid parser for game controllers, otherwise atleast add the most common like PS4 & PS3 pads.



EDIT:
The device is now being sold.

Ordering procedure:
Send me a PM (with your email address) or an email and let me know what you need and for which computer, then I  will confirm and add you to my list.
And when it is ready, I will email you with Paypal details and ask for your shipping address.

Current pricing is:
Imperium Solo with DC Y splitter cable for regular CPC, 15 euro
Imperium Solo with DC Y splitter cable and adapter for CPC plus, 16 euro
Shipping worldwide (unregistered) up to 100 grams, 4 euro
+ Paypal fee which is 1 euro or pay as friend (but you loose the ability to make a claim to Paypal afaik. if you are not happy with the product etc, so up to you!)

Short instructions/information here (click on a specific game controller in the database to learn button mappings):
https://www.spinpoint.org/imperium
« Last Edit: 10:16, 26 April 19 by Duke »

Offline mr_lou

  • 6128 Plus
  • ******
  • Posts: 2.892
  • Country: dk
    • index.php?action=treasury
    • 8-bit Memoirs - a Blu-ray diskmag-like eBook about the 8-bit era
  • Liked: 1052
  • Likes Given: 2264
Re: USB game controllers and mice
« Reply #1 on: 09:28, 02 February 19 »
Nice! So this allows us to use USB gamepads for the CPC?

Like PlayStation 3/4 controllers too? And Logitech F310 / F510 / F710? Does it require firmware flashing depending on controller then?

Funnily enough, I'm involved in a minor project to do the opposite these days: Make it possible to use an Amstrad CPC joystick / gamepad for Blu-ray games.  :)
The creator of this adapter is currently writing the firmware for it that should make this possible. Then you need to flash the adapter with this firmware. If successful you should be able to play any Blu-ray game, such as Bolt's Be-Awesome Mission
Bolt's Be-Awesome Mission on your standard Blu-ray player using your Amstrad joystick.   :)
Very niche of course.
My interest in this spawned from my interest in Blu-ray homebrew games - code games in Java, and run them on PS3 + PS4 + XB1 from the very same disc.

Offline Duke

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.118
  • Country: dk
    • spinpoint.org
  • Liked: 1198
  • Likes Given: 874
Re: USB game controllers and mice
« Reply #2 on: 10:20, 02 February 19 »
Nice! So this allows us to use USB gamepads for the CPC?
Yes, and mice too.
Quote
Like PlayStation 3/4 controllers too? And Logitech F310 / F510 / F710? Does it require firmware flashing depending on controller then?
It's the plan to add as many as I can get my hands on, PS3 & 4 for sure.
It will be possible to update the firmware, when more are added to it (thumb drive required).

Quote
Funnily enough, I'm involved in a minor project to do the opposite these days: Make it possible to use an Amstrad CPC joystick / gamepad for Blu-ray games.  :)
The creator of this adapter is currently writing the firmware for it that should make this possible. Then you need to flash the adapter with this firmware. If successful you should be able to play any Blu-ray game, such as Bolt's Be-Awesome Mission
Bolt's Be-Awesome Mission on your standard Blu-ray player using your Amstrad joystick.   :)
Sounds cool :) - yeah quite the opposite. I am finding good joysticks hard to find these days. I only have 1 left, rest are garbage (non microswitches, yuck!).
Quote
Very niche of course.
My interest in this spawned from my interest in Blu-ray homebrew games - code games in Java, and run them on PS3 + PS4 + XB1 from the very same disc.
I am sure many will find it cool! - Good luck with it.

Offline VincentGR

  • 6128 Plus
  • ******
  • Posts: 1.096
  • Country: gr
    • Parts from the past.
  • Liked: 573
  • Likes Given: 1538
Re: USB game controllers and mice
« Reply #3 on: 14:13, 02 February 19 »
Hey Duke, will the mouse work normally or will need a kick to scroll like a joystick?
Seen this to another adapter I have.

Offline HAL 6128

  • 464 Plus
  • *****
  • Posts: 489
  • Country: de
    • index.php?action=treasury
  • Liked: 242
  • Likes Given: 1187
Re: USB game controllers and mice
« Reply #4 on: 17:23, 02 February 19 »
Yeah... same question. It would be good to test it on OCP Art Studio to get a smooth and proper movement.
...proudly supported Pentomino and NQ-Music-Disc with GFX

Offline Duke

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.118
  • Country: dk
    • spinpoint.org
  • Liked: 1198
  • Likes Given: 874
Re: USB game controllers and mice
« Reply #5 on: 12:52, 03 February 19 »
Hey Duke, will the mouse work normally or will need a kick to scroll like a joystick?
Seen this to another adapter I have.
Yeah... same question. It would be good to test it on OCP Art Studio to get a smooth and proper movement.

Still working on the mouse driver. I cannot remember how good ie. AMX mouse was.
Was it able to be used smoothly in ie. OCP Art Studio? or was it a chunky affair?
And @VincentGR what do you mean with needing a kick?  Like set the mouse of in one direction and pull it again to stop going?

Offline GUNHED

  • 6128 Plus
  • ******
  • Posts: 1.313
  • Country: de
  • Reincarnation of TFM
    • FutureOS - The quickest OS for the CPC and Plus
  • Liked: 712
  • Likes Given: 1589
Re: USB game controllers and mice
« Reply #6 on: 16:20, 03 February 19 »
Just an idea... There are Adaptors for f.e. Atari ST mice for the CPC. They transfer proportional data instead of joystick-compatible data.

Here an example:
http://www.cpcwiki.eu/index.php/Atari-ST_mouse_adapter

Would it be possible to have a small switch, for joy-mode / proportional mode? So we can get proportional data from such an USB mouse? There is already some well software for it (including G-Paint!). That would be awesome!  :) :) :)   
« Last Edit: 16:23, 03 February 19 by GUNHED »
http://futureos.de --> Get the revolutionary FutureOS (Recent update: 2019.08.07)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2019.08.14)

Offline Duke

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.118
  • Country: dk
    • spinpoint.org
  • Liked: 1198
  • Likes Given: 874
Re: USB game controllers and mice
« Reply #7 on: 19:06, 03 February 19 »
Just an idea... There are Adaptors for f.e. Atari ST mice for the CPC. They transfer proportional data instead of joystick-compatible data.

Here an example:
http://www.cpcwiki.eu/index.php/Atari-ST_mouse_adapter

Would it be possible to have a small switch, for joy-mode / proportional mode? So we can get proportional data from such an USB mouse? There is already some well software for it (including G-Paint!). That would be awesome!  :) :) :)
It may be :)
How would I test it in FutureOS - I mean quick guide to enable ST / Amiga Mouse mode in FutureOS (don't have one for my ST :) but I think it is just to swap x,y iirc).. Thanks.
« Last Edit: 22:09, 03 February 19 by Duke »

Offline VincentGR

  • 6128 Plus
  • ******
  • Posts: 1.096
  • Country: gr
    • Parts from the past.
  • Liked: 573
  • Likes Given: 1538
Re: USB game controllers and mice
« Reply #8 on: 20:34, 03 February 19 »
My adapter works like a joystick scroll at the beginning and later moves like a mouse until I stop it.
I can't draw like this.

Offline Duke

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.118
  • Country: dk
    • spinpoint.org
  • Liked: 1198
  • Likes Given: 874
Re: USB game controllers and mice
« Reply #9 on: 22:05, 03 February 19 »
Current progress of mouse implementation:

https://www.youtube.com/watch?v=5fA4fb1rmYQ

It's hard to get it good in regular "joystick" mode. I wonder how it compares to AMX mouse atm.

Offline HAL 6128

  • 464 Plus
  • *****
  • Posts: 489
  • Country: de
    • index.php?action=treasury
  • Liked: 242
  • Likes Given: 1187
Re: USB game controllers and mice
« Reply #10 on: 00:00, 04 February 19 »
Yes. It would be good to have some kind of adjustments (speed, acceleration) from software side.
...proudly supported Pentomino and NQ-Music-Disc with GFX

Offline Duke

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.118
  • Country: dk
    • spinpoint.org
  • Liked: 1198
  • Likes Given: 874
Re: USB game controllers and mice
« Reply #11 on: 00:33, 04 February 19 »
Yes. It would be good to have some kind of adjustments (speed, acceleration) from software side.
Yes, finetuning it now. I can do some averaging & keep  moving for repeated frames until new direction or the mouse move (steps) count out.
But at the end of the day, software like Art Studio reads the joystick port only 50 times per second, so technically that is 50 pixels per second in either direction, but of course it also does its own acceleration when a direction is continuously pressed, so this is where I can adjust the mouse driver a bit to simulate the move like a joystick.
Ideally I add a secondary mode, ie. something like @GUNHED suggested for proper accelleration.

Offline TotO

  • 6128 Plus
  • ******
  • Posts: 3.408
  • Country: fr
    • ?area=showdonations;u=4
  • Liked: 2592
  • Likes Given: 1525
Re: USB game controllers and mice
« Reply #12 on: 11:34, 04 February 19 »
Yes. It would be good to have some kind of adjustments (speed, acceleration) from software side.
The adapter should embed some counters to handle the mouse ballistic to produce usable values, to not have extra computing into the softwares.
« Last Edit: 11:39, 04 February 19 by TotO »
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

Offline Duke

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.118
  • Country: dk
    • spinpoint.org
  • Liked: 1198
  • Likes Given: 874
Re: USB game controllers and mice
« Reply #13 on: 12:39, 04 February 19 »
The adapter should embed some counters to handle the mouse ballistic to produce usable values, to not have extra computing into the softwares.
As for a custom defined mode, yes.
USB mouses use delta offset from last position, so if you send this value to CPC you already have ballistics as CPC then has the movement over time.
One way to do it would be to have two consecutive reads of the joyport (key scan row) per frame, where first value read is delta X (say 5 bits) and 2nd value is delta Y . Remaining bits for ID (ΔX or ΔY) & buttons (3).
Using 5 bits you will acheive a max. speed of 31 pixels per frame or 50 * 31 = 1550 pixels per second, so you can like on PC move quickly from one side of the screen to the other.

Edit: actually it would need a sign bit for the direction changes, but still sufficiently fast at approx 800 pixels per second.
« Last Edit: 12:43, 04 February 19 by Duke »

Offline Bryce

  • The Hardware Guy.
  • Supporter
  • 6128 Plus
  • *
  • Posts: 10.982
  • Country: wf
  • It's not broken, it just hasn't been fixed yet.
    • index.php?action=treasury
  • Liked: 3862
  • Likes Given: 401
Re: USB game controllers and mice
« Reply #14 on: 13:15, 04 February 19 »
The problem with custom methods is that it then makes the device non-compatible with all software with mouse support from back then.

Bryce.

Offline Duke

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.118
  • Country: dk
    • spinpoint.org
  • Liked: 1198
  • Likes Given: 874
Re: USB game controllers and mice
« Reply #15 on: 13:23, 04 February 19 »
The problem with custom methods is that it then makes the device non-compatible with all software with mouse support from back then.
Yes, agreed. It would need to support the old "AMX" method too. But if someone wants to implement a better way in their software the "new" method could be used.

Offline GUNHED

  • 6128 Plus
  • ******
  • Posts: 1.313
  • Country: de
  • Reincarnation of TFM
    • FutureOS - The quickest OS for the CPC and Plus
  • Liked: 712
  • Likes Given: 1589
Re: USB game controllers and mice
« Reply #16 on: 13:47, 04 February 19 »
It may be :)
How would I test it in FutureOS - I mean quick guide to enable ST / Amiga Mouse mode in FutureOS (don't have one for my ST :) but I think it is just to swap x,y iirc).. Thanks.

Just plug it in and it will work. The mouse-adapter will set the spare pin on the joystick port to indicate the proportional mouse.  :) :) :)

Oh, this does not work for 6128 Plus, because it lacks the spare signal.
 
http://futureos.de --> Get the revolutionary FutureOS (Recent update: 2019.08.07)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2019.08.14)

Offline TotO

  • 6128 Plus
  • ******
  • Posts: 3.408
  • Country: fr
    • ?area=showdonations;u=4
  • Liked: 2592
  • Likes Given: 1525
Re: USB game controllers and mice
« Reply #17 on: 14:23, 04 February 19 »
AMX is a poor joystick on a ball... A pure shit to use for few old softwares that have better to be patched to be able to properly use them instead of the keyboard or that.
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

Offline TotO

  • 6128 Plus
  • ******
  • Posts: 3.408
  • Country: fr
    • ?area=showdonations;u=4
  • Liked: 2592
  • Likes Given: 1525
Re: USB game controllers and mice
« Reply #18 on: 14:58, 04 February 19 »
One way to do it would be to have two consecutive reads of the joyport (key scan row) per frame, where first value read is delta X (say 5 bits) and 2nd value is delta Y. Remaining bits for ID (ΔX or ΔY) & buttons (3). Using 5 bits you will acheive a max. speed of 31 pixels per frame or 50 * 31 = 1550 pixels per second, so you can like on PC move quickly from one side of the screen to the other. Edit: actually it would need a sign bit for the direction changes, but still sufficiently fast at approx 800 pixels per second.
Should be 4bit with up to 300Hz interrup. But sure, 5/6bit is great. Unused bits to set the actions.
« Last Edit: 15:03, 04 February 19 by TotO »
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

Offline Duke

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.118
  • Country: dk
    • spinpoint.org
  • Liked: 1198
  • Likes Given: 874
Re: USB game controllers and mice
« Reply #19 on: 20:33, 05 February 19 »

Tried to experiment with a custom mode, for those interested below is a video of the result.
It's sending 5 bits of delta X and Y + sign bit, so 6 bits total for each delta coordinate and 1 bit to indicate if its X or Y.
The program I wrote quickly to test, is in mode 2 and only reads  the mouse once per frame.


https://youtu.be/4Rm1psdePbg

The result is much better than my AMX mode test, also beware I am no artist ;)

Here is the code to read the DX/DY values:
Code: [Select]
    ld a,0x49
    call key_scan

    bit 5,a        ; 0 = delta X, 1 = delta Y
    jr    nz,isDeltaY
   
    ld hl,(xpos)
    bit 6,a        ; check sign bit
    jr nz, dx_not_signed
    and 0x1F        ; keep lower 5 bits
    ld e,a
    ld d,0
    or a
    sbc hl,de
    ld (xpos),hl
    jr    delta_done
dx_not_signed:       
    and 0x1F        ; keep lower 5 bits
    ld e,a
    ld d,0
    add hl,de
    ld (xpos),hl
    jr    delta_done
isDeltaY:
    ld a,0x49
    call key_scan
    ...
    ; same stuff as for DX
delta_done:   
    ...
   
xpos: dw 0
ypos: dw 0


I will have to up the format to two more packet, as I don't have room for buttons in this mode when compatible with CPC plus (no fire3), the ID bit to be 2 bits (00, 01, 10)
So like this:
ID DATA
00 XXXX
01 XXBB
10 YYYY
11 YYBB

Also Basic wont like my packet sending when its scanning the keyboard, so need to figure out how to "enable" enhanced mode.. Maybe just a button on the PCB (yeah sucks) or press both mouse buttons when inserting (otherwise AMX mode).

Let me know what the you think.
« Last Edit: 20:56, 05 February 19 by Duke »

Offline GUNHED

  • 6128 Plus
  • ******
  • Posts: 1.313
  • Country: de
  • Reincarnation of TFM
    • FutureOS - The quickest OS for the CPC and Plus
  • Liked: 712
  • Likes Given: 1589
Re: USB game controllers and mice
« Reply #20 on: 21:26, 05 February 19 »
Of course it would be nice to have something super fancy, but somebody needs to patch soft then.
IMHO it's great to have something compatible which does run with already existing software. I like this project.  :) :) :)
http://futureos.de --> Get the revolutionary FutureOS (Recent update: 2019.08.07)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2019.08.14)

Offline TotO

  • 6128 Plus
  • ******
  • Posts: 3.408
  • Country: fr
    • ?area=showdonations;u=4
  • Liked: 2592
  • Likes Given: 1525
Re: USB game controllers and mice
« Reply #21 on: 22:08, 05 February 19 »
How many softwares will require to be patcked? 1, 2, 5 ?  ;D
Probably less work that doing a special adapter... And they will be better after that.
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

Offline GUNHED

  • 6128 Plus
  • ******
  • Posts: 1.313
  • Country: de
  • Reincarnation of TFM
    • FutureOS - The quickest OS for the CPC and Plus
  • Liked: 712
  • Likes Given: 1589
Re: USB game controllers and mice
« Reply #22 on: 22:08, 05 February 19 »
How many softwares will require to be patcked? 1, 2, 5 ?  ;D


For something new? 99%  ;)
http://futureos.de --> Get the revolutionary FutureOS (Recent update: 2019.08.07)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2019.08.14)

Offline HAL 6128

  • 464 Plus
  • *****
  • Posts: 489
  • Country: de
    • index.php?action=treasury
  • Liked: 242
  • Likes Given: 1187
Re: USB game controllers and mice
« Reply #23 on: 20:13, 10 February 19 »
How about the idea to integrate an AD-converter on the stick which reads out a analog signal (AD571 > 10 Bits in 0,000015 sec.)?
...proudly supported Pentomino and NQ-Music-Disc with GFX

Offline Duke

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.118
  • Country: dk
    • spinpoint.org
  • Liked: 1198
  • Likes Given: 874
Re: USB game controllers and mice
« Reply #24 on: 22:01, 10 February 19 »
How about the idea to integrate an AD-converter on the stick which reads out a analog signal (AD571 > 10 Bits in 0,000015 sec.)?
Not sure for what advantage?
 The USB readings are all digital, although they can contain analog readings.
Fwiw. I have pretty good success with a 5 bit resolution for mouse movement, I did try to patch Art Studio to read my 4 packet format and all goes swell until I pick up some paint tool, where the screen updating starts to lag for some reason I have not found why yet.
Otherwise the mouse can accelerate very nicely across the screen with effortless movement. Which imo. is impossible with AMX mouse, regardless of sensitivity level, as it will take several seconds moving from one side of screen to the other (even with a constant direction for every reading).
Spent a bit too much time on patching Adv. Art Studio :/ - Rather than writing the device firmware.
Anyway, I will try to finish it up, in the next weekend or two.

Main usage will be USB gamepads as plain joysticks and USB mouse as AMX mouse  (sucky as it is, but compatible with whatever there is).
Enhanced 5 bit resolution mode for USB mouse and enhanced gamepad mode, will be available too, but not as default setting.
The board will be upgradable via USB thumb-drive.