if value == 0:
# 'up' - remove from downlist
if code in self.downlist:
- del self.downlist[self.downlist.index(code)]
+ self.downlist.remove(code)
else:
# 'down' - add to downlist
if code not in self.downlist:
self.on_event(self.down_count(), typ, code, value)
return True
def down_count(self):
+ if len(self.downlist) == 0:
+ return 0
+ # double check, we might have missed an 'up' event somehow.
+ try:
+ rv = fcntl.ioctl(self.f, EVIOCGKEY(768/8), (768/8) * " " )
+ l = len(rv)/4
+ ra = struct.unpack('%dI' % l, rv)
+ isup = []
+ for k in self.downlist:
+ by = int(k/8)
+ bt = k % 8
+ if by < l and ((ra[by] >> bt) & 1) == 0:
+ isup.append[k]
+ for k in isup:
+ self.downlist.remove(k)
+ except:
+ pass
return len(self.downlist)
def grab(self):
if self.grabbed:
return
#print "grab"
- fcntl.ioctl(self.f, EVIOC_GRAB, 1)
+ fcntl.ioctl(self.f, EVIOCGRAB, 1)
self.grabbed = True
def ungrab(self):
if not self.grabbed:
return
#print "release"
- fcntl.ioctl(self.f, EVIOC_GRAB, 0)
+ fcntl.ioctl(self.f, EVIOCGRAB, 0)
self.grabbed = False
FBIOBLANK = 0x4611
FB_BLANK_UNBLANK = 0
FB_BLANK_POWERDOWN = 4
-EVIOC_GRAB = 0x40044590
+EVIOCGRAB = 0x40044590
+def EVIOCGKEY(len):
+ return 0x80004518 + len * 65536
class Screen:
def __init__(self):