So I finally solved this problem by writing my own little utility that
would help me discern what was actually going on. here is the source
<Yes I know the code is not the best>:
#include <stdio.h>
#include <stdlib.h>
#include <linux/input.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
#include <error.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define ERROR fprintf(stderr, "Error %d:%s on line: %d in file: %s\n",
errno, strerror(errno), __LINE__, __FILE__)
/* These constants are not defined in linux/input.h but they are part
of the multitouch
* input protocol. */
#define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching ellipse */
#define ABS_MT_TOUCH_MINOR 0x31 /* Minor axis (omit if circular) */
#define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse
*/
#define ABS_MT_WIDTH_MINOR 0x33 /* Minor axis (omit if circular) */
#define ABS_MT_ORIENTATION 0x34 /* Ellipse orientation */
#define ABS_MT_POSITION_X 0x35 /* Center X ellipse position */
#define ABS_MT_POSITION_Y 0x36 /* Center Y ellipse position */
#define ABS_MT_TOOL_TYPE 0x37 /* Type of touching device (finger,
pen, ...) */
#define ABS_MT_BLOB_ID 0x38 /* Group a set of packets as a blob
*/
#define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */
#define ABS_MT_PRESSURE 0x3a /* Pressure on contact area */
#define SYN_MT_REPORT 2
#define MT_TOOL_FINGER 0 /* Identifies a finger */
#define MT_TOOL_PEN 1 /* Identifies a pen */
void signal_handler(int signum);
char *const event_type_to_string(int event_type);
char *const code_to_string(int code);
static int quit = 0;
char str[32] = {0};
int main(int argc, char *argv[]) {
struct input_event ev;
int mt_fd;
if(signal(SIGINT, signal_handler) == SIG_ERR) {
ERROR;
exit(EXIT_FAILURE);
}
mt_fd = open("/dev/input/event10", O_RDONLY);
if(mt_fd < 0) {
ERROR;
exit(EXIT_FAILURE);
}
//until we exit loop reading events
while(!quit) {
int bytes_read = 0;
//read one event, keep calling read until event is filled
do {
bytes_read += read(mt_fd, &ev, sizeof(ev));
} while(bytes_read < sizeof(ev) && bytes_read != 0);
printf( "ev.time: %ld\n"
"ev.type: %s\n"
"ev.code: %s\n"
"ev.value %d\n", ev.time.tv_sec,
event_type_to_string(ev.type),
code_to_string(ev.code), ev.value);
}
exit(EXIT_SUCCESS);
}
char *const code_to_string(int code) {
char *code_string;
switch(code) {
case ABS_MT_TOUCH_MAJOR:
code_string = "ABS_MT_TOUCH_MAJOR";
break;
case ABS_MT_TOUCH_MINOR:
code_string = "ABS_MT_TOUCH_MINOR";
break;
case ABS_MT_WIDTH_MAJOR:
code_string = "ABS_MT_WIDTH_MAJOR";
break;
case ABS_MT_WIDTH_MINOR:
code_string = "ABS_MT_WIDTH_MINOR";
break;
case ABS_MT_ORIENTATION:
code_string = "ABS_MT_ORIENTATION";
break;
case ABS_MT_POSITION_X:
code_string = "ABS_MT_POSITION_X";
break;
case ABS_MT_POSITION_Y:
code_string = "ABS_MT_POSITION_Y";
break;
case ABS_MT_TOOL_TYPE:
code_string = "ABS_MT_TOOL_TYPE";
break;
case ABS_MT_BLOB_ID:
code_string = "ABS_MT_BLOB_ID";
break;
case ABS_MT_TRACKING_ID:
code_string = "ABS_MT_TRACKING_ID";
break;
case ABS_MT_PRESSURE:
code_string = "ABS_MT_PRESSURE";
break;
case SYN_MT_REPORT:
code_string = "SYN_MT_REPORT";
break;
default:
sprintf(str, "%d", code);
code_string = str;
}
return code_string;
}
char *const event_type_to_string(int event_type) {
char *event_string;
switch(event_type) {
case EV_SYN:
event_string = "EV_SYN";
break;
case EV_KEY:
event_string = "EV_KEY";
break;
case EV_REL:
event_string = "EV_REL";
break;
case EV_ABS:
event_string = "EV_ABS";
break;
case EV_MSC:
event_string = "EV_MSC";
break;
case EV_SW:
event_string = "EV_SW";
break;
case EV_LED:
event_string = "EV_LED";
break;
case EV_SND:
event_string = "EV_SND";
break;
case EV_REP:
event_string = "EV_REP";
break;
case EV_FF:
event_string = "EV_FF";
break;
case EV_PWR:
event_string = "EV_PWR";
break;
case EV_FF_STATUS:
event_string = "EV_FF_STATUS";
break;
case EV_MAX:
event_string = "EV_MAX";
break;
default:
sprintf(str, "%d", event_type);
event_string = str;
}
return event_string;
}
void signal_handler(int signum) {
switch(signum) {
case SIGINT:
quit = 1;
break;
}
return;
}
On Jun 3, 11:50 pm, Tsai Gaggery <[email protected]> wrote:
> Hi Bill,
>
> There is a good utility for you to understand the input subsystem
> event. You may reference to the source code for details.
>
> http://cgit.freedesktop.org/~whot/evtest/
>
> regards,
> Gaggery
>
> 2011/6/3 badcc0de <[email protected]>:
>
>
>
> > Hello,
> > I am having an issue of understanding the raw dumps off /dev/input/
> > event3 which is mytouchscreen. I have read the kernel docs, used mtd-
> > tool and read their source and I am still lost; maybe someone can
> > straighten me out. So when I cat the aforementioned file I get the
> > dump below:
>
> > 0011e80: e312 0000 dcd3 0800 0300 3500 bf00 0000 ..........5.....
> > 0011e90: e312 0000 6bd4 0800 0300 3600 dd01 0000 ....k.....6.....
> > 0011ea0: e312 0000 a1d4 0800 0300 3000 2800 0000 ..........0.(...
> > 0011eb0: e312 0000 d4d4 0800 0300 3200 0700 0000 ..........2.....
> > 0011ec0: e312 0000 07d5 0800 0000 0200 0000 0000 ................
> > 0011ed0: e312 0000 48d5 0800 0000 0000 0000 0000 ....H...........
> > 0011ee0: e312 0000 48c2 0900 0300 3500 bf00 0000 ....H.....5.....
> > 0011ef0: e312 0000 5ec2 0900 0300 3600 dd01 0000 ....^.....6.....
> > 0011f00: e312 0000 65c2 0900 0300 3000 0000 0000 ....e.....0.....
> > 0011f10: e312 0000 6cc2 0900 0300 3200 0300 0000 ....l.....2.....
> > 0011f20: e312 0000 73c2 0900 0000 0200 0000 0000 ....s...........
> > 0011f30: e312 0000 7dc2 0900 0000 0000 0000 0000 ....}...........
>
> > I think I got these bytes down (bytes are 0 - 7 inclusive starting at
> > the low address)
>
> > Byte 5 --> ABS_MT_TOUCH_MAJOR ABS_MT_POSITION_X
> > Byte 6/7 --> data related to what byte 5 is, for instance if byte 5 is
> > ABS_MT_POSITION_X those bytes have x coordinate
>
> > Can anybody tell me which bytes contain what?
>
> > I am running Froyo with a 2.6.32.9 kernel
>
> > Thank you...
>
> > --
> > unsubscribe: [email protected]
> > website:http://groups.google.com/group/android-porting
>
> --
> Regards,
> Gaggery
--
unsubscribe: [email protected]
website: http://groups.google.com/group/android-porting