├── README ├── buttonExample.c ├── font_8x8.c ├── framebuffer.c ├── main.c ├── touch.c └── touch.h /README: -------------------------------------------------------------------------------- 1 | A simple program that demonstrates how to program for a 2 | touchscreen. Specifically on the Raspberry Pi. 3 | This prgram can be used for most Linux based systems. 4 | 5 | For more details: ozzmaker.com 6 | 7 | Compile buttonExample with "gcc -g -o buttonExample buttonExample.c -l wiringPi" 8 | -------------------------------------------------------------------------------- /buttonExample.c: -------------------------------------------------------------------------------- 1 | /* 2 | A simple program that demonstrates how to program for a 3 | touch screen. Specifically on the Raspberry Pi. 4 | This program can be used for most Linux based systems. 5 | For more details: www.marks-space.com 6 | 7 | Copyright (C) 2013 Mark Williams 8 | 9 | This library is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU Library General Public 11 | License as published by the Free Software Foundation; either 12 | version 2 of the License, or (at your option) any later version. 13 | 14 | This library is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Library General Public License for more details. 18 | 19 | You should have received a copy of the GNU Library General Public 20 | License along with this library; if not, write to the Free 21 | Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 22 | MA 02111-1307, USA 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include "touch.h" 30 | #include "touch.c" 31 | #include "framebuffer.c" 32 | #include 33 | #include 34 | #include 35 | #include "wiringPi.h" 36 | 37 | #define BUTTON_ON 1 38 | #define BUTTON_OFF 0 39 | 40 | 41 | #define LED_RED 1 42 | #define LED_GREEN 6 43 | #define LED_BLUE 4 44 | 45 | 46 | 47 | #define X 0 48 | #define Y 1 49 | #define W 2 50 | #define H 3 51 | 52 | void createButton(int x, int y, int w, int h, char *text, int backgroundColor, int foregroundColor) 53 | 54 | { 55 | int size = sizeof(text); 56 | char *p = text; 57 | int length = 0; 58 | 59 | //get length of the string *text 60 | while(*(p+length)) 61 | length++; 62 | 63 | // 64 | if((length*8)> (w-2)){ 65 | printf("####error,button too small for text####\n"); 66 | exit(1); 67 | } 68 | 69 | //Draw button outline 70 | drawSquare(x-2,y-2,w+4,h+4,backgroundColor); 71 | 72 | //Draw button foreground 73 | drawSquare(x,y,w,h,foregroundColor); 74 | //Place text on the button. Try and center it in a primitive way 75 | put_string(x+((w-(length*8))/2), y+((h-8)/2),text,4); 76 | } 77 | 78 | int SetPinsOut() 79 | { 80 | if (wiringPiSetup () == -1) 81 | exit (1) ; 82 | 83 | pinMode (LED_RED, OUTPUT) ; 84 | pinMode (LED_GREEN, OUTPUT) ; 85 | pinMode (LED_BLUE, OUTPUT) ; 86 | 87 | digitalWrite(LED_RED,LOW); 88 | digitalWrite(LED_GREEN,LOW); 89 | digitalWrite(LED_BLUE,LOW); 90 | 91 | } 92 | int mymillis() 93 | { 94 | struct timeval tv; 95 | gettimeofday(&tv, NULL); 96 | return (tv.tv_sec) * 1000 + (tv.tv_usec)/1000; 97 | } 98 | 99 | 100 | void INThandler(int sig) 101 | { 102 | digitalWrite(LED_RED,LOW); 103 | digitalWrite(LED_GREEN,LOW); 104 | digitalWrite(LED_BLUE,LOW); 105 | 106 | signal(sig, SIG_IGN); 107 | closeFramebuffer(); 108 | exit(0); 109 | } 110 | 111 | int main() 112 | { 113 | signal(SIGINT, INThandler); 114 | 115 | int xres,yres,x; 116 | 117 | 118 | int screenXmax, screenXmin; 119 | int screenYmax, screenYmin; 120 | 121 | float scaleXvalue, scaleYvalue; 122 | 123 | int rawX, rawY, rawPressure, scaledX, scaledY; 124 | 125 | 126 | 127 | //Used to monitor the timers for each button 128 | 129 | int buttonTimer2 = mymillis(); 130 | int buttonTimer3 = mymillis(); 131 | int buttonTimer4 = mymillis(); 132 | 133 | //To keep track of the button states 134 | int button2= BUTTON_OFF; 135 | int button3= BUTTON_OFF; 136 | int button4= BUTTON_OFF; 137 | 138 | //Our buttons. X, Y, Width, Height 139 | int buttonCords2[4] = {45,75,60,80}; 140 | int buttonCords3[4] = {135,75,60,80}; 141 | int buttonCords4[4] = {225,75,60,80}; 142 | 143 | 144 | 145 | if (openTouchScreen() == 1) 146 | perror("error opening touch screen"); 147 | 148 | 149 | getTouchScreenDetails(&screenXmin,&screenXmax,&screenYmin,&screenYmax); 150 | 151 | framebufferInitialize(&xres,&yres); 152 | 153 | scaleXvalue = ((float)screenXmax-screenXmin) / xres; 154 | printf ("X Scale Factor = %f\n", scaleXvalue); 155 | scaleYvalue = ((float)screenYmax-screenYmin) / yres; 156 | printf ("Y Scale Factor = %f\n", scaleYvalue); 157 | 158 | 159 | 160 | createButton(buttonCords2[X],buttonCords2[Y],buttonCords2[W],buttonCords2[H],"RED",GREY,RED); 161 | createButton(buttonCords3[X],buttonCords3[Y],buttonCords3[W],buttonCords3[H],"GREEN",GREY,GREEN); 162 | createButton(buttonCords4[X],buttonCords4[Y],buttonCords4[W],buttonCords4[H],"BLUE",GREY,BLUE); 163 | 164 | //Setup pins 165 | SetPinsOut(); 166 | 167 | 168 | 169 | while(1){ 170 | getTouchSample(&rawX, &rawY, &rawPressure); 171 | 172 | scaledX = rawX/scaleXvalue; 173 | scaledY = rawY/scaleYvalue; 174 | 175 | 176 | 177 | 178 | //See if the results retuned by the touch event fall within the coordinates of the button 179 | if((scaledX > buttonCords2[X] && scaledX < (buttonCords2[X]+buttonCords2[W])) && (scaledY > buttonCords2[Y] && scaledY < (buttonCords2[Y]+buttonCords2[H]))) 180 | //Has 500ms passed since the last time this button was pressed? 181 | if (mymillis() - buttonTimer2 > 500) 182 | //Is the button currently on? If so, we need to turn it off. 183 | if(button2){ 184 | //Change color to a darker red 185 | createButton(buttonCords2[X],buttonCords2[Y],buttonCords2[W],buttonCords2[H],"RED",GREY,RED); 186 | //Change state to off 187 | button2= BUTTON_OFF; 188 | //Start the timer 189 | buttonTimer2 = mymillis(); 190 | //Turn the LED off 191 | digitalWrite(LED_RED,LOW); 192 | 193 | } 194 | else{ 195 | //The button must be off.. so we need to turn it on. 196 | createButton(buttonCords2[X],buttonCords2[Y],buttonCords2[W],buttonCords2[H],"RED",WHITE,LIGHT_RED); 197 | //Change state to on 198 | button2= BUTTON_ON; 199 | //Start the timer 200 | buttonTimer2 = mymillis(); 201 | //Turn the LED on 202 | digitalWrite(LED_RED,HIGH); 203 | } 204 | 205 | if((scaledX > buttonCords3[X] && scaledX < (buttonCords3[X]+buttonCords3[W])) && (scaledY > buttonCords3[Y] && scaledY < (buttonCords3[Y]+buttonCords3[H]))) 206 | if (mymillis() - buttonTimer3 > 500) 207 | if(button3){ 208 | createButton(buttonCords3[X],buttonCords3[Y],buttonCords3[W],buttonCords3[H],"GREEN",GREY,GREEN); 209 | button3= BUTTON_OFF; 210 | buttonTimer3 = mymillis(); 211 | digitalWrite(LED_GREEN,LOW); 212 | } 213 | else{ 214 | createButton(buttonCords3[X],buttonCords3[Y],buttonCords3[W],buttonCords3[H],"GREEN",WHITE,LIGHT_GREEN); 215 | 216 | button3= BUTTON_ON; 217 | buttonTimer3 = mymillis(); 218 | digitalWrite(LED_GREEN,HIGH); 219 | } 220 | 221 | if((scaledX > buttonCords4[X] && scaledX < (buttonCords4[X]+buttonCords4[W])) && (scaledY > buttonCords4[Y] && scaledY < (buttonCords4[Y]+buttonCords4[H]))) 222 | if (mymillis() - buttonTimer4 > 500) 223 | if(button4){ 224 | createButton(buttonCords4[X],buttonCords4[Y],buttonCords4[W],buttonCords4[H],"BLUE",GREY,BLUE); 225 | button4= BUTTON_OFF; 226 | buttonTimer4 = mymillis(); 227 | digitalWrite(LED_BLUE,LOW); 228 | } 229 | else{ 230 | createButton(buttonCords4[X],buttonCords4[Y],buttonCords4[W],buttonCords4[H],"BLUE",WHITE,LIGHT_BLUE); 231 | button4= BUTTON_ON; 232 | buttonTimer4 = mymillis(); 233 | digitalWrite(LED_BLUE,HIGH); 234 | } 235 | 236 | } 237 | } 238 | 239 | 240 | 241 | 242 | 243 | -------------------------------------------------------------------------------- /font_8x8.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mwilliams03/Pi-Touchscreen-basic/57d25be08025d3e5b82d8ce9d556f58e934f3f3f/font_8x8.c -------------------------------------------------------------------------------- /framebuffer.c: -------------------------------------------------------------------------------- 1 | /* 2 | A simple program that demonstrates how to program for a 3 | touch screen. Specifically on the Raspberry Pi. 4 | This prgram can be used for most Linux based systems. 5 | For more details: www.marks-space.com 6 | 7 | Copyright (C) 2013 Mark Williams 8 | 9 | This library is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU Library General Public 11 | License as published by the Free Software Foundation; either 12 | version 2 of the License, or (at your option) any later version. 13 | 14 | This library is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Library General Public License for more details. 18 | 19 | You should have received a copy of the GNU Library General Public 20 | License along with this library; if not, write to the Free 21 | Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 22 | MA 02111-1307, USA 23 | */ 24 | #include 25 | #include 26 | #include 27 | #include "font_8x8.c" 28 | 29 | 30 | #define KNRM "\x1B[0m" 31 | #define KRED "\x1B[31m" 32 | #define KGRN "\x1B[32m" 33 | #define KYEL "\x1B[33m" 34 | #define KBLU "\x1B[34m" 35 | #define KMAG "\x1B[35m" 36 | #define KCYN "\x1B[36m" 37 | #define KWHT "\x1B[37m" 38 | 39 | static struct fb_fix_screeninfo fix; 40 | static struct fb_var_screeninfo orig_var; 41 | static struct fb_var_screeninfo var; 42 | char *fbp = 0; 43 | int fb=0; 44 | long int screensize = 0; 45 | 46 | 47 | 48 | // default framebuffer palette 49 | typedef enum { 50 | BLACK = 0, /* 0, 0, 0 */ 51 | BLUE = 1, /* 0, 0, 172 */ 52 | GREEN = 2, /* 0, 172, 0 */ 53 | CYAN = 3, /* 0, 172, 172 */ 54 | RED = 4, /* 172, 0, 0 */ 55 | PURPLE = 5, /* 172, 0, 172 */ 56 | ORANGE = 6, /* 172, 84, 0 */ 57 | LTGREY = 7, /* 172, 172, 172 */ 58 | GREY = 8, /* 84, 84, 84 */ 59 | LIGHT_BLUE = 9, /* 84, 84, 255 */ 60 | LIGHT_GREEN = 10, /* 84, 255, 84 */ 61 | LIGHT_CYAN = 11, /* 84, 255, 255 */ 62 | LIGHT_RED = 12, /* 255, 84, 84 */ 63 | LIGHT_PURPLE = 13, /* 255, 84, 255 */ 64 | YELLOW = 14, /* 255, 255, 84 */ 65 | WHITE = 15 /* 255, 255, 255 */ 66 | } COLOR_INDEX_T; 67 | static unsigned short def_r[] = 68 | { 0, 0, 0, 0, 172, 172, 172, 168, 69 | 84, 84, 84, 84, 255, 255, 255, 255}; 70 | static unsigned short def_g[] = 71 | { 0, 0, 168, 168, 0, 0, 84, 168, 72 | 84, 84, 255, 255, 84, 84, 255, 255}; 73 | static unsigned short def_b[] = 74 | { 0, 172, 0, 168, 0, 172, 0, 168, 75 | 84, 255, 84, 255, 84, 255, 84, 255}; 76 | 77 | 78 | 79 | void put_pixel_16bpp(int x, int y, int r, int g, int b) 80 | { 81 | unsigned int pix_offset; 82 | unsigned short c; 83 | 84 | // calculate the pixel's byte offset inside the buffer 85 | pix_offset = x*2 + y * fix.line_length; 86 | 87 | //some magic to work out the color 88 | c = ((r / 8) << 11) + ((g / 4) << 5) + (b / 8); 89 | 90 | // write 'two bytes at once' 91 | *((unsigned short*)(fbp + pix_offset)) = c; 92 | } 93 | 94 | 95 | void drawSquare(int x, int y,int height, int width, int c) 96 | //void drawSquare(int x, int y) 97 | { 98 | // int height = 20; 99 | // int width = 20; 100 | int h = 0; 101 | int w = 0; 102 | for ( h = 0; h< height;h++) 103 | for ( w = 0; w< width;w++) 104 | put_pixel_16bpp( h+(x-2), w+(y-2) , def_r[c],def_g[c],def_b[c]); 105 | 106 | } 107 | 108 | 109 | int framebufferInitialize(int *xres, int *yres) 110 | { 111 | char *fbdevice = "/dev/fb1" ; 112 | 113 | fb = open(fbdevice, O_RDWR); 114 | if (fb == -1) { 115 | perror("open fbdevice"); 116 | return -1; 117 | } 118 | 119 | if (ioctl(fb, FBIOGET_FSCREENINFO, &fix) < 0) { 120 | perror("ioctl FBIOGET_FSCREENINFO"); 121 | close(fb); 122 | return -1; 123 | } 124 | 125 | if (ioctl(fb, FBIOGET_VSCREENINFO, &var) < 0) { 126 | perror("ioctl FBIOGET_VSCREENINFO"); 127 | close(fb); 128 | return -1; 129 | } 130 | 131 | printf("Original %dx%d, %dbpp\n", var.xres, var.yres, 132 | var.bits_per_pixel ); 133 | 134 | memcpy(&orig_var, &var, sizeof(struct fb_var_screeninfo)); 135 | 136 | 137 | 138 | printf("Framebuffer %s%s%s resolution;\n",KYEL, fbdevice, KWHT); 139 | 140 | printf("%dx%d, %d bpp\n\n\n", var.xres, var.yres, var.bits_per_pixel ); 141 | 142 | // map framebuffer to user memory 143 | screensize = fix.smem_len; 144 | fbp = (char*)mmap(0, 145 | screensize, 146 | PROT_READ | PROT_WRITE, 147 | MAP_SHARED, 148 | fb, 0); 149 | if ((int)fbp == -1) { 150 | printf("Failed to mmap.\n"); 151 | } 152 | 153 | *xres = var.xres; 154 | *yres = var.yres; 155 | 156 | //clear framebuffer 157 | int x, y; 158 | for (x = 0; x 26 | #include 27 | #include 28 | #include 29 | #include "touch.h" 30 | #include "touch.c" 31 | #include "framebuffer.c" 32 | #include 33 | 34 | 35 | #define SAMPLE_AMOUNT 2 36 | 37 | void INThandler(int sig) 38 | { 39 | signal(sig, SIG_IGN); 40 | closeFramebuffer(); 41 | exit(0); 42 | } 43 | 44 | int main() 45 | { 46 | signal(SIGINT, INThandler); 47 | 48 | int xres,yres,x; 49 | 50 | int Xsamples[20]; 51 | int Ysamples[20]; 52 | 53 | int screenXmax, screenXmin; 54 | int screenYmax, screenYmin; 55 | 56 | float scaleXvalue, scaleYvalue; 57 | 58 | int rawX, rawY, rawPressure, scaledX, scaledY; 59 | 60 | int Xaverage = 0; 61 | int Yaverage = 0; 62 | 63 | 64 | if (openTouchScreen() == 1) 65 | perror("error opening touch screen"); 66 | 67 | 68 | getTouchScreenDetails(&screenXmin,&screenXmax,&screenYmin,&screenYmax); 69 | 70 | framebufferInitialize(&xres,&yres); 71 | 72 | scaleXvalue = ((float)screenXmax-screenXmin) / xres; 73 | printf ("X Scale Factor = %f\n", scaleXvalue); 74 | scaleYvalue = ((float)screenYmax-screenYmin) / yres; 75 | printf ("Y Scale Factor = %f\n", scaleYvalue); 76 | 77 | 78 | 79 | 80 | int h; 81 | 82 | 83 | int sample; 84 | 85 | while(1){ 86 | for (sample = 0; sample < SAMPLE_AMOUNT; sample++){ 87 | getTouchSample(&rawX, &rawY, &rawPressure); 88 | Xsamples[sample] = rawX; 89 | Ysamples[sample] = rawY; 90 | } 91 | 92 | Xaverage = 0; 93 | Yaverage = 0; 94 | 95 | for ( x = 0; x < SAMPLE_AMOUNT; x++ ){ 96 | Xaverage += Xsamples[x]; 97 | Yaverage += Ysamples[x]; 98 | } 99 | 100 | Xaverage = Xaverage/SAMPLE_AMOUNT; 101 | Yaverage = Yaverage/SAMPLE_AMOUNT; 102 | 103 | scaledX = Xaverage / scaleXvalue; 104 | scaledY = Yaverage / scaleYvalue; 105 | drawSquare(scaledX, scaledY,5,5,WHITE); 106 | } 107 | } 108 | 109 | 110 | -------------------------------------------------------------------------------- /touch.c: -------------------------------------------------------------------------------- 1 | /* 2 | A simple program that demonstrates how to program for a 3 | touch screen. Specifically on the Raspberry Pi. 4 | This prgram can be used for most Linux based systems. 5 | For more details: ozzmaker.com 6 | 7 | Copyright (C) 2013 Mark Williams 8 | 9 | This library is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU Library General Public 11 | License as published by the Free Software Foundation; either 12 | version 2 of the License, or (at your option) any later version. 13 | 14 | This library is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Library General Public License for more details. 18 | 19 | You should have received a copy of the GNU Library General Public 20 | License along with this library; if not, write to the Free 21 | Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 22 | MA 02111-1307, USA 23 | */ 24 | #define KWHT "\x1B[37m" 25 | #define KYEL "\x1B[33m" 26 | 27 | int fd; 28 | 29 | 30 | int openTouchScreen() 31 | { 32 | if ((fd = open("/dev/input/event0", O_RDONLY)) < 0) { 33 | return 1; 34 | } 35 | } 36 | 37 | 38 | void getTouchScreenDetails(int *screenXmin,int *screenXmax,int *screenYmin,int *screenYmax) 39 | { 40 | unsigned short id[4]; 41 | unsigned long bit[EV_MAX][NBITS(KEY_MAX)]; 42 | char name[256] = "Unknown"; 43 | int abs[6] = {0}; 44 | 45 | ioctl(fd, EVIOCGNAME(sizeof(name)), name); 46 | printf("Input device name: \"%s\"\n", name); 47 | 48 | memset(bit, 0, sizeof(bit)); 49 | ioctl(fd, EVIOCGBIT(0, EV_MAX), bit[0]); 50 | printf("Supported events:\n"); 51 | 52 | int i,j,k; 53 | for (i = 0; i < EV_MAX; i++) 54 | if (test_bit(i, bit[0])) { 55 | printf(" Event type %d (%s)\n", i, events[i] ? events[i] : "?"); 56 | if (!i) continue; 57 | ioctl(fd, EVIOCGBIT(i, KEY_MAX), bit[i]); 58 | for (j = 0; j < KEY_MAX; j++){ 59 | if (test_bit(j, bit[i])) { 60 | printf(" Event code %d (%s)\n", j, names[i] ? (names[i][j] ? names[i][j] : "?") : "?"); 61 | if (i == EV_ABS) { 62 | ioctl(fd, EVIOCGABS(j), abs); 63 | for (k = 0; k < 5; k++) 64 | if ((k < 3) || abs[k]){ 65 | printf(" %s %6d\n", absval[k], abs[k]); 66 | if (j == 0){ 67 | if (absval[k] == "Min ") *screenXmin = abs[k]; 68 | if (absval[k] == "Max ") *screenXmax = abs[k]; 69 | } 70 | if (j == 1){ 71 | if (absval[k] == "Min ") *screenYmin = abs[k]; 72 | if (absval[k] == "Max ") *screenYmax = abs[k]; 73 | } 74 | } 75 | } 76 | 77 | } 78 | } 79 | } 80 | } 81 | 82 | 83 | void getTouchSample(int *rawX, int *rawY, int *rawPressure) 84 | { 85 | int i; 86 | /* how many bytes were read */ 87 | size_t rb; 88 | /* the events (up to 64 at once) */ 89 | struct input_event ev[64]; 90 | 91 | rb=read(fd,ev,sizeof(struct input_event)*64); 92 | for (i = 0; i < (rb / sizeof(struct input_event)); i++){ 93 | if (ev[i].type == EV_SYN) 94 | printf("Event type is %s%s%s = Start of New Event\n",KYEL,events[ev[i].type],KWHT); 95 | 96 | else if (ev[i].type == EV_KEY && ev[i].code == 330 && ev[i].value == 1) 97 | printf("Event type is %s%s%s & Event code is %sTOUCH(330)%s & Event value is %s1%s = Touch Starting\n", KYEL,events[ev[i].type],KWHT,KYEL,KWHT,KYEL,KWHT); 98 | 99 | else if (ev[i].type == EV_KEY && ev[i].code == 330 && ev[i].value == 0) 100 | printf("Event type is %s%s%s & Event code is %sTOUCH(330)%s & Event value is %s0%s = Touch Finished\n", KYEL,events[ev[i].type],KWHT,KYEL,KWHT,KYEL,KWHT); 101 | 102 | else if (ev[i].type == EV_ABS && ev[i].code == 0 && ev[i].value > 0){ 103 | printf("Event type is %s%s%s & Event code is %sX(0)%s & Event value is %s%d%s\n", KYEL,events[ev[i].type],KWHT,KYEL,KWHT,KYEL,ev[i].value,KWHT); 104 | *rawX = ev[i].value; 105 | } 106 | else if (ev[i].type == EV_ABS && ev[i].code == 1 && ev[i].value > 0){ 107 | printf("Event type is %s%s%s & Event code is %sY(1)%s & Event value is %s%d%s\n", KYEL,events[ev[i].type],KWHT,KYEL,KWHT,KYEL,ev[i].value,KWHT); 108 | *rawY = ev[i].value; 109 | } 110 | else if (ev[i].type == EV_ABS && ev[i].code == 24 && ev[i].value > 0){ 111 | printf("Event type is %s%s%s & Event code is %sPressure(24)%s & Event value is %s%d%s\n", KYEL,events[ev[i].type],KWHT,KYEL,KWHT,KYEL,ev[i].value,KWHT); 112 | *rawPressure = ev[i].value; 113 | } 114 | 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /touch.h: -------------------------------------------------------------------------------- 1 | /* 2 | A simple program that demonstrates how to program for a 3 | touch screen. Specifically on the Raspberry Pi. 4 | This prgram can be used for most Linux based systems. 5 | For more details: www.marks-space.com 6 | 7 | Copyright (C) 2013 Mark Williams 8 | 9 | This library is free software; you can redistribute it and/or 10 | modify it under the terms of the GNU Library General Public 11 | License as published by the Free Software Foundation; either 12 | version 2 of the License, or (at your option) any later version. 13 | 14 | This library is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | Library General Public License for more details. 18 | 19 | You should have received a copy of the GNU Library General Public 20 | License along with this library; if not, write to the Free 21 | Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 22 | MA 02111-1307, USA 23 | */ 24 | #define BITS_PER_LONG (sizeof(long) * 8) 25 | #define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1) 26 | #define OFF(x) ((x)%BITS_PER_LONG) 27 | #define BIT(x) (1UL<> OFF(bit)) & 1) 30 | 31 | 32 | char *events[EV_MAX + 1] = { 33 | [0 ... EV_MAX] = NULL, 34 | [EV_SYN] = "Sync", [EV_KEY] = "Key", 35 | [EV_REL] = "Relative", [EV_ABS] = "Absolute", 36 | [EV_MSC] = "Misc", [EV_LED] = "LED", 37 | [EV_SND] = "Sound", [EV_REP] = "Repeat", 38 | [EV_FF] = "ForceFeedback", [EV_PWR] = "Power", 39 | [EV_FF_STATUS] = "ForceFeedbackStatus", 40 | }; 41 | 42 | char *keys[KEY_MAX + 1] = { 43 | [0 ... KEY_MAX] = NULL, 44 | [KEY_RESERVED] = "Reserved", [KEY_ESC] = "Esc", 45 | [KEY_1] = "1", [KEY_2] = "2", 46 | [KEY_3] = "3", [KEY_4] = "4", 47 | [KEY_5] = "5", [KEY_6] = "6", 48 | [KEY_7] = "7", [KEY_8] = "8", 49 | [KEY_9] = "9", [KEY_0] = "0", 50 | [KEY_MINUS] = "Minus", [KEY_EQUAL] = "Equal", 51 | [KEY_BACKSPACE] = "Backspace", [KEY_TAB] = "Tab", 52 | [KEY_Q] = "Q", [KEY_W] = "W", 53 | [KEY_E] = "E", [KEY_R] = "R", 54 | [KEY_T] = "T", [KEY_Y] = "Y", 55 | [KEY_U] = "U", [KEY_I] = "I", 56 | [KEY_O] = "O", [KEY_P] = "P", 57 | [KEY_LEFTBRACE] = "LeftBrace", [KEY_RIGHTBRACE] = "RightBrace", 58 | [KEY_ENTER] = "Enter", [KEY_LEFTCTRL] = "LeftControl", 59 | [KEY_A] = "A", [KEY_S] = "S", 60 | [KEY_D] = "D", [KEY_F] = "F", 61 | [KEY_G] = "G", [KEY_H] = "H", 62 | [KEY_J] = "J", [KEY_K] = "K", 63 | [KEY_L] = "L", [KEY_SEMICOLON] = "Semicolon", 64 | [KEY_APOSTROPHE] = "Apostrophe", [KEY_GRAVE] = "Grave", 65 | [KEY_LEFTSHIFT] = "LeftShift", [KEY_BACKSLASH] = "BackSlash", 66 | [KEY_Z] = "Z", [KEY_X] = "X", 67 | [KEY_C] = "C", [KEY_V] = "V", 68 | [KEY_B] = "B", [KEY_N] = "N", 69 | [KEY_M] = "M", [KEY_COMMA] = "Comma", 70 | [KEY_DOT] = "Dot", [KEY_SLASH] = "Slash", 71 | [KEY_RIGHTSHIFT] = "RightShift", [KEY_KPASTERISK] = "KPAsterisk", 72 | [KEY_LEFTALT] = "LeftAlt", [KEY_SPACE] = "Space", 73 | [KEY_CAPSLOCK] = "CapsLock", [KEY_F1] = "F1", 74 | [KEY_F2] = "F2", [KEY_F3] = "F3", 75 | [KEY_F4] = "F4", [KEY_F5] = "F5", 76 | [KEY_F6] = "F6", [KEY_F7] = "F7", 77 | [KEY_F8] = "F8", [KEY_F9] = "F9", 78 | [KEY_F10] = "F10", [KEY_NUMLOCK] = "NumLock", 79 | [KEY_SCROLLLOCK] = "ScrollLock", [KEY_KP7] = "KP7", 80 | [KEY_KP8] = "KP8", [KEY_KP9] = "KP9", 81 | [KEY_KPMINUS] = "KPMinus", [KEY_KP4] = "KP4", 82 | [KEY_KP5] = "KP5", [KEY_KP6] = "KP6", 83 | [KEY_KPPLUS] = "KPPlus", [KEY_KP1] = "KP1", 84 | [KEY_KP2] = "KP2", [KEY_KP3] = "KP3", 85 | [KEY_KP0] = "KP0", [KEY_KPDOT] = "KPDot", 86 | [KEY_ZENKAKUHANKAKU] = "Zenkaku/Hankaku", [KEY_102ND] = "102nd", 87 | [KEY_F11] = "F11", [KEY_F12] = "F12", 88 | [KEY_RO] = "RO", [KEY_KATAKANA] = "Katakana", 89 | [KEY_HIRAGANA] = "HIRAGANA", [KEY_HENKAN] = "Henkan", 90 | [KEY_KATAKANAHIRAGANA] = "Katakana/Hiragana", [KEY_MUHENKAN] = "Muhenkan", 91 | [KEY_KPJPCOMMA] = "KPJpComma", [KEY_KPENTER] = "KPEnter", 92 | [KEY_RIGHTCTRL] = "RightCtrl", [KEY_KPSLASH] = "KPSlash", 93 | [KEY_SYSRQ] = "SysRq", [KEY_RIGHTALT] = "RightAlt", 94 | [KEY_LINEFEED] = "LineFeed", [KEY_HOME] = "Home", 95 | [KEY_UP] = "Up", [KEY_PAGEUP] = "PageUp", 96 | [KEY_LEFT] = "Left", [KEY_RIGHT] = "Right", 97 | [KEY_END] = "End", [KEY_DOWN] = "Down", 98 | [KEY_PAGEDOWN] = "PageDown", [KEY_INSERT] = "Insert", 99 | [KEY_DELETE] = "Delete", [KEY_MACRO] = "Macro", 100 | [KEY_MUTE] = "Mute", [KEY_VOLUMEDOWN] = "VolumeDown", 101 | [KEY_VOLUMEUP] = "VolumeUp", [KEY_POWER] = "Power", 102 | [KEY_KPEQUAL] = "KPEqual", [KEY_KPPLUSMINUS] = "KPPlusMinus", 103 | [KEY_PAUSE] = "Pause", [KEY_KPCOMMA] = "KPComma", 104 | [KEY_HANGUEL] = "Hanguel", [KEY_HANJA] = "Hanja", 105 | [KEY_YEN] = "Yen", [KEY_LEFTMETA] = "LeftMeta", 106 | [KEY_RIGHTMETA] = "RightMeta", [KEY_COMPOSE] = "Compose", 107 | [KEY_STOP] = "Stop", [KEY_AGAIN] = "Again", 108 | [KEY_PROPS] = "Props", [KEY_UNDO] = "Undo", 109 | [KEY_FRONT] = "Front", [KEY_COPY] = "Copy", 110 | [KEY_OPEN] = "Open", [KEY_PASTE] = "Paste", 111 | [KEY_FIND] = "Find", [KEY_CUT] = "Cut", 112 | [KEY_HELP] = "Help", [KEY_MENU] = "Menu", 113 | [KEY_CALC] = "Calc", [KEY_SETUP] = "Setup", 114 | [KEY_SLEEP] = "Sleep", [KEY_WAKEUP] = "WakeUp", 115 | [KEY_FILE] = "File", [KEY_SENDFILE] = "SendFile", 116 | [KEY_DELETEFILE] = "DeleteFile", [KEY_XFER] = "X-fer", 117 | [KEY_PROG1] = "Prog1", [KEY_PROG2] = "Prog2", 118 | [KEY_WWW] = "WWW", [KEY_MSDOS] = "MSDOS", 119 | [KEY_COFFEE] = "Coffee", [KEY_DIRECTION] = "Direction", 120 | [KEY_CYCLEWINDOWS] = "CycleWindows", [KEY_MAIL] = "Mail", 121 | [KEY_BOOKMARKS] = "Bookmarks", [KEY_COMPUTER] = "Computer", 122 | [KEY_BACK] = "Back", [KEY_FORWARD] = "Forward", 123 | [KEY_CLOSECD] = "CloseCD", [KEY_EJECTCD] = "EjectCD", 124 | [KEY_EJECTCLOSECD] = "EjectCloseCD", [KEY_NEXTSONG] = "NextSong", 125 | [KEY_PLAYPAUSE] = "PlayPause", [KEY_PREVIOUSSONG] = "PreviousSong", 126 | [KEY_STOPCD] = "StopCD", [KEY_RECORD] = "Record", 127 | [KEY_REWIND] = "Rewind", [KEY_PHONE] = "Phone", 128 | [KEY_ISO] = "ISOKey", [KEY_CONFIG] = "Config", 129 | [KEY_HOMEPAGE] = "HomePage", [KEY_REFRESH] = "Refresh", 130 | [KEY_EXIT] = "Exit", [KEY_MOVE] = "Move", 131 | [KEY_EDIT] = "Edit", [KEY_SCROLLUP] = "ScrollUp", 132 | [KEY_SCROLLDOWN] = "ScrollDown", [KEY_KPLEFTPAREN] = "KPLeftParenthesis", 133 | [KEY_KPRIGHTPAREN] = "KPRightParenthesis", [KEY_F13] = "F13", 134 | [KEY_F14] = "F14", [KEY_F15] = "F15", 135 | [KEY_F16] = "F16", [KEY_F17] = "F17", 136 | [KEY_F18] = "F18", [KEY_F19] = "F19", 137 | [KEY_F20] = "F20", [KEY_F21] = "F21", 138 | [KEY_F22] = "F22", [KEY_F23] = "F23", 139 | [KEY_F24] = "F24", [KEY_PLAYCD] = "PlayCD", 140 | [KEY_PAUSECD] = "PauseCD", [KEY_PROG3] = "Prog3", 141 | [KEY_PROG4] = "Prog4", [KEY_SUSPEND] = "Suspend", 142 | [KEY_CLOSE] = "Close", [KEY_PLAY] = "Play", 143 | [KEY_FASTFORWARD] = "Fast Forward", [KEY_BASSBOOST] = "Bass Boost", 144 | [KEY_PRINT] = "Print", [KEY_HP] = "HP", 145 | [KEY_CAMERA] = "Camera", [KEY_SOUND] = "Sound", 146 | [KEY_QUESTION] = "Question", [KEY_EMAIL] = "Email", 147 | [KEY_CHAT] = "Chat", [KEY_SEARCH] = "Search", 148 | [KEY_CONNECT] = "Connect", [KEY_FINANCE] = "Finance", 149 | [KEY_SPORT] = "Sport", [KEY_SHOP] = "Shop", 150 | [KEY_ALTERASE] = "Alternate Erase", [KEY_CANCEL] = "Cancel", 151 | [KEY_BRIGHTNESSDOWN] = "Brightness down", [KEY_BRIGHTNESSUP] = "Brightness up", 152 | [KEY_MEDIA] = "Media", [KEY_UNKNOWN] = "Unknown", 153 | [BTN_0] = "Btn0", [BTN_1] = "Btn1", 154 | [BTN_2] = "Btn2", [BTN_3] = "Btn3", 155 | [BTN_4] = "Btn4", [BTN_5] = "Btn5", 156 | [BTN_6] = "Btn6", [BTN_7] = "Btn7", 157 | [BTN_8] = "Btn8", [BTN_9] = "Btn9", 158 | [BTN_LEFT] = "LeftBtn", [BTN_RIGHT] = "RightBtn", 159 | [BTN_MIDDLE] = "MiddleBtn", [BTN_SIDE] = "SideBtn", 160 | [BTN_EXTRA] = "ExtraBtn", [BTN_FORWARD] = "ForwardBtn", 161 | [BTN_BACK] = "BackBtn", [BTN_TASK] = "TaskBtn", 162 | [BTN_TRIGGER] = "Trigger", [BTN_THUMB] = "ThumbBtn", 163 | [BTN_THUMB2] = "ThumbBtn2", [BTN_TOP] = "TopBtn", 164 | [BTN_TOP2] = "TopBtn2", [BTN_PINKIE] = "PinkieBtn", 165 | [BTN_BASE] = "BaseBtn", [BTN_BASE2] = "BaseBtn2", 166 | [BTN_BASE3] = "BaseBtn3", [BTN_BASE4] = "BaseBtn4", 167 | [BTN_BASE5] = "BaseBtn5", [BTN_BASE6] = "BaseBtn6", 168 | [BTN_DEAD] = "BtnDead", [BTN_A] = "BtnA", 169 | [BTN_B] = "BtnB", [BTN_C] = "BtnC", 170 | [BTN_X] = "BtnX", [BTN_Y] = "BtnY", 171 | [BTN_Z] = "BtnZ", [BTN_TL] = "BtnTL", 172 | [BTN_TR] = "BtnTR", [BTN_TL2] = "BtnTL2", 173 | [BTN_TR2] = "BtnTR2", [BTN_SELECT] = "BtnSelect", 174 | [BTN_START] = "BtnStart", [BTN_MODE] = "BtnMode", 175 | [BTN_THUMBL] = "BtnThumbL", [BTN_THUMBR] = "BtnThumbR", 176 | [BTN_TOOL_PEN] = "ToolPen", [BTN_TOOL_RUBBER] = "ToolRubber", 177 | [BTN_TOOL_BRUSH] = "ToolBrush", [BTN_TOOL_PENCIL] = "ToolPencil", 178 | [BTN_TOOL_AIRBRUSH] = "ToolAirbrush", [BTN_TOOL_FINGER] = "ToolFinger", 179 | [BTN_TOOL_MOUSE] = "ToolMouse", [BTN_TOOL_LENS] = "ToolLens", 180 | [BTN_TOUCH] = "Touch", [BTN_STYLUS] = "Stylus", 181 | [BTN_STYLUS2] = "Stylus2", [BTN_TOOL_DOUBLETAP] = "Tool Doubletap", 182 | [BTN_TOOL_TRIPLETAP] = "Tool Tripletap", [BTN_TOOL_QUADTAP] = "Tool Quadtap", 183 | [BTN_GEAR_DOWN] = "WheelBtn", 184 | [BTN_GEAR_UP] = "Gear up", [KEY_OK] = "Ok", 185 | [KEY_SELECT] = "Select", [KEY_GOTO] = "Goto", 186 | [KEY_CLEAR] = "Clear", [KEY_POWER2] = "Power2", 187 | [KEY_OPTION] = "Option", [KEY_INFO] = "Info", 188 | [KEY_TIME] = "Time", [KEY_VENDOR] = "Vendor", 189 | [KEY_ARCHIVE] = "Archive", [KEY_PROGRAM] = "Program", 190 | [KEY_CHANNEL] = "Channel", [KEY_FAVORITES] = "Favorites", 191 | [KEY_EPG] = "EPG", [KEY_PVR] = "PVR", 192 | [KEY_MHP] = "MHP", [KEY_LANGUAGE] = "Language", 193 | [KEY_TITLE] = "Title", [KEY_SUBTITLE] = "Subtitle", 194 | [KEY_ANGLE] = "Angle", [KEY_ZOOM] = "Zoom", 195 | [KEY_MODE] = "Mode", [KEY_KEYBOARD] = "Keyboard", 196 | [KEY_SCREEN] = "Screen", [KEY_PC] = "PC", 197 | [KEY_TV] = "TV", [KEY_TV2] = "TV2", 198 | [KEY_VCR] = "VCR", [KEY_VCR2] = "VCR2", 199 | [KEY_SAT] = "Sat", [KEY_SAT2] = "Sat2", 200 | [KEY_CD] = "CD", [KEY_TAPE] = "Tape", 201 | [KEY_RADIO] = "Radio", [KEY_TUNER] = "Tuner", 202 | [KEY_PLAYER] = "Player", [KEY_TEXT] = "Text", 203 | [KEY_DVD] = "DVD", [KEY_AUX] = "Aux", 204 | [KEY_MP3] = "MP3", [KEY_AUDIO] = "Audio", 205 | [KEY_VIDEO] = "Video", [KEY_DIRECTORY] = "Directory", 206 | [KEY_LIST] = "List", [KEY_MEMO] = "Memo", 207 | [KEY_CALENDAR] = "Calendar", [KEY_RED] = "Red", 208 | [KEY_GREEN] = "Green", [KEY_YELLOW] = "Yellow", 209 | [KEY_BLUE] = "Blue", [KEY_CHANNELUP] = "ChannelUp", 210 | [KEY_CHANNELDOWN] = "ChannelDown", [KEY_FIRST] = "First", 211 | [KEY_LAST] = "Last", [KEY_AB] = "AB", 212 | [KEY_NEXT] = "Next", [KEY_RESTART] = "Restart", 213 | [KEY_SLOW] = "Slow", [KEY_SHUFFLE] = "Shuffle", 214 | [KEY_BREAK] = "Break", [KEY_PREVIOUS] = "Previous", 215 | [KEY_DIGITS] = "Digits", [KEY_TEEN] = "TEEN", 216 | [KEY_TWEN] = "TWEN", [KEY_DEL_EOL] = "Delete EOL", 217 | [KEY_DEL_EOS] = "Delete EOS", [KEY_INS_LINE] = "Insert line", 218 | [KEY_DEL_LINE] = "Delete line", 219 | [KEY_VIDEOPHONE] = "Videophone", [KEY_GAMES] = "Games", 220 | [KEY_ZOOMIN] = "Zoom In", [KEY_ZOOMOUT] = "Zoom Out", 221 | [KEY_ZOOMRESET] = "Zoom Reset", [KEY_WORDPROCESSOR] = "Word Processor", 222 | [KEY_EDITOR] = "Editor", [KEY_SPREADSHEET] = "Spreadsheet", 223 | [KEY_GRAPHICSEDITOR] = "Graphics Editor", [KEY_PRESENTATION] = "Presentation", 224 | [KEY_DATABASE] = "Database", [KEY_NEWS] = "News", 225 | [KEY_VOICEMAIL] = "Voicemail", [KEY_ADDRESSBOOK] = "Addressbook", 226 | [KEY_MESSENGER] = "Messenger", [KEY_DISPLAYTOGGLE] = "Display Toggle", 227 | [KEY_SPELLCHECK] = "Spellcheck", [KEY_LOGOFF] = "Log Off", 228 | [KEY_DOLLAR] = "Dollar", [KEY_EURO] = "Euro", 229 | [KEY_FRAMEBACK] = "Frame Back", [KEY_FRAMEFORWARD] = "Frame Forward", 230 | [KEY_CONTEXT_MENU] = "Context Menu", [KEY_MEDIA_REPEAT] = "Media Repeat", 231 | [KEY_DEL_EOL] = "Delete EOL", [KEY_DEL_EOS] = "Delete EOS", 232 | [KEY_INS_LINE] = "Insert Line", [KEY_DEL_LINE] = "Delete Line", 233 | [KEY_FN] = "Fn", [KEY_FN_ESC] = "Fn Esc", 234 | [KEY_FN_F1] = "Fn F1", [KEY_FN_F2] = "Fn F2", 235 | [KEY_FN_F3] = "Fn F3", [KEY_FN_F4] = "Fn F4", 236 | [KEY_FN_F5] = "Fn F5", [KEY_FN_F6] = "Fn F6", 237 | [KEY_FN_F7] = "Fn F7", [KEY_FN_F8] = "Fn F8", 238 | [KEY_FN_F9] = "Fn F9", [KEY_FN_F10] = "Fn F10", 239 | [KEY_FN_F11] = "Fn F11", [KEY_FN_F12] = "Fn F12", 240 | [KEY_FN_1] = "Fn 1", [KEY_FN_2] = "Fn 2", 241 | [KEY_FN_D] = "Fn D", [KEY_FN_E] = "Fn E", 242 | [KEY_FN_F] = "Fn F", [KEY_FN_S] = "Fn S", 243 | [KEY_FN_B] = "Fn B", 244 | [KEY_BRL_DOT1] = "Braille Dot 1", [KEY_BRL_DOT2] = "Braille Dot 2", 245 | [KEY_BRL_DOT3] = "Braille Dot 3", [KEY_BRL_DOT4] = "Braille Dot 4", 246 | [KEY_BRL_DOT5] = "Braille Dot 5", [KEY_BRL_DOT6] = "Braille Dot 6", 247 | [KEY_BRL_DOT7] = "Braille Dot 7", [KEY_BRL_DOT8] = "Braille Dot 8", 248 | [KEY_BRL_DOT9] = "Braille Dot 9", [KEY_BRL_DOT10] = "Braille Dot 10", 249 | [KEY_NUMERIC_0] = "Numeric 0", [KEY_NUMERIC_1] = "Numeric 1", 250 | [KEY_NUMERIC_2] = "Numeric 2", [KEY_NUMERIC_3] = "Numeric 3", 251 | [KEY_NUMERIC_4] = "Numeric 4", [KEY_NUMERIC_5] = "Numeric 5", 252 | [KEY_NUMERIC_6] = "Numeric 6", [KEY_NUMERIC_7] = "Numeric 7", 253 | [KEY_NUMERIC_8] = "Numeric 8", [KEY_NUMERIC_9] = "Numeric 9", 254 | [KEY_NUMERIC_STAR] = "Numeric *", [KEY_NUMERIC_POUND] = "Numeric #", 255 | [KEY_BATTERY] = "Battery", 256 | [KEY_BLUETOOTH] = "Bluetooth", [KEY_BRIGHTNESS_CYCLE] = "Brightness Cycle", 257 | [KEY_BRIGHTNESS_ZERO] = "Brightness Zero", [KEY_DASHBOARD] = "Dashboard", 258 | [KEY_DISPLAY_OFF] = "Display Off", [KEY_DOCUMENTS] = "Documents", 259 | [KEY_FORWARDMAIL] = "Forward Mail", [KEY_NEW] = "New", 260 | [KEY_KBDILLUMDOWN] = "Kbd Illum Down", [KEY_KBDILLUMUP] = "Kbd Illum Up", 261 | [KEY_KBDILLUMTOGGLE] = "Kbd Illum Toggle", [KEY_REDO] = "Redo", 262 | [KEY_REPLY] = "Reply", [KEY_SAVE] = "Save", 263 | [KEY_SCALE] = "Scale", [KEY_SEND] = "Send", 264 | [KEY_SCREENLOCK] = "Screen Lock", [KEY_SWITCHVIDEOMODE] = "Switch Video Mode", 265 | [KEY_UWB] = "UWB", [KEY_VIDEO_NEXT] = "Video Next", 266 | [KEY_VIDEO_PREV] = "Video Prev", [KEY_WIMAX] = "WIMAX", 267 | [KEY_WLAN] = "WLAN" 268 | 269 | }; 270 | 271 | char *absval[6] = { "Value", "Min ", "Max ", "Fuzz ", "Flat ", "Resolution "}; 272 | 273 | char *relatives[REL_MAX + 1] = { 274 | [0 ... REL_MAX] = NULL, 275 | [REL_X] = "X", [REL_Y] = "Y", 276 | [REL_Z] = "Z", [REL_HWHEEL] = "HWheel", 277 | [REL_DIAL] = "Dial", [REL_WHEEL] = "Wheel", 278 | [REL_MISC] = "Misc", 279 | }; 280 | 281 | char *absolutes[ABS_MAX + 1] = { 282 | [0 ... ABS_MAX] = NULL, 283 | [ABS_X] = "X", [ABS_Y] = "Y", 284 | [ABS_Z] = "Z", [ABS_RX] = "Rx", 285 | [ABS_RY] = "Ry", [ABS_RZ] = "Rz", 286 | [ABS_THROTTLE] = "Throttle", [ABS_RUDDER] = "Rudder", 287 | [ABS_WHEEL] = "Wheel", [ABS_GAS] = "Gas", 288 | [ABS_BRAKE] = "Brake", [ABS_HAT0X] = "Hat0X", 289 | [ABS_HAT0Y] = "Hat0Y", [ABS_HAT1X] = "Hat1X", 290 | [ABS_HAT1Y] = "Hat1Y", [ABS_HAT2X] = "Hat2X", 291 | [ABS_HAT2Y] = "Hat2Y", [ABS_HAT3X] = "Hat3X", 292 | [ABS_HAT3Y] = "Hat 3Y", [ABS_PRESSURE] = "Pressure", 293 | [ABS_DISTANCE] = "Distance", [ABS_TILT_X] = "XTilt", 294 | [ABS_TILT_Y] = "YTilt", [ABS_TOOL_WIDTH] = "Tool Width", 295 | [ABS_VOLUME] = "Volume", [ABS_MISC] = "Misc", 296 | [ABS_MT_TOUCH_MAJOR] = "Touch Major", 297 | [ABS_MT_TOUCH_MINOR] = "Touch Minor", 298 | [ABS_MT_WIDTH_MAJOR] = "Width Major", 299 | [ABS_MT_WIDTH_MINOR] = "Width Minor", 300 | [ABS_MT_ORIENTATION] = "Orientation", 301 | [ABS_MT_POSITION_X] = "Position X", 302 | [ABS_MT_POSITION_Y] = "Position Y", 303 | [ABS_MT_TOOL_TYPE] = "Tool Type", 304 | [ABS_MT_BLOB_ID] = "Blob ID", 305 | [ABS_MT_TRACKING_ID] = "Tracking ID", 306 | 307 | }; 308 | 309 | char *misc[MSC_MAX + 1] = { 310 | [ 0 ... MSC_MAX] = NULL, 311 | [MSC_SERIAL] = "Serial", [MSC_PULSELED] = "Pulseled", 312 | [MSC_GESTURE] = "Gesture", [MSC_RAW] = "RawData", 313 | [MSC_SCAN] = "ScanCode", 314 | }; 315 | 316 | char *leds[LED_MAX + 1] = { 317 | [0 ... LED_MAX] = NULL, 318 | [LED_NUML] = "NumLock", [LED_CAPSL] = "CapsLock", 319 | [LED_SCROLLL] = "ScrollLock", [LED_COMPOSE] = "Compose", 320 | [LED_KANA] = "Kana", [LED_SLEEP] = "Sleep", 321 | [LED_SUSPEND] = "Suspend", [LED_MUTE] = "Mute", 322 | [LED_MISC] = "Misc", 323 | }; 324 | 325 | char *repeats[REP_MAX + 1] = { 326 | [0 ... REP_MAX] = NULL, 327 | [REP_DELAY] = "Delay", [REP_PERIOD] = "Period" 328 | }; 329 | 330 | char *sounds[SND_MAX + 1] = { 331 | [0 ... SND_MAX] = NULL, 332 | [SND_CLICK] = "Click", [SND_BELL] = "Bell", 333 | [SND_TONE] = "Tone" 334 | }; 335 | 336 | char **names[EV_MAX + 1] = { 337 | [0 ... EV_MAX] = NULL, 338 | [EV_SYN] = events, [EV_KEY] = keys, 339 | [EV_REL] = relatives, [EV_ABS] = absolutes, 340 | [EV_MSC] = misc, [EV_LED] = leds, 341 | [EV_SND] = sounds, [EV_REP] = repeats, 342 | }; 343 | 344 | 345 | 346 | --------------------------------------------------------------------------------