![]() |
Forum Index : Microcontroller and PC projects : CMM2: Recommendations for joystick/game controller I/F standard
![]() ![]() ![]() ![]() |
|||||
Author | Message | ||||
Turbo46![]() Guru ![]() Joined: 24/12/2017 Location: AustraliaPosts: 1636 |
Thanks AZ. Could I please make another suggestion for joystick pin allocation? If I am correct, it is unlikely that analogue and digital joysticks will be used in the same game? so how about using the analogue pins for one or the other to suit joystick being used: analog x1 / digital up - pin 7 analog y1 / digital down - pin 13 analog x2 / digital left - pin 15 analog y2 / digital right - pin 26 Button A - pin 32 Button B - pin 33 Button C - pin 27 Button D - pin 28 That means that joystick with a pot(paddle?) is not catered for but it should leave enough pins for a second joystick if the need arises but that may interfere with COMs functions. Bill Keep safe. Live long and prosper. |
||||
Turbo46![]() Guru ![]() Joined: 24/12/2017 Location: AustraliaPosts: 1636 |
This shows the pins chosen by VegePete along with the normal functions. ![]() Bill Keep safe. Live long and prosper. |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10010 |
All Thanks for the input. Thinking about it more my view is to just implement the Wii Classic as this does everything that anyone could need. The firmware will support up to three controllers on the three I2C ports as per the Nunchuk. In the next release the NUNCHUK command will change to WII NUNCHUK and there will be a new subcommand WII CLASSIC The NUNCHUK() function will remain as-is and a new function CLASSIC() will handle that controller. I have a Classic on order so should have beta firmware by the end of next week. If you want to build a games console like CG's then the simple solution is to hack a classic and remote the required buttons. By standardising on the Nunchuk and the Classic code can be developed with a good expectation that a user will have, or can cheaply acquire, the required input device and that the program will work without modification |
||||
Turbo46![]() Guru ![]() Joined: 24/12/2017 Location: AustraliaPosts: 1636 |
Thanks Peter, I'm sure that will be popular but it's a pity that the original purpose of this post wasn't achieved. A standard approach to joysticks would have been appreciated. Bill Keep safe. Live long and prosper. |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4245 |
I'm confused ![]() Naively I would have thought any joystick could be attached now. Either by butchering a Wii Classic controller for its PCB or by the use of a secondary/cheaper microcontroller between the joystick and the CMM2's Nunchuck port. I guess that's not as nice as simply tying the joystick and its buttons directly into the CMM2's digital inputs but it does mean we only have to support a single "Wii Nunchuk/Classic" standard. Regards, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4245 |
My suggestion to game developers who happen to read this: Consider using a level of indirection between your controller hardware reading code (in a separate .inc file) and your game engine. That way you or your users can just swap out the hardware reading specifics ... the CMM2 version of a device driver. Regards, Tom Edited 2020-07-06 21:22 by thwill MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10010 |
The issue is that anyone can write code with any I/O pins being used for anything. Suppose I've built a clever USB I/F for some particular controller and I connect it to pins 3,5,15, etc. or I simply connect switches to a particular selection of pins. If I publish my code no-one else can run it without mimicking my controller and connecting it up exactly like I did. By encouraging all developers to use either a Wii Nunchuk or Wii Classic and by building in support into the firmware then everyone can run the code by simply spending a very few dollars for the "standard" controller. Of course coding with some indirection is good practice but it would still mean the end user having to implement their own H/W compatibility function unless they used the same controller and same pin connections as you. |
||||
Turbo46![]() Guru ![]() Joined: 24/12/2017 Location: AustraliaPosts: 1636 |
Butchering? Maybe there is a better term for it but the result would be a bit untidy. That's what I have done and I will test it when Australia Post decide to deliver my CMM2 - three weeks and three days from across the ditch so far. Agreed. Nick Marentes who wrote MAXMAN and DONUT provided for the use of Joystick, Keyboard and Nunchuk so I don't know why others can't. A joystick requires no changes to the firmware just a consistent approach by games programmers and a standard pin allocation would go some way to encourage that. Bill Keep safe. Live long and prosper. |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4245 |
Sorry, yes, I knew 90% of that, you assumed the wrong-level of cluelessness ![]() My question was regarding the following: If there is a defined hardware standard, i.e. Wii Nunchuck/Classic and that standard uses a published protocol over I2C then cannot someone interface any other joystick/controller via a cheaper microcontroller to do the native -> I2C conversion ? I get the impression that Bill might be able to do the h/w end of that blindfolded ![]() Yes, but for the moment the user base is pretty technically savvy and if for example everyone put their (hopefully thin) controller code in "control.inc" the the user or some other helpful soul would have a step-up towards making the necessary changes. Regards, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
MauroXavier Guru ![]() Joined: 06/03/2016 Location: BrazilPosts: 303 |
Oh yes! This will open great possibilities! |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 3989 |
So long as it uses the same interface, including accepting the same commands and delivering compatible results, it'll work OK. John |
||||
lizby Guru ![]() Joined: 17/05/2016 Location: United StatesPosts: 3299 |
And surely if someone is not into nunchuk butchering, following the pin suggestions of matherp/vegipete/Turbo46 would go a long way towards insuring compatibility and non-interference with other hardware which might be connected to the pi-format header (e.g., I2C, Tx1/Rx1, Tx2/Rx2, SPI, PWM 1A/B/C). It's not certain to me that C driver code would be required--standardized Basic routines should be quick enough to handle human interface requirements, no? It could be a convention rather than a standard, with little or no functionality baked in to MMBasic. PS: I get the feeling that vegipete may already have hardware and software which uses this convention (and perhaps starts to establish the software parts of it). ~ Edited 2020-07-06 22:47 by lizby PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
capsikin Guru ![]() Joined: 30/06/2020 Location: AustraliaPosts: 341 |
It does look like it's reusing an I2C pin pair though. I think that's right. The existing SETPIN command and PIN command and function already let the program access pins, and not much more should be needed -- Caspian |
||||
capsikin Guru ![]() Joined: 30/06/2020 Location: AustraliaPosts: 341 |
Anyone who is using part of this convention, do you have any CMM2 basic code to share for setting up and reading the joystick/controller, either a game or test program? |
||||
capsikin Guru ![]() Joined: 30/06/2020 Location: AustraliaPosts: 341 |
Replying to myself... I reread things and thought about it more - both I2C and the joystick buttons use pull high, active low signal, and so the signals shouldn't harm each other. Maybe you already thought of that when you designed it. I saw an example here that I think I can adapt to the CMM2 pin assignments. 'initialisation SetPin 35,din,pullup ' joystick digital up SetPin 36,din,pullup ' joystick digital down SetPin 38,din,pullup ' joystick digital left SetPin 40,din,pullup ' joystick digital right SetPin 32,din,pullup ' joystick button A 'Check movements GoRight = 0 : GoUp = 0 : GoLeft = 0 keypressed = keydown(1) 'Joystick up or button for thrust. If (Pin(35) = 0) Or (Pin(32) = 0) Or keypressed = 128) Then GoUP = 1 If (Pin(40) = 0) Or keypressed = 131) Then GoRight = 1 If (Pin(38) = 0) Or keypressed = 130) Then GoLeft = 1 Might be better with some constants set for the PIN numbers, but it's a start. Edited 2020-07-22 13:08 by capsikin |
||||
Quazee137![]() Guru ![]() Joined: 07/08/2016 Location: United StatesPosts: 586 |
Why not use something like MCP23017 - i2c 16 input/output port expander could plug into Wii port could do maybe two controllers. I added to this adding two Edited 2020-07-22 14:14 by Quazee137 |
||||
Turbo46![]() Guru ![]() Joined: 24/12/2017 Location: AustraliaPosts: 1636 |
As I said before, it's a pity that the original reason for this post was not achieved. I would like to build an I/O interface box in a case the same as the CMM1 and 2 to provide communications ports and an Atari joystick connector among other things. A standard pin allocation for joysticks would allow that. There is no point doing that if everyone is going to go their own way as they did for the original Maximites. I don't want to remove the lid to move jumpers around. I would love to have a 'standard' joystick pin allocation included in the manual as threatened above. Probably the suggestions above could be refined a little because: 1. It is unlikely that a nunchuk and a joystick will be used at the same time. 2. It is also unlikely that an analogue joystick and a digital one will be used at the same time. 3. It would be best to avoid communications ports because that has been a sticking point in the past. 4. Probably only need to consider one joystick because I suspect that the vast majority of games will be single player. I also like Tom's idea of a 'controls.inc' file that games programmers could use in their games to provide a standard allocation of controls functions. So many games have already been written and are being written that I fear it may be too late already. ![]() Bill Keep safe. Live long and prosper. |
||||
berighteous Senior Member ![]() Joined: 18/07/2020 Location: United StatesPosts: 110 |
how do you connect more than one classic controller to the nunchuk port? And can't we just put a hub on the usb port and have multiple usb game controllers? |
||||
Turbo46![]() Guru ![]() Joined: 24/12/2017 Location: AustraliaPosts: 1636 |
The manual says that you cannot use a USB hub. To connect a second and third controller you need to use the other I2C pins on the rear connector and provide your own nunchuk connector(s). Check out the link in Quazee137's post earlier in this thread. Bill Edited 2020-07-22 15:17 by Turbo46 Keep safe. Live long and prosper. |
||||
berighteous Senior Member ![]() Joined: 18/07/2020 Location: United StatesPosts: 110 |
So basically we need a little box that plugs into the back of the maximite with two nunchuk ports on the back. Something like this? Whack one end off and solder to a connector on the gpio? https://www.amazon.com/Extension-Nintendo-Classic-Controller-Nunchuck-Extender/dp/B01MYTE1HW |
||||
![]() ![]() ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |