Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 17:00 26 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 : MMB4W Controller interface

     Page 2 of 3    
Author Message
Turbo46

Guru

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

Thanks everyone,

I've seen an SC project that uses an Arduino to simulate a keyboard but that's not for me. C is in my past and will remain there. If someone else wants to run with that I'd be pleased to help if I can.

The HT82K629A keyboard chip is more my speed but once you have chosen the keys and hardwired them there is little scope for flexibility.

Jim's Serial to HID Keyboard emulator requires something (a 'mite?) to convert the button press to serial and that would mean an extra lag. It does allow some flexibility though and the lag may be negligible.

Thanks again.

Bill
Keep safe. Live long and prosper.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6787
Posted: 09:23am 12 Dec 2023
Copy link to clipboard 
Print this post

I don't think there's going to be any appreciable lag from a serial-HID keyboard converter if the serial port is reasonable. After all, it basically *is* a keyboard. I might consider one of the designs using a pico to do the keyboard emulation. It's probably faster than the arduino and I prefer Python to C. :)
Mick

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

Joined: 18/11/2011
Location: United Kingdom
Posts: 3801
Posted: 09:25am 12 Dec 2023
Copy link to clipboard 
Print this post

Importantly, I meant whatever the device is it should have the same buttons etc as you'd use with a Game*mite.

That way anyone could develop software on MMB4W if they wished before changing it minimally to work on an actual Game*mite.

It would be even better if NO changes were needed but that's not possible due to the lack of GPIO etc on a standard PC.

John
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6787
Posted: 09:43am 12 Dec 2023
Copy link to clipboard 
Print this post

It looks relatively easy to emulate Game*Mite controls using keyboard emulation. No reason why you couldn't have a Game*Mite-type board but with the Pico emulating a USB keyboard rather than driving a display. The PC would be set to use keyboard input, of course, and would "see" the expected keys being pressed.

That doesn't mean it *is* easy, of course. :)
Mick

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

Joined: 18/11/2011
Location: United Kingdom
Posts: 3801
Posted: 11:48am 12 Dec 2023
Copy link to clipboard 
Print this post

There's no existing USB-oriented code to run on the Pico to do that, is there?

Whereas using a USB serial or similar device the non-PC (e.g. Pico) end just has to send chars over a serial interface - trivial in MMBasic, for example.

John
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6787
Posted: 12:21pm 12 Dec 2023
Copy link to clipboard 
Print this post

Not in MMBasic, no. There is in Circuit Python though.
Mick

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

Joined: 18/11/2011
Location: United Kingdom
Posts: 3801
Posted: 12:40pm 12 Dec 2023
Copy link to clipboard 
Print this post

  Mixtel90 said  Not in MMBasic, no. There is in Circuit Python though.

After you with that...

John
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6787
Posted: 12:57pm 12 Dec 2023
Copy link to clipboard 
Print this post

I've made a start by downloading Thonny. :)


============================

Edit:
Yes, it can definitely be done in Circuit Python. I'm just playing with the early stages of using my prototype PZ Control to send alphanumeric characters (e.g. W,A,S,D) to a PC. It's probably possible to send any character or string that a PS2 keyboard can send. Not experimented with special characters like the arrow keys yet.

EDIT 2:
Yes! The Keycode library supports things like RIGHT_ARROW, F1 and TAB so this is looking easier.  :)  Should be feasible to use a (real 16-bit) SNES controller or a PZ Control natively on a Pico or CMM2 and via a Pico or similar to a USB input on a PC.
 Programming in Python is strange after MMBasic.
Edited 2023-12-13 02:10 by Mixtel90
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:03pm 16 Dec 2023
Copy link to clipboard 
Print this post

Hi Mick,

Do you intend to carry on with this? I would like to achieve some useable end result out of it. Please let me know if you are not and I will muddle along in my own way. But it won't involve Circuit Python.

Bill
Keep safe. Live long and prosper.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6787
Posted: 11:26am 17 Dec 2023
Copy link to clipboard 
Print this post

Please go ahead if you wish. :)

