import struct tsdevice = "/dev/input/ts" format = "iihhi" file = open(tsdevice,"rb") event = file.read(16) x = 0 y = 0 while True: (time1, time2, type, code, value) = struct.unpack(format,event) if type == 3: if code == 0: x = value if code == 1: y = value if type == 0: print x, ":", y event = file.read(16)