Keyboard input over serial into Pi. How to inject characters into ES, Retroarch?
-
Hello, a request for help please. I have searched “serial”, “keyboard” and other keywords and would like to request some guidance please. I briefly looked at the xbox controller input drivers but failed to follow if that was a good or bad idea to pursue. TIA for any guidance here please!
I have a working Retropie installation and would like to connect an external keyboard, over serial. The idea; to type characters on the external keyboard and see them appear in Retropie, to a) navigate Emulation station and b) these characters to appear as keypresses within the emulated systems i.e. zxspectrum, Atari 800, Amstrad CPC, and [ideally] also the retroarch emulations.
Background: I have a Commodore SX-64 (a portable Commodore 64) that’s had an LCD mod and gained an extra VGA input. So as well as the working 'C64' hardware, it’s now also got a Pi Zero W fitted, running Retropie connected to that spare VGA input.
I want to type on the 64’s keyboard and see the keypresses processed by ES and the emulated systems as if it was a USB keyboard plugged into the pi. This is just because what’s cooler than an SX-64? An sx-64 that can also switch to Retropie.
I already have a basic program running on the C64 that captures ASCII keypresses, sends those over the user port to the pi, then via a CH340 serial>usb adaptor. This plugs into the Pi USB port. It is detected as /dev/ttyusb0. The C64’s ASCII keypress data is [presently] read in via Python/pyserial library running on the pi, and printed on screen. This part seems to work.
I would now like to inject the characters from python into ES and retroarch. How best do this please?
Notes:
- Some of the ASCII codes I expect to trap and change to map to Function key codes etc. (I can work that out)
- I had assumed I’ll need encode the ASCII as Unicode in python (I can work that out)
- I could instead bring the serial data into the pi over GPIO pins if that helps (I can work that out)
- I note if I reset ES’s input settings, reboot without a normal USB keyboard it doesn’t detect the serial> usb device or any keypresses. I guess its not a HID device(?)
- I did consider redirecting output to a tty or similar to achieve this but dont know if it'll work , or which one. Uinput? another function?
Questions!:
I looked at the es_input cfg file, does that config also apply to emulated systems under retroarch or otherwise?And once I have this working, If I set up ES with a normal USB keyboard and later remove it totally, will I still be able to inject chars or codes into ES and Retroarch?
Please could someone provide some guidance how to acheive this injection etc.
has anyone done anything similar they could share details how they did it?
Thank you v much for any guidance.
Iain :)System details:
Pi Model or other hardware: (Pi Zero W)
Power Supply used: (SX-64’s 12v , over a a 12v>5v regulator. Set to 5.2v)
RetroPie Version Used (4.4 from the Retropie site):
Built From: (Pre made SD Image on RetroPie website, Retropie 0/1, retropie-4.4-rpi..img.gz)
USB Devices connected: 1 x CH340 serial>usb adaptor
Controller used: none yet
Error messages received: none
Log found in /dev/shm/runcommand.log (if relevant):
Guide used: (Mention if you followed a guide) none yet
File: (File with issue - with FULL path) none yet
Emulator: (Name of emulator - if applicable) would like it to work with zxspectrum, Amstradcpc, vice. -
Maybe something like UHID - https://dvdhrm.wordpress.com/2012/07/16/uhid-user-space-hid-io-drivers/ - can help you.
-
i'm afraid I cant find much on how to output to this from python. Im no coder, it needs to be call-able from python once Ive done with my process.
thanks for info!.. do you have any more?
Other options please! what other options do I have to get my character input into ES and retroarch please?
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.