~gnome15-team/gnome15/trunk

« back to all changes in this revision

Viewing changes to gnome15/src/main/python/gnome15/drivers/pylibg15.py

  • Committer: tanktarta
  • Date: 2012-11-24 10:27:36 UTC
  • Revision ID: tanktarta-20121124102736-0drhasy3jdn862wx
0.9.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import time
22
22
from ctypes import *
23
23
from threading import Thread
 
24
 
24
25
libg15 = cdll.LoadLibrary("libg15.so.1")
25
26
 
26
 
# Default kKey read timeout. Too low and keys will be missed (very obvious in a VM)
 
27
# Default key read timeout. Too low and keys will be missed (very obvious in a VM)
27
28
KEY_READ_TIMEOUT = 100
28
29
 
29
30
G15_LCD = 1
62
63
        if self._run:
63
64
            self._run = False
64
65
        
65
 
    def run(self):      
66
 
        pressed_keys = c_int(0)
 
66
    def run(self):    
67
67
        try:
68
 
            while self._run:
 
68
            pressed_keys = c_int(0)
 
69
            while self._run:  
69
70
                err = libg15.getPressedKeys(byref(pressed_keys), 10)
70
71
                code = 0
71
72
                ext_code = 0
89
90
                            break
90
91
                    else:
91
92
                        code = pressed_keys.value
92
 
                        
 
93
 
93
94
                    self.callback(code, ext_code)
94
95
                elif err in [ G15_TRY_AGAIN, G15_ERROR_READING_USB_DEVICE ] :
95
96
                    continue