Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. static int startDevice(const char *touchdevice) {
  2.  
  3. struct uinput_user_dev uidev;
  4. int fd;
  5.  
  6. fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
  7. if (fd < 0) {
  8. die("error: open");
  9. }
  10. memset(&uidev, 0, sizeof(uidev));
  11.  
  12. snprintf(uidev.name, UINPUT_MAX_NAME_SIZE, "%s",touchdevice);
  13.  
  14.  
  15. uidev.id.bustype = 0;
  16. uidev.id.vendor = 0x0;
  17. uidev.id.product = 0x0;
  18. uidev.id.version = 0;
  19. uidev.absmax[ABS_MT_POSITION_X] = 1280;
  20. uidev.absmax[ABS_MT_POSITION_Y] = 800;
  21.  
  22. if (write(fd, &uidev, sizeof(uidev)) < 0) {
  23. die("error: write");
  24. }
  25. ioctl(fd, UI_SET_EVBIT, EV_ABS);
  26.  
  27.  
  28. ioctl(fd, UI_SET_ABSBIT, ABS_MT_POSITION_X);
  29. ioctl(fd, UI_SET_ABSBIT, ABS_MT_POSITION_Y);
  30. ioctl(fd, UI_SET_ABSBIT, ABS_MT_PRESSURE);
  31. ioctl(fd, UI_SET_ABSBIT, ABS_MT_TOUCH_MAJOR);
  32. ioctl(fd, UI_SET_ABSBIT, ABS_MT_SLOT);
  33. ioctl(fd, UI_SET_ABSBIT, ABS_MT_TRACKING_ID);
  34.  
  35. ioctl(fd, UI_SET_KEYBIT, BTN_TOUCH);
  36.  
  37.  
  38. if (ioctl(fd, UI_DEV_CREATE, 0) < 0) {
  39. die("error: ioctl");
  40. }
  41.  
  42. idVirtualTouch = fd;
  43.  
  44. return 55;
  45. }
  46.  
  47. touch.deviceType = touchScreen
  48. touch.internal = 1
  49.  
  50. uidev.absmax[ABS_MT_TRACKING_ID] = 65535;
  51. uidev.absmax[ABS_MT_SLOT] = 9;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement