View Single Post
Old 05-16-2012, 06:25 PM   #2
geekmaster
Carpe diem, c'est la vie.
geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.geekmaster ought to be getting tired of karma fortunes by now.
 
geekmaster's Avatar
 
Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
Quote:
Originally Posted by JoppyFurr View Post
Hi,

I'm just getting started with Kindle development. My goal is to eventually write some form of terminal emulator, so that I could use my Kindle Touch to ssh back to my home computer.

I've started learning to use the frame buffer and touch screen. However, am curious of how to take over the touch screen so that the normal Kindle interface isn't trying to use it at the same time.

I've read this thread:
https://www.mobileread.com/forums/sho....php?t=178143-
Which showed me that touch events can be found at /dev/input/event3. However, I have not been able to find information on allowing a program to completely take over the input.

I've seen other programs that seem to do this. For example, the Sokoban game linked to on the Kindle Touch Hacks page allows you to play without it interfearing with menu items 'behind' the game.

I've made a program that allows you to draw to the screen with your finger. However, it seems like my program is figting with another over the touch screen. When drawing a line with my finger, it shows dashed. As if it was taking turns with the touch screen, getting access to it in chunks of a half second or so.

I have attached my code, if anybody wants to play with it. When it is running, you can stop the program by draging your finger to the top right corner and releasing. I've been compiling with the tcc compiler linked to from here:
https://www.mobileread.com/forums/sho...d.php?t=175834

Any tips would be appreciated :3
Thanks,

JoppyFurr
Actually, the device event number is different depending on whether you boot from main or diags, which is why the code shown searches for a device that returns the "zforce" identifier. You cannot trust that it will always be device 3.

If you look at my simpler version of that, published as a "signature capture" script, you will see that it pauses and resumes the framework (Xorg and cvm). That works quite well for my needs. You can do the same as a script command by enclosing it in a system() call; You can also see how it is handled in the various scripts published in the "eink algorithmic art" scripts thread. Of course, the "official" way is to use ioctl() calls to capture the event device, but because amazone BROKE stuff in the eink header files (and probably more), that would lock your program to only work on a specific minor version of the firmware. Doing it the "script" way is more robust because of amazon's recent arbitrary changes that violate linux standards. You can see how to capture a device by looking in the "myts" onscreen terminal code. Touchscreen events are just like keyboard events used there.

You can search to find the threads containing my various scripts and C programs. They give examples how to do lots of things from scripts and from C. I also have a series of C programs that do much faster graphics, including smooth animation and video playback on a K3 and newer.

I will look at your code now...


A few little tips:
1) If your code is based on other code (such as my simplified touch code in the script you referenced and translated to C), it is considered polite to give credit to the person whose ideas you borrow (although not strictly required under the MIT license that I use). This is called "user attribution" and is required under some licenses. In this case, the event code as documented is a lot more complex, and it took me significant experimentation and refinement to simplify it to the level in my sigcap script (almost identical to what you used).

2) If you want to share your code with others, many people cannot use it unless it has a clear open source license. GPL is forbidden to be used by programmers who white commercial apps, so I recommend MIT (or BSD).

3) In conditional expressions, experienced programmer ALWAYS put the constant to the left of the variable, so that accidentally changing "==" to "=" will cause a compiler warning instead of just changing to a VERY DIFFICULT to debug program error.

Now I am going to test your program...

It is a good start. I like the grid. Your lag is a lot worse in this C program than in my sigcap script that uses "dd" to write pixels to the screen. Your program will be MUCH faster after that little problem is solved. And yes, even my programs suffer these problems while they are in development. Each problem needs to be tracked down and fixed.

I am giving you the "geekmaster award" (bumping your karma to 2600, a special numbers familiar to hackers from long before there were computers).

P.S. Please add a "thanks geekmaster!" comment (or similar) and add the MIT license to it like I use. That will make me happy, and will make your code useful to a lot more people. Thanks.

*** I see that you defined the upper right corner as exit. Because I do most of my touch capture in landscape mode, I defined the lower right corner as exit (which IS the upper right corner when rotated the way I use if for signature capture).

Check out my "newtrix" demo to see how to shaded lines and circles from C, and how to draw vector art captured from the touchscreen using my sigcap script (which outputs a C structure to use in the newtrix code).


Last edited by geekmaster; 05-16-2012 at 07:03 PM.
geekmaster is offline   Reply With Quote