// =========================================================================== // cyio.h // Copyright (C) 2008-2010 Bookeen - All rights reserved // =========================================================================== #define CYIO_EVENT_VERSION 1 typedef struct sCyEvent_t { unsigned char type; unsigned char flags; unsigned char version; /*** Use for later compatibility */ union { unsigned char raw[13]; struct { unsigned short x1; unsigned short y1; unsigned short x2; unsigned short y2; } touch; struct { unsigned char key_ascii; } key; } data; } CyEvent_t; enum { CYIO_EVENT_KEY = 'k', CYIO_EVENT_TOUCH = 't', CYIO_EVENT_SD = 's', CYIO_EVENT_ACCEL = 'a', CYIO_EVENT_TIMER = 'z', CYIO_EVENT_SYSTEM = 'u', //CYIO_EVENT_ = '', }; // Key events #define CYEVENT_KEY_ENTER 'e' #define CYEVENT_KEY_RIGHT 'r' #define CYEVENT_KEY_DOWN 'd' #define CYEVENT_KEY_LEFT 'l' #define CYEVENT_KEY_UP 'u' #define CYEVENT_KEY_F1 '1' #define CYEVENT_KEY_F2 '2' #define CYEVENT_KEY_F3 '3' #define CYEVENT_KEY_F4 '4' #define CYEVENT_KEY_OFF 'o' #define CYEVENT_KEY_DSLP 's' #define CYEVENT_KEY_VOLP '+' #define CYEVENT_KEY_VOLN '-' #define CYEVENT_KEY_TOGGLE_ACCEL 'a' #define CYEVENT_KEY_FACTORY_RESET 'f' /* Flags definitions */ /* Bit 7 to Bit 4 are event type dependent. If the event need more than 4 flags, * it can use it's own "private" values */ /* Key event flags */ #define CYEVENT_FLAG_KEY_REPEAT (1 << 7) /*** Signal that this key is repeated */ #define CYEVENT_FLAG_KEY_END_OF_REPEAT (1 << 6) /*** Signal that the repeat is finished */ #define CYEVENT_FLAG_KEY_CONTROL_CHARS (1 << 5) /*** Signal that the current key is not a real key (ie not an ascii value) */ /* Touch event flags */ #define CYEVENT_FLAG_TOUCH_UP (0x1 << 6) #define CYEVENT_FLAG_TOUCH_MOVE (0x2 << 6) #define CYEVENT_FLAG_TOUCH_DOWN (0x3 << 6) /* System Event */ #define CYEVENT_FLAG_USB_STATE (1 << 7) /*** If not set, the USB is unplugged */ #define CYEVENT_FLAG_AC_STATE (1 << 6) /*** If not set, the AC is unplugged */ #define CYEVENT_FLAG_AC_STATE (1 << 5) /*** If not set, the SD is unplugged */ /* Timer event */ #define CYEVENT_FLAG_TIMER_SCREEN (1 << 7) #define CYEVENT_FLAG_TIMER_DEVICE (1 << 6) /* Bit 3 to Bit 1 are reserved (v1) */ #define CYEVENT_FLAG_UNIQUEEVENT (1 << 0) /*** Used internaly to prevent other event of the same type to be pushed */ /* TODO: This part should be moved elsewhere... */ // =========================================================================== /* Non directly CyIO related values, but used for the Accelerometer */ #define G_SENSOR_ON '1' #define G_SENSOR_OFF '0' #define G_SENSOR_CAL 'C' enum { CYGSENSOR_STATUS_ENABLED = 0, /** The accelerometer is enabled */ CYGSENSOR_STATUS_DISABLED = 1, /** The accelerometer is disabled */ CYGSENSOR_STATUS_NOTCALIB = 2, /** Not calibrated, or invalid calibration data */ CYGSENSOR_STATUS_CALIBRATED = 3, /** This status should never been read, but it could help to debug */ CYGSENSOR_STATUS_UNKNOWN = 4, /** This status should never been read, but it could help to debug */ CYGSENSOR_STATUS_CHIPDETECTED = 5, /** This status should never been read, used to say if we correctly detected the I²C accelerometer Chip */ CYGSENSOR_STATUS_CRITICALERROR = 6, /** If we are in this status, the G-Sensor is non working: possible cause, defective chip */ CYGSENSOR_STATUS_SUSPENDED = 7, /** The GSENSOR was on, the device go to deepsleep, so we go in this state. */ }; // =========================================================================== /* Exported function of CyIO */ void Cyio_ResetTimer(void); int __deprecated Cyio_PushEvent(char eventId, char unique); /* Old way */ int Cyio_PushCyEvent(char eventId, char unique); // ===========================================================================