03-02-2012, 11:36 PM | #1 |
Carpe diem, c'est la vie.
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
geekmaster simple touchscreen script support hack
UPDATE: Added MIT license (not in download files yet).
This simple "ascii finger paint" demo shows a simple hack to use kindle touchscreen and eInk support in a shell script. I need touchscreen support for the GUI elements in my kindle recovery script, but I used a simple "ascii art" paint program to test it. Because it does not lock the touchscreen device to prevent touches from affecting other apps using the touchscreen, it is best to run it from outside the framework. I suggest testing in in diagnostics "Lock to HOME button" menu, which prevents selecting anything while using this program. You can put this "touchpaint-1.3" script on your kindle USB drive, then run it from an SSH session (or launch it in the kindle touch launcher menu). To exit the program, touch the upper-left corner. The screenshots were taken before the "touch here to exit" code was added to the source code, but those updates are included in the script source code below. Here is a little guy I painted quickly with my finger. I touched around him to test "button support": And here are some "quick and dirty" crude text characters I drew with my finger on the kindle touchscreen (there was a fat USB cable under the kindle and it was rocking a little while drawing this): And here is is the touchpaint script code: PHP Code:
Here is a safe place to test this touchscreen script: This is what you see when you select that menu item: To Do: In my script code, I plan to use eips to put a screenshot of the kindle framework keyboard screens on the screen and use the touchscreen to detect keypresses. I have already taken keyboard screenshots for my script GUI, and I have all my script output piped through eips, using its screen text scrolling feature (just put a pair of parentheses around the entire script, and pipe that indirectly to eips through a script variable). With this and the above touchscreen code, I will have a simple onscreen terminal console (but with no term ESC controls until later). You are welcome to make free use of my touchscreen script support hack, and if you figure out cool things to do with script touchscreen support, please post your code back to this thread. But you do not need to worry about that -- just use my part of functions in your scripts and it will "just work". Thanks. Enjoy! P.S. As the versions progress, the code is following a typical pattern for me, where I add features by removing limitations, which has the side-effect of making the code smaller and simpler. As of version 1.3, the artwork you create with this program is automatically saved to touchpaint.raw on your USB drive when you exit the program (the previous image is renamed to touchcpaint.raw.bak). You can use IrfanView (in Windows, or the Gimp in linux) to import raw framebuffer images as 608 wide by 800 high, 8 bits-per-pixel, then clip it to 600x800 and reduce it to 300x400 (eips text is pixel-doubled), and save it in your favorite file format. If it appears skewed when you load the raw image, try loading it as 600 wide instead. The virtual x_res can vary in different screen modes. You can find the current screen mode settings with: eips -i (I forgot to clip the above screenshot images before resizing, so they are 304 px wide instead of 300.) Last edited by geekmaster; 04-04-2012 at 12:32 PM. Reason: version 1.3 update |
03-03-2012, 08:10 AM | #2 |
Carpe diem, c'est la vie.
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
Bump...
What, no feedback? No improvements, or thanks? And here I had all these OTHER ideas I was planning to post. I thought posts like this one might encourage the "script kitties" (meow!) amongst us to create good things... And even for experienced developers, there are times when only a script will do, like when you have only serial port or reverse shell access, but you CAN paste text into a file from the clipboard (like this script, so you can get feedback and control through the touchscreen). Come on guys! If you want to see more stuff like this, give me some feedback, so I know that I am not wasting my valuable and limited time! Okay? Last edited by geekmaster; 03-03-2012 at 08:53 AM. |
Advert | |
|
03-03-2012, 09:47 AM | #3 |
Connoisseur
Posts: 55
Karma: 46
Join Date: Feb 2012
Device: Kindle
|
That's cool! I can see a lot of potential in this.
|
03-03-2012, 10:28 AM | #4 |
Carpe diem, c'est la vie.
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
It looks like I can eliminate the filter function by using "subshell piping" to allow passing vars outside the loop. Also, after trying a number of string splitting methods that do not work on the touch busybox shell, I found one that does work.
Because this is an interactive application, I want to optimize it for speed by not calling external processes (like "[" and "cat"), replacing them with built-ins (like "[[" and shell string functions) whenever possible. I will post an updated script soon. I am redirecting my shell script STDOUT and STDERR to the eInk screen now, and I will eventually use this touchscreen hack to add onscreen keyboad support, for use in recovery (or other) shell scripts, with minimal dependency on external processes. Last edited by geekmaster; 03-03-2012 at 10:38 AM. |
03-03-2012, 02:43 PM | #5 |
Carpe diem, c'est la vie.
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
Updated first post in this thread to gmpaint-1.2.
Replaced "cut" subprocess calls with shell string processing (actually "set" command-line parsing used to parse output lines from hexdump). Replaced wrapper filter function with parentheses around entire subprocess loop, and added subprocess exit status check. It is "more better smaller faster simpler", and that is a "good thing" in my book! I hope you learn something from this -- I know *I* did! Enjoy! P.S. I left the original gmpaint-1.0.gz file in the dowload links in the first post above, in case you want to compare the original and latest versions of the script, to see what I was talking about above. Last edited by geekmaster; 03-03-2012 at 03:26 PM. |
Advert | |
|
03-03-2012, 11:35 PM | #6 |
Guru
Posts: 608
Karma: 1588610
Join Date: Jan 2012
Device: Kindle Scribe
|
just use
Code:
lipc-set-prop com.lab126.appmgrd start app://com.lab126.draw Last edited by aditya3098; 03-03-2012 at 11:37 PM. |
03-04-2012, 12:17 AM | #7 | |
Carpe diem, c'est la vie.
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
Quote:
But that is not the point. The "paint" function is merely a test stub for the touchscreen function. The final scripts (besides this ascii fingerpaint toy) will be a touchscreen reader script that returns scaled coordinates of your choice (600x800, 800x600, 50x40, or whatever). And another version will provide an onscreen keyboard, and will return a text string of whatever the user typed on the onscreen keyboard. These general touchscreen utility scripts will be callable by other scripts, for use in RUNME.sh recovery scripts (or anywhere else you want to use them). As mentioned in previous posts, this is primarily intended to be used in diagnostics mode. Are you sure that your recommended lipc command will work in that mode? And how about BEFORE the startup scripts run, when the framework has not been started yet? And for that matter, instead of that "paint" program you suggested I should use as a "practical" solution (it is really just a webpage) -- I make a counter suggestion: to be really "practical" (as you suggested) use the Gimp on a *real* computer. Last edited by geekmaster; 03-04-2012 at 12:34 AM. |
|
03-04-2012, 12:24 AM | #8 |
Carpe diem, c'est la vie.
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
The touchscreen paint program has been upgraded in the first post. It is now at version 1.3.
Check out the script code in the first post. It is getting smaller, and simpler, and better. It will be of more general use when it evolves into an onscreen touchscreen keyboard than can be called from shell scripts. As the versions progress, the code is following a typical pattern for me, where I add features by removing limitations, which has the side-effect of making the code smaller and simpler. As of version 1.3, the artwork you create with this program is automatically saved to touchpaint.raw on your USB drive when you exit the program (the previous image is renamed to touchpaint.raw.bak). Last edited by geekmaster; 03-22-2012 at 12:32 PM. Reason: fix typo |
04-06-2012, 02:31 AM | #9 |
Member
Posts: 18
Karma: 10
Join Date: Feb 2012
Device: K4NT
|
Keep up the great work GeekMaster, I can't wait to see the finished keyboard
|
04-06-2012, 08:27 AM | #10 |
Connoisseur
Posts: 92
Karma: 10
Join Date: Dec 2011
Device: Kindle Touch
|
A drawing program is amusing. An improved keyboard would be AMAZING! As a lurker, I can barely follow the commentary, much less the code, but please continue with your development, GeekMaster.
|
07-02-2012, 09:31 AM | #11 |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Týr
Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
a horse, a horse, my horse for a touchscreen....
|
07-02-2012, 10:58 AM | #12 |
Carpe diem, c'est la vie.
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
The next version of this that supports full 600x800 pixels was stripped down and released as "geekmaster signature capture": https://www.mobileread.com/forums/sho...d.php?t=178356
That is what I used to capture the signature used in my first "gmplay" video (and the newtrix demo, where the video generation code came from). |
04-21-2021, 11:38 PM | #13 |
Member
Posts: 11
Karma: 10
Join Date: Apr 2021
Device: KPW4
|
Help.
It works badly in KPW4, the words display is worse, plus that when i touch bottom right, it displays top left |
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
geekmaster's simple guide to tcc (tinycc) | geekmaster | Kindle Developer's Corner | 188 | 04-21-2021 07:09 PM |
geekmaster touchscreen signature capture script | geekmaster | Kindle Developer's Corner | 21 | 03-24-2016 05:59 PM |
Simple Esperanto ePub conversion script? | amuzulo | ePub | 10 | 03-06-2010 02:54 PM |
Simple Script to move content to CF Card (works around WLAN - CF Performance Bug) | torben | iRex | 0 | 12-03-2008 02:45 AM |
PRS-500 Hack script reference for the 500? | mdhuang | Sony Reader Dev Corner | 0 | 10-13-2007 12:15 AM |