Example #1
0
 def MenuButtonPushed(self, *args):
     print "MenuButtonDown"
     try:
         import keypress
         keypress.simulate_key(EKeyLeftSoftkey, EScancodeLeftSoftkey)
     except:
         pass
Example #2
0
 def mainCallBack(self, key):
     if key not in self.keymapkbd:
         return
     if self.isExceptionInFg():
         self.mainCapturer.stop()
         simulate_key(key, key)
         self.mainCapturer.start()
         return
     self.checkTime()
     if self.lastKey == key :
         self.backspaceCapturer.stop()
         sim_key = self.getSimKey(key)
         if sim_key == key :
             self.mainCapturer.stop()
         simulate_key(EKeyBackspace, EScancodeBackspace)
         if sim_key in self.needctrl:
             simulate_key(sim_key, 0, EModifierCtrl)
         else:
             simulate_key(sim_key, sim_key)
         if sim_key == key:
             self.mainCapturer.start()
         self.backspaceCapturer.start()
     else:
         self.mod = 0
         sim_key = self.getSimKey(key)
         simulate_key(sim_key, sim_key)
Example #3
0
 def mainCallBack(self, key):
     if key not in self.keymapkbd:
         return
     if self.isExceptionInFg():
         self.mainCapturer.stop()
         simulate_key(key, key)
         self.mainCapturer.start()
         return
     self.checkTime()
     if self.lastKey == key:
         self.backspaceCapturer.stop()
         sim_key = self.getSimKey(key)
         if sim_key == key:
             self.mainCapturer.stop()
         simulate_key(EKeyBackspace, EScancodeBackspace)
         if sim_key in self.needctrl:
             simulate_key(sim_key, 0, EModifierCtrl)
         else:
             simulate_key(sim_key, sim_key)
         if sim_key == key:
             self.mainCapturer.start()
         self.backspaceCapturer.start()
     else:
         self.mod = 0
         sim_key = self.getSimKey(key)
         simulate_key(sim_key, sim_key)
Example #4
0
    def mainCallBackKbd(self, key):
        if self.isExceptionInFg():
            self.mainCapturerKbd.stop()
            simulate_key(key, key)
            self.mainCapturerKbd.start()
            return

        sim_key = self.keymapkbd[key]
        simulate_key(sim_key, sim_key)
Example #5
0
 def switcherCallBack(self, key):
     if key in self.getSwitcherSecondKey():
         if self.isExceptionInFg():
             return False
         if not self.needToggle():
             return False
         retval = self.toggle()
         simulate_key(EKeyHash, EScancodeHash)
         return retval
Example #6
0
 def switcherCallBack(self, key):
     if key in self.getSwitcherSecondKey():
         if self.isExceptionInFg():
             return False
         if not self.needToggle():
             return False
         retval = self.toggle()
         simulate_key(EKeyHash, EScancodeHash)
         return retval
 def parse_data(self, data, sock):
     # dictionary used instead of a switch statement
     print "data len", len(data)
     opcode = data[0]
     print "received opcode", ord(opcode)
     # these functions require path parameter
     if (opcode == OPCODE_KEY_RECEIVED):
         print "key received"
         #http://docs.python.org/lib/module-struct.html
         try:
             data_tuple = struct.unpack('!cHHH', data)
             repeat = data_tuple[1]
             scancode = data_tuple[2]
             code = data_tuple[3]
             print "code", code
             print "repeat", repeat
             print "scancode", scancode
             #pykeygrab.sendToForeground(repeat, scancode, code)
             keypress.simulate_key(code, scancode)
         except:
             import traceback
             tracback.print_exc()
     elif (opcode == OPCODE_CHANGEPROFILE):
         print "change profile received"
     else:
         try:
             # these functions require no parameters
             {
                 OPCODE_DISCONNECT: self.disconnect,
                 OPCODE_BACKLIGHT_ON: self.backlight_on,
                 OPCODE_BACKLIGHT_OFF: self.backlight_off,
                 OPCODE_STOPSOUND: self.stop_sound,
                 OPCODE_START_KEYCAPTURE: self.start_keycapture,
                 OPCODE_STOP_KEYCAPTURE: self.stop_keycapture,
             }[opcode]()
         except:
             print 'No match for first batch of opcodes'
             path = ''
             if (len(data) > 2):
                 path_length = ord(data[1])
                 print "path_length", path_length
                 path = data[2:]
                 print "path", path
                 while (len(path) != path_length):
                     path = path + sock.recv(path_length - len(path))
                     print "path", path
             try:
                 # these functions require path parameter
                 {
                     OPCODE_PLAYSOUND: self.play_sound,
                     OPCODE_LAUNCHAPP: self.launch_app,
                     OPCODE_CLOSEAPP: self.close_app,
                     OPCODE_LAUNCHMEDIA: self.launch_media,
                 }[opcode](path)
             except:
                 print 'No match for second batch of opcodes'
	def parse_data(self, data, sock):
		# dictionary used instead of a switch statement
		print "data len", len(data)
		opcode = data[0]
		print "received opcode", ord(opcode)
		# these functions require path parameter
		if(opcode == OPCODE_KEY_RECEIVED):
			print "key received"
			#http://docs.python.org/lib/module-struct.html
			try:
				data_tuple = struct.unpack('!cHHH', data)
				repeat = data_tuple[1]
				scancode = data_tuple[2]
				code = data_tuple[3]
				print "code", code
				print "repeat", repeat
				print "scancode", scancode
				#pykeygrab.sendToForeground(repeat, scancode, code)
				keypress.simulate_key(code, scancode)
			except:
				import traceback
				tracback.print_exc()
		elif( opcode == OPCODE_CHANGEPROFILE):
			print "change profile received"
		else:
			try:
				# these functions require no parameters
				{OPCODE_DISCONNECT: self.disconnect,
				 OPCODE_BACKLIGHT_ON: self.backlight_on,
				 OPCODE_BACKLIGHT_OFF: self.backlight_off,
				 OPCODE_STOPSOUND: self.stop_sound,
				 OPCODE_START_KEYCAPTURE: self.start_keycapture,
				 OPCODE_STOP_KEYCAPTURE: self.stop_keycapture,
				}[opcode]()
			except:
				print 'No match for first batch of opcodes'			
				path = ''
				if(len(data) > 2):
					path_length = ord(data[1])
					print "path_length", path_length
					path = data[2:] 
					print "path", path
					while(len(path) != path_length):
						path = path + sock.recv(path_length - len(path))
						print "path", path
				try:
					# these functions require path parameter
					{OPCODE_PLAYSOUND: self.play_sound,
					 OPCODE_LAUNCHAPP: self.launch_app,
					 OPCODE_CLOSEAPP: self.close_app,
					 OPCODE_LAUNCHMEDIA: self.launch_media,
					}[opcode](path)
				except:
					print 'No match for second batch of opcodes'