I used Circuit Python for one particular reason - it has HID support which MMBasic hasn't. You can squirt characters out to the console via USB, but AFAIK MMB4W has no way of seeing them from within a game. I might be wrong. Using HID allows me to simulate key presses on the keyboard so it will work with any game that has keyboard support. I'm not at all fluent in Python so it's not a quick job.

In addition I've also been trying to sort out the mechanical aspects of controllers. I now have PZee Control, which needs a little more polish to check the positions of the shoulder buttons, I think. Apart from that it's ready to get some boards made, but that won't be until the new year now.
Mick

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

Joined: 11/12/2012
Location: United Kingdom
Posts: 9115
Posted: 12:20pm 17 Dec 2023
Copy link to clipboard 
Print this post

MMB4W has full support for serial ports so a Pico outputting on the console port would wotk fine
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6787
Posted: 12:38pm 17 Dec 2023
Copy link to clipboard 
Print this post

That makes things *much* easier. Thanks Peter. :)
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: 08:18pm 17 Dec 2023
Copy link to clipboard 
Print this post

  Quote  MMB4W has full support for serial ports so a Pico outputting on the console port would work fine

The trouble as I see it is - what port will Windows decide to allocate to the com port? It may be different sometimes on the same PC let alone different PCs. That means you can't hard code it into a game.

This post has led me to believe that, providing the PC will happily accept having two keyboards, then emulating a keyboard or HID (Human Interface Device) is the best plug and play solution. You can't unplug the existing keyboard on a laptop.

Possible methods are:

The Pico can be programmed to look like an HID using Circuit Python as Mick is looking at. That would be a viable option if it comes to fruition but I don't like Mick's keypad layout (sorry Mick). Tom and Big Mick went to a lot of trouble to get that layout the best it could be and that's what I like. 'Tis a pity that MMBasic on the Pico doesn't support operation as an HID.  

Some versions of the Arduino can made to do HID emulation also. But not by me.

The "Serial to HID Keyboard Emulator" that Jim linked to is an option but needs an additional device to scan the buttons and convert the button selection to ASCII. A PicoMite or a Micromite could do that to keep it in the family.

The HT82K629A keyboard chip or similar wired up to a Game*Mite type keypad seems to be the simplest option and is probably what I will look at.

Bill
Keep safe. Live long and prosper.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6787
Posted: 09:02pm 17 Dec 2023
Copy link to clipboard 
Print this post

You can have any keypad layout you like providing you stick within the pin capabilities of the device you are using. PZee Control only has a lot of buttons to make it easy to use with Pico PETSCII, which struggles with the Game*Mite keypad. It would be very easy to make a Game*Mite controls compatible version.

The Circuit Python code is easily changed, you simply specify which pins are inputs and which sends which character. At the moment I only have it sending single characters. That needs changing to handle multiple button presses - especially a Game*Mite version.

If I could arrange the insides of a consistent version of the SNE controller then PZee Control wouldn't exist. :)
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: 04:51am 18 Dec 2023
Copy link to clipboard 
Print this post

I found this today. I looks very simple to use, just connect a USB cable, wire up a few switches and away you go. KB103 - powered by USB it looks almost too easy.





I may have to buy a couple.

Bill
Keep safe. Live long and prosper.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6098
Posted: 06:23am 18 Dec 2023
Copy link to clipboard 
Print this post

That is a good find Bill.
It would be ideal for interfacing a few buttons or digital joystick (if both sides of the buttons are available).

My option would suit converting a wii or nunchuk using a pico.

I originally purchased it to simulate high speed typing to test MMEdit cos my typing is way too slow for stress testing.

I wouldn't be too concerned about serial ports and finding them.
Even MMB4W could scan each com port in turn skipping over errors and looking for a suitable response. You wold only have to do it when the remembered port doesn't respond.

Jim
VK7JH
MMedit   MMBasic Help
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6787
Posted: 07:56am 18 Dec 2023
Copy link to clipboard 
Print this post

Handy device for using up that stock of 1.8mm pitch card edge connectors. :)
You may need the "with socket" version to stand a chance.

