×

Discussion Board

Results 1 to 5 of 5

Thread: Key to PC

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    13

    Key to PC

    Hello,

    thanks to the guys on this forum all my problems are no more but there is one more problem that i need anwsering if you have the anwser that is...

    how can i get a key that was pressed on my phone and send it to my PC and i have to combine my accelerator data and the key data to be sent, so when i press a key I send a key and when the accelerator data wants to be sent i send the accelerator data. But the problem is that i don't know how to sign the PythonShell so i can use keycapture(i just dont know how to sing or what to sign i have PythonShell 2.0.0) so im stuck with using this...

    Code:
    import appuifw
    import graphics
    import e32
    
    keyboard_state={}
    last_keycode=0
    
    def draw_state():
        canvas.clear()
        canvas.text((0,12),u'Scancodes of pressed keys:',0x008000)
        canvas.text((0,24),u' '.join([unicode(k) for k in keyboard_state if keyboard_state[k]]))
        canvas.text((0,36),u' '.join([unicode(hex(k)) for k in keyboard_state if keyboard_state[k]]))
        canvas.text((0,48),u'Last received keycode:', 0x008000)    
        canvas.text((0,60),u'%s (0x%x)'%(last_keycode,last_keycode))
        
    def callback(event):
        global last_keycode
        if event['type'] == appuifw.EEventKeyDown:
            keyboard_state[event['scancode']]=1
        elif event['type'] == appuifw.EEventKeyUp:
            keyboard_state[event['scancode']]=0
        elif event['type'] == appuifw.EEventKey:
            last_keycode=event['keycode']
        draw_state()
    
    canvas=appuifw.Canvas(event_callback=callback,
                          redraw_callback=lambda rect:draw_state())
    appuifw.app.body=canvas
    
    lock=e32.Ao_lock()
    appuifw.app.exit_key_handler=lock.signal
    lock.wait()
    but insted of using a canvas to print my data i would like to save the presed key into a string but i dont know how...

    i would like to do something like this...
    if key was pressed...
    keyPressed = str(canvas.text((0,24),u' '.join([unicode(k) for k in keyboard_state if keyboard_state[k]]))) -> or something so i know what key was pressed
    if key was Release
    keyRelease = str(u' '.join([unicode(hex(k)) for k in keyboard_state if keyboard_state[k]]))) -> or something to know that the previous key was released

    also how do i combine so that both key and accelerator data would work in the same function

    Im using the folowing to send...

    Code:
    def gamePlay():
    	hostServer = "192.168.1.169"
    	hostPort = 12312
    	apo = sel_access_point()	
    	if apo is not None:
    		apo.start()
    		sock = socket(AF_INET, SOCK_DGRAM)
    		class MetaApp():
    			def __init__(self):
    				self.accelerometer = \
    					AccelerometerXYZAxisData(data_filter=LowPassFilter())
    				self.accelerometer.set_callback(data_callback=self.my_callback)
    				self.counter = 0  
    			def my_callback(self):
    				#to more bit drugače bo pošiljalo 35 paketkov na sekundo, kar pa ni vredu
    				if self.counter % 5 == 0:
    					#pogoj da s katerim omejujemo občutljivost
    					if (self.accelerometer.x > kCorX+faktObcutlj) or (self.accelerometer.x < kCorX-faktObcutlj) or (self.accelerometer.y > kCorY+faktObcutlj) or (self.accelerometer.y < kCorY-faktObcutlj):
    						tmest = u"X: " + str(MyGData)
    						n = sock.sendto(tmest,(hostServer,hostPort))
                                            if Key event == true
                                                    tnest = keyPress
                                                    n = sock.sendto(tnest,(hostServer,hostPort))
    				self.counter = self.counter + 1
    			def run(self):
    				self.accelerometer.start_listening()
    				
    		if __name__ == '__main__':
    			d = MetaApp()
    			d.run()
    			#al uporabiš sleep al pa oni handler spodaj :D kaj bo ljubše :D
    			#e32.ao_sleep(20000)
    			appuifw.app.exit_key_handler = quit
    Thank you for your help,

    Rok

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    13

    Re: Key to PC

    can someone please at least tell me how to enable keycapturer? couse i don't even know where to start using SymbianSigned... Please is there any tutorial showing how to enable this function with PythonScriptShell_2.0.0_3_2.sis how do i sign it so it will work? Where do i download the unsigned version?

  3. #3
    Registered User
    Join Date
    Apr 2009
    Posts
    166

    Re: Key to PC

    if i am allowed to say this hack your device and install an unsigned shellscript with max caps.
    if i am not allowed to say this please ignore this post and/or delete it ...

  4. #4
    Registered User
    Join Date
    May 2010
    Posts
    13

    Red face Re: Key to PC

    yeah well hacking is all good and well but i think i'm gonna try it with threading can someone give me a good site where everything about threding is explained well?

    Also I kinda don't know how to hack my device do you have any idea how to do that it's not for profit or anytihg it's for a school project and my profesor is not helping couse he has no idea about python also my school mates don't want to help couse they see me as an adversary...

    Thank you for yourr help so far ,

    Rok

  5. #5
    Registered User
    Join Date
    Apr 2009
    Posts
    166

    Re: Key to PC

    about hack:
    i'd need to know what device you have

    about threading:
    http://developer.symbian.org/wiki/in...ad_Programming

    scroll down to threading

Similar Threads

  1. Replies: 106
    Last Post: 2009-05-11, 05:53
  2. Replies: 3
    Last Post: 2008-09-09, 04:53
  3. Sending from PC to 7650 via BT
    By glr in forum Bluetooth Technology
    Replies: 0
    Last Post: 2003-11-24, 16:53
  4. Replies: 8
    Last Post: 2003-07-11, 12:56
  5. keybindings nokia7650 and nokia6310i
    By topisystems in forum Mobile Java General
    Replies: 1
    Last Post: 2002-06-05, 14:25

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×