Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 16:55 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 1 of 3    
Author Message
Turbo46

Guru

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

LeoNicolas' Knightmare game he is developing and the recent addition of the Wii controller to the PicoMite firmware has got me thinking of a controller interface for MMB4W. Lizby has already demonstrated a serial client for MMB4W and I was thinking that sort of thing might be suitable for a controller interface.

I was thinking of a small PicoMite board with joystick and NES inputs like Micks PicoGAME plus a Wii connector. A small USB to serial module mounted on it would provide comms to the PC.

My thinking of the software for it is to incorporate Tom's controller library with a little extra software. The MMB4W program would tell it which controller the Pico should use. To reduce lag the Pico could poll the selected controller at a rapid rate as the CMM2 does with the Wii controllers. When the MMB4W program requests the controller input the Pico would respond with the last known state of the selected controller.

Not sure if too much data will come back from the CLASSIC but if so, the request could be for only certain blocks of data as required.

Problem: How does the MMB4W program which comms port to use? I know that you can find it in Device Manager > Ports (COM & LPT) and that some programs can find out which comms ports are available but I don't know how to do it.

Does anyone have any thoughts on the concept?

Bill
Keep safe. Live long and prosper.
 
Mixtel90

Guru

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

I could squirt bytes of data over a COM port rather than I2C on the controller I've been experimenting with, after all it has a PicoMite as its "brain". How you'd decode them at the PC end I've no idea. For a PC you really need USB though. Not many PCs have COM ports now and using a TTL serial to USB converter is a bit clonky.

There are SNES USB controllers that work on a PC but some sort of a driver might be needed to interface one to the game.

There are USB to I2C adapters on ebay. Those would be a neat way to connect I2C controllers, but using a WII Classic would need special software.
Edited 2023-12-10 19:32 by Mixtel90
Mick

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

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 11:29am 10 Dec 2023
Copy link to clipboard 
Print this post

  Quote   using a TTL serial to USB converter is a bit clunky.

Do you need a TTL / USB converter?
If your Pico based controller Prints Hex strings to its console it may be possible to get MMB4W to read and decode them.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4039
Posted: 12:20pm 10 Dec 2023
Copy link to clipboard 
Print this post

  Turbo46 said  Problem: How does the MMB4W program which comms port to use? I know that you can find it in Device Manager > Ports (COM & LPT) and that some programs can find out which comms ports are available but I don't know how to do it.


There is probably a PowerShell command/commands that can perhaps be issued using MMB4W's SYSTEM command that will provide this information.

Best wishes,

Tom
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
pwillard
Senior Member

Joined: 07/06/2022
Location: United States
Posts: 292
Posted: 12:33pm 10 Dec 2023
Copy link to clipboard 
Print this post

A simple python script can keep track of active ports...





#-------------------------------------------------------------------------------
# Name:
# Purpose:     Simple tracker for active serial ports attached to windows PC
#
# Author:      Pete Willard
#
# Created:     15/08/2023
# Copyright:   (c) willard 2023
# Licence:     CC BY-NC-SA
#-------------------------------------------------------------------------------
import serial.tools.list_ports
import time
import PySimpleGUI as sg

def main():
   layout = [
       [sg.Text("Available Serial Ports:")],
       [sg.Listbox(values=[], size=(40, 10), key="-PORTS-")],
       [sg.Button("Exit")]
   ]

   window = sg.Window("Port Tracker", layout)

   while True:
       event, values = window.read(timeout=1000)  # Auto-update every 1000 milliseconds

       if event == sg.WINDOW_CLOSED or event == "Exit":
           break

       refresh_ports(window)

   window.close()

def refresh_ports(window):
   ports = [port.device for port in serial.tools.list_ports.comports()]
   window["-PORTS-"].update(values=ports)

if __name__ == "__main__":
   main()



Could be modified to show Device ID, if you really wanted it I suppose.
 
Mixtel90

Guru

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

Hmmm....
My I2C controller (PZee Control) has the USB-C port in a good position to use it with a USB-C lead to a PC. Sending hex to the console should be fine. As I said though, it is just a PCB without a case.


Edited 2023-12-10 22:50 by Mixtel90
Mick

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

Joined: 17/05/2016
Location: United States
Posts: 3150
Posted: 03:00pm 10 Dec 2023
Copy link to clipboard 
Print this post

  Mixtel90 said  using a TTL serial to USB converter is a bit clonky


I don't understand that. Cheap and trivial to use. I probably have dozens of them: CH340 ttl/serial usb Some have been working continuously for years.

Perhaps that Waveshare RP2040-GEEK usb module pointed out by Bernie3D, with I2C and serial, would be just the ticket for attaching a controller to MMB4W.



~
Edited 2023-12-11 01:02 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Mixtel90

Guru

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

I was just thinking about it being an external dongle of some sort. Ideally I'm aiming for something that requires little or even no assembly skills, that can be used by someone who is buying into MMBasic as a gaming platform. As such I'd prefer I2C as that's available on everything, you can have more than one controller on two pins and it's supported in MMBasic. There are several USB-I2C converters so connection to a PC should be ok. However, sending hex to the "console" via the USB port is rather nice. I might add that as an option.
Mick

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

Guru

Joined: 13/08/2020
Location: Canada
Posts: 368
Posted: 05:51pm 10 Dec 2023
Copy link to clipboard 
Print this post

I've been working on addressing the issue of needing a PC to transfer files onto and off of the CMM2. Basically, my solution involves hooking up an ESP-32 chip to the COM2 port on the CMM2 (which is easily accessible from the back port on all versions, and has a dedicated spot on the motherboard on Gen 2), using the onboard WiFi chip and some cloud computing.