Nice little module. It actually does a lot more than we need though as it's a full x-y matrix keyboard scanner. You can hard wire particular keys but you can't redefine a key for a different game very easily. That's relatively easy in software.


========================================

EDIT:
Game*Mite version of PZee Control is on the other thread now. :)
Edited 2023-12-18 18:39 by Mixtel90
Mick

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

Joined: 31/01/2020
Location: France
Posts: 76
Posted: 10:48am 18 Dec 2023
Copy link to clipboard 
Print this post

@Jim ,

  Quote  My option would suit converting a wii or nunchuk using a pico.


If you dont have it done , here is my Wii joystick drivers for STM32 from 2014  


wii_cc.zip

And how to use it :


#include "stm32f4xx.h"
#include "wii_cc.h"

char StrNumber[40];
WII_CC_DATA wii_data;

void Wii_Classic_Controller_Test(void);

int main(void)
{
 // Init the Wii Classic Controller
 wiiCCInit();
 Wii_Classic_Controller_Test();
}

void Wii_Classic_Controller_Test(void)
{
 while(wii_data.buttons.a != 1)
 {
   wiiCCRead(&wii_data);

   sprintf(StrNumber, "left analog x  : %d", wii_data.left_analog_x);
   sprintf(StrNumber, "left analog y  : %d", wii_data.left_analog_y);
   sprintf(StrNumber, "right analog x : %d", wii_data.right_analog_x);
   sprintf(StrNumber, "right analog y : %d", wii_data.right_analog_y);
   sprintf(StrNumber, "buttons a      : %d", wii_data.buttons.a);
   sprintf(StrNumber, "buttons b      : %d", wii_data.buttons.b);
   sprintf(StrNumber, "buttons right  : %d", wii_data.buttons.right);
   sprintf(StrNumber, "buttons left   : %d", wii_data.buttons.left);
   sprintf(StrNumber, "buttons up     : %d", wii_data.buttons.up);
   sprintf(StrNumber, "buttons down   : %d", wii_data.buttons.down);
   sprintf(StrNumber, "rtrigger push  : %d", wii_data.buttons.rtrigger_push);
   sprintf(StrNumber, "ltrigger push  : %d", wii_data.buttons.ltrigger_push);
   sprintf(StrNumber, "buttons home   : %d", wii_data.buttons.home);
   sprintf(StrNumber, "buttons minus  : %d", wii_data.buttons.minus);
   sprintf(StrNumber, "buttons plus   : %d", wii_data.buttons.plus);
   sprintf(StrNumber, "buttons x      : %d", wii_data.buttons.x);
   sprintf(StrNumber, "buttons y      : %d", wii_data.buttons.y);
   sprintf(StrNumber, "buttons zr     : %d", wii_data.buttons.zr);
   sprintf(StrNumber, "buttons zl     : %d", wii_data.buttons.zl);
   delay_ms(25);
   }
}



It worked very well.
You can check the result here at 2m47 , "sorry for the crap video"  

wii test youtube


Cheers.
Edited 2023-12-19 09:05 by darthvader
Theory is when we know everything but nothing work ...
Practice is when everything work but no one know why ;)
 
Turbo46

Guru

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

  Mixtel90 said  You can hard wire particular keys but you can't redefine a key for a different game very easily.

That is true but do you really want to modify the controller to suit each game? There are not many controllers that you can reconfigure as far as I know. Much easier to just modify the game and only have to do it once.

  TassyJim said  It would be ideal for interfacing a ... digital joystick

Yes, One could make something like this Which supposedly works on a PC but I can't find any useful information. Maybe Xbox?

Bill
Keep safe. Live long and prosper.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6098
Posted: 06:59am 19 Dec 2023
Copy link to clipboard 
Print this post

  Quote  Yes, One could make something like this Which supposedly works on a PC but I can't find any useful information. Maybe Xbox?

That should be usable provided you can get to all the switch terminals and cut out the existing electronics. Hopefully there is room to squeeze the other board in as well.

Jim
VK7JH
MMedit   MMBasic Help
 
     Page 2 of 3    
Print this page
© JAQ Software 2024