12-26-2023, 09:00 AM | #1 |
Junior Member
Posts: 7
Karma: 10
Join Date: Dec 2023
Device: kobo clara hd
|
Best way to detect touch for python app
Hello, I have started working on making a small game for my kobo device using python and FBInk. This has worked out fine but I am now looking for the best way to detect touch input.
I tried using this python module which allowed me to det touch coords, but it still registers touch input from behind my game screen, e.g. clicking on a book. Is there anyway to disable the default touch behaviour, or a different way I can be detecting touch inputs within a python app? |
12-26-2023, 05:34 PM | #2 |
Connoisseur
Posts: 63
Karma: 18290
Join Date: Jul 2016
Location: France
Device: Kobo H2O (broken), Kobo H2O Edition 2 v1 (stolen), Kobo Clara 2E
|
Yes it is possible and quite easy actually. You need to make an IOCTL call to grab the touch input. Then Nickel (the default software) won't register any input, although it will keep running. Which brings the question: do you really want to keep Nickel in the background? If you do not need it, I highly recommend killing everything to avoid conflicts. For instance, Nickel may keep updating the clock above your app, or go to sleep.
To do that, you should run the following bash commands: Code:
# Stop kobo software when it's running killall nickel hindenburg sickel fickel fmon > /dev/null 2>&1 Short version since you use KIP: Code:
t = KIP.inputObject(touchPath, 1080, 1440, grabInput=True) Long version for those who do not use my module (KIP): Spoiler:
That code was used within PSSM. It was a tool I made to create Python apps on the Kobo, it helped a lot with creating interfaces. But I completely stopped developping this tool because Python was not really appropriate on such a low-performance device. However, you can run the example files. They do work! And I do think it makes life much easier... Last edited by Mavireck; 12-26-2023 at 05:56 PM. |
12-27-2023, 08:58 AM | #3 | |
Junior Member
Posts: 7
Karma: 10
Join Date: Dec 2023
Device: kobo clara hd
|
Quote:
The killall solution does seem like the best, but is there a way to restart the services so I can close the game the continue using my device without restarting? |
|
12-27-2023, 03:33 PM | #4 | |
Connoisseur
Posts: 63
Karma: 18290
Join Date: Jul 2016
Location: France
Device: Kobo H2O (broken), Kobo H2O Edition 2 v1 (stolen), Kobo Clara 2E
|
Quote:
https://github.com/baskerville/plato...trib/nickel.sh And https://github.com/baskerville/plato...ntrib/plato.sh |
|
12-27-2023, 05:16 PM | #5 |
BLAM!
Posts: 13,478
Karma: 26012494
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
Prior art is from KOReader, actually ;p.
(I should know, it took a lot of pain and cursing to make it all behave somewhat properly). Meaning I wouldn't necessarily encourage anybody to go that route unless you like stuff randomly breaking if you don't commit to keeping up to date on this stuff . |
12-27-2023, 11:30 PM | #6 |
Guru
Posts: 856
Karma: 2676800
Join Date: Aug 2008
Location: Taranaki - NZ
Device: Kobo Aura H2O, Kobo Forma
|
Once upon a time, I was dabbling with using NickelDBus to create a blank widget which sole purpose was to "eat" touch inputs in Nickel. Problem was, you plugging the device into USB would exit that widget, so I deemed it rather fragile, and didn't investigate further.
Another idea was to use that widget to generate "sane" touch events. Ideally those would be sent to a "uinput" device. But older Kobo's don't have uinput included in their kernel's, so I didn't get any further than that either. |
12-28-2023, 08:44 AM | #7 |
Junior Member
Posts: 7
Karma: 10
Join Date: Dec 2023
Device: kobo clara hd
|
Hmm ok that does seem like a hassle. So if instead of killing nickel I instead just wanted to stop the top status bar from updating (clock, battery), is there an easy way to achieve that?
|
12-30-2023, 06:45 AM | #8 |
Connoisseur
Posts: 63
Karma: 18290
Join Date: Jul 2016
Location: France
Device: Kobo H2O (broken), Kobo H2O Edition 2 v1 (stolen), Kobo Clara 2E
|
I don't know any way do to that. I would recommend killing Nickel, and when you want to quit your app you can use the 'reboot' command to reboot the kobo without having to long press the power button. It only takes a few more seconds than restarting nickel with the script mentioned above!
|
12-30-2023, 03:38 PM | #9 |
BLAM!
Posts: 13,478
Karma: 26012494
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
And, FWIW, it takes a fraction of that time on devices running on newer SoCs (ELipsa, Sage; I assume Elipsa 2E too).
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
General question about packaging and shipping python desktop app | gsteinberg | Development | 1 | 02-13-2023 11:49 PM |
Python + PyGTK for Kindle Touch and Paperwhite | dos1 | Kindle Developer's Corner | 25 | 07-14-2021 09:52 AM |
WolframAlpha app for Kobo - and some Python stuff (keyboard, touch input librairies) | Mavireck | Kobo Developer's Corner | 17 | 08-11-2019 01:42 PM |
Can't detect Kobo Touch - 2.58 on Windows 7 | mzurer | Devices | 3 | 06-05-2016 12:22 PM |
How does the app store detect country? | geertm | Nook Color & Nook Tablet | 6 | 05-10-2011 03:11 AM |