After, I have visited one of the few arcades in my city. I was fairly disappointed by the game choice. The biggest problem is that most of the newer games play themselves. One was a racing game, and it almost made no difference if you drove straight into a wall or not. You were also bombarded by fancy items. Suffice to say, that I have stayed the remainder of my stay at the pinball machines. I actually never played pinball and was pleasantly surprised how fun it is. My training in 3D Pinball actually paid off, big time.
The reason why I am so joyful is that I have naturally thought about making my own arcade, after seeing in what disastrous state they are (at least here). My first test was if it was feasible to make a GPIO controller I could use to play native games on Linux, and it was such a breeze!!! :fall: After a quick search, I found python-evdev, which I could easily install thanks to apt and the Raspbian repository. I remember that I always had trouble with Python, but it's so cool to be able to do everything just using apt, and if some dependency is missing, I could easily enable a virtual environment with pip. It even told me that when I tried to do it wrong the first time around! All python-evdev does is inject input right into the kernel of Linux! This is so awesome! I'm amazed at how stupid simple it is. Only been using Linux for a year or so, but every time I learn how smart it is, I am overwhelmed with joy. I wrote a couple of lines of Python, shown below, and was able to create a virtual controller. Running evtest, I was able to see the controller and its inputs, but most critically, when running supertux2, Tux was jumping!
Next up I have to hook up the buttons via GPIO. I already found a library I could use to talk with it more easily https://gpiozero.readthedocs.io.
It's really hard for me to express how happy I am about all those tools we have available, and how well they fit together. It's amazing how I am able to create a virtual controller just from some lines of code, without any drivers that have to be installed in every corner of the OS. Love Python, Love Linux, Love python-evdev and I also still like the Raspberry.
from evdev import UInput, ecodes as e
from time import sleep
capabilities = {
e.EV_KEY: [
e.BTN_A
]
}
ui = UInput(capabilities, name="VirtualController", vendor0x1234, product=0x5678)
while (True):
ui.write(e.EV_KEY, e.BTN_A, 1)
ui.syn()
sleep(1)
ui.write(e.EV_KEY, e.BTN_A, 0)
ui.syn()
sleep(1)
#linux #python #hardware #hacking #rpi #project #opensource