driver.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #pragma once
  2. #include <semaphore.h>
  3. #include <libusb-1.0/libusb.h>
  4. //passive auth flags
  5. #define PA_STOP 0x00
  6. #define PA_START 0x01
  7. #define PA_SUCCESS 0x02
  8. #define PA_FAILED 0x03
  9. #define BUFLEN_PACKETDATA 2052
  10. #define BUFLEN_RAMDATA 96
  11. #define BUFLEN_DATA 38912
  12. #define MODE_IDLE 0x00
  13. #define MODE_TOUCHPAD 0x10
  14. #define MODE_TOUCHPAD_MOUSE 0x11
  15. #define MODE_TOUCHPAD_WHEELS 0x12
  16. #define MODE_TOUCHPAD_ARROWS 0x13
  17. #define MODE_SCANNING 0x20
  18. #define STATE_RUNNING 0x00
  19. #define STATE_WAIT_IPC 0x01
  20. //#define STATE_ERROR 0x02
  21. struct driverInstance {
  22. libusb_device_handle* deviceHandle;
  23. int launcherdSocket;
  24. sem_t semaphoreIpc;
  25. sem_t semaphoreIdle;
  26. sem_t semaphoreScan;
  27. sem_t semaphoreInterrupt;
  28. unsigned char modeIndicator;
  29. unsigned char modeSwitcher;
  30. unsigned char touchpadMode;
  31. unsigned char driverState;
  32. unsigned char requestCounter;
  33. //send
  34. unsigned char sendPacketType;
  35. int sendPacketMessageLength;
  36. //rcv means received
  37. unsigned char rcvPacketType;
  38. int rcvPacketMessageLength;
  39. //packet buffer
  40. unsigned char _packetData[BUFLEN_PACKETDATA];
  41. unsigned char* packetMessage;// &_packetData[7]
  42. //data buffer
  43. unsigned char data[BUFLEN_DATA];
  44. int dataLength;
  45. //ram buffer
  46. unsigned char ramData[BUFLEN_RAMDATA];
  47. //interrupt and control
  48. int interruptStatus;
  49. unsigned char controlStatus[8];
  50. //used for communicate between driver and ipcd in scan mode
  51. int scanResult;
  52. unsigned char scanQuality;
  53. //used to communicate between driver and ipcd in passive auth
  54. char* passiveAuthUsername;
  55. unsigned char passiveAuthModeSwitcher;
  56. unsigned char passiveAuthModeIndicator;
  57. };