Mouse movement coordinate signedness consistency
This commit is contained in:
parent
9957b28eee
commit
6de29af7cd
3 changed files with 16 additions and 16 deletions
|
@ -11,8 +11,8 @@
|
|||
#include <zmk/event_manager.h>
|
||||
|
||||
struct zmk_mouse_state_changed {
|
||||
uint32_t x;
|
||||
uint32_t y;
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
bool state;
|
||||
int64_t timestamp;
|
||||
};
|
||||
|
@ -22,8 +22,8 @@ ZMK_EVENT_DECLARE(zmk_mouse_state_changed);
|
|||
static inline struct zmk_mouse_state_changed_event *
|
||||
zmk_mouse_state_changed_from_encoded(uint32_t encoded, bool pressed, int64_t timestamp) {
|
||||
|
||||
uint32_t x = (encoded & 0xFFFF0000) >> 16;
|
||||
uint32_t y = encoded & 0x0000FFFF;
|
||||
int32_t x = (encoded & 0xFFFF0000) >> 16;
|
||||
int32_t y = encoded & 0x0000FFFF;
|
||||
|
||||
return new_zmk_mouse_state_changed(
|
||||
(struct zmk_mouse_state_changed){.x = x, .y = y, .state = pressed, .timestamp = timestamp});
|
||||
|
|
|
@ -231,10 +231,10 @@ struct zmk_hid_consumer_report {
|
|||
|
||||
struct zmk_hid_mouse_report_body {
|
||||
zmk_mouse_button_flags_t buttons;
|
||||
uint16_t x;
|
||||
uint16_t y;
|
||||
uint8_t wheel_vert;
|
||||
uint8_t wheel_hor;
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
int8_t wheel_vert;
|
||||
int8_t wheel_hor;
|
||||
} __packed;
|
||||
|
||||
struct zmk_hid_mouse_report {
|
||||
|
@ -261,10 +261,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_buttons_press(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_release(uint16_t x, uint16_t y);
|
||||
int zmk_hid_mouse_wheel_press(uint8_t hor, uint8_t vert);
|
||||
int zmk_hid_mouse_wheel_release(uint8_t hor, uint8_t vert);
|
||||
int zmk_hid_mouse_movement_press(int16_t x, int16_t y);
|
||||
int zmk_hid_mouse_movement_release(int16_t x, int16_t y);
|
||||
int zmk_hid_mouse_wheel_press(int8_t hor, int8_t vert);
|
||||
int zmk_hid_mouse_wheel_release(int8_t hor, int8_t vert);
|
||||
void zmk_hid_mouse_clear();
|
||||
|
||||
struct zmk_hid_keyboard_report *zmk_hid_get_keyboard_report();
|
||||
|
|
|
@ -245,14 +245,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); \
|
||||
}
|
||||
|
||||
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_y += y;
|
||||
SET_MOUSE_MOVEMENT(curr_x, curr_y);
|
||||
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_y -= y;
|
||||
SET_MOUSE_MOVEMENT(curr_x, curr_y);
|
||||
|
@ -267,14 +267,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); \
|
||||
}
|
||||
|
||||
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_vert += vert;
|
||||
SET_MOUSE_WHEEL(curr_hor, curr_vert);
|
||||
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_vert -= vert;
|
||||
SET_MOUSE_WHEEL(curr_hor, curr_vert);
|
||||
|
|
Loading…
Add table
Reference in a new issue