Replace linear event list with a representation based on bit and byte location in the HID Report

This commit is contained in:
mbanth
2021-06-11 15:20:30 +01:00
parent 1f6140c912
commit a411b864c2

View File

@@ -5,47 +5,17 @@
#define __USER_HID_H__ #define __USER_HID_H__
/** /**
* \brief HID event identifiers * \brief HID event
* *
* This enumeration defines a constant value for each HID event. * This struct identifies the location within the HID Report for an event and
* It defines one value for each of the four GPI pins supported in the standard voice products. * The value to report for that location.
* It defines a further 28 values for generic events. * It assumes only single bit flags within the HID Report.
*/ */
typedef enum hidEventId_t { typedef struct hidEvent_t {
HID_EVENT_ID_EVT0 = 0, unsigned bit;
HID_EVENT_ID_EVT1, unsigned byte;
HID_EVENT_ID_EVT2, unsigned value;
HID_EVENT_ID_EVT3, } hidEvent_t;
HID_EVENT_ID_EVT4,
HID_EVENT_ID_EVT5,
HID_EVENT_ID_EVT6,
HID_EVENT_ID_EVT7,
HID_EVENT_ID_EVT8,
HID_EVENT_ID_EVT9,
HID_EVENT_ID_EVT10,
HID_EVENT_ID_EVT11,
HID_EVENT_ID_EVT12,
HID_EVENT_ID_EVT13,
HID_EVENT_ID_EVT14,
HID_EVENT_ID_EVT15,
HID_EVENT_ID_EVT16,
HID_EVENT_ID_EVT17,
HID_EVENT_ID_EVT18,
HID_EVENT_ID_EVT19,
HID_EVENT_ID_EVT20,
HID_EVENT_ID_EVT21,
HID_EVENT_ID_EVT22,
HID_EVENT_ID_EVT23,
HID_EVENT_ID_EVT24,
HID_EVENT_ID_EVT25,
HID_EVENT_ID_EVT26,
HID_EVENT_ID_EVT27,
HID_EVENT_ID_EVT28,
HID_EVENT_ID_EVT29,
HID_EVENT_ID_EVT30,
HID_EVENT_ID_EVT31,
HID_EVENT_ID_INVALID = 0xffffffff,
} hidEventId_t;
#define HID_MAX_DATA_BYTES 4 #define HID_MAX_DATA_BYTES 4
@@ -70,15 +40,15 @@ void UserHIDInit( void );
/** /**
* \brief Record that a HID event has occurred * \brief Record that a HID event has occurred
* *
* \param{in} hidEventId The identifier of an event which has occurred. * \param{in} hidEvent A list of events which have occurred.
* Each event corresponds to bit in the HID Report: * Each element specifies a bit and byte in the HID Report and the value for it.
* Events 0- 7 to bits 0-7 of byte 0, * \param{in} hidEventCnt The length of the \a hidEvent list.
* Events 8-15 to bits 0-7 of byte 1, etc. *
* \param{in} hidEventData A Boolean indicating the state of the event: * \returns A Boolean flag indicating the status of the operation
* Zero = deasserted, * \retval False No recording of the event(s) occurred
* Any other value = asserted. * \retval True Recording of the event(s) occurred
*/ */
void UserHIDRecordEvent( const hidEventId_t hidEventId, const unsigned hidEventData ); unsigned UserHIDRecordEvent( const hidEvent_t hidEvent[], const unsigned hidEventCnt );
#endif /* ( 0 < HID_CONTROLS ) */ #endif /* ( 0 < HID_CONTROLS ) */
#endif /* __USER_HID_H__ */ #endif /* __USER_HID_H__ */