def joystickLoop(eventFile): FORMAT = 'llHHI' EVENT_SIZE = struct.calcsize(FORMAT) with open(eventFile, 'rb') as infile: while True: event = infile.read(EVENT_SIZE) _, _, t, c, v = struct.unpack(FORMAT, event) print(t, c, v) if t == 3 and v == 4294967295: if c == 17: # press UP: elif c == 16: # press LEFT elif t == 3 and v == 1: if c == 17: # press DOWN: elif c == 16: # press RIGHT elif t == 3 and v == 0: if c == 17 or c == 16: # pass elif t == 1 and v == 1: if c == 307: # Camera up if c == 305: # Cameta down if c == 304: # Cameta right if c == 308: # Camera left elif t == 1 and v == 1: pass