Mouse movement coordinate signedness consistency
This commit is contained in:
parent
33518ef5c9
commit
fdcd7241e3
3 changed files with 16 additions and 16 deletions
|
@ -11,8 +11,8 @@
|
||||||
#include <zmk/event_manager.h>
|
#include <zmk/event_manager.h>
|
||||||
|
|
||||||
struct zmk_mouse_state_changed {
|
struct zmk_mouse_state_changed {
|
||||||
uint32_t x;
|
int32_t x;
|
||||||
uint32_t y;
|
int32_t y;
|
||||||
bool state;
|
bool state;
|
||||||
int64_t timestamp;
|
int64_t timestamp;
|
||||||
};
|
};
|
||||||
|
@ -22,8 +22,8 @@ ZMK_EVENT_DECLARE(zmk_mouse_state_changed);
|
||||||
static inline struct zmk_mouse_state_changed_event *
|
static inline struct zmk_mouse_state_changed_event *
|
||||||
zmk_mouse_state_changed_from_encoded(uint32_t encoded, bool pressed, int64_t timestamp) {
|
zmk_mouse_state_changed_from_encoded(uint32_t encoded, bool pressed, int64_t timestamp) {
|
||||||
|
|
||||||
uint32_t x = (encoded & 0xFFFF0000) >> 16;
|
int32_t x = (encoded & 0xFFFF0000) >> 16;
|
||||||
uint32_t y = encoded & 0x0000FFFF;
|
int32_t y = encoded & 0x0000FFFF;
|
||||||
|
|
||||||
return new_zmk_mouse_state_changed(
|
return new_zmk_mouse_state_changed(
|
||||||
(struct zmk_mouse_state_changed){.x = x, .y = y, .state = pressed, .timestamp = timestamp});
|
(struct zmk_mouse_state_changed){.x = x, .y = y, .state = pressed, .timestamp = timestamp});
|
||||||
|
|
|
@ -229,10 +229,10 @@ struct zmk_hid_consumer_report {
|
||||||
|
|
||||||
struct zmk_hid_mouse_report_body {
|
struct zmk_hid_mouse_report_body {
|
||||||
zmk_mouse_button_flags_t buttons;
|
zmk_mouse_button_flags_t buttons;
|
||||||
uint16_t x;
|
int16_t x;
|
||||||
uint16_t y;
|
int16_t y;
|
||||||
uint8_t wheel_vert;
|
int8_t wheel_vert;
|
||||||
uint8_t wheel_hor;
|
int8_t wheel_hor;
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
struct zmk_hid_mouse_report {
|
struct zmk_hid_mouse_report {
|
||||||
|
@ -259,10 +259,10 @@ int zmk_hid_mouse_button_press(zmk_mouse_button_t button);
|
||||||
int zmk_hid_mouse_button_release(zmk_mouse_button_t button);
|
int zmk_hid_mouse_button_release(zmk_mouse_button_t button);
|
||||||
int zmk_hid_mouse_buttons_press(zmk_mouse_button_flags_t buttons);
|
int zmk_hid_mouse_buttons_press(zmk_mouse_button_flags_t buttons);
|
||||||
int zmk_hid_mouse_buttons_release(zmk_mouse_button_flags_t buttons);
|
int zmk_hid_mouse_buttons_release(zmk_mouse_button_flags_t buttons);
|
||||||
int zmk_hid_mouse_movement_press(uint16_t x, uint16_t y);
|
int zmk_hid_mouse_movement_press(int16_t x, int16_t y);
|
||||||
int zmk_hid_mouse_movement_release(uint16_t x, uint16_t y);
|
int zmk_hid_mouse_movement_release(int16_t x, int16_t y);
|
||||||
int zmk_hid_mouse_wheel_press(uint8_t hor, uint8_t vert);
|
int zmk_hid_mouse_wheel_press(int8_t hor, int8_t vert);
|
||||||
int zmk_hid_mouse_wheel_release(uint8_t hor, uint8_t vert);
|
int zmk_hid_mouse_wheel_release(int8_t hor, int8_t vert);
|
||||||
void zmk_hid_mouse_clear();
|
void zmk_hid_mouse_clear();
|
||||||
|
|
||||||
struct zmk_hid_keyboard_report *zmk_hid_get_keyboard_report();
|
struct zmk_hid_keyboard_report *zmk_hid_get_keyboard_report();
|
||||||
|
|
|
@ -236,14 +236,14 @@ int zmk_hid_mouse_buttons_release(zmk_mouse_button_flags_t buttons) {
|
||||||
LOG_DBG("Mouse movement y set to 0x%02X", mouse_report.body.y); \
|
LOG_DBG("Mouse movement y set to 0x%02X", mouse_report.body.y); \
|
||||||
}
|
}
|
||||||
|
|
||||||
int zmk_hid_mouse_movement_press(uint16_t x, uint16_t y) {
|
int zmk_hid_mouse_movement_press(int16_t x, int16_t y) {
|
||||||
curr_x += x;
|
curr_x += x;
|
||||||
curr_y += y;
|
curr_y += y;
|
||||||
SET_MOUSE_MOVEMENT(curr_x, curr_y);
|
SET_MOUSE_MOVEMENT(curr_x, curr_y);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int zmk_hid_mouse_movement_release(uint16_t x, uint16_t y) {
|
int zmk_hid_mouse_movement_release(int16_t x, int16_t y) {
|
||||||
curr_x -= x;
|
curr_x -= x;
|
||||||
curr_y -= y;
|
curr_y -= y;
|
||||||
SET_MOUSE_MOVEMENT(curr_x, curr_y);
|
SET_MOUSE_MOVEMENT(curr_x, curr_y);
|
||||||
|
@ -258,14 +258,14 @@ int zmk_hid_mouse_movement_release(uint16_t x, uint16_t y) {
|
||||||
LOG_DBG("Mouse wheel vert set to 0x%02X", mouse_report.body.wheel_vert); \
|
LOG_DBG("Mouse wheel vert set to 0x%02X", mouse_report.body.wheel_vert); \
|
||||||
}
|
}
|
||||||
|
|
||||||
int zmk_hid_mouse_wheel_press(uint8_t hor, uint8_t vert) {
|
int zmk_hid_mouse_wheel_press(int8_t hor, int8_t vert) {
|
||||||
curr_hor += hor;
|
curr_hor += hor;
|
||||||
curr_vert += vert;
|
curr_vert += vert;
|
||||||
SET_MOUSE_WHEEL(curr_hor, curr_vert);
|
SET_MOUSE_WHEEL(curr_hor, curr_vert);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int zmk_hid_mouse_wheel_release(uint8_t hor, uint8_t vert) {
|
int zmk_hid_mouse_wheel_release(int8_t hor, int8_t vert) {
|
||||||
curr_hor -= hor;
|
curr_hor -= hor;
|
||||||
curr_vert -= vert;
|
curr_vert -= vert;
|
||||||
SET_MOUSE_WHEEL(curr_hor, curr_vert);
|
SET_MOUSE_WHEEL(curr_hor, curr_vert);
|
||||||
|
|
Loading…
Add table
Reference in a new issue