Changeset 17 for liacs/mss/project/uinput.c
- Timestamp:
- Dec 1, 2009, 10:51:51 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
liacs/mss/project/uinput.c
r16 r17 66 66 &event.xbutton.state); 67 67 68 //printf("Mouse Coordinates: %d %d\n", event.xbutton.x, event.xbutton.y);68 printf("Mouse Coordinates: %d %d\n", event.xbutton.x, event.xbutton.y); 69 69 XCloseDisplay( dsp ); 70 70 xy_current.x = event.xbutton.x; … … 90 90 device.id.version=UINPUT_VERSION; 91 91 92 for (i=0; i < ABS_MAX; i++) {93 device.absmax[i] = -1;94 device.absmin[i] = -1;95 device.absfuzz[i] = -1;96 device.absflat[i] = -1;97 }92 //for (i=0; i < ABS_MAX; i++) { 93 // device.absmax[i] = -1; 94 // device.absmin[i] = -1; 95 // device.absfuzz[i] = -1; 96 // device.absflat[i] = -1; 97 //} 98 98 99 99 if (write(fd,&device,sizeof(device)) != sizeof(device)) … … 109 109 * Also, mouse buttons have to send sync events. 110 110 */ 111 ioctl(fd, UI_SET_EVBIT, EV_KEY);111 //ioctl(fd, UI_SET_EVBIT, EV_KEY); 112 112 ioctl(fd, UI_SET_EVBIT, EV_REL); 113 113 ioctl(fd, UI_SET_EVBIT, EV_SYN); … … 115 115 ioctl(fd, UI_SET_RELBIT, REL_X); 116 116 ioctl(fd, UI_SET_RELBIT, REL_Y); 117 ioctl(fd, UI_SET_RELBIT, REL_WHEEL);117 //ioctl(fd, UI_SET_RELBIT, REL_WHEEL); 118 118 119 119 ioctl(fd, UI_SET_KEYBIT, BTN_LEFT); 120 ioctl(fd, UI_SET_KEYBIT, BTN_RIGHT);121 ioctl(fd, UI_SET_KEYBIT, BTN_MIDDLE);120 //ioctl(fd, UI_SET_KEYBIT, BTN_RIGHT); 121 //ioctl(fd, UI_SET_KEYBIT, BTN_MIDDLE); 122 122 123 for (i=0; i < 256; i++) {124 ioctl(fd, UI_SET_KEYBIT, i);125 }123 //for (i=0; i < 256; i++) { 124 // ioctl(fd, UI_SET_KEYBIT, i); 125 //} 126 126 127 127 ioctl(fd, UI_DEV_CREATE, NULL); … … 130 130 131 131 int set_pointer(const struct coords xy_target) { 132 struct coords xy_current, xy_diff; 132 struct coords xy_diff, xy_prev; 133 struct coords xy_current = { -1 , -1 }; // Bogus inital value 134 char c; 133 135 // Force pointer to absolute location on the screen 134 136 while ( 1 ) { 135 xy_current = get_coords(); 136 xy_diff.x = -(xy_current.x - xy_target.x); 137 xy_diff.y = -(xy_current.y - xy_target.y); 137 //XXX: Screen pointer get updated really slow 138 xy_prev.x = xy_current.x; 139 xy_prev.y = xy_current.y; 140 while ( 1 ) { 141 xy_current = get_coords(); 142 // Found ourself an update 143 printf("old->new coordinates %ix%i -> %ix%i\n", 144 xy_prev.x,xy_prev.y, 145 xy_current.x,xy_current.y); 146 if (xy_prev.x != xy_current.x || xy_prev.y != xy_current.y) { 147 //ex_program(1); 148 break; 149 } 150 usleep(200000); 151 } 152 153 xy_diff.x = (xy_target.x - xy_current.x); 154 xy_diff.y = (xy_target.y - xy_current.y); 138 155 if (xy_diff.x == 0 && xy_diff.y == 0) { 156 printf("Location %ix%i\n", xy_current.x, xy_current.y); 139 157 break; 140 158 } else { … … 146 164 send_event(fd, EV_REL, REL_Y, xy_diff.y); 147 165 send_event(fd, EV_SYN, SYN_REPORT, 0); 148 // Wait some small period of time to get it populated (and the screen get updated 149 usleep(2000000); 150 break; 166 // Wait some small period of time to get it populated (and the screen get updated) 167 usleep(200000); 151 168 } 152 169 } … … 155 172 int 156 173 main() { 157 struct coords xy_target = { 500,500 };174 struct coords xy_target = { 200,200 }; 158 175 init_pointer(); 159 176 set_pointer(xy_target); 160 xy_target.x = 700;161 xy_target.y = 700;177 xy_target.x = 500; 178 xy_target.y = 500; 162 179 set_pointer(xy_target); 163 180 close_pointer();
Note:
See TracChangeset
for help on using the changeset viewer.