The ESP-32 is controlled via ASCII commands on the COM 2 port. Although it's being developed for the CMM2, there's very little reason that I can see that it can't also be used by the other Mites.





If we have an ESP-32 attached to this port anyway - it could be used as a 4 port USB hub for keyboards/mouse/game controllers and memory sticks (see project below).

https://hackaday.io/project/178213-esp32-usb-software-host

I haven't done any work on the USB side (I'm concentrating on the WiFI bit for now), but it might make sense to combine the two projects into one board? I have zero experience with the PicoMite, but I am assuming it has a buffered COM port like the CMM2. Which means you could Poll the ESP-32 to provide gamepad/joystick values at the start op the game loop, and by the time you're half way through the game loop, the values would be waiting for you in the COM2 buffer.
 
Turbo46

Guru

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

  thwill said  MMB4W has NO controller support. Hence Bill having started this thread

Exactly.

  thwill said  this is the sort of "craziness" that hardware engineers come up with when unsupervised

Then we chuck it at the software gurus and say "make it work".  

Of course a if a USB controller was supported that would be ideal but Peter hasn't said that it's impossible so I don't think that will happen.

It seems to me that MMB4W would be a good tool for developing games and utilities for the CMM2. Coupled with MMEdit, edit the program, click on a button and it runs almost instantly.

I was just looking for a game controller solution that would work without too much lag. Maybe next year I might do some experimenting.

Bill
Keep safe. Live long and prosper.
 
Mixtel90

Guru

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

To be fair, the CMM2 isn't a bad machine to do software development on anyway. Using MMB4W to do that isn't really as useful as it is with the PicoMite. Yes, you can do it, but you don't gain quite as much IMHO.

Since someone decided to drop the Centronics port from the PC it's gone downhill. ;)
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: 02:16pm 11 Dec 2023
Copy link to clipboard 
Print this post

Maybe MMB4W could use something connected as a (USB) COM port.

The something could be on the non-USB end of the device (USB end in the PC).

Maybe RP2040 on the non-USB (may as well be serial) device, handling Game buttons etc and changing them into chars to send over the serial-to-USB device.

(RP2040 is overkill but cheap & easily programmed.)

The existing games for the Game*mite would need to be changed (a little) to look for the chars arriving over the COM port.

For non-Game stuff, the RP2040 could handle I2C, SPI, etc.

John
Edited 2023-12-12 00:19 by JohnS
 
Turbo46

Guru

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

Thanks John, I think you are talking about a controller with it's own buttons? The sort of thing Mixtel90 has been playing with. Something like the Game*Mite with no screen but with a serial to USB port? That's another option.

Bill

Edit: I do seem to recall a project where someone used a keyboard chip driven by something and used it to simulate keystrokes. I think the PC thought it was a keyboard. That sort of thing may work also. I don't remember where or when I saw that.
Edited 2023-12-12 10:20 by Turbo46
Keep safe. Live long and prosper.
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 03:03am 12 Dec 2023
Copy link to clipboard 
Print this post

Here 'tis.https://www.thebackshed.com/forum/ViewTopic.php?TID=6617#69183
 
Turbo46

Guru

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

Thanks Phil, That is not the one I was thinking about but it's food for though.

I wonder what the effect of plugging a second keyboard into a PC? Easy enough to find out. I have only laptops but a few spare keyboards I can plug in.

It could be the basis for a games controller using buttons to send keyboard controls to MMB4W.

Bill
Keep safe. Live long and prosper.
 
TassyJim

Guru

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

Multiple keyboards is usually OK

I have some of these but haven't had time to play yet.


  Quote  
This module is a serial port to HID device, which is recognized as a standard USB HID keyboard device on the computer. It is suitable for one-way data transmission. It can receive the data (such as ASCII code) sent by the serial port, and according to the HID keyboard device specification, package the data into a standard keyboard code value and upload it to the computer through the USB port.

Through the provided host computer software, users can also configure the chip’s VID, PID, and various character string descriptors by themselves. No need to drive, plug and play.
Features:

   Support 12Mbps full-speed USB transmission, compatible with USB V2.0.
   The default serial port communication baud rate is 9600bps, which supports multiple serial communication formats and various common baud rate settings.
   Support 5V power supply voltage and 3.3V power supply voltage.
   You can configure the chip’s VID, PID, and various string descriptors of the chip by yourself.  (upper machine software)
   You can configure the default baud rate of the chip by yourself. (upper machine software)
   Comply with USB related specifications and HID device related specifications.
   A variety of working modes, application of different needs, can simulate the full keyboard function.
   The operation of the setting mode is simple and clear, it is easy to use, convenient and fast, and the information is complete.


https://www.electrodragon.com/product/serial-to-hid-keyboard-emulator/

Jim
VK7JH
MMedit   MMBasic Help
 
Turbo46

Guru

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

Thanks Jim, Another thing for me to follow up  

Bill
Keep safe. Live long and prosper.
 
Mixtel90

Guru

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

How about an arduino?

Or how about a WII Clasic for the PC?
Edited 2023-12-12 18:09 by Mixtel90
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: 08:08am 12 Dec 2023
Copy link to clipboard 
Print this post

  Turbo46 said  Thanks John, I think you are talking about a controller with it's own buttons? The sort of thing Mixtel90 has been playing with. Something like the Game*Mite with no screen but with a serial to USB port? That's another option.

Bill

Yes, so that you play like you're on a Game*mite but it's MMB4W with a controller which looks & feels like a Game*mite but it works with a PC.

The problem being that nowadays a PC is lacking inputs other than (mainly) USB.

John
 
Mixtel90

Guru

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

Another pico version.

Or a complete arcade game pad using a Pico. :)
Edited 2023-12-12 18:27 by Mixtel90
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
     Page 1 of 3    
Print this page
© JAQ Software 2024