Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 03:42 27 Nov 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 : Controllers - here's an approach

     Page 2 of 2    
Author Message
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2129
Posted: 07:51pm 19 Dec 2023
Copy link to clipboard 
Print this post

  Mixtel90 said  The code is no problem - I just haven't finished writing it yet. You'll be welcome to it once it's done. :) I've had an early version running so I'm happy that it's possible. I do need to standardize on the IO pins though and I can't do that without a PCB design. There's no point in releasing the code so that everyone can build incompatible controllers with it. :)

I've used the RP2040-Zero for several reasons:
It's less than half the price of a Pico
It has USB-C
It has a built in WS LED & reset button
It's a lot smaller than a Pico.

There's plenty of IO available for a controller, including four ADC ports so you could have two analogue joysticks if you wanted to. I could have used a standard Pico but it simply doesn't fit mechanically where I want it to go. Unfortunately it's not veroboard friendly, but as I've no intention of using it like that it doesn't matter. :)

You mentioned it before so I looked it up and even ae near same price as rpi pico and no basic programming :( like saying use a arduino nano for io and analogue.,, (which I could do with gcb and help to interface to mmb as aside)
This universal controller is giving me a haddock,it's not carp but whale kipper whelk um in the eel side
What games need analogue joysticks? missile command? how do you do the slow pixel at a time plot for line xs,ys to xe,ye? l8r .
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6795
Posted: 08:35pm 19 Dec 2023
Copy link to clipboard 
Print this post

Why design a system that's limited to start off with and is going to have to be replaced later? If the controller is programmable it is very easy to update. You might not want analogue just at the moment, but what about in a couple of months?

I now have three PCB designs:
Game*Mite buttons
SNES-a-like but with buttons on both sides (I can't do a D-pad)
Analogue + digital (you can use the joystick as a variable sensitivity D-pad)
They all use the same RP2040-Zero and can all be programmed in MMBasic.
All three can be I2C or TTL serial. I've been experimenting with HID over USB using Circuit Python, but that's not a necessity.

The RP2040-Zero is a normal Pico but smaller. Same chip, same ram. Just less pins. They run MMBsic just like a Pico does. They are available under the Waveshare name or generic on AE. They are about £1.80 each. Here.. Don't just buy one, they work out expensive that way. Get 5 or so to qualify for free shipping.
Edited 2023-12-20 06:37 by Mixtel90
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1109
Posted: 08:38pm 19 Dec 2023
Copy link to clipboard 
Print this post

Here is the list of what the Wii controller built into the firmware can report:
DEVICE(WII funct)

Returns data from a Wii Classic controller.
'funct' is a 1 or 2 letter code indicating the information to return as follows:
T  returns the ID code of the controller - should be hex &H4200101
LX returns the position of the analog left joystick x axis
LY returns the position of the analog left joystick y axis
RX returns the position of the analog right joystick x axis
RY returns the position of the analog right joystick y axis
L  returns the position of the analog left button
R  returns the position of the analog right button
B  returns a bitmap of the state of all the buttons. A bit will be set to 1 if the button is pressed.
The button bitmap is as follows:
BIT 0: Button R
BIT 1: Button start
BIT 2: Button home
BIT 3: Button select
BIT 4: Button L
BIT 5: Button down cursor
BIT 6: Button right cursor
BIT 7: Button up cursor
BIT 8: Button left cursor
BIT 9: Button ZR
BIT 10: Button x
BIT 11: Button a
BIT 12: Button y
BIT 13: Button b
BIT 14: Button ZL

The nice part is that the data just magically appears. My programs don't have to do anything other than start the controller.

For others building or interfacing a controller, look at this list of buttons and inputs and determine if your desired controller can be covered by what is on the list. As it stands, the list holds 6 analog readings and 15 digital signals. A sixteenth digital one could be added, I'm sure.

Could the firmware be modified or augmented so that the signals from other controllers are put into suitable positions in this list. For many controllers, this means some of the positions will be blank. For others, the definitions might be slightly different. Maybe a CSub could be written, that is automagically called by the firmware at some rate and reads the hardware (somehow - serial, SPI, I2C, port pins, whatever) and populates the list with the results.

The other question is how to get more than one controller, for two (or more) player games. I could imagine that opening a controller determines both the type and which position (out of 2, 4?) it occupies.
Visit Vegipete's *Mite Library for cool programs.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6795
Posted: 08:45pm 19 Dec 2023
Copy link to clipboard 
Print this post

You can't have more than one WII controller on a port as they all have the same I2C address which is hard-wired. The PicoMite implementation depends on it being on System I2C, so you can only have one anyway.

My proposed I2C system would normally allow 4 controllers on one port. That's a restriction that I propose because of cable capacitance. Four player games are unlikely on a PicoMite anyway. :)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1611
Posted: 11:25pm 19 Dec 2023
Copy link to clipboard 
Print this post

This subject has been going on since the dawn of the Maximite. In over 20 years we have not even achieved a standard set of input pins for a joystick let alone anything more complex.

Way back when Nick developed Maxman (AKA Pacman) for the mono Maximite he provided control using Keyboard, Nunchuk and Joystick but there were no standards.

For what it's worth, I have played Tom's Lazer Cycle on the CMM2 (PS Labs Deluxe) with every controller that it supports and they all work flawlessly. I think it is the closest we are going to get to any standard. I'm not much of a gamer and any game that needs more than a joystick is probably too much for my tired old brain and arthritic fingers though.

I can imagine using a 'black box' running Tom's controller library talking to MMB4W using something like Peter's original post describes but would worry about any lag that it might introduce. A method of determining which port was allocated by Windows for that device would go a long way to making it viable. You don't want to have people having to use Device Manager to identify which port to open.

Of course if MMB4W could one of the available USB controllers that would be almost ideal.

One last thing: Stan, Please stop banging on about the mcp23017. You are probably the only one to want to use bit 7 of either port as an input against the manufactures recommendation. I may work for you but YOU cannot guarantee it!

Bill
Keep safe. Live long and prosper.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4040
Posted: 11:50pm 19 Dec 2023
Copy link to clipboard 
Print this post

  vegipete said  Could the firmware be modified or augmented so that the signals from other controllers are put into suitable positions in this list. For many controllers, this means some of the positions will be blank.


<banging-on>

It's not the firmware, but that's exactly what my controller library does, returns the same bit-pattern (for NES, SNES, Atari Joystick and Game*Mite) as the Wii Classic controllers do on CMM2 and PicoMite.

</banging-on>

Best wishes,

Tom
Edited 2023-12-20 09:51 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
al18
Senior Member

Joined: 06/07/2019
Location: United States
Posts: 205
Posted: 01:34am 20 Dec 2023
Copy link to clipboard 
Print this post

I think the Wii Classic Controller is an excellent choice.

While I enjoy building PicoMites, when I’m gaming I want an ergonomically designed controller that works well and will continue to work for years without fixing it. If it does break, I can easily buy a replacement.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6098
Posted: 05:12am 20 Dec 2023
Copy link to clipboard 
Print this post

  Quote   A method of determining which port was allocated by Windows for that device would go a long way to making it viable. You don't want to have people having to use Device Manager to identify which port to open.

This snippit is all you need to scan for ports that are present.
 '
 FOR n = 1 TO 32
   ON ERROR SKIP
   OPEN "com"+STR$(n)+":115200" AS #2
   
   IF MM.ERRNO THEN
     ' print mm.errmsg$
   ELSE
     PRINT "com"+STR$(n)+" present"
     'pause(100)
     test$ = INPUT$(20,#2)
     PRINT test$
     CLOSE #2
   ENDIF
 NEXT n
END
 

If your Wii emulator is running and spitting out data, there should be something recognisable in the buffer.
You can use that to work out which port is the one you want.

I put this on a pico
'
DO
PRINT "Hello Wii people"
PAUSE(10)
LOOP


and the results from the scan running in MMBasic for DOS was:
Windows MMBasic Ver 5.05.05
Copyright 2011-2021 Geoff Graham

com4 present

com5 present

com6 present
ople
Hello Wii peop
com7 present

>


com6 is the one we want.

Unfortunately, there seems to be a bug in MMB4W



I tried a number of different betas with the same result.
Bugger...

Jim
VK7JH
MMedit   MMBasic Help
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1611
Posted: 06:42am 20 Dec 2023
Copy link to clipboard 
Print this post

Thanks Jim, I tried that in MMBasic for DOS and MMB4W and the scanning code works well. I had no com ports used but plugged in my MM2 test/programming board and it was then found.

One way I thought of identifying the games port would be to first scan the ports and build an array of ports identified (just noughts and ones), have the user plug the device in, then rescan. The new device will be on the newly found com port.

The MMBasic for DOS response looks funny:
com6 present
ople
Hello Wii peop
com7 present

Was that some type of typo? or was that actually what you saw?
AHA! no you just got the end of one message and the beginning of the next.  

An arcade type games controller would be easy to realize with an MM2, a serial to USB and a few buttons and resistors. A Wii interface could be even simpler if we could use the USB to simulate a keyboard.

But first the bug needs squashing.



Bill

PS plugging in a second keyboard also works well - I'm typing on it now
Keep safe. Live long and prosper.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9120
Posted: 08:34am 20 Dec 2023
Copy link to clipboard 
Print this post

On  MMB4W you can you the function comport(n) to test if a port exists without using the abomination that is "on error"
 
LeoNicolas

Guru

Joined: 07/10/2020
Location: Canada
Posts: 479
Posted: 03:44pm 20 Dec 2023
Copy link to clipboard 
Print this post

I'm just watching this discussion because I'm not a hardware engineer, and for sure, my suggestion, if I had one, will sound dumb  

The results you decide will be great for the MMBasic community and the games we are developing for the platforms. I couldn't implement support for gamepads yet in Knightmare because MMB4W doesn't support them. For me, the development workflow from the MMB4W is much better than developing directly on the target machine. After completing the game I will tweak the source code (or anyone who wants to) to run on other machines.
 
Bleep
Guru

Joined: 09/01/2022
Location: United Kingdom
Posts: 509
Posted: 06:40pm 20 Dec 2023
Copy link to clipboard 
Print this post

I bought a Wii classic, because it's cheap & there was hardware support now built in, interfacing it to Petscii Robots was very simple, it supports 2 analogue joysticks, 1 up/down/left/right switch & 11 various other buttons, I realise my interpretation of what knobs/buttons to use for Petscii may not be optimal, but they are trivial to change to whatever you may want. So my vote is to stick with Wii Classic or Pro, I think electricly they are the same, they just added handles & moved some of the buttons a bit. From a game point of view I can't envisage needing more.
Regards Kevin.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6795
Posted: 07:27pm 20 Dec 2023
Copy link to clipboard 
Print this post

The Pro has some bits moved around, the wire out of the back and the "shoulder" buttons changed from analogue+ s witch to switch only. You used to be able to get similar handles to fit the normal Classic onto.

If I had the right screwdriver I'd try opening mine up, taking the latch mechanism out and re-routing the wire through the hole where the latch button is.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Bleep
Guru

Joined: 09/01/2022
Location: United Kingdom
Posts: 509
Posted: 07:49pm 20 Dec 2023
Copy link to clipboard 
Print this post

Yes I will probably do that, the wire out the bottom seems wrong.
Regards Kevin
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6795
Posted: 08:45pm 20 Dec 2023
Copy link to clipboard 
Print this post

You have to remember how they are intended to be used - plugged into a wiicontroller, which gives a bluetooth link to the box. The lead is towards user because the wiicontroller is on their belt or round their neck. A short lead is fine, as is a fixed I2C address.

The screwdriver is a little 3-wing design that needs to be long enough to get down the holes. I have a security bit that would probably do it but it's too short. :(
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1611
Posted: 09:01pm 20 Dec 2023
Copy link to clipboard 
Print this post

  matherp said  On  MMB4W you can you the function comport(n) to test if a port exists without using the abomination that is "on error"

Thank you Peter, this works:
'
FOR n = 1 TO 32
   if Comport(n) then
     PRINT "com"+STR$(n)+" present"
   ENDIF
 NEXT n
END


I have not updated to the latest MMB4W yet.

Bill
Keep safe. Live long and prosper.
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1611
Posted: 05:05am 21 Dec 2023
Copy link to clipboard 
Print this post

For interest sake:

If I have Teraterm connected to a 'mite and run the program:
FOR n = 1 TO 32
  ON ERROR SKIP
  OPEN "com"+STR$(n)+":38400" AS #2
  IF MM.ERRNO THEN
  ELSE
    PRINT "com"+STR$(n)+" present"
    test$ = INPUT$(20,#2)
    PRINT test$
    CLOSE #2
  ENDIF
NEXT n
END

Does not detect the port but it does if I close down Teraterm though.

The program:
FOR n = 1 TO 32
  if Comport(n) then
    PRINT "com"+STR$(n)+" present"
  ENDIF
NEXT n
END

method does detect the port whether the port is active or not.

So the ON ERROR method may still be useful for detecting a device plugged in but not yet in use.

Bill
Keep safe. Live long and prosper.
 
     Page 2 of 2    
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024