Using the Pimoroni touchphat GPIO hat (https://github.com/pimoroni/touch-phat), I'm trying to map button press to keystroke on a raspberry pi using uinput, in order to control a command line internet radio program and scroll up or down a list of options.
It is successfully printing "working" when the button is pressed, but doesn't show signs of controlling the program. The code below is written in sudo python, while the program I wish control runs on a separate terminal window. could this be the issue? If so, how do I link the two together?
sudo modprobe uinput
sudo python
import uinput
import touchphat
@touchphat.on_touch("A")
def handle_touch():
# Map touchphat key press to keyboard click
with uinput.Device([uinput.KEY_J]) as device:
device.emit_click(uinput.KEY_J)
print("working")
"J" is defined as up in the program.