69 lines
3.8 KiB
C
69 lines
3.8 KiB
C
|
#include "main.h"
|
||
|
|
||
|
const field_map_t api_field_map[] = {
|
||
|
/* Index, Rdonly, Type, Len, Offset in struct */
|
||
|
{ 0, true, UINT8, 1, offsetof(device_t, active_output) },
|
||
|
{ 1, true, INT16, 2, offsetof(device_t, pointer_x) },
|
||
|
{ 2, true, INT16, 2, offsetof(device_t, pointer_y) },
|
||
|
{ 3, true, INT16, 2, offsetof(device_t, mouse_buttons) },
|
||
|
|
||
|
/* Output A */
|
||
|
{ 10, false, UINT32, 4, offsetof(device_t, config.output[0].number) },
|
||
|
{ 11, false, UINT32, 4, offsetof(device_t, config.output[0].screen_count) },
|
||
|
{ 12, false, INT32, 4, offsetof(device_t, config.output[0].speed_x) },
|
||
|
{ 13, false, INT32, 4, offsetof(device_t, config.output[0].speed_y) },
|
||
|
{ 14, false, INT32, 4, offsetof(device_t, config.output[0].border.top) },
|
||
|
{ 15, false, INT32, 4, offsetof(device_t, config.output[0].border.bottom) },
|
||
|
{ 16, false, UINT8, 1, offsetof(device_t, config.output[0].os) },
|
||
|
{ 17, false, UINT8, 1, offsetof(device_t, config.output[0].pos) },
|
||
|
{ 18, false, UINT8, 1, offsetof(device_t, config.output[0].mouse_park_pos) },
|
||
|
{ 19, false, UINT8, 1, offsetof(device_t, config.output[0].screensaver.mode) },
|
||
|
{ 20, false, UINT8, 1, offsetof(device_t, config.output[0].screensaver.only_if_inactive) },
|
||
|
|
||
|
/* Until we increase the payload size from 8 bytes, clamp to avoid exceeding the field size */
|
||
|
{ 21, false, UINT64, 7, offsetof(device_t, config.output[0].screensaver.idle_time_us) },
|
||
|
{ 22, false, UINT64, 7, offsetof(device_t, config.output[0].screensaver.max_time_us) },
|
||
|
|
||
|
/* Output B */
|
||
|
{ 40, false, UINT32, 4, offsetof(device_t, config.output[1].number) },
|
||
|
{ 41, false, UINT32, 4, offsetof(device_t, config.output[1].screen_count) },
|
||
|
{ 42, false, INT32, 4, offsetof(device_t, config.output[1].speed_x) },
|
||
|
{ 43, false, INT32, 4, offsetof(device_t, config.output[1].speed_y) },
|
||
|
{ 44, false, INT32, 4, offsetof(device_t, config.output[1].border.top) },
|
||
|
{ 45, false, INT32, 4, offsetof(device_t, config.output[1].border.bottom) },
|
||
|
{ 46, false, UINT8, 1, offsetof(device_t, config.output[1].os) },
|
||
|
{ 47, false, UINT8, 1, offsetof(device_t, config.output[1].pos) },
|
||
|
{ 48, false, UINT8, 1, offsetof(device_t, config.output[1].mouse_park_pos) },
|
||
|
{ 49, false, UINT8, 1, offsetof(device_t, config.output[1].screensaver.mode) },
|
||
|
{ 50, false, UINT8, 1, offsetof(device_t, config.output[1].screensaver.only_if_inactive) },
|
||
|
{ 51, false, UINT64, 7, offsetof(device_t, config.output[1].screensaver.idle_time_us) },
|
||
|
{ 52, false, UINT64, 7, offsetof(device_t, config.output[1].screensaver.max_time_us) },
|
||
|
|
||
|
/* Common config */
|
||
|
{ 70, false, UINT32, 4, offsetof(device_t, config.version) },
|
||
|
{ 71, false, UINT8, 1, offsetof(device_t, config.force_mouse_boot_mode) },
|
||
|
{ 72, false, UINT8, 1, offsetof(device_t, config.force_kbd_boot_protocol) },
|
||
|
{ 73, false, UINT8, 1, offsetof(device_t, config.kbd_led_as_indicator) },
|
||
|
{ 74, false, UINT8, 1, offsetof(device_t, config.hotkey_toggle) },
|
||
|
{ 75, false, UINT8, 1, offsetof(device_t, config.enable_acceleration) },
|
||
|
{ 76, false, UINT8, 1, offsetof(device_t, config.enforce_ports) },
|
||
|
{ 77, false, UINT16, 2, offsetof(device_t, config.jump_treshold) },
|
||
|
|
||
|
/* Firmware */
|
||
|
{ 78, true, UINT16, 2, offsetof(device_t, _running_fw.version) },
|
||
|
{ 79, true, UINT32, 4, offsetof(device_t, _running_fw.checksum) },
|
||
|
|
||
|
{ 80, true, UINT8, 1, offsetof(device_t, keyboard_connected) },
|
||
|
{ 81, true, UINT8, 1, offsetof(device_t, switch_lock) },
|
||
|
{ 82, true, UINT8, 1, offsetof(device_t, relative_mouse) },
|
||
|
};
|
||
|
|
||
|
const field_map_t* get_field_map_entry(uint32_t index) {
|
||
|
for (unsigned int i = 0; i < ARRAY_SIZE(api_field_map); i++) {
|
||
|
if (api_field_map[i].idx == index) {
|
||
|
return &api_field_map[i];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return NULL;
|
||
|
}
|