cyio.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // ===========================================================================
  2. // cyio.h
  3. // Copyright (C) 2008-2010 Bookeen - All rights reserved
  4. // ===========================================================================
  5. #define CYIO_EVENT_VERSION 1
  6. typedef struct sCyEvent_t
  7. {
  8. unsigned char type;
  9. unsigned char flags;
  10. unsigned char version; /*** Use for later compatibility */
  11. union
  12. {
  13. unsigned char raw[13];
  14. struct
  15. {
  16. unsigned short x1;
  17. unsigned short y1;
  18. unsigned short x2;
  19. unsigned short y2;
  20. } touch;
  21. struct
  22. {
  23. unsigned char key_ascii;
  24. } key;
  25. } data;
  26. } CyEvent_t;
  27. enum
  28. {
  29. CYIO_EVENT_KEY = 'k',
  30. CYIO_EVENT_TOUCH = 't',
  31. CYIO_EVENT_SD = 's',
  32. CYIO_EVENT_ACCEL = 'a',
  33. CYIO_EVENT_TIMER = 'z',
  34. CYIO_EVENT_SYSTEM = 'u',
  35. //CYIO_EVENT_ = '',
  36. };
  37. // Key events
  38. #define CYEVENT_KEY_ENTER 'e'
  39. #define CYEVENT_KEY_RIGHT 'r'
  40. #define CYEVENT_KEY_DOWN 'd'
  41. #define CYEVENT_KEY_LEFT 'l'
  42. #define CYEVENT_KEY_UP 'u'
  43. #define CYEVENT_KEY_F1 '1'
  44. #define CYEVENT_KEY_F2 '2'
  45. #define CYEVENT_KEY_F3 '3'
  46. #define CYEVENT_KEY_F4 '4'
  47. #define CYEVENT_KEY_OFF 'o'
  48. #define CYEVENT_KEY_DSLP 's'
  49. #define CYEVENT_KEY_VOLP '+'
  50. #define CYEVENT_KEY_VOLN '-'
  51. #define CYEVENT_KEY_TOGGLE_ACCEL 'a'
  52. #define CYEVENT_KEY_FACTORY_RESET 'f'
  53. /* Flags definitions */
  54. /* Bit 7 to Bit 4 are event type dependent. If the event need more than 4 flags,
  55. * it can use it's own "private" values
  56. */
  57. /* Key event flags */
  58. #define CYEVENT_FLAG_KEY_REPEAT (1 << 7) /*** Signal that this key is repeated */
  59. #define CYEVENT_FLAG_KEY_END_OF_REPEAT (1 << 6) /*** Signal that the repeat is finished */
  60. #define CYEVENT_FLAG_KEY_CONTROL_CHARS (1 << 5) /*** Signal that the current key is not a real key (ie not an ascii value) */
  61. /* Touch event flags */
  62. #define CYEVENT_FLAG_TOUCH_UP (0x1 << 6)
  63. #define CYEVENT_FLAG_TOUCH_MOVE (0x2 << 6)
  64. #define CYEVENT_FLAG_TOUCH_DOWN (0x3 << 6)
  65. /* System Event */
  66. #define CYEVENT_FLAG_USB_STATE (1 << 7) /*** If not set, the USB is unplugged */
  67. #define CYEVENT_FLAG_AC_STATE (1 << 6) /*** If not set, the AC is unplugged */
  68. #define CYEVENT_FLAG_AC_STATE (1 << 5) /*** If not set, the SD is unplugged */
  69. /* Timer event */
  70. #define CYEVENT_FLAG_TIMER_SCREEN (1 << 7)
  71. #define CYEVENT_FLAG_TIMER_DEVICE (1 << 6)
  72. /* Bit 3 to Bit 1 are reserved (v1) */
  73. #define CYEVENT_FLAG_UNIQUEEVENT (1 << 0) /*** Used internaly to prevent other event of the same type to be pushed */
  74. /* TODO: This part should be moved elsewhere... */
  75. // ===========================================================================
  76. /* Non directly CyIO related values, but used for the Accelerometer */
  77. #define G_SENSOR_ON '1'
  78. #define G_SENSOR_OFF '0'
  79. #define G_SENSOR_CAL 'C'
  80. enum
  81. {
  82. CYGSENSOR_STATUS_ENABLED = 0, /** The accelerometer is enabled */
  83. CYGSENSOR_STATUS_DISABLED = 1, /** The accelerometer is disabled */
  84. CYGSENSOR_STATUS_NOTCALIB = 2, /** Not calibrated, or invalid calibration data */
  85. CYGSENSOR_STATUS_CALIBRATED = 3, /** This status should never been read, but it could help to debug */
  86. CYGSENSOR_STATUS_UNKNOWN = 4, /** This status should never been read, but it could help to debug */
  87. CYGSENSOR_STATUS_CHIPDETECTED = 5, /** This status should never been read, used to say if we correctly detected the I²C accelerometer Chip */
  88. CYGSENSOR_STATUS_CRITICALERROR = 6, /** If we are in this status, the G-Sensor is non working: possible cause, defective chip */
  89. CYGSENSOR_STATUS_SUSPENDED = 7, /** The GSENSOR was on, the device go to deepsleep, so we go in this state. */
  90. };
  91. // ===========================================================================
  92. /* Exported function of CyIO */
  93. void Cyio_ResetTimer(void);
  94. int __deprecated Cyio_PushEvent(char eventId, char unique); /* Old way */
  95. int Cyio_PushCyEvent(char eventId, char unique);
  96. // ===========================================================================