mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-14 18:57:07 -07:00
Add Touchpad Feedback History Formatting
This commit is contained in:
parent
0b9f8798eb
commit
02d026f205
2 changed files with 20 additions and 1 deletions
|
@ -44,7 +44,7 @@ typedef struct chiaki_feedback_state_t
|
|||
CHIAKI_EXPORT void chiaki_feedback_state_format(uint8_t *buf, ChiakiFeedbackState *state);
|
||||
|
||||
|
||||
#define CHIAKI_HISTORY_EVENT_SIZE_MAX 0x3 // TODO: will be bigger later for touchpad at least
|
||||
#define CHIAKI_HISTORY_EVENT_SIZE_MAX 0x5
|
||||
|
||||
typedef struct chiaki_feedback_history_event_t
|
||||
{
|
||||
|
@ -58,6 +58,14 @@ typedef struct chiaki_feedback_history_event_t
|
|||
*/
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_feedback_history_event_set_button(ChiakiFeedbackHistoryEvent *event, uint64_t button, uint8_t state);
|
||||
|
||||
/**
|
||||
* @param pointer_id identifier for the touch from 0 to 127
|
||||
* @param x from 0 to 1920
|
||||
* @param y from 0 to 942
|
||||
*/
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_feedback_history_event_set_touchpad(ChiakiFeedbackHistoryEvent *event,
|
||||
bool down, uint8_t pointer_id, uint16_t x, uint16_t y);
|
||||
|
||||
/**
|
||||
* Ring buffer of ChiakiFeedbackHistoryEvent
|
||||
*/
|
||||
|
|
|
@ -119,6 +119,17 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_feedback_history_event_set_button(ChiakiFee
|
|||
return CHIAKI_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_feedback_history_event_set_touchpad(ChiakiFeedbackHistoryEvent *event,
|
||||
bool down, uint8_t pointer_id, uint16_t x, uint16_t y)
|
||||
{
|
||||
event->len = 5;
|
||||
event->buf[0] = down ? 0xd0 : 0xc0;
|
||||
event->buf[1] = pointer_id / 0x7f;
|
||||
event->buf[2] = (uint8_t)(x >> 4);
|
||||
event->buf[3] = (uint8_t)((x & 0xf) << 4) | (uint8_t)(y >> 8);
|
||||
event->buf[4] = (uint8_t)y;
|
||||
}
|
||||
|
||||
CHIAKI_EXPORT ChiakiErrorCode chiaki_feedback_history_buffer_init(ChiakiFeedbackHistoryBuffer *feedback_history_buffer, size_t size)
|
||||
{
|
||||
feedback_history_buffer->events = calloc(size, sizeof(ChiakiFeedbackHistoryEvent));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue