News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

CPC464 Wireless Controller/Gamepad

Started by dannyh, 15:17, 13 August 25

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

dannyh

Hi All,

Just wanted to share a little something I put together last night. I'm sure it's been done by others many times before. I've been struggling to find a gamepad for my 464. I unscrewed a few of the aftermarket "Mega Drive" style pads, but they contained chips for the rapid-fire etc., meaning rewiring them internally wasn't as straightforward as I'd hoped. After digging through some boxes, I grabbed an EPS32 and a ULN2803A, and knocked together a very crude bluetooth host/joystick interface. Surprisingly (considering my soldering skills) it worked flawlessly the first time and I can now use my Xbox controller (or any other Bluetooth controller) with my 464!  :)

You cannot view this attachment.You cannot view this attachment.

This weekend I might try to make a PCB/boxed version and see if I can power it from the +5v of the joystick port. Also, because there's plenty of spare buttons not in use on the controller, I'm going to try and implement rapid-fire, macros etc. in the ESP code. Should keep me busy for a few days.

I used the BluePad32 library on the ESP32...
https://github.com/ricardoquesada/bluepad32




arnoldemu

How many fire buttons on the amstrad side are supported?
Also does this have the equivalent of diodes to prevent keyboard/joystick clash?

dannyh

Hi Arnold,

Currently I've wired up the two fire buttons. Apparently there's a third (undocumented) FIRE button pin for a mouse or something like that? I didn't bother with that. The joystick port allows connection of 2 joysticks using the COM/COM2 pins, so technically you could connect two controllers to the same ESP for 2 player games etc.

I'm not 100% on the diodes, but the ULN2803A does have internal suppression diodes, so I don't think external are needed. I didn't notice any keyboard noise during use.

Brocky

#3
i dont think you even need the ULN2803A... should be able to connect the esp32 directly

this has given me an idea to upgrade my DIY arcade style joystick i built for my CPC, to wireless, by hooking up an esp32 and battery inside it.. and an ESP32 on the cpc side....
and the benefit, i could then use a ESP32 on my PC and use the joystick for things like mame!

dannyh

Hi Brocky,

The ESP32 is 3.3v and the port is 5v active low. I didn't want to risk feeding 5v into a 3.3v chip hence using the ULN2803A. It might work direct, I wouldn't like to try. I'd be too scared about frying something in my 464  :laugh:




arnoldemu

Quote from: dannyh on 16:48, 13 August 25Hi Arnold,

Currently I've wired up the two fire buttons. Apparently there's a third (undocumented) FIRE button pin for a mouse or something like that? I didn't bother with that. The joystick port allows connection of 2 joysticks using the COM/COM2 pins, so technically you could connect two controllers to the same ESP for 2 player games etc.

I'm not 100% on the diodes, but the ULN2803A does have internal suppression diodes, so I don't think external are needed. I didn't notice any keyboard noise during use.
Two button support: nice. I was thinking 2 buttons is ideal for games. 

I'd definitely agree with supporting a 2nd pad.

You can check for keyboard/joystick  clash in the following way.

On a CPC:

Run Gauntlet: https://www.cpc-power.com/index.php?page=detail&num=960
Choose 2 player with one using keyboard and the other using joystick.

Press two of the keyboard controls for one player  (e.g. down and left might do it), and at the same time press up on the joystick for other player and if you then see this other character move to the side or fire then this is the issue the use of diodes can resolve. It definitely happens with this game on CPC and it's frustrating.



Brocky

#6
Quote from: dannyh on 23:03, 13 August 25Hi Brocky,
The ESP32 is 3.3v and the port is 5v active low. I didn't want to risk feeding 5v into a 3.3v chip hence using the ULN2803A. It might work direct, I wouldn't like to try. I'd be too scared about frying something in my 464  :laugh:
https://www.voodoo.business/blog/2021/05/19/are-the-esp32-and-esp8266-5v-tolerant-yes-they-officially-are/

