USB game controllers and mice

Started by Duke, 01:30, 02 February 19

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Duke


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, 16.5 euro
Imperium Solo with DC Y splitter cable and adapter for CPC plus, 16.5 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

mr_lou

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 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.

Duke

Quote from: mr_lou on 09:28, 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 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.

VincentGR

Hey Duke, will the mouse work normally or will need a kick to scroll like a joystick?
Seen this to another adapter I have.

HAL6128

Yeah... same question. It would be good to test it on OCP Art Studio to get a smooth and proper movement.
...proudly supported Schnapps Demo, Pentomino and NQ-Music-Disc with GFX

Duke

Quote from: VincentGR 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.
Quote from: HAL 6128 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.

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?

GUNHED

#6
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!  :) :) :)   
http://futureos.de --> Get the revolutionary FutureOS (Update: 2022.03.09)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

Duke

#7
Quote from: GUNHED 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!  :) :) :)
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.

VincentGR

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.

Duke

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.

HAL6128

Yes. It would be good to have some kind of adjustments (speed, acceleration) from software side.
...proudly supported Schnapps Demo, Pentomino and NQ-Music-Disc with GFX

Duke

Quote from: HAL 6128 on 00:00, 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.

TotO

#12
Quote from: HAL 6128 on 00:00, 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.
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

Duke

#13
Quote from: TotO on 11:34, 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.

Bryce

The problem with custom methods is that it then makes the device non-compatible with all software with mouse support from back then.

Bryce.

Duke

Quote from: Bryce 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.
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.

GUNHED

Quote from: Duke on 19:06, 03 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 (Update: 2022.03.09)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

TotO

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)

TotO

#18
Quote from: Duke on 12:39, 04 February 19One 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.
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

Duke

#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:

    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.

GUNHED

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 (Update: 2022.03.09)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

TotO

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)

GUNHED

Quote from: TotO 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 (Update: 2022.03.09)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

HAL6128

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 Schnapps Demo, Pentomino and NQ-Music-Disc with GFX

Duke

Quote from: HAL 6128 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.)?
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.

Powered by SMFPacks Menu Editor Mod