11-19-2012, 03:36 PM | #1 |
Wizard
Posts: 2,986
Karma: 18343081
Join Date: Oct 2010
Location: Sudbury, ON, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623, PB 840, PB 633
|
Programming pinch events on the Touch
Does anyone know anything about handling pinch events within the Inkview API? The SDK hasn't been updated in a while, and there are new events showing up in the handler that aren't defined in inkview.h. Specifically event types 39 and 44 are showing up. EVT_TOUCHUP is 40, EVT_TOUCHDOWN is 41, and EVT_TOUCHMOVE is 42, so the new types are probably touch related, as well. I suspect that they are necessary to handle pinch events, but I have no idea how. Even source code for a program that handles pinches would be good. Is there no one writing applications for the Touch?
|
11-27-2012, 02:46 AM | #2 |
Junior Member
Posts: 2
Karma: 11426
Join Date: Mar 2010
Device: PocketBook 301+
|
Event 39 is EVT_MTSYNC, for multi-touch handling, par2 is touch count. Full information about the event is obtained with GetTouchInfo() function, it returns an array of iv_mtinfo structures. Here is an example:
iv_mtinfo *mti = GetTouchInfo(); int tcnt = par2; int cx = (tcnt > 1) ? (mti[0].x + mti[1].x) / 2 : mti[0].x; int cy = (tcnt > 1) ? (mti[0].y + mti[1].y) / 2 : mti[0].y; Event 44 is EVT_POINTERDRAG, like EVT_POINTERMOVE but with some dead zone, to filter accidental finger move. |
11-27-2012, 03:19 AM | #3 |
Wizard
Posts: 2,986
Karma: 18343081
Join Date: Oct 2010
Location: Sudbury, ON, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623, PB 840, PB 633
|
Thanks! The 1.1a release of the SDK doesn't include the definition of iv_mtinfo. Does it look like this?:
Code:
typedef struct iv_mtinfo_s { int x; int y; } iv_mtinfo; Also, will par2 (touch count) only ever be 1 or 2, or can there be more than that (for example, if three fingers are used)? I assume that the iv_mtinfo array only includes points from a single point in time, and not from multiple points concatenated together. Finally, does par1 mean anything in EVT_MYSYNC events? Oops, one more question: should the iv_mtinfo array returned by GetTouchInfo() be freed? Last edited by rkomar; 11-27-2012 at 02:33 PM. Reason: Added another question |
11-27-2012, 06:49 PM | #4 |
Wizard
Posts: 2,986
Karma: 18343081
Join Date: Oct 2010
Location: Sudbury, ON, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623, PB 840, PB 633
|
There is no GetTouchInfo() function in libinkview.so within the 1.1a SDK. I guess this means that I cannot build an executable that handles multi-touch events until a new SDK comes out. Too bad. The function is also missing from libinkview.so on my 902 reader (2.1.3 firmware), so a different executable would have to be built for the Touch, or I'd have to figure out how to dynamically use the function.
Edit: I looks like I can build it using dlopen()/dlsym() to call the GetTouchInfo function if it exists. It's ugly code, though. Last edited by rkomar; 11-27-2012 at 07:44 PM. Reason: Added comment about being able to build without GetTouchInfo(). |
11-30-2012, 02:06 AM | #5 |
Junior Member
Posts: 2
Karma: 11426
Join Date: Mar 2010
Device: PocketBook 301+
|
Here is an actual inkview.h, with all needed structures and functions.
For 902, it's not a problem - you will call GetTouchInfo() only from MTSYNC event, there's no such event on 902, and because of lazy resolving, "unresolved symbol" will not occur. |
11-30-2012, 03:02 AM | #6 |
Wizard
Posts: 2,986
Karma: 18343081
Join Date: Oct 2010
Location: Sudbury, ON, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623, PB 840, PB 633
|
Thank you very much. The iv_mtinfo struct is quite different from what I imagined, so my guess would not have worked.
I cannot get the application to link if I call GetTouchInfo() because it is missing from my libinkview.so (SDK 1.1a). Anyways, it doesn't matter because I can use dlopen/dlsym to make the call inside the if(type == EVT_MTSYNC) {} block for now. I will have to wait for an updated SDK before I can write code to call the function directly. |
12-25-2012, 05:03 PM | #7 |
Wizard
Posts: 2,986
Karma: 18343081
Join Date: Oct 2010
Location: Sudbury, ON, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623, PB 840, PB 633
|
If anyone wants to know how to call GetTouchInfo() (or any other function) if it isn't part of their SDK, here's some simple example code showing how to do it:
Code:
#include <stdio.h> #include <dlfcn.h> #define EVT_MTSYNC 39 #define EVT_POINTERDRAG 44 typedef struct iv_mtinfo_s { int active; int x; int y; int pressure; int rsv_1; int rsv_2; } iv_mtinfo; iv_mtinfo* (*gti)(void); /* Pointer to GetTouchInfo() function. */ int main_handler(int type, int par1, int par2) { void *handle; iv_mtinfo *mti; int i; if (type == EVT_INIT) { if ((handle = dlopen("libinkview.so", RTLD_LAZY))) { *(void **) (>i) = dlsym(handle, "GetTouchInfo"); dlclose(handle); } else gti = NULL; } if type == EVT_MTSYNC) { if (gti && (mti = (*gti)())) { for (i = 0; i < par2; i++) printf(" x = %d, y = %d\n", mti[i].x, mti[i].y); } } return 0; } Last edited by rkomar; 12-25-2012 at 06:16 PM. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
kindle pw pinch to zoom in pdf | max99 | Amazon Kindle | 0 | 10-29-2012 08:19 AM |
Detecting headphone events on kindle touch | inuxy | Kindle Developer's Corner | 4 | 07-15-2012 11:38 AM |
Touch uinput : send simulated touch/key events to Kobo ? | Rom1 | Kobo Reader | 0 | 06-08-2012 08:50 AM |
Touch screen events | Ehhh | Kindle Developer's Corner | 3 | 05-16-2012 02:33 PM |
pinch to zoom on the kindle touch | Cavestory | Amazon Kindle | 9 | 10-14-2011 01:11 PM |