Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 07:14 11 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CMM2: Recommendations for joystick/game controller I/F standard

     Page 2 of 5    
Author Message
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1595
Posted: 02:11am 06 Jul 2020
Copy link to clipboard 
Print this post

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: Australia
Posts: 1595
Posted: 06:13am 06 Jul 2020
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 8600
Posted: 07:20am 06 Jul 2020
Copy link to clipboard 
Print this post

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: Australia
Posts: 1595
Posted: 11:11am 06 Jul 2020
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 3854
Posted: 11:18am 06 Jul 2020
Copy link to clipboard 
Print this post

  Turbo46 said  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


I'm confused and would like educating.

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
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 3854
Posted: 11:22am 06 Jul 2020
Copy link to clipboard 
Print this post

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
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8600
Posted: 11:42am 06 Jul 2020
Copy link to clipboard 
Print this post

  Quote  I'm confused and would like educating.


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: Australia
Posts: 1595
Posted: 11:53am 06 Jul 2020
Copy link to clipboard 
Print this post

  Quote  butchering a Wii Classic controller for its PCB

Butchering? Maybe there is a better term for it but the result would be a bit untidy.
  Quote  the use of a secondary/cheaper microcontroller between the joystick and the CMM2's Nunchuck port.

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.
  Quote  not as nice as simply tying the joystick and its buttons directly into the CMM2's digital inputs

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 Kingdom
Posts: 3854
Posted: 12:01pm 06 Jul 2020
Copy link to clipboard 
Print this post

  matherp said  The issue is that anyone can write code with any I/O pins being used for anything ...


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

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


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
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
MauroXavier
Guru

Joined: 06/03/2016
Location: Brazil
Posts: 303
Posted: 12:19pm 06 Jul 2020
Copy link to clipboard 
Print this post

  matherp said  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


Oh yes! This will open great possibilities!
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3675
Posted: 12:33pm 06 Jul 2020
Copy link to clipboard 
Print this post

  thwill said  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 ?

Tom

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 States
Posts: 3024
Posted: 12:36pm 06 Jul 2020
Copy link to clipboard 
Print this post

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: Australia
Posts: 341
Posted: 03:09pm 06 Jul 2020
Copy link to clipboard 
Print this post

  lizby said  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 does look like it's reusing an I2C pin pair though.

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

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: Australia
Posts: 341
Posted: 06:36am 21 Jul 2020
Copy link to clipboard 
Print this post

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: Australia
Posts: 341
Posted: 03:05am 22 Jul 2020
Copy link to clipboard 
Print this post

Replying to myself...

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


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.

  capsikin said  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?

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 States
Posts: 527
Posted: 04:07am 22 Jul 2020
Copy link to clipboard 
Print this post

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: Australia
Posts: 1595
Posted: 04:52am 22 Jul 2020
Copy link to clipboard 
Print this post

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 States
Posts: 110
Posted: 05:01am 22 Jul 2020
Copy link to clipboard 
Print this post

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: Australia
Posts: 1595
Posted: 05:12am 22 Jul 2020
Copy link to clipboard 
Print this post

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 States
Posts: 110
Posted: 08:25am 22 Jul 2020
Copy link to clipboard 
Print this post

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
 
     Page 2 of 5    
Print this page
© JAQ Software 2024