mirror of
https://github.com/hrvach/deskhop.git
synced 2024-11-24 16:54:18 +01:00
feat: add horizontal scrolling
This commit is contained in:
parent
8abd1c26dc
commit
6d371d096a
@ -166,6 +166,14 @@ void extract_data(hid_interface_t *iface, report_val_t *val) {
|
|||||||
.dst = &iface->mouse.wheel,
|
.dst = &iface->mouse.wheel,
|
||||||
.id = &iface->mouse.report_id},
|
.id = &iface->mouse.report_id},
|
||||||
|
|
||||||
|
{.usage_page = HID_USAGE_PAGE_CONSUMER,
|
||||||
|
.global_usage = HID_USAGE_DESKTOP_MOUSE,
|
||||||
|
.usage = HID_USAGE_CONSUMER_AC_PAN,
|
||||||
|
.handler = _store,
|
||||||
|
.receiver = process_mouse_report,
|
||||||
|
.dst = &iface->mouse.pan,
|
||||||
|
.id = &iface->mouse.report_id},
|
||||||
|
|
||||||
{.usage_page = HID_USAGE_PAGE_KEYBOARD,
|
{.usage_page = HID_USAGE_PAGE_KEYBOARD,
|
||||||
.global_usage = HID_USAGE_DESKTOP_KEYBOARD,
|
.global_usage = HID_USAGE_DESKTOP_KEYBOARD,
|
||||||
.handler = handle_keyboard_descriptor_values,
|
.handler = handle_keyboard_descriptor_values,
|
||||||
@ -293,4 +301,4 @@ int32_t extract_kbd_data(
|
|||||||
|
|
||||||
/* This is something completely different, look at the report */
|
/* This is something completely different, look at the report */
|
||||||
return _extract_kbd_other(raw_report, len, iface, report);
|
return _extract_kbd_other(raw_report, len, iface, report);
|
||||||
}
|
}
|
||||||
|
@ -98,6 +98,7 @@ typedef struct {
|
|||||||
report_val_t move_x;
|
report_val_t move_x;
|
||||||
report_val_t move_y;
|
report_val_t move_y;
|
||||||
report_val_t wheel;
|
report_val_t wheel;
|
||||||
|
report_val_t pan;
|
||||||
|
|
||||||
uint8_t report_id;
|
uint8_t report_id;
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ typedef struct {
|
|||||||
#define KEYARRAY_BIT_OFFSET 16
|
#define KEYARRAY_BIT_OFFSET 16
|
||||||
#define KEYS_IN_USB_REPORT 6
|
#define KEYS_IN_USB_REPORT 6
|
||||||
#define KBD_REPORT_LENGTH 8
|
#define KBD_REPORT_LENGTH 8
|
||||||
#define MOUSE_REPORT_LENGTH 7
|
#define MOUSE_REPORT_LENGTH 8
|
||||||
#define CONSUMER_CONTROL_LENGTH 4
|
#define CONSUMER_CONTROL_LENGTH 4
|
||||||
#define SYSTEM_CONTROL_LENGTH 1
|
#define SYSTEM_CONTROL_LENGTH 1
|
||||||
#define MODIFIER_BIT_LENGTH 8
|
#define MODIFIER_BIT_LENGTH 8
|
||||||
@ -345,6 +345,7 @@ typedef struct TU_ATTR_PACKED {
|
|||||||
int16_t x;
|
int16_t x;
|
||||||
int16_t y;
|
int16_t y;
|
||||||
int8_t wheel;
|
int8_t wheel;
|
||||||
|
int8_t pan;
|
||||||
uint8_t mode;
|
uint8_t mode;
|
||||||
} mouse_report_t;
|
} mouse_report_t;
|
||||||
|
|
||||||
@ -460,7 +461,7 @@ int32_t extract_bit_variable(uint32_t, uint32_t, uint8_t *, int, uint8_t *);
|
|||||||
int32_t extract_kbd_data(uint8_t *, int, uint8_t, hid_interface_t *, hid_keyboard_report_t *);
|
int32_t extract_kbd_data(uint8_t *, int, uint8_t, hid_interface_t *, hid_keyboard_report_t *);
|
||||||
|
|
||||||
/********* Mouse **********/
|
/********* Mouse **********/
|
||||||
bool tud_mouse_report(uint8_t mode, uint8_t buttons, int16_t x, int16_t y, int8_t wheel);
|
bool tud_mouse_report(uint8_t mode, uint8_t buttons, int16_t x, int16_t y, int8_t wheel, int8_t pan);
|
||||||
|
|
||||||
void process_mouse_report(uint8_t *, int, uint8_t, hid_interface_t *);
|
void process_mouse_report(uint8_t *, int, uint8_t, hid_interface_t *);
|
||||||
void parse_report_descriptor(hid_interface_t *, uint8_t const *, int);
|
void parse_report_descriptor(hid_interface_t *, uint8_t const *, int);
|
||||||
|
@ -98,6 +98,15 @@ HID_COLLECTION ( HID_COLLECTION_APPLICATION ) ,\
|
|||||||
HID_REPORT_SIZE ( 8 ) ,\
|
HID_REPORT_SIZE ( 8 ) ,\
|
||||||
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_RELATIVE ) ,\
|
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_RELATIVE ) ,\
|
||||||
\
|
\
|
||||||
|
/* Horizontal wheel (AC Pan) */ \
|
||||||
|
HID_USAGE_PAGE ( HID_USAGE_PAGE_CONSUMER ) ,\
|
||||||
|
HID_LOGICAL_MIN ( 0x81 ) ,\
|
||||||
|
HID_LOGICAL_MAX ( 0x7f ) ,\
|
||||||
|
HID_REPORT_COUNT( 1 ) ,\
|
||||||
|
HID_REPORT_SIZE ( 8 ) ,\
|
||||||
|
HID_USAGE_N ( HID_USAGE_CONSUMER_AC_PAN, 2 ) ,\
|
||||||
|
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_RELATIVE ) ,\
|
||||||
|
\
|
||||||
/* Mouse mode (0 = absolute, 1 = relative) */ \
|
/* Mouse mode (0 = absolute, 1 = relative) */ \
|
||||||
HID_REPORT_COUNT( 1 ), \
|
HID_REPORT_COUNT( 1 ), \
|
||||||
HID_REPORT_SIZE ( 8 ), \
|
HID_REPORT_SIZE ( 8 ), \
|
||||||
|
@ -219,6 +219,7 @@ void extract_report_values(uint8_t *raw_report, device_t *state, mouse_values_t
|
|||||||
values->move_x = mouse_report->x;
|
values->move_x = mouse_report->x;
|
||||||
values->move_y = mouse_report->y;
|
values->move_y = mouse_report->y;
|
||||||
values->wheel = mouse_report->wheel;
|
values->wheel = mouse_report->wheel;
|
||||||
|
values->pan = mouse_report->pan;
|
||||||
values->buttons = mouse_report->buttons;
|
values->buttons = mouse_report->buttons;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -230,6 +231,7 @@ void extract_report_values(uint8_t *raw_report, device_t *state, mouse_values_t
|
|||||||
values->move_x = get_report_value(raw_report, &iface->mouse.move_x);
|
values->move_x = get_report_value(raw_report, &iface->mouse.move_x);
|
||||||
values->move_y = get_report_value(raw_report, &iface->mouse.move_y);
|
values->move_y = get_report_value(raw_report, &iface->mouse.move_y);
|
||||||
values->wheel = get_report_value(raw_report, &iface->mouse.wheel);
|
values->wheel = get_report_value(raw_report, &iface->mouse.wheel);
|
||||||
|
values->pan = get_report_value(raw_report, &iface->mouse.pan);
|
||||||
values->buttons = get_report_value(raw_report, &iface->mouse.buttons);
|
values->buttons = get_report_value(raw_report, &iface->mouse.buttons);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,6 +241,7 @@ mouse_report_t create_mouse_report(device_t *state, mouse_values_t *values) {
|
|||||||
.x = state->pointer_x,
|
.x = state->pointer_x,
|
||||||
.y = state->pointer_y,
|
.y = state->pointer_y,
|
||||||
.wheel = values->wheel,
|
.wheel = values->wheel,
|
||||||
|
.pan = values->pan,
|
||||||
.mode = ABSOLUTE,
|
.mode = ABSOLUTE,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -296,7 +299,8 @@ void process_mouse_queue_task(device_t *state) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* Try sending it to the host, if it's successful */
|
/* Try sending it to the host, if it's successful */
|
||||||
bool succeeded = tud_mouse_report(report.mode, report.buttons, report.x, report.y, report.wheel);
|
bool succeeded
|
||||||
|
= tud_mouse_report(report.mode, report.buttons, report.x, report.y, report.wheel, report.pan);
|
||||||
|
|
||||||
/* ... then we can remove it from the queue */
|
/* ... then we can remove it from the queue */
|
||||||
if (succeeded)
|
if (succeeded)
|
||||||
|
@ -81,10 +81,10 @@ uint8_t const *tud_hid_descriptor_report_cb(uint8_t instance) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tud_mouse_report(uint8_t mode, uint8_t buttons, int16_t x, int16_t y, int8_t wheel) {
|
|
||||||
mouse_report_t report = {.buttons = buttons, .wheel = wheel, .x = x, .y = y, .mode = mode};
|
|
||||||
uint8_t instance = ITF_NUM_HID;
|
uint8_t instance = ITF_NUM_HID;
|
||||||
uint8_t report_id = REPORT_ID_MOUSE;
|
uint8_t report_id = REPORT_ID_MOUSE;
|
||||||
|
bool tud_mouse_report(uint8_t mode, uint8_t buttons, int16_t x, int16_t y, int8_t wheel, int8_t pan) {
|
||||||
|
mouse_report_t report = {.buttons = buttons, .wheel = wheel, .x = x, .y = y, .mode = mode, .pan = pan};
|
||||||
|
|
||||||
if (mode == RELATIVE) {
|
if (mode == RELATIVE) {
|
||||||
instance = ITF_NUM_HID_REL_M;
|
instance = ITF_NUM_HID_REL_M;
|
||||||
|
Loading…
Reference in New Issue
Block a user