Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Kobo Reader > Kobo Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 12-26-2023, 09:00 AM   #1
sheep_wizard
Junior Member
sheep_wizard began at the beginning.
 
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?
sheep_wizard is offline   Reply With Quote
Old 12-26-2023, 05:34 PM   #2
Mavireck
Connoisseur
Mavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a Texan
 
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
If you do want to keep everything running (as I did in my Bing Maps proof of concept), you can use the following:

Short version since you use KIP:
Code:
t = KIP.inputObject(touchPath, 1080, 1440, grabInput=True)
Should work (note the grabInput argument... It was made for that purpose )

Long version for those who do not use my module (KIP):

Spoiler:

Code:
from fcntl import ioctl
import grabInput as grabber

devFile = open("/dev/input/event1", "rb")

ioctl(devFile, grabber.EVIOCGRAB(1), True) # To grab the input
ioctl(devFile, grabber.EVIOCGRAB(1), False) # To release it
How I integrated it in KIP's updated version which is shipped with PSSM.

The grabInput module is not a default Python module, but you can find it here:
The module I used
The module I (largely) based my work on (GNU license)

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.
Mavireck is offline   Reply With Quote
Old 12-27-2023, 08:58 AM   #3
sheep_wizard
Junior Member
sheep_wizard began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Dec 2023
Device: kobo clara hd
Quote:
Originally Posted by Mavireck View Post
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
If you do want to keep everything running (as I did in my Bing Maps proof of concept), you can use the following:

Short version since you use KIP:
Code:
t = KIP.inputObject(touchPath, 1080, 1440, grabInput=True)
Should work (note the grabInput argument... It was made for that purpose )

Long version for those who do not use my module (KIP):

Spoiler:

Code:
from fcntl import ioctl
import grabInput as grabber

devFile = open("/dev/input/event1", "rb")

ioctl(devFile, grabber.EVIOCGRAB(1), True) # To grab the input
ioctl(devFile, grabber.EVIOCGRAB(1), False) # To release it
How I integrated it in KIP's updated version which is shipped with PSSM.

The grabInput module is not a default Python module, but you can find it here:
The module I used
The module I (largely) based my work on (GNU license)

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...
Thanks for the reply, I have been using your repos for help already 😄

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?
sheep_wizard is offline   Reply With Quote
Old 12-27-2023, 03:33 PM   #4
Mavireck
Connoisseur
Mavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a Texan
 
Posts: 63
Karma: 18290
Join Date: Jul 2016
Location: France
Device: Kobo H2O (broken), Kobo H2O Edition 2 v1 (stolen), Kobo Clara 2E
Quote:
Originally Posted by sheep_wizard View Post
Thanks for the reply, I have been using your repos for help already 😄

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?
I always got away with a reboot personally. However, Plato manages to restart Nickel without rebooting, you should check its scripts:

https://github.com/baskerville/plato...trib/nickel.sh
And https://github.com/baskerville/plato...ntrib/plato.sh
Mavireck is offline   Reply With Quote
Old 12-27-2023, 05:16 PM   #5
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
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 .
NiLuJe is offline   Reply With Quote
Old 12-27-2023, 11:30 PM   #6
sherman
Guru
sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.sherman ought to be getting tired of karma fortunes by now.
 
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.
sherman is offline   Reply With Quote
Old 12-28-2023, 08:44 AM   #7
sheep_wizard
Junior Member
sheep_wizard began at the beginning.
 
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?
sheep_wizard is offline   Reply With Quote
Old 12-30-2023, 06:45 AM   #8
Mavireck
Connoisseur
Mavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a TexanMavireck might easily be mistaken for a Texan
 
Posts: 63
Karma: 18290
Join Date: Jul 2016
Location: France
Device: Kobo H2O (broken), Kobo H2O Edition 2 v1 (stolen), Kobo Clara 2E
Quote:
Originally Posted by sheep_wizard View Post
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?
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!
Mavireck is offline   Reply With Quote
Old 12-30-2023, 03:38 PM   #9
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
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).
NiLuJe is offline   Reply With Quote
Reply


Forum Jump

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


All times are GMT -4. The time now is 05:44 PM.


MobileRead.com is a privately owned, operated and funded community.