so the code is being autostarted but on the terminal, I need it to autostart itself on retropie/emulationstation instead...
idk if the code is important in this situation since i only want to autorun a python script but this is what I got, only one direction of one axis is working atm, which is the left key.. for testing purposes ..
Code: Select all
GNU nano 2.2.6 File: pcf2.py
from smbus import SMBus
import uinput
import time
bus = SMBus(1)
events = (uinput.KEY_UP, uinput.KEY_DOWN, uinput.KEY_LEFT, uinput.KEY_RIGHT)
bus.write_byte(0x48, 1)
last_reading =-1
device = uinput.Device(events)
while(0 == 0):
reading = bus.read_byte(0x48)
if(abs(last_reading - reading) > 2):
last_reading = reading
if(reading>120):
device.emit(uinput.KEY_LEFT, 1)
time.sleep(0.1)
device.emit(uinput.KEY_LEFT, 0)