mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-20 14:42:03 +00:00
Fix axis names
This commit is contained in:
parent
9efbd11052
commit
24dc311de1
@ -88,9 +88,9 @@ bool spacemouse_init(void) {
|
|||||||
|
|
||||||
spacemouse_data_t spacemouse_get_data(void) {
|
spacemouse_data_t spacemouse_get_data(void) {
|
||||||
spacemouse_data_t data = {0};
|
spacemouse_data_t data = {0};
|
||||||
uint8_t retry_attempts = 0, index = 0, payload[SPACEMOUSE_LENGTH_DATA + SPACEMOUSE_LENGTH_CHECKSUM] = {0};
|
uint8_t retry_attempts = 0, index = 0, payload[SPACEMOUSE_LENGTH_DATA + SPACEMOUSE_LENGTH_CHECKSUM] = {0};
|
||||||
uint16_t checksum = 0, checksum_received = 0;
|
uint16_t checksum = 0, checksum_received = 0;
|
||||||
bool has_started = false;
|
bool has_started = false;
|
||||||
uart_write(SPACEMOUSE_CMD_REQUEST_DATA);
|
uart_write(SPACEMOUSE_CMD_REQUEST_DATA);
|
||||||
while (retry_attempts <= 15) {
|
while (retry_attempts <= 15) {
|
||||||
uint8_t buf = uart_read();
|
uint8_t buf = uart_read();
|
||||||
@ -123,12 +123,12 @@ spacemouse_data_t spacemouse_get_data(void) {
|
|||||||
|
|
||||||
if (has_started) {
|
if (has_started) {
|
||||||
if (checksum_received == checksum) {
|
if (checksum_received == checksum) {
|
||||||
data.x = (int16_t)((payload[0] << 7) + payload[1]) - SPACEMOUSE_INPUT_OFFSET;
|
data.x = (int16_t)((payload[0] << 7) + payload[1]) - SPACEMOUSE_INPUT_OFFSET;
|
||||||
data.z = (int16_t)((payload[2] << 7) + payload[3]) - SPACEMOUSE_INPUT_OFFSET;
|
data.z = (int16_t)((payload[2] << 7) + payload[3]) - SPACEMOUSE_INPUT_OFFSET;
|
||||||
data.y = (int16_t)((payload[4] << 7) + payload[5]) - SPACEMOUSE_INPUT_OFFSET;
|
data.y = (int16_t)((payload[4] << 7) + payload[5]) - SPACEMOUSE_INPUT_OFFSET;
|
||||||
data.a = (int16_t)((payload[6] << 7) + payload[7]) - SPACEMOUSE_INPUT_OFFSET;
|
data.tilt_y = (int16_t)((payload[6] << 7) + payload[7]) - SPACEMOUSE_INPUT_OFFSET;
|
||||||
data.b = (int16_t)((payload[8] << 7) + payload[9]) - SPACEMOUSE_INPUT_OFFSET;
|
data.twist = (int16_t)((payload[8] << 7) + payload[9]) - SPACEMOUSE_INPUT_OFFSET;
|
||||||
data.c = (int16_t)((payload[10] << 7) + payload[11]) - SPACEMOUSE_INPUT_OFFSET;
|
data.tilt_x = (int16_t)((payload[10] << 7) + payload[11]) - SPACEMOUSE_INPUT_OFFSET;
|
||||||
} else {
|
} else {
|
||||||
pd_dprintf("Space Mouse Checksum error: 0x%04x != 0x%04x \n", checksum_received, checksum);
|
pd_dprintf("Space Mouse Checksum error: 0x%04x != 0x%04x \n", checksum_received, checksum);
|
||||||
}
|
}
|
||||||
|
@ -36,9 +36,9 @@ typedef struct {
|
|||||||
int16_t x;
|
int16_t x;
|
||||||
int16_t y;
|
int16_t y;
|
||||||
int16_t z;
|
int16_t z;
|
||||||
int16_t a;
|
int16_t twist;
|
||||||
int16_t b;
|
int16_t tilt_x;
|
||||||
int16_t c;
|
int16_t tilt_y;
|
||||||
} spacemouse_data_t;
|
} spacemouse_data_t;
|
||||||
|
|
||||||
bool spacemouse_send_command(uint8_t cmd);
|
bool spacemouse_send_command(uint8_t cmd);
|
||||||
|
@ -499,16 +499,14 @@ static bool spacemouse_present = false;
|
|||||||
__attribute__((weak)) void spacemouse_module_handle_axises(spacemouse_data_t *spacemouse_data, report_mouse_t* mouse_report) {
|
__attribute__((weak)) void spacemouse_module_handle_axises(spacemouse_data_t *spacemouse_data, report_mouse_t* mouse_report) {
|
||||||
mouse_report->x = CONSTRAIN_HID_XY(spacemouse_data->x);
|
mouse_report->x = CONSTRAIN_HID_XY(spacemouse_data->x);
|
||||||
mouse_report->y = CONSTRAIN_HID_XY(spacemouse_data->y);
|
mouse_report->y = CONSTRAIN_HID_XY(spacemouse_data->y);
|
||||||
// mouse_report->h = CONSTRAIN_HID(spacemouse_data->b);
|
|
||||||
// mouse_report->v = CONSTRAIN_HID(spacemouse_data->c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static report_mouse_t spacemouse_get_report(report_mouse_t mouse_report) {
|
static report_mouse_t spacemouse_get_report(report_mouse_t mouse_report) {
|
||||||
if (spacemouse_present) {
|
if (spacemouse_present) {
|
||||||
spacemouse_data_t data = spacemouse_get_data();
|
spacemouse_data_t data = spacemouse_get_data();
|
||||||
|
|
||||||
if (data.x || data.y || data.z || data.a || data.b || data.c) {
|
if (data.x || data.y || data.z || data.twist || data.tilt_x || data.tilt_y) {
|
||||||
pd_dprintf("Raw ] X: %d, Y: %d, Z: %d, A: %d, B: %d, C: %d\n", data.x, data.y, data.z, data.a, data.b, data.c);
|
pd_dprintf("Raw ] X: %d, Y: %d, Z: %d, twist: %d, tilt X: %d, tilt Y: %d\n", data.x, data.y, data.z, data.twist, data.tilt_x, data.tilt_y);
|
||||||
}
|
}
|
||||||
spacemouse_module_handle_axises(&data, &mouse_report);
|
spacemouse_module_handle_axises(&data, &mouse_report);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user