they sink the current fine on the digital IO... the board in your photo has a 5v power input pin too by the looks of it..hence the voltage reg (derp USB is 5v! but theres usually a pin ya can use to power, or take 5v from if using usb..)

they just wont output 5v..stuck at 3.3v...but 3.3v is often enough to trigger 5v logic..

GUNHED

Cool thing! If it ever gets released Fire 3 would be a gem, for AMX Pagemaker / Stop Press for example amog other software.  :)
http://futureos.de --> Get the revolutionary FutureOS (Update: 2024.10.27)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

kawickboy

There is a third button supported but only on the classic range CPC 464/664/6128. This no more available on 464+/6128+/GX series.
AMX mouse is a good example.

eto

I guess we could easily support up 8 buttons on the CPC and Plus by using COM2 (basically use the second joystick port for additional buttons). Sure, it would not work for two player games but they are rare anyway. 

andycadley

Quote from: eto on 15:10, 19 August 25I guess we could easily support up 8 buttons on the CPC and Plus by using COM2 (basically use the second joystick port for additional buttons). Sure, it would not work for two player games but they are rare anyway.
I've pondered something similar. Indeed with a Plus and a suitably ridiculous cable you can support two analog sticks and 12 different buttons (Four directions and two fire buttons per player) so there is basically enough for most of the buttons of an XBox controller... 

eto

Quote from: andycadley on 16:10, 19 August 25Indeed with a Plus and a suitably ridiculous cable
Also with the CPC. 

And no need for a ridiculous cable I think. All signals are available on the first joystick port on both the CPC and the Plus. 

I guess at the moment the ESP puts the data on the bus when COM goes low. The only difference is to connect one more GPIO and put the data for the additional buttons on the bus when COM2 goes low. 

andycadley

Quote from: eto on 16:19, 19 August 25
Quote from: andycadley on 16:10, 19 August 25Indeed with a Plus and a suitably ridiculous cable
Also with the CPC.

And no need for a ridiculous cable I think. All signals are available on the first joystick port on both the CPC and the Plus.

I guess at the moment the ESP puts the data on the bus when COM goes low. The only difference is to connect one more GPIO and put the data for the additional buttons on the bus when COM2 goes low.
Not if you wanted the analog sticks too. Although I suspect that is diminishing returns, so not entirely serious.

But having a standard for connecting even say SNES style controllers onto the CPC and mapping to both digital joysticks in a predictable way might be a useful thing. At the moment the utility of all the GX ports that map extra controls onto Joystick 2 largely depends on how people imagine the layout. If we could agree that Joystick 2 L/R map to shoulder buttons, for example, coming up with controls that feel natural by default would be easier.

I guess the first thing would be finding a suitable modern controller that is abundantly available and has the right configuration of buttons. The Xbox or PlayStation controllers seem like a natural choice, although the analog sticks are kind of in the way a bit if you're always playing with the D-pad on the Xbox. So maybe an interface for PS controllers is the way to go?

GUNHED

Quote from: kawickboy on 09:56, 19 August 25There is a third button supported but only on the classic range CPC 464/664/6128. This no more available on 464+/6128+/GX series.
AMX mouse is a good example.
Just solder a single diode into the 6128plus and you have Fire 3 again :-)
http://futureos.de --> Get the revolutionary FutureOS (Update: 2024.10.27)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

dannyh

I've removed the ULN2803A and added diodes as there was keyboard 'clash'. Thanks to Brocky and Arnold for the advice. It's working much better now. I've managed to get 2 controllers to work simultaneously (an xbox and a playstation). I've tried to implement rapid-fire (with mixed results) by holding down one of the spare controller buttons. I guess it depends on how often the game polls the joystick/keyboard for input. I'll keep experimenting. Next I'll implement FIRE3 see how that goes.



Powered by SMFPacks Menu Editor Mod