Example #9
0
 def toggleKbd(self):
     if self.currentLangKbd == u'ka':
         self.currentLangKbd = u'default'
         self.stopKbd()
         if  self.c('noteSwitch') == 0:
             return True
         conf(u("default"))
         e32.ao_sleep(0.2)
         simulate_key(EKeyHash, EScancodeHash)
     else:
         self.startKbd()
         self.currentLangKbd = u'ka'
         if  self.c('noteSwitch') == 0:
             return True
         conf(u('ქართული'))
         e32.ao_sleep(0.2)
         simulate_key(EKeyHash, EScancodeHash)
         return True
Example #10
0
def page_down(self):
    keypress.simulate_key(EKeyPageDown, EStdKeyPageDown)
    e32.ao_yield()
Example #11
0
def page_up(self):
    keypress.simulate_key(EKeyPageUp, EStdKeyPageUp)
    e32.ao_yield()
Example #12
0
 def mainCallBack(self, key):
     if self.isExceptionInFg():
         self.mainCapturer.stop()
         simulate_key(key, key)
         self.mainCapturer.start()
         return
     if key == EKey0:
         if self.switcherCallBack(key):
             return
     self.checkTime()
     if self.lastKey == key:
         self.backspaceCapturer.stop(
         )  # we must stop backspace, because the next call is a "dummy backSpace" to remove a digit in-place
         sim_key = self.getSimKey(key)  #self.keymap[key][mod]
         if sim_key == key:  # got number, we need special handling
             self.mainCapturer.stop(
             )  # commonCapturer must not capture next fired keyKode.
             simulate_key(EKeyBackspace, EScancodeBackspace)
             simulate_key(key, 0, EModifierCtrl)  # send number code
             self.mainCapturer.start()
         else:  # usuall handling
             simulate_key(EKeyBackspace, EScancodeBackspace)
             simulate_key(sim_key, sim_key)
         self.backspaceCapturer.start()  # enable backspace forwarding
     else:
         sim_key = self.keymap[key][0]
         simulate_key(sim_key, sim_key)
         self.lastKey = key
         self.mod = 1
Example #13
0
def page_down(self):
    keypress.simulate_key(EKeyPageDown, EStdKeyPageDown)
    e32.ao_yield()
Example #14
0
def page_up(self):
    keypress.simulate_key(EKeyPageUp, EStdKeyPageUp)
    e32.ao_yield()
Example #15
0
 def mainCallBackKbd(self, key):
     if key not in self.keymapkbd:
         return
     if self.isExceptionInFg():
         self.mainCapturerKbd.stop()
         simulate_key(key, key)
         self.mainCapturerKbd.start()
         return
     self.checkTime()
     if self.lastKey == key :
         self.backspaceCapturer.stop() # we must stop backspace, because the next call is a "dummy backSpace" to remove a digit in-place
         sim_key = self.getSimKeyKbd(key) #self.keymap[key][mod]
         if sim_key == key : # got number, we need special handling
             self.mainCapturerKbd.stop()  # commonCapturer must not capture next fired keyKode.
             simulate_key(EKeyBackspace, EScancodeBackspace)
             simulate_key(key, key)
             self.mainCapturerKbd.start()
         elif sim_key in self.numbers:
             simulate_key(EKeyBackspace, EScancodeBackspace)
             simulate_key(sim_key, 0, EModifierCtrl) # send number code
         else : # usuall handling
             simulate_key(EKeyBackspace, EScancodeBackspace)
             simulate_key(sim_key, sim_key)
         self.backspaceCapturer.start() # enable backspace forwarding
     else:
         self.mod = 0
         sim_key = self.getSimKeyKbd(key)
         simulate_key(sim_key, sim_key)
Example #16
0
def read_sms():
    ##############################à
    sms_text="#REC#START" # DEBUG*********
    ##############################à
    e32.ao_sleep(0.1)
    #i=inbox.Inbox() #DEBUG
    #sms_text=i.content(id) #DEBUG
    appuifw.note(u"Messaggio da elaborare: " + sms_text, "info")

    # Execute different actions depending on SMS contents:
    if sms_text[0:5] == '#REC#':
      print 'Message received'
      if appswitch.switch_to_fg(APPLICATION_NAME) == 1:
        e32.ao_sleep(1)
        keypress.simulate_key(53,53)
        keypress.simulate_key(54,54)
        keypress.simulate_key(55,55)
        keypress.simulate_key(63495,63495)
        keypress.simulate_key(63495,63495)
        keypress.simulate_key(52,52)
      else:
        print "ERROR: Couldnt bring " + APPLICATION_NAME + " to foreground."