![]() |
#1 |
Connoisseur
![]() Posts: 85
Karma: 13
Join Date: Oct 2016
Location: Mars
Device: KV,KOA2,PW5
|
![]()
My KO2 jailbreaked, I installed Python on the KO2, currently I am working on a Python TK(tkinter) App for the KO2.
I want to use KO2 physical button to trigger something on my App, but python TK can not capture the event of the physical buttons on KO2, my testing python script as follows (py_tk_event_test.py) : Code:
import Tkinter as tk def hotkey_manager(event): key = event.keysym key_chr = event.char key_code = event.keycode mouse_button = event.num # mouse button index typ = event.type print(key, key_chr, key_code, mouse_button, typ) if key.lower() == 'next': print('---page dw---') #if page down key is clicked , print "page dw" if key.lower() == 'prior': print('---page up---') #if page up key is clicked , print "page up" def tk_event_test(): root = tk.Tk() root.title('L:A_N:dialog_ID:TkSide0') #set win title for kindle sys button_test = tk.Button(text='Close', height=4, width=30, font=("Sans", '12', 'bold'), command=(root.destroy)) button_test.pack() # create TK button root.bind('<Button-1>', hotkey_manager) #bind mouse left button to TK UI root.bind('<KeyPress>', hotkey_manager) #bind anykey press to TK UI (to show test reaction) root.mainloop() #launch UI tk_event_test() press anykey on the keyboard, it prints out the key name, key char, key hex code, event type info. when I run the python script on my linux laptop, it works fine as I expect: #press 'a' on the keyboard ('a', 'a', 38, '??', '2') #press 'b' on the keyboard ('b', 'b', 56, '??', '2') #Press 'page-up' on the keyboard ('Prior', '', 112, '??', '2') ---page up--- #Press 'Page-down' on the keyboard ('Next', '', 117, '??', '2') ---Page down--- #Press mouse button 1 (left mouse button) ('??', '??', '??', 1, '4') Launch the python TK UI on KO2 (the UI only contains one "Close" button): Spoiler:
But when I run the Python script on Kindle KO2, the script can not capture any keyboard event, only the mouse button-1 event (single click on the touchscreen) can be captured. I press the KO2 physical button, there is no feedback from my python script, When I click touchscreen on the "Close" button, I get mouse event feedback as follows: ('??', '??', '??', 1, '4') The interesting thing is that the Python script on Kindle cannot capture the physical button event, but I can see unexceptional feedback in the terminal when I press physical button( page-up, page-down) , get something like this #press the KO2 physical button "page-up": ^[[5~ #Press the KO2 physical button "page down": ^[[6~ Spoiler:
repeat press the page-down button two more times: Spoiler:
the mouse event can be captured (single click "Close" button on the touchscreen, quit from the TK UI): Spoiler:
I searched in Google, “^[[5~” and “^[[6~” are some kind of key code for "page-up" and "page-down". When I click the terminal's on-screen keyboard "page-up" and "page-down" key, I get the same rustle: ^[[5~ ^[[6~ This terminal feedback only happens after I run my Python script, So at least the terminal can capture the KO2 physics button event, then I use the "dmesg" command to list all the events triggered on the KO2. dmesg | grep keys #the last 4 rows as follows: [5782.691165] gpio_keys_gpio_report_event: type=1, code=104, state=1 [5791.110264] gpio_keys_gpio_report_event: type=1, code=109, state=1 [5795.610269] gpio_keys_gpio_report_event: type=1, code=109, state=1 [5799.202911] gpio_keys_gpio_report_event: type=1, code=109, state=1 I think the "gpio_keys code=104" is page-up, the "gpio_keys code=109" is page-down. Speculate and question: there is no module (or driver) for physical keyboard on the kindle, the gpio_keys physical button is simulated as "page-up" and "page-down" key, it is not a real physical keyboard event. I guess this is the reason why Python TK cannot capture the physical button event. The question is: how to capture this gpio_keys physical button event, If it is not easy to implement in Python, how to capture it in C? Thank you for reading my post, I appreciate your reply. Last edited by kdusr; 07-18-2024 at 12:21 AM. |
![]() |
![]() |
![]() |
#2 |
Connoisseur
![]() Posts: 85
Karma: 13
Join Date: Oct 2016
Location: Mars
Device: KV,KOA2,PW5
|
I tried to use
lipc-wait-event -s 5 com.lab126.system "*" to capture the gpio-key events (run the lipc-wait-event command, press the physical button to see if any event is triggered ), but nothing captured,then I go through following "com.lab126.[events]", but nothing captured... ![]() com.lab126.powerd com.lab126.cmd com.lab126.wan com.lab126.wifid com.lab126.dpmManager com.lab126.kaf com.lab126.appmgrd com.lab126.foobar com.lab126.framework com.lab126.hal com.lab126.winmgr com.lab126.dynconfig com.lab126.deviced com.lab126.grokservice com.lab126.odot com.lab126.pmond com.lab126.blanket com.lab126.archive com.lab126.quickactions com.lab126.system com.lab126.yjr com.lab126.certmand com.lab126.dsus com.lab126.indexer com.lab126.transfer com.lab126.keyboard com.lab126.pillow com.lab126.dpm.apps com.lab126.lxinit com.lab126.devicemetrics com.lab126.phd com.lab126.sph com.lab126.volumd com.lab126.demd com.lab126.tphv3 com.lab126.btfd com.lab126.KindleIdentity |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,399
Karma: 99236514
Join Date: Apr 2011
Device: pb360
|
Here is what I was able to figure out in 2018, but from wanting to turn page parspective:
https://www.mobileread.com/forums/sh...d.php?t=294071 Basically it involved changing /dev/input/event5 so detecting a page turn would involve detecting particular changes in /dev/input/event5 |
![]() |
![]() |
![]() |
#4 | |
Connoisseur
![]() Posts: 85
Karma: 13
Join Date: Oct 2016
Location: Mars
Device: KV,KOA2,PW5
|
Quote:
I read the thread,maybe I did not descript it clearly My idea is: 1. user press the physical button > 2. trigger kindle gpio-key event > 3. in my app capture the gpio-key event > 4. execute page-up or page-down inside of my tk UI app (not execute page-up or page-down for kindle book UI). when user press the physical button, kindle system automatically trigger a gpio-key event in global, this event is made by kindle system, nothing I can change, currently I stuck on step 3, my python script is unable to capture the gpio-key event, the step 4 to exec page-down is relatively easy in python Tk: tk.xxx_widget.event_generate('<Next>') Last edited by kdusr; 07-19-2024 at 09:53 PM. |
|
![]() |
![]() |
![]() |
#5 | |
Connoisseur
![]() Posts: 85
Karma: 13
Join Date: Oct 2016
Location: Mars
Device: KV,KOA2,PW5
|
Quote:
thanks, J.P.S!! ![]() |
|
![]() |
![]() |
Advert | |
|
![]() |
Thread Tools | Search this Thread |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Hardware about capture hardware page up(down) button event? | kdusr | Kindle Developer's Corner | 5 | 12-13-2018 02:10 PM |
K5 Physical home button | Cinisajoy | Kindle Developer's Corner | 0 | 08-21-2015 12:09 PM |
[Help] Kindle Touch - Any apps/function could replace dead physical Home button? | vankhoa | Kindle Developer's Corner | 4 | 11-24-2013 01:11 PM |
The Menu (physical) button is your friend! | sarah11918 | enTourage Archive | 0 | 04-15-2010 11:39 AM |
iLiad non-GTK+ apps not getting button event from X | ericshliao | iRex Developer's Corner | 7 | 08-30-2009 06:52 AM |