![]() |
Forum Index : Microcontroller and PC projects : CMM2: Recommendations for joystick/game controller I/F standard
Page 1 of 5 ![]() ![]() |
|||||
Author | Message | ||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10008 |
This has been a topic of discussion elsewhere so here are my recommendations for a joystick I/F standard. Use this thread to add comments in order to reach a general consensus. If this is agreed it will be included in the manual and any external devices should then be built to meet the standard. All digital pins to be pulled high and will be active low. NB: all digital pins are 5V capable. Analog inputs to be in range 0-3.3V. Center zero inputs should give a value of 1.65V analog x - pin 7 analog y - pin 13 analog z - pin 15 digital up - pin 35 digital down - pin 36 digital left - pin 38 digital right - pin 40 Button A - pin 32 Button B - pin 33 Button C - pin 27 Button D - pin 28 |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4245 |
I can't comment on "the electronics" but you should define a standard to allow at least 2 joystick/game controllers ... with a bit of luck we will have Gauntlet so you could argue we need a standard for 4 controllers. Regards, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
lizby Guru ![]() Joined: 17/05/2016 Location: United StatesPosts: 3299 |
How to find all that on this: ![]() PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
mkopack73 Senior Member ![]() Joined: 03/07/2020 Location: United StatesPosts: 261 |
Joysticks come in several flavors. The old Atari 9 pin used discrete digital on/off pins for up/down/left/right and fire, and a pair of analog pins for analog paddles 1 and 2. Later newer devices that supported more buttons changed to a shift register style approach where bits were read in batches and depending upon which functions were activated (pressed), certain bits would be set. This takes slightly more work to process but allows for way more functions on the port with less pins needed. (It’s effectively serial communications between the game stick and the computer). 8-Bit guy did a good video on this where he adapted a NES gamepads controller time work on a C64 and he explains it all really well: https://youtu.be/71HCFKvDby0 Given that it’s pretty straightforward to make a circuit to convert the Atari style to work in a shift register style setup, I would suggest going with the shift register style as the standard, and then adapters can be created to convert from that to whatever port/type you want. As such it shouldn’t take more than 6-8 pins per controller to support Dual analog sticks (4 pins) and however many buttons/d-pads you want (2 pins, since you probably need a clock line) with power+ground and maybe some other pin for a latch signal or something like that. |
||||
robert.rozee Guru ![]() Joined: 31/12/2012 Location: New ZealandPosts: 2396 |
hi peter, just an idea to consider: instead of using the inputs on the 40-pin connector, how about using a small PIC or arduino attached to the nunchuk port. this is assuming that the port is accessible from MMbasic as a general purpose SPI port, and that the nunchuk protocol is generally available. or a completely new protocol could be used. if someone came up with a very simple design using something like a 1455 (or arduino, or even an MX170 running a basic program), this could then act as a bridge between existing joystick(s)/controller(s) and the nunchuk port. the micro that acts as the bridge could even be built into a nunchuk plug housing. the downside of this idea is that connecting up a joystick/controller would be more complicated than just connecting up a few wires. but it is just an idea. regarding centre-zero inputs, from the perspective of simplifying some aspects of controller design i'd like to suggest that the centre voltage be defined by an external resistive divider (two resistors of identical value) strung between 3v3 and ground, and read by a defined analog input pin. having that centre voltage available to external electronics sidesteps a whole load of problems that may crop up later on. cheers, rob :-) Edited 2020-07-03 23:32 by robert.rozee |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10008 |
I have to confess I have less than zero interest in this but it seems to be exercising some people so I started the thread FWIW my preferred approach is to support just the Nunchuk and the WII classic. These are both I2C connected and this allows up to 3 controllers to be connected at any one time. I can include firmware support for the WII Classic but I'm not going to do that unless there is a general consensus. The issue is that it is pointless developing a program for a controller that only you possess if you want it to be generally used. External uP devices and shift registers don't solve the issue they are just a H/W approach. The develop needs to know that UP produces some specific input that he can code to. My simple proposal above does that as does the WII-only approach |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4245 |
Thanks "lizby", I mispoke, I could comment on "the electronics" as I understand the principles and have interfaced one of the shift-register style NES controllers to the CMM1 before now. However I don't have the breadth of experience or inclination to argue one hardware design against another. The point I really wanted to make is that it should support at least 2 controllers and facilitate the creation of a standard controller interface board to attach to the GPIO so users who aren't interested in hardware can use it without being expected to attach their own Heath Robinson contraption by flying leads. Regards, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
mkopack73 Senior Member ![]() Joined: 03/07/2020 Location: United StatesPosts: 261 |
I agree there needs to be some sort of standard defined. As I see it, the shift register style approach has a lot of merit as it's easy to convert to, takes very few pins and little glue logic to make it work. Could literally define a bit encoding "standard": Button 1-32 as bits. 4 more axis for analog (supports 2 sticks). You then define a standard such as: Button 1 = DPad 1 up Button 2= DPad 1 down Button 3=DPad 1 left Button 4 = DPad 1 right Button 5 = DPad 2 up Button 6= DPad 2 down Button 7=DPad 2 left Button 8 = DPad 2 right Button 9 - 32 = various other buttons. We have enough pins on the 40 pin GPIO to run at least 4 controllers like that. So have the OS report that back as: Port 1, Pot1X,Pot1Y,Pot2X,Pot2X,Button stream You take the button stream back and XOR it with the pattern you want to check (up, down, left, right, etc) to get which function is being done... So long as everyone wires up their sticks to match the mapping, everything works fine. You have enough bits there to handle basically every type of joystick you can think of (including some of the more advanced PC ones before the switch over to USB)... I'm sure something similar could be done with I2C as well... Again, it all just comes down to defining both the electrical hardware configuration and the software mapping so it's standardized for everyone to use and expect the same thing. |
||||
Turbo46![]() Guru ![]() Joined: 24/12/2017 Location: AustraliaPosts: 1636 |
Thank you for the proposal Peter. It seems to me that perhaps a standard for one joystick would be the best approach and if more joysticks are needed then a different approach is needed. I hope it can be settled on without too much kerfuffle. If I recall correctly, the issue with the CMM1 joystick controls was that some of the pins chosen where also used for communications and that meant that an external device could not be controlled by a joystick using the 'standard' pins. I have already written a program for a 170 to take an input from a joystick and interface it to the nunchuk port using the same principle as Rob described. The joystick switches will switch the centre point of a resistor divider high or low to simulate an analogue joystick. An analogue joystick could also be used - replacing the resistor divider. I may put this in the box that holds the arcade style joystick I have shown elsewhere. I agree but my approach will give me the best of both worlds, a joystick for my arthritis and the ability to use the existing interface. Bill Keep safe. Live long and prosper. |
||||
Sasquatch![]() Guru ![]() Joined: 08/05/2020 Location: United StatesPosts: 375 |
I'll renew my vote for native Wii Classic Controller support. Chinese copies of these controllers are about $8.00US. These are decent controllers as-is and come in several variants. The Wii Classic Controller has a D-pad, 4 "direction" buttons, two analog joysticks, and 2 or 4 "trigger" buttons. Also, they can be hacked (connector and cable + PCB) to build a plug-in adapter for the old Atari/C64 style joysticks (9pin D connector) or just about anything else you would care to interface including an arcade style console with high-quality microswitch components. -Carl |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 3989 |
You might want to say which pins a "Wii Classic Controller" would use. John |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10008 |
Uses I2C with a Nunchuk style connector - that's the great advantage of going that way |
||||
vegipete![]() Guru ![]() Joined: 29/01/2013 Location: CanadaPosts: 1121 |
I just had a look at what a "Wii Classic Controller" is and support for one of them seems to have merit. They are available off the shelf, brand new and don't require expeditions to thrift stores hoping for a lucky find. Plus they should be hack-able to connect alternate joystick mechanisms and/or buttons. The protocol is available out there for those who wish to make custom devices. ============== As far as Peter's opening proposal at the top of this thread, I would only suggest the following minor change: analog x1 - pin 7 renamed analog y1 - pin 13 renamed analog x2 - pin 15 renamed analog y2 - pin 26 extra analog pin added Everything else is perfect and AND IS NOW THE STANDARD (that I will be using for anything I write.) Visit Vegipete's *Mite Library for cool programs. |
||||
GregZone Senior Member ![]() Joined: 22/05/2020 Location: New ZealandPosts: 114 |
+1 for Wii Classic support. ![]() I'm also not a Nunchuk fan, and supporting Wii Classic controllers (which use the same interface) certainly seem like the obvious & logical "standard" solution. This should also work with my Xgaming X-Arcade, using their Wii interface adapter. |
||||
capsikin Guru ![]() Joined: 30/06/2020 Location: AustraliaPosts: 341 |
I see some appeal in the simplicity of having something where you can wire in the individual switches, and not need any other electronics, and the softare to read the pins is very simple. In that case I probably would not need the analog pins. Digital joystick and some buttons would be enough for many 80's arcade games, for example. On the other hand, I2C/Wii classic is better for allowing multiple controllers with more features, without using too many pins. I particularly like the option for multiplayer games. My preference would be to have both I2C/Wii classic, and direct pin reading similar to the proposal being discussed, including at least the 4 digital directions. Admittedly having two standards is not ideal. Maybe recommending that programs support Wii classic first, if they don't support both. |
||||
capsikin Guru ![]() Joined: 30/06/2020 Location: AustraliaPosts: 341 |
One concern about using pins 27 and 28, since I think they're also the recommended pins for one of the I2C ports. Would there be a risk of hardware damage if someone had the joystick buttons connected there as listed above, but the program was expecting the Nintendo nunchuck? That would be bad. I don't think there would be any problem the other way around (i.e. nunchuks plugged in when joystick buttons are expected), since if the program was expecting joystick buttons it would just be reading the pins. Edited 2020-07-05 14:41 by capsikin |
||||
GregZone Senior Member ![]() Joined: 22/05/2020 Location: New ZealandPosts: 114 |
In that case I probably would not need the analog pins. Digital joystick and some buttons would be enough for many 80's arcade games, for example. On the other hand, I2C/Wii classic is better for allowing multiple controllers with more features, without using too many pins. I particularly like the option for multiplayer games. My preference would be to have both I2C/Wii classic, and direct pin reading similar to the proposal being discussed, including at least the 4 digital directions. Admittedly having two standards is not ideal. Maybe recommending that programs support Wii classic first, if they don't support both. If the Wii Classic was to be supported in firmware (for coding simplicity), then for wiring up your own prefered digital joystick / buttons you could presumably avoid the "electronics" of making your own, by simply buying a cheap Chinese clone Wii Classic Controller (only a few $ on AliExpress), and rip it apart to connect your preferred switches across the DPad / Button contacts on the controller's PCB. ie. No need to play with electronics, just wire up your button switches / digital joystick switches to the Wii Controllers PCB (instead of wiring up to the CMM2's GPIO pins). This approach should allow you to make your own custom digital game controllers, but benefit from a "standard" firmware supported Wii Classic Controller interface. Just a thought to consider / explore. ![]() |
||||
Turbo46![]() Guru ![]() Joined: 24/12/2017 Location: AustraliaPosts: 1636 |
Nunchuk Wii Classic Joystick Keyboard It's starting to get complicated for a games programmer to cater for all of them. Not being a game player, I can't imagine why all of the controls on a Wii Classic are needed and if they were included in a game that would preclude people not using one from playing a game. I can't imagine too many people wanting to hack into a controller to wire up their own input devices nor games programmers providing for them. Do any games programmers even intend to use the accelerometer function of the Nunchuk? The only games I've looked at have only used the joystick and Z button and then the joystick was treated as a digital one so a good old fashioned joystick would do the same job. I would be interested in comments by games programmers. Bill Keep safe. Live long and prosper. |
||||
RC_tech Newbie ![]() Joined: 05/07/2020 Location: GermanyPosts: 14 |
I have a different approach, without wasting I/O ports, just the Nunchuk port is neccessary. The base component is the PCB of a Nunchuk controller. This has an analog joystick with two buttons. The Commodore 1351 mouse for the C64 uses the 8-bit-A/D-converters in the SID, so it outputs an analog voltage. This can be used instead of the Nunchuk's potentiometers. The 1351 also has two buttons, so it would fit perfectly. Now to digital joysticks. How to connect these? The Nunchuk uses the ST LIS3L02AL accelerometer. It outputs per axis one analog voltage. To get the different movements of a joystick, the outputs will be connected as an resistor array. So every movement will create a different voltage, even if buttons are pressed. As minimum it would possible to get five values, the four directions and the button. Optionally five more buttons could be added. How will this be possible, classic joysticks have just one button. It's easy: Instead of an DSUB9 a two-row DSUB15 is used, the PC gameport connector. If two pins are removed, a DSUB9 can be inserted, and there are four extra pins. The Atari game port always supports two buttons. So, with a custom DSUB15 connector a digital joystick with 6 buttons would be possible! And because the accelerometer has three axis, it would be possible to connect three joysticks! It would just be a matter of creating the voltages, and reading the correct values for the movements and button presses. By the way: A four-direction, six button device has 10 inputs. So, it could be configured for two standard joysticks with four directions and one button. This would allow six standard joysticks on the Nunchuk port! If this is planned, it would be better to use three DSUB25 connectors. Two DSUB9 joysticks will fit in one DSUB25 connector if some pins are removed. 3 pins in the middle of the connector will be available. These could be used to recognize if a custom device with up to 10 inputs is connected. What do you think, would this be possible? A breakout box with support for 6 joysticks and a Commodore 1351 mouse port, using a Nunchuk controller board? It would be awesome, allowing multiplayer games on the Maximite. And for Point'n'Click adventures is a mouse required. But there's an external 5V PSU neccessary, the 1351 requires 5V, the Nunchuk has just 3.3V. Greets, RC. |
||||
Atomizer_Zero Senior Member ![]() Joined: 04/07/2020 Location: United KingdomPosts: 134 |
A standard gamepad like the Wii Classic controller is ideal. Cheap, easy to find, good quality. The Wii Classic Pro controller would work too if the wii classic controller was supported and has a better form factor. I'd imagine wii arcade sticks would also work. The accelerometer is fun for ball maze games where you balance the maze and allow the ball to roll around it.. but that can also be achieved with the analog stick. I don't see many (if any) games being used with it in mind. Fighting games use anywhere from 2 to 8 buttons. platformer games use a minimum of two (jump and run), with exceptions like Super Metroid where it uses every button on the SNES controller. rpg's use probably just 2 buttons. Action rpgs though would need more than 2. In the event that a player doesn't have a controller, theres always a keyboard...sure, no analog sticks on the keyboard, but having directions mapped to WASD would probably suffice. I don't actually see the analog sticks on the classic controller being used too much when there's a D-PAD on there anyway. I highly doubt there's going to be too many (if any) 3D games like whats the Playstation 1 or Nintendo64. One more thing. Classic controller support will allow other variants of the classic controller like the Super Nintendo Classsic controller, which is directly compatible (minus the analog sticks). |
||||
Page 1 of 5 ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |