Delete unuse functions.
This commit is contained in:
parent
d78bcd4638
commit
0f3e2187ab
|
@ -15,14 +15,14 @@ const config_t default_config = {
|
||||||
},
|
},
|
||||||
.screen_count = 1,
|
.screen_count = 1,
|
||||||
.screen_index = 1,
|
.screen_index = 1,
|
||||||
.os = OUTPUT_A_OS,
|
// .os = OUTPUT_A_OS,
|
||||||
.pos = RIGHT,
|
.pos = RIGHT,
|
||||||
.screensaver = {
|
// .screensaver = {
|
||||||
.mode = SCREENSAVER_A_MODE,
|
// .mode = SCREENSAVER_A_MODE,
|
||||||
.only_if_inactive = SCREENSAVER_A_ONLY_IF_INACTIVE,
|
// .only_if_inactive = SCREENSAVER_A_ONLY_IF_INACTIVE,
|
||||||
.idle_time_us = SCREENSAVER_A_IDLE_TIME_SEC * 1000000,
|
// .idle_time_us = SCREENSAVER_A_IDLE_TIME_SEC * 1000000,
|
||||||
.max_time_us = SCREENSAVER_A_MAX_TIME_SEC * 1000000,
|
// .max_time_us = SCREENSAVER_A_MAX_TIME_SEC * 1000000,
|
||||||
}
|
// }
|
||||||
},
|
},
|
||||||
.output[OUTPUT_B] =
|
.output[OUTPUT_B] =
|
||||||
{
|
{
|
||||||
|
@ -35,14 +35,14 @@ const config_t default_config = {
|
||||||
},
|
},
|
||||||
.screen_count = 1,
|
.screen_count = 1,
|
||||||
.screen_index = 1,
|
.screen_index = 1,
|
||||||
.os = OUTPUT_B_OS,
|
// .os = OUTPUT_B_OS,
|
||||||
.pos = LEFT,
|
.pos = LEFT,
|
||||||
.screensaver = {
|
// .screensaver = {
|
||||||
.mode = SCREENSAVER_B_MODE,
|
// .mode = SCREENSAVER_B_MODE,
|
||||||
.only_if_inactive = SCREENSAVER_B_ONLY_IF_INACTIVE,
|
// .only_if_inactive = SCREENSAVER_B_ONLY_IF_INACTIVE,
|
||||||
.idle_time_us = SCREENSAVER_B_IDLE_TIME_SEC * 1000000,
|
// .idle_time_us = SCREENSAVER_B_IDLE_TIME_SEC * 1000000,
|
||||||
.max_time_us = SCREENSAVER_B_MAX_TIME_SEC * 1000000,
|
// .max_time_us = SCREENSAVER_B_MAX_TIME_SEC * 1000000,
|
||||||
}
|
// }
|
||||||
},
|
},
|
||||||
.enforce_ports = ENFORCE_PORTS,
|
.enforce_ports = ENFORCE_PORTS,
|
||||||
.force_kbd_boot_protocol = ENFORCE_KEYBOARD_BOOT_PROTOCOL,
|
.force_kbd_boot_protocol = ENFORCE_KEYBOARD_BOOT_PROTOCOL,
|
||||||
|
|
249
src/handlers.c
249
src/handlers.c
|
@ -24,8 +24,8 @@
|
||||||
/* This is the main hotkey for switching outputs */
|
/* This is the main hotkey for switching outputs */
|
||||||
void output_toggle_hotkey_handler(device_t *state, hid_keyboard_report_t *report) {
|
void output_toggle_hotkey_handler(device_t *state, hid_keyboard_report_t *report) {
|
||||||
/* If switching explicitly disabled, return immediately */
|
/* If switching explicitly disabled, return immediately */
|
||||||
if (state->switch_lock)
|
// if (state->switch_lock)
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
state->active_output ^= 1;
|
state->active_output ^= 1;
|
||||||
switch_output(state, state->active_output);
|
switch_output(state, state->active_output);
|
||||||
|
@ -39,115 +39,115 @@ void _get_border_position(device_t *state, border_size_t *border) {
|
||||||
border->top = state->pointer_y;
|
border->top = state->pointer_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _screensaver_set(device_t *state, uint8_t value) {
|
// void _screensaver_set(device_t *state, uint8_t value) {
|
||||||
if (CURRENT_BOARD_IS_ACTIVE_OUTPUT)
|
// if (CURRENT_BOARD_IS_ACTIVE_OUTPUT)
|
||||||
state->config.output[BOARD_ROLE].screensaver.mode = value;
|
// state->config.output[BOARD_ROLE].screensaver.mode = value;
|
||||||
else
|
// else
|
||||||
send_value(value, SCREENSAVER_MSG);
|
// send_value(value, SCREENSAVER_MSG);
|
||||||
};
|
// };
|
||||||
|
|
||||||
/* This key combo records switch y top coordinate for different-size monitors */
|
// /* This key combo records switch y top coordinate for different-size monitors */
|
||||||
void screen_border_hotkey_handler(device_t *state, hid_keyboard_report_t *report) {
|
// void screen_border_hotkey_handler(device_t *state, hid_keyboard_report_t *report) {
|
||||||
border_size_t *border = &state->config.output[state->active_output].border;
|
// border_size_t *border = &state->config.output[state->active_output].border;
|
||||||
if (CURRENT_BOARD_IS_ACTIVE_OUTPUT) {
|
// if (CURRENT_BOARD_IS_ACTIVE_OUTPUT) {
|
||||||
_get_border_position(state, border);
|
// _get_border_position(state, border);
|
||||||
save_config(state);
|
// save_config(state);
|
||||||
}
|
// }
|
||||||
|
|
||||||
queue_packet((uint8_t *)border, SYNC_BORDERS_MSG, sizeof(border_size_t));
|
// queue_packet((uint8_t *)border, SYNC_BORDERS_MSG, sizeof(border_size_t));
|
||||||
};
|
// };
|
||||||
|
|
||||||
/* This key combo puts board A in firmware upgrade mode */
|
// /* This key combo puts board A in firmware upgrade mode */
|
||||||
void fw_upgrade_hotkey_handler_A(device_t *state, hid_keyboard_report_t *report) {
|
// void fw_upgrade_hotkey_handler_A(device_t *state, hid_keyboard_report_t *report) {
|
||||||
reset_usb_boot(1 << PICO_DEFAULT_LED_PIN, 0);
|
// reset_usb_boot(1 << PICO_DEFAULT_LED_PIN, 0);
|
||||||
};
|
// };
|
||||||
|
|
||||||
/* This key combo puts board B in firmware upgrade mode */
|
// /* This key combo puts board B in firmware upgrade mode */
|
||||||
void fw_upgrade_hotkey_handler_B(device_t *state, hid_keyboard_report_t *report) {
|
// void fw_upgrade_hotkey_handler_B(device_t *state, hid_keyboard_report_t *report) {
|
||||||
send_value(ENABLE, FIRMWARE_UPGRADE_MSG);
|
// send_value(ENABLE, FIRMWARE_UPGRADE_MSG);
|
||||||
};
|
// };
|
||||||
|
|
||||||
/* This key combo prevents mouse from switching outputs */
|
// /* This key combo prevents mouse from switching outputs */
|
||||||
void switchlock_hotkey_handler(device_t *state, hid_keyboard_report_t *report) {
|
// void switchlock_hotkey_handler(device_t *state, hid_keyboard_report_t *report) {
|
||||||
state->switch_lock ^= 1;
|
// state->switch_lock ^= 1;
|
||||||
send_value(state->switch_lock, SWITCH_LOCK_MSG);
|
// send_value(state->switch_lock, SWITCH_LOCK_MSG);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* This key combo toggles gaming mode */
|
// /* This key combo toggles gaming mode */
|
||||||
void toggle_gaming_mode_handler(device_t *state, hid_keyboard_report_t *report) {
|
// void toggle_gaming_mode_handler(device_t *state, hid_keyboard_report_t *report) {
|
||||||
state->gaming_mode ^= 1;
|
// state->gaming_mode ^= 1;
|
||||||
send_value(state->gaming_mode, GAMING_MODE_MSG);
|
// send_value(state->gaming_mode, GAMING_MODE_MSG);
|
||||||
};
|
// };
|
||||||
|
|
||||||
/* This key combo locks both outputs simultaneously */
|
// /* This key combo locks both outputs simultaneously */
|
||||||
void screenlock_hotkey_handler(device_t *state, hid_keyboard_report_t *report) {
|
// void screenlock_hotkey_handler(device_t *state, hid_keyboard_report_t *report) {
|
||||||
hid_keyboard_report_t lock_report = {0}, release_keys = {0};
|
// hid_keyboard_report_t lock_report = {0}, release_keys = {0};
|
||||||
|
|
||||||
for (int out = 0; out < NUM_SCREENS; out++) {
|
// for (int out = 0; out < NUM_SCREENS; out++) {
|
||||||
switch (state->config.output[out].os) {
|
// switch (state->config.output[out].os) {
|
||||||
case WINDOWS:
|
// case WINDOWS:
|
||||||
case LINUX:
|
// case LINUX:
|
||||||
lock_report.modifier = KEYBOARD_MODIFIER_LEFTGUI;
|
// lock_report.modifier = KEYBOARD_MODIFIER_LEFTGUI;
|
||||||
lock_report.keycode[0] = HID_KEY_L;
|
// lock_report.keycode[0] = HID_KEY_L;
|
||||||
break;
|
// break;
|
||||||
case MACOS:
|
// case MACOS:
|
||||||
lock_report.modifier = KEYBOARD_MODIFIER_LEFTCTRL | KEYBOARD_MODIFIER_LEFTGUI;
|
// lock_report.modifier = KEYBOARD_MODIFIER_LEFTCTRL | KEYBOARD_MODIFIER_LEFTGUI;
|
||||||
lock_report.keycode[0] = HID_KEY_Q;
|
// lock_report.keycode[0] = HID_KEY_Q;
|
||||||
break;
|
// break;
|
||||||
default:
|
// default:
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (BOARD_ROLE == out) {
|
// if (BOARD_ROLE == out) {
|
||||||
queue_kbd_report(&lock_report, state);
|
// queue_kbd_report(&lock_report, state);
|
||||||
release_all_keys(state);
|
// release_all_keys(state);
|
||||||
} else {
|
// } else {
|
||||||
queue_packet((uint8_t *)&lock_report, KEYBOARD_REPORT_MSG, KBD_REPORT_LENGTH);
|
// queue_packet((uint8_t *)&lock_report, KEYBOARD_REPORT_MSG, KBD_REPORT_LENGTH);
|
||||||
queue_packet((uint8_t *)&release_keys, KEYBOARD_REPORT_MSG, KBD_REPORT_LENGTH);
|
// queue_packet((uint8_t *)&release_keys, KEYBOARD_REPORT_MSG, KBD_REPORT_LENGTH);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* When pressed, erases stored config in flash and loads defaults on both boards */
|
// /* When pressed, erases stored config in flash and loads defaults on both boards */
|
||||||
void wipe_config_hotkey_handler(device_t *state, hid_keyboard_report_t *report) {
|
// void wipe_config_hotkey_handler(device_t *state, hid_keyboard_report_t *report) {
|
||||||
wipe_config();
|
// wipe_config();
|
||||||
load_config(state);
|
// load_config(state);
|
||||||
send_value(ENABLE, WIPE_CONFIG_MSG);
|
// send_value(ENABLE, WIPE_CONFIG_MSG);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* When pressed, toggles the current mouse zoom mode state */
|
// /* When pressed, toggles the current mouse zoom mode state */
|
||||||
void mouse_zoom_hotkey_handler(device_t *state, hid_keyboard_report_t *report) {
|
// void mouse_zoom_hotkey_handler(device_t *state, hid_keyboard_report_t *report) {
|
||||||
state->mouse_zoom ^= 1;
|
// state->mouse_zoom ^= 1;
|
||||||
send_value(state->mouse_zoom, MOUSE_ZOOM_MSG);
|
// send_value(state->mouse_zoom, MOUSE_ZOOM_MSG);
|
||||||
};
|
// };
|
||||||
|
|
||||||
/* When pressed, enables the screensaver on active output */
|
// /* When pressed, enables the screensaver on active output */
|
||||||
void enable_screensaver_hotkey_handler(device_t *state, hid_keyboard_report_t *report) {
|
// void enable_screensaver_hotkey_handler(device_t *state, hid_keyboard_report_t *report) {
|
||||||
uint8_t desired_mode = state->config.output[BOARD_ROLE].screensaver.mode;
|
// uint8_t desired_mode = state->config.output[BOARD_ROLE].screensaver.mode;
|
||||||
|
|
||||||
/* If the user explicitly asks for screensaver to be active, ignore config and turn it on */
|
// /* If the user explicitly asks for screensaver to be active, ignore config and turn it on */
|
||||||
if (desired_mode == DISABLED)
|
// if (desired_mode == DISABLED)
|
||||||
desired_mode = PONG;
|
// desired_mode = PONG;
|
||||||
|
|
||||||
_screensaver_set(state, desired_mode);
|
// _screensaver_set(state, desired_mode);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* When pressed, disables the screensaver on active output */
|
// /* When pressed, disables the screensaver on active output */
|
||||||
void disable_screensaver_hotkey_handler(device_t *state, hid_keyboard_report_t *report) {
|
// void disable_screensaver_hotkey_handler(device_t *state, hid_keyboard_report_t *report) {
|
||||||
_screensaver_set(state, DISABLED);
|
// _screensaver_set(state, DISABLED);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* Put the device into a special configuration mode */
|
// /* Put the device into a special configuration mode */
|
||||||
void config_enable_hotkey_handler(device_t *state, hid_keyboard_report_t *report) {
|
// void config_enable_hotkey_handler(device_t *state, hid_keyboard_report_t *report) {
|
||||||
/* If config mode is already active, skip this and reboot to return to normal mode */
|
// /* If config mode is already active, skip this and reboot to return to normal mode */
|
||||||
if (!state->config_mode_active) {
|
// if (!state->config_mode_active) {
|
||||||
watchdog_hw->scratch[5] = MAGIC_WORD_1;
|
// watchdog_hw->scratch[5] = MAGIC_WORD_1;
|
||||||
watchdog_hw->scratch[6] = MAGIC_WORD_2;
|
// watchdog_hw->scratch[6] = MAGIC_WORD_2;
|
||||||
}
|
// }
|
||||||
|
|
||||||
release_all_keys(state);
|
// release_all_keys(state);
|
||||||
state->reboot_requested = true;
|
// state->reboot_requested = true;
|
||||||
};
|
// };
|
||||||
|
|
||||||
|
|
||||||
/**==================================================== *
|
/**==================================================== *
|
||||||
|
@ -181,15 +181,15 @@ void handle_output_select_msg(uart_packet_t *packet, device_t *state) {
|
||||||
restore_leds(state);
|
restore_leds(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* On firmware upgrade message, reboot into the BOOTSEL fw upgrade mode */
|
// /* On firmware upgrade message, reboot into the BOOTSEL fw upgrade mode */
|
||||||
void handle_fw_upgrade_msg(uart_packet_t *packet, device_t *state) {
|
// void handle_fw_upgrade_msg(uart_packet_t *packet, device_t *state) {
|
||||||
reset_usb_boot(1 << PICO_DEFAULT_LED_PIN, 0);
|
// reset_usb_boot(1 << PICO_DEFAULT_LED_PIN, 0);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* Comply with request to turn mouse zoom mode on/off */
|
// /* Comply with request to turn mouse zoom mode on/off */
|
||||||
void handle_mouse_zoom_msg(uart_packet_t *packet, device_t *state) {
|
// void handle_mouse_zoom_msg(uart_packet_t *packet, device_t *state) {
|
||||||
state->mouse_zoom = packet->data[0];
|
// state->mouse_zoom = packet->data[0];
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* Process request to update keyboard LEDs */
|
/* Process request to update keyboard LEDs */
|
||||||
void handle_set_report_msg(uart_packet_t *packet, device_t *state) {
|
void handle_set_report_msg(uart_packet_t *packet, device_t *state) {
|
||||||
|
@ -201,10 +201,10 @@ void handle_set_report_msg(uart_packet_t *packet, device_t *state) {
|
||||||
restore_leds(state);
|
restore_leds(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process request to block mouse from switching, update internal state */
|
// /* Process request to block mouse from switching, update internal state */
|
||||||
void handle_switch_lock_msg(uart_packet_t *packet, device_t *state) {
|
// void handle_switch_lock_msg(uart_packet_t *packet, device_t *state) {
|
||||||
state->switch_lock = packet->data[0];
|
// state->switch_lock = packet->data[0];
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* Handle border syncing message that lets the other device know about monitor height offset */
|
/* Handle border syncing message that lets the other device know about monitor height offset */
|
||||||
void handle_sync_borders_msg(uart_packet_t *packet, device_t *state) {
|
void handle_sync_borders_msg(uart_packet_t *packet, device_t *state) {
|
||||||
|
@ -224,16 +224,16 @@ void handle_flash_led_msg(uart_packet_t *packet, device_t *state) {
|
||||||
blink_led(state);
|
blink_led(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* When this message is received, wipe the local flash config */
|
// /* When this message is received, wipe the local flash config */
|
||||||
void handle_wipe_config_msg(uart_packet_t *packet, device_t *state) {
|
// void handle_wipe_config_msg(uart_packet_t *packet, device_t *state) {
|
||||||
wipe_config();
|
// wipe_config();
|
||||||
load_config(state);
|
// load_config(state);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* Update screensaver state after received message */
|
// /* Update screensaver state after received message */
|
||||||
void handle_screensaver_msg(uart_packet_t *packet, device_t *state) {
|
// void handle_screensaver_msg(uart_packet_t *packet, device_t *state) {
|
||||||
state->config.output[BOARD_ROLE].screensaver.mode = packet->data[0];
|
// state->config.output[BOARD_ROLE].screensaver.mode = packet->data[0];
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* Process consumer control message */
|
/* Process consumer control message */
|
||||||
void handle_consumer_control_msg(uart_packet_t *packet, device_t *state) {
|
void handle_consumer_control_msg(uart_packet_t *packet, device_t *state) {
|
||||||
|
@ -255,10 +255,10 @@ void handle_proxy_msg(uart_packet_t *packet, device_t *state) {
|
||||||
queue_packet(&packet->data[1], (enum packet_type_e)packet->data[0], PACKET_DATA_LENGTH - 1);
|
queue_packet(&packet->data[1], (enum packet_type_e)packet->data[0], PACKET_DATA_LENGTH - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process relative mouse command */
|
// /* Process relative mouse command */
|
||||||
void handle_toggle_gaming_msg(uart_packet_t *packet, device_t *state) {
|
// void handle_toggle_gaming_msg(uart_packet_t *packet, device_t *state) {
|
||||||
state->gaming_mode = packet->data[0];
|
// state->gaming_mode = packet->data[0];
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* Process api communication messages */
|
/* Process api communication messages */
|
||||||
void handle_api_msgs(uart_packet_t *packet, device_t *state) {
|
void handle_api_msgs(uart_packet_t *packet, device_t *state) {
|
||||||
|
@ -320,7 +320,7 @@ void handle_response_byte_msg(uart_packet_t *packet, device_t *state) {
|
||||||
uint32_t address = packet->data32[0];
|
uint32_t address = packet->data32[0];
|
||||||
|
|
||||||
if (address != state->fw.address) {
|
if (address != state->fw.address) {
|
||||||
state->fw.upgrade_in_progress = false;
|
// state->fw.upgrade_in_progress = false;
|
||||||
state->fw.address = 0;
|
state->fw.address = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -346,16 +346,17 @@ void handle_response_byte_msg(uart_packet_t *packet, device_t *state) {
|
||||||
void handle_heartbeat_msg(uart_packet_t *packet, device_t *state) {
|
void handle_heartbeat_msg(uart_packet_t *packet, device_t *state) {
|
||||||
uint16_t other_running_version = packet->data16[0];
|
uint16_t other_running_version = packet->data16[0];
|
||||||
|
|
||||||
if (state->fw.upgrade_in_progress)
|
// if (state->fw.upgrade_in_progress)
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
/* If the other board isn't running a newer version, we are done */
|
/* If the other board isn't running a newer version, we are done */
|
||||||
if (other_running_version <= state->_running_fw.version)
|
if (other_running_version <= state->_running_fw.version)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* It is? Ok, kick off the firmware upgrade */
|
/* It is? Ok, kick off the firmware upgrade */
|
||||||
state->fw = (fw_upgrade_state_t) {
|
// state->fw = (fw_upgrade_state_t) {
|
||||||
.upgrade_in_progress = true,
|
state->fw = () {
|
||||||
|
// .upgrade_in_progress = true,
|
||||||
.byte_done = true,
|
.byte_done = true,
|
||||||
.address = 0,
|
.address = 0,
|
||||||
.checksum = 0xffffffff,
|
.checksum = 0xffffffff,
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
#define TOUCH 2
|
#define TOUCH 2
|
||||||
|
|
||||||
#define MOUSE_BOOT_REPORT_LEN 4
|
#define MOUSE_BOOT_REPORT_LEN 4
|
||||||
#define MOUSE_ZOOM_SCALING_FACTOR 2
|
// #define MOUSE_ZOOM_SCALING_FACTOR 2
|
||||||
#define NUM_SCREENS 2 // Will be more in the future
|
#define NUM_SCREENS 2 // Will be more in the future
|
||||||
#define CONFIG_MODE_TIMEOUT 300000000 // 5 minutes into the future
|
#define CONFIG_MODE_TIMEOUT 300000000 // 5 minutes into the future
|
||||||
|
|
||||||
|
@ -116,16 +116,16 @@ enum packet_type_e {
|
||||||
KEYBOARD_REPORT_MSG = 1,
|
KEYBOARD_REPORT_MSG = 1,
|
||||||
MOUSE_REPORT_MSG = 2,
|
MOUSE_REPORT_MSG = 2,
|
||||||
OUTPUT_SELECT_MSG = 3,
|
OUTPUT_SELECT_MSG = 3,
|
||||||
FIRMWARE_UPGRADE_MSG = 4,
|
// FIRMWARE_UPGRADE_MSG = 4,
|
||||||
MOUSE_ZOOM_MSG = 5,
|
// MOUSE_ZOOM_MSG = 5,
|
||||||
KBD_SET_REPORT_MSG = 6,
|
KBD_SET_REPORT_MSG = 6,
|
||||||
SWITCH_LOCK_MSG = 7,
|
// SWITCH_LOCK_MSG = 7,
|
||||||
SYNC_BORDERS_MSG = 8,
|
SYNC_BORDERS_MSG = 8,
|
||||||
FLASH_LED_MSG = 9,
|
FLASH_LED_MSG = 9,
|
||||||
WIPE_CONFIG_MSG = 10,
|
// WIPE_CONFIG_MSG = 10,
|
||||||
SCREENSAVER_MSG = 11,
|
// SCREENSAVER_MSG = 11,
|
||||||
HEARTBEAT_MSG = 12,
|
HEARTBEAT_MSG = 12,
|
||||||
GAMING_MODE_MSG = 13,
|
// GAMING_MODE_MSG = 13,
|
||||||
CONSUMER_CONTROL_MSG = 14,
|
CONSUMER_CONTROL_MSG = 14,
|
||||||
SYSTEM_CONTROL_MSG = 15,
|
SYSTEM_CONTROL_MSG = 15,
|
||||||
SAVE_CONFIG_MSG = 18,
|
SAVE_CONFIG_MSG = 18,
|
||||||
|
@ -205,12 +205,12 @@ enum screen_pos_e {
|
||||||
MIDDLE = 3,
|
MIDDLE = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum screensaver_mode_e {
|
// enum screensaver_mode_e {
|
||||||
DISABLED = 0,
|
// DISABLED = 0,
|
||||||
PONG = 1,
|
// PONG = 1,
|
||||||
JITTER = 2,
|
// JITTER = 2,
|
||||||
MAX_SS_VAL = JITTER,
|
// MAX_SS_VAL = JITTER,
|
||||||
};
|
// };
|
||||||
|
|
||||||
#define ITF_NUM_HID 0
|
#define ITF_NUM_HID 0
|
||||||
#define ITF_NUM_HID_REL_M 1
|
#define ITF_NUM_HID_REL_M 1
|
||||||
|
@ -223,13 +223,13 @@ typedef struct {
|
||||||
// height
|
// height
|
||||||
} border_size_t;
|
} border_size_t;
|
||||||
|
|
||||||
/* Define screensaver parameters */
|
// /* Define screensaver parameters */
|
||||||
typedef struct {
|
// typedef struct {
|
||||||
uint8_t mode;
|
// uint8_t mode;
|
||||||
uint8_t only_if_inactive;
|
// uint8_t only_if_inactive;
|
||||||
uint64_t idle_time_us;
|
// uint64_t idle_time_us;
|
||||||
uint64_t max_time_us;
|
// uint64_t max_time_us;
|
||||||
} screensaver_t;
|
// } screensaver_t;
|
||||||
|
|
||||||
/* Define output parameters */
|
/* Define output parameters */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -242,7 +242,7 @@ typedef struct {
|
||||||
uint8_t os; // Operating system on this output
|
uint8_t os; // Operating system on this output
|
||||||
uint8_t pos; // Screen position on this output
|
uint8_t pos; // Screen position on this output
|
||||||
uint8_t mouse_park_pos; // Where the mouse goes after switch
|
uint8_t mouse_park_pos; // Where the mouse goes after switch
|
||||||
screensaver_t screensaver; // Screensaver parameters for this output
|
// screensaver_t screensaver; // Screensaver parameters for this output
|
||||||
} output_t;
|
} output_t;
|
||||||
|
|
||||||
/* Data structure defining how configuration is stored */
|
/* Data structure defining how configuration is stored */
|
||||||
|
@ -372,13 +372,13 @@ typedef struct {
|
||||||
|
|
||||||
typedef enum { IDLE, READING_PACKET, PROCESSING_PACKET } receiver_state_t;
|
typedef enum { IDLE, READING_PACKET, PROCESSING_PACKET } receiver_state_t;
|
||||||
|
|
||||||
typedef struct {
|
// typedef struct {
|
||||||
uint32_t address; // Address we're sending to the other box
|
// uint32_t address; // Address we're sending to the other box
|
||||||
uint32_t checksum;
|
// uint32_t checksum;
|
||||||
uint16_t version;
|
// uint16_t version;
|
||||||
bool byte_done; // Has the byte been successfully transferred
|
// bool byte_done; // Has the byte been successfully transferred
|
||||||
bool upgrade_in_progress; // True if firmware transfer from the other box is in progress
|
// bool upgrade_in_progress; // True if firmware transfer from the other box is in progress
|
||||||
} fw_upgrade_state_t;
|
// } fw_upgrade_state_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t kbd_dev_addr; // Address of the keyboard device
|
uint8_t kbd_dev_addr; // Address of the keyboard device
|
||||||
|
@ -410,7 +410,7 @@ typedef struct {
|
||||||
uint32_t dma_tx_channel; // DMA TX channel we're using to send
|
uint32_t dma_tx_channel; // DMA TX channel we're using to send
|
||||||
|
|
||||||
/* Firmware */
|
/* Firmware */
|
||||||
fw_upgrade_state_t fw; // State of the firmware upgrader
|
// fw_upgrade_state_t fw; // State of the firmware upgrader
|
||||||
firmware_metadata_t _running_fw; // RAM copy of running fw metadata
|
firmware_metadata_t _running_fw; // RAM copy of running fw metadata
|
||||||
bool reboot_requested; // If set, stop updating watchdog
|
bool reboot_requested; // If set, stop updating watchdog
|
||||||
uint64_t config_mode_timer; // Counts how long are we to remain in config mode
|
uint64_t config_mode_timer; // Counts how long are we to remain in config mode
|
||||||
|
@ -422,11 +422,11 @@ typedef struct {
|
||||||
bool keyboard_connected; // True when our keyboard is connected locally
|
bool keyboard_connected; // True when our keyboard is connected locally
|
||||||
|
|
||||||
/* Feature flags */
|
/* Feature flags */
|
||||||
bool mouse_zoom; // True when "mouse zoom" is enabled
|
// bool mouse_zoom; // True when "mouse zoom" is enabled
|
||||||
bool switch_lock; // True when device is prevented from switching
|
// bool switch_lock; // True when device is prevented from switching
|
||||||
bool onboard_led_state; // True when LED is ON
|
bool onboard_led_state; // True when LED is ON
|
||||||
bool relative_mouse; // True when relative mouse mode is used
|
bool relative_mouse; // True when relative mouse mode is used
|
||||||
bool gaming_mode; // True when gaming mode is on (relative passthru + lock)
|
// bool gaming_mode; // True when gaming mode is on (relative passthru + lock)
|
||||||
bool config_mode_active; // True when config mode is active
|
bool config_mode_active; // True when config mode is active
|
||||||
bool digitizer_active; // True when digitizer Win/Mac workaround is active
|
bool digitizer_active; // True when digitizer Win/Mac workaround is active
|
||||||
|
|
||||||
|
@ -509,8 +509,8 @@ void usb_device_task(device_t *);
|
||||||
void kick_watchdog_task(device_t *);
|
void kick_watchdog_task(device_t *);
|
||||||
void usb_host_task(device_t *);
|
void usb_host_task(device_t *);
|
||||||
void packet_receiver_task(device_t *);
|
void packet_receiver_task(device_t *);
|
||||||
void screensaver_task(device_t *);
|
// void screensaver_task(device_t *);
|
||||||
void firmware_upgrade_task(device_t *);
|
// void firmware_upgrade_task(device_t *);
|
||||||
void heartbeat_output_task(device_t *);
|
void heartbeat_output_task(device_t *);
|
||||||
void led_blinking_task(device_t *);
|
void led_blinking_task(device_t *);
|
||||||
|
|
||||||
|
@ -519,7 +519,7 @@ void task_scheduler(device_t *, task_t *);
|
||||||
/********* Configuration **********/
|
/********* Configuration **********/
|
||||||
void load_config(device_t *);
|
void load_config(device_t *);
|
||||||
void save_config(device_t *);
|
void save_config(device_t *);
|
||||||
void wipe_config(void);
|
// void wipe_config(void);
|
||||||
void reset_config_timer(device_t *);
|
void reset_config_timer(device_t *);
|
||||||
|
|
||||||
extern const field_map_t api_field_map[];
|
extern const field_map_t api_field_map[];
|
||||||
|
@ -531,30 +531,30 @@ void queue_cfg_packet(uart_packet_t *, device_t *);
|
||||||
|
|
||||||
/********* Handlers **********/
|
/********* Handlers **********/
|
||||||
void output_toggle_hotkey_handler(device_t *, hid_keyboard_report_t *);
|
void output_toggle_hotkey_handler(device_t *, hid_keyboard_report_t *);
|
||||||
void screen_border_hotkey_handler(device_t *, hid_keyboard_report_t *);
|
// void screen_border_hotkey_handler(device_t *, hid_keyboard_report_t *);
|
||||||
void fw_upgrade_hotkey_handler_A(device_t *, hid_keyboard_report_t *);
|
// void fw_upgrade_hotkey_handler_A(device_t *, hid_keyboard_report_t *);
|
||||||
void fw_upgrade_hotkey_handler_B(device_t *, hid_keyboard_report_t *);
|
// void fw_upgrade_hotkey_handler_B(device_t *, hid_keyboard_report_t *);
|
||||||
void mouse_zoom_hotkey_handler(device_t *, hid_keyboard_report_t *);
|
// void mouse_zoom_hotkey_handler(device_t *, hid_keyboard_report_t *);
|
||||||
void all_keys_released_handler(device_t *);
|
// void all_keys_released_handler(device_t *);
|
||||||
void switchlock_hotkey_handler(device_t *, hid_keyboard_report_t *);
|
// void switchlock_hotkey_handler(device_t *, hid_keyboard_report_t *);
|
||||||
void toggle_gaming_mode_handler(device_t *, hid_keyboard_report_t *);
|
// void toggle_gaming_mode_handler(device_t *, hid_keyboard_report_t *);
|
||||||
void screenlock_hotkey_handler(device_t *, hid_keyboard_report_t *);
|
// void screenlock_hotkey_handler(device_t *, hid_keyboard_report_t *);
|
||||||
void output_config_hotkey_handler(device_t *, hid_keyboard_report_t *);
|
// void output_config_hotkey_handler(device_t *, hid_keyboard_report_t *);
|
||||||
void wipe_config_hotkey_handler(device_t *, hid_keyboard_report_t *);
|
// void wipe_config_hotkey_handler(device_t *, hid_keyboard_report_t *);
|
||||||
void config_enable_hotkey_handler(device_t *, hid_keyboard_report_t *);
|
// void config_enable_hotkey_handler(device_t *, hid_keyboard_report_t *);
|
||||||
void enable_screensaver_hotkey_handler(device_t *, hid_keyboard_report_t *);
|
// void enable_screensaver_hotkey_handler(device_t *, hid_keyboard_report_t *);
|
||||||
void disable_screensaver_hotkey_handler(device_t *, hid_keyboard_report_t *);
|
// void disable_screensaver_hotkey_handler(device_t *, hid_keyboard_report_t *);
|
||||||
|
|
||||||
void handle_keyboard_uart_msg(uart_packet_t *, device_t *);
|
void handle_keyboard_uart_msg(uart_packet_t *, device_t *);
|
||||||
void handle_mouse_abs_uart_msg(uart_packet_t *, device_t *);
|
void handle_mouse_abs_uart_msg(uart_packet_t *, device_t *);
|
||||||
void handle_output_select_msg(uart_packet_t *, device_t *);
|
void handle_output_select_msg(uart_packet_t *, device_t *);
|
||||||
void handle_mouse_zoom_msg(uart_packet_t *, device_t *);
|
// void handle_mouse_zoom_msg(uart_packet_t *, device_t *);
|
||||||
void handle_set_report_msg(uart_packet_t *, device_t *);
|
void handle_set_report_msg(uart_packet_t *, device_t *);
|
||||||
void handle_switch_lock_msg(uart_packet_t *, device_t *);
|
// void handle_switch_lock_msg(uart_packet_t *, device_t *);
|
||||||
void handle_sync_borders_msg(uart_packet_t *, device_t *);
|
void handle_sync_borders_msg(uart_packet_t *, device_t *);
|
||||||
void handle_flash_led_msg(uart_packet_t *, device_t *);
|
void handle_flash_led_msg(uart_packet_t *, device_t *);
|
||||||
void handle_fw_upgrade_msg(uart_packet_t *, device_t *);
|
// void handle_fw_upgrade_msg(uart_packet_t *, device_t *);
|
||||||
void handle_wipe_config_msg(uart_packet_t *, device_t *);
|
// void handle_wipe_config_msg(uart_packet_t *, device_t *);
|
||||||
void handle_consumer_control_msg(uart_packet_t *, device_t *);
|
void handle_consumer_control_msg(uart_packet_t *, device_t *);
|
||||||
void handle_read_config_msg(uart_packet_t *, device_t *);
|
void handle_read_config_msg(uart_packet_t *, device_t *);
|
||||||
void handle_save_config_msg(uart_packet_t *, device_t *);
|
void handle_save_config_msg(uart_packet_t *, device_t *);
|
||||||
|
@ -567,7 +567,7 @@ void handle_proxy_msg(uart_packet_t *, device_t *);
|
||||||
void handle_api_msgs(uart_packet_t *, device_t *);
|
void handle_api_msgs(uart_packet_t *, device_t *);
|
||||||
void handle_api_read_all_msg(uart_packet_t *, device_t *);
|
void handle_api_read_all_msg(uart_packet_t *, device_t *);
|
||||||
void handle_toggle_gaming_msg(uart_packet_t *, device_t *);
|
void handle_toggle_gaming_msg(uart_packet_t *, device_t *);
|
||||||
void handle_screensaver_msg(uart_packet_t *, device_t *);
|
// void handle_screensaver_msg(uart_packet_t *, device_t *);
|
||||||
|
|
||||||
void switch_output(device_t *, uint8_t);
|
void switch_output(device_t *, uint8_t);
|
||||||
|
|
||||||
|
|
|
@ -113,8 +113,8 @@
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#define SCREENSAVER_A_MODE DISABLED
|
// #define SCREENSAVER_A_MODE DISABLED
|
||||||
#define SCREENSAVER_B_MODE DISABLED
|
// #define SCREENSAVER_B_MODE DISABLED
|
||||||
|
|
||||||
/**================================================== *
|
/**================================================== *
|
||||||
*
|
*
|
||||||
|
@ -123,8 +123,8 @@
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#define SCREENSAVER_A_IDLE_TIME_SEC 240
|
// #define SCREENSAVER_A_IDLE_TIME_SEC 240
|
||||||
#define SCREENSAVER_B_IDLE_TIME_SEC 240
|
// #define SCREENSAVER_B_IDLE_TIME_SEC 240
|
||||||
|
|
||||||
/**================================================== *
|
/**================================================== *
|
||||||
*
|
*
|
||||||
|
@ -133,8 +133,8 @@
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#define SCREENSAVER_A_MAX_TIME_SEC 0
|
// #define SCREENSAVER_A_MAX_TIME_SEC 0
|
||||||
#define SCREENSAVER_B_MAX_TIME_SEC 0
|
// #define SCREENSAVER_B_MAX_TIME_SEC 0
|
||||||
|
|
||||||
/**================================================== *
|
/**================================================== *
|
||||||
*
|
*
|
||||||
|
@ -143,8 +143,8 @@
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#define SCREENSAVER_A_ONLY_IF_INACTIVE 0
|
// #define SCREENSAVER_A_ONLY_IF_INACTIVE 0
|
||||||
#define SCREENSAVER_B_ONLY_IF_INACTIVE 0
|
// #define SCREENSAVER_B_ONLY_IF_INACTIVE 0
|
||||||
|
|
||||||
/**================================================== *
|
/**================================================== *
|
||||||
* ================ Output OS Config =============== *
|
* ================ Output OS Config =============== *
|
||||||
|
@ -160,8 +160,8 @@
|
||||||
*
|
*
|
||||||
* */
|
* */
|
||||||
|
|
||||||
#define OUTPUT_A_OS MACOS
|
// #define OUTPUT_A_OS MACOS
|
||||||
#define OUTPUT_B_OS LINUX
|
// #define OUTPUT_B_OS LINUX
|
||||||
|
|
||||||
|
|
||||||
/**================================================== *
|
/**================================================== *
|
||||||
|
|
134
src/keyboard.c
134
src/keyboard.c
|
@ -29,83 +29,83 @@ hotkey_combo_t hotkeys[] = {
|
||||||
.pass_to_os = false,
|
.pass_to_os = false,
|
||||||
.action_handler = &output_toggle_hotkey_handler},
|
.action_handler = &output_toggle_hotkey_handler},
|
||||||
|
|
||||||
/* Pressing right ALT + right CTRL toggles the slow mouse mode */
|
// /* Pressing right ALT + right CTRL toggles the slow mouse mode */
|
||||||
{.modifier = KEYBOARD_MODIFIER_RIGHTALT | KEYBOARD_MODIFIER_RIGHTCTRL,
|
// {.modifier = KEYBOARD_MODIFIER_RIGHTALT | KEYBOARD_MODIFIER_RIGHTCTRL,
|
||||||
.keys = {},
|
// .keys = {},
|
||||||
.key_count = 0,
|
// .key_count = 0,
|
||||||
.pass_to_os = true,
|
// .pass_to_os = true,
|
||||||
.acknowledge = true,
|
// .acknowledge = true,
|
||||||
.action_handler = &mouse_zoom_hotkey_handler},
|
// .action_handler = &mouse_zoom_hotkey_handler},
|
||||||
|
|
||||||
/* Switch lock */
|
// /* Switch lock */
|
||||||
{.modifier = KEYBOARD_MODIFIER_RIGHTCTRL,
|
// {.modifier = KEYBOARD_MODIFIER_RIGHTCTRL,
|
||||||
.keys = {HID_KEY_K},
|
// .keys = {HID_KEY_K},
|
||||||
.key_count = 1,
|
// .key_count = 1,
|
||||||
.acknowledge = true,
|
// .acknowledge = true,
|
||||||
.action_handler = &switchlock_hotkey_handler},
|
// .action_handler = &switchlock_hotkey_handler},
|
||||||
|
|
||||||
/* Screen lock */
|
// /* Screen lock */
|
||||||
{.modifier = KEYBOARD_MODIFIER_RIGHTCTRL,
|
// {.modifier = KEYBOARD_MODIFIER_RIGHTCTRL,
|
||||||
.keys = {HID_KEY_L},
|
// .keys = {HID_KEY_L},
|
||||||
.key_count = 1,
|
// .key_count = 1,
|
||||||
.acknowledge = true,
|
// .acknowledge = true,
|
||||||
.action_handler = &screenlock_hotkey_handler},
|
// .action_handler = &screenlock_hotkey_handler},
|
||||||
|
|
||||||
/* Toggle gaming mode */
|
// /* Toggle gaming mode */
|
||||||
{.modifier = KEYBOARD_MODIFIER_LEFTCTRL | KEYBOARD_MODIFIER_RIGHTSHIFT,
|
// {.modifier = KEYBOARD_MODIFIER_LEFTCTRL | KEYBOARD_MODIFIER_RIGHTSHIFT,
|
||||||
.keys = {HID_KEY_G},
|
// .keys = {HID_KEY_G},
|
||||||
.key_count = 1,
|
// .key_count = 1,
|
||||||
.acknowledge = true,
|
// .acknowledge = true,
|
||||||
.action_handler = &toggle_gaming_mode_handler},
|
// .action_handler = &toggle_gaming_mode_handler},
|
||||||
|
|
||||||
/* Enable screensaver for active output */
|
// /* Enable screensaver for active output */
|
||||||
{.modifier = KEYBOARD_MODIFIER_LEFTCTRL | KEYBOARD_MODIFIER_RIGHTSHIFT,
|
// {.modifier = KEYBOARD_MODIFIER_LEFTCTRL | KEYBOARD_MODIFIER_RIGHTSHIFT,
|
||||||
.keys = {HID_KEY_S},
|
// .keys = {HID_KEY_S},
|
||||||
.key_count = 1,
|
// .key_count = 1,
|
||||||
.acknowledge = true,
|
// .acknowledge = true,
|
||||||
.action_handler = &enable_screensaver_hotkey_handler},
|
// .action_handler = &enable_screensaver_hotkey_handler},
|
||||||
|
|
||||||
/* Disable screensaver for active output */
|
// /* Disable screensaver for active output */
|
||||||
{.modifier = KEYBOARD_MODIFIER_LEFTCTRL | KEYBOARD_MODIFIER_RIGHTSHIFT,
|
// {.modifier = KEYBOARD_MODIFIER_LEFTCTRL | KEYBOARD_MODIFIER_RIGHTSHIFT,
|
||||||
.keys = {HID_KEY_X},
|
// .keys = {HID_KEY_X},
|
||||||
.key_count = 1,
|
// .key_count = 1,
|
||||||
.acknowledge = true,
|
// .acknowledge = true,
|
||||||
.action_handler = &disable_screensaver_hotkey_handler},
|
// .action_handler = &disable_screensaver_hotkey_handler},
|
||||||
|
|
||||||
/* Erase stored config */
|
// /* Erase stored config */
|
||||||
{.modifier = KEYBOARD_MODIFIER_RIGHTSHIFT,
|
// {.modifier = KEYBOARD_MODIFIER_RIGHTSHIFT,
|
||||||
.keys = {HID_KEY_F12, HID_KEY_D},
|
// .keys = {HID_KEY_F12, HID_KEY_D},
|
||||||
.key_count = 2,
|
// .key_count = 2,
|
||||||
.acknowledge = true,
|
// .acknowledge = true,
|
||||||
.action_handler = &wipe_config_hotkey_handler},
|
// .action_handler = &wipe_config_hotkey_handler},
|
||||||
|
|
||||||
/* Record switch y coordinate */
|
// /* Record switch y coordinate */
|
||||||
{.modifier = KEYBOARD_MODIFIER_RIGHTSHIFT,
|
// {.modifier = KEYBOARD_MODIFIER_RIGHTSHIFT,
|
||||||
.keys = {HID_KEY_F12, HID_KEY_Y},
|
// .keys = {HID_KEY_F12, HID_KEY_Y},
|
||||||
.key_count = 2,
|
// .key_count = 2,
|
||||||
.acknowledge = true,
|
// .acknowledge = true,
|
||||||
.action_handler = &screen_border_hotkey_handler},
|
// .action_handler = &screen_border_hotkey_handler},
|
||||||
|
|
||||||
/* Switch to configuration mode */
|
// /* Switch to configuration mode */
|
||||||
{.modifier = KEYBOARD_MODIFIER_LEFTCTRL | KEYBOARD_MODIFIER_RIGHTSHIFT,
|
// {.modifier = KEYBOARD_MODIFIER_LEFTCTRL | KEYBOARD_MODIFIER_RIGHTSHIFT,
|
||||||
.keys = {HID_KEY_C, HID_KEY_O},
|
// .keys = {HID_KEY_C, HID_KEY_O},
|
||||||
.key_count = 2,
|
// .key_count = 2,
|
||||||
.acknowledge = true,
|
// .acknowledge = true,
|
||||||
.action_handler = &config_enable_hotkey_handler},
|
// .action_handler = &config_enable_hotkey_handler},
|
||||||
|
|
||||||
/* Hold down left shift + right shift + F12 + A ==> firmware upgrade mode for board A (kbd) */
|
// /* Hold down left shift + right shift + F12 + A ==> firmware upgrade mode for board A (kbd) */
|
||||||
{.modifier = KEYBOARD_MODIFIER_RIGHTSHIFT | KEYBOARD_MODIFIER_LEFTSHIFT,
|
// {.modifier = KEYBOARD_MODIFIER_RIGHTSHIFT | KEYBOARD_MODIFIER_LEFTSHIFT,
|
||||||
.keys = {HID_KEY_A},
|
// .keys = {HID_KEY_A},
|
||||||
.key_count = 1,
|
// .key_count = 1,
|
||||||
.acknowledge = true,
|
// .acknowledge = true,
|
||||||
.action_handler = &fw_upgrade_hotkey_handler_A},
|
// .action_handler = &fw_upgrade_hotkey_handler_A},
|
||||||
|
|
||||||
/* Hold down left shift + right shift + F12 + B ==> firmware upgrade mode for board B (mouse) */
|
// /* Hold down left shift + right shift + F12 + B ==> firmware upgrade mode for board B (mouse) */
|
||||||
{.modifier = KEYBOARD_MODIFIER_RIGHTSHIFT | KEYBOARD_MODIFIER_LEFTSHIFT,
|
// {.modifier = KEYBOARD_MODIFIER_RIGHTSHIFT | KEYBOARD_MODIFIER_LEFTSHIFT,
|
||||||
.keys = {HID_KEY_B},
|
// .keys = {HID_KEY_B},
|
||||||
.key_count = 1,
|
// .key_count = 1,
|
||||||
.acknowledge = true,
|
// .acknowledge = true,
|
||||||
.action_handler = &fw_upgrade_hotkey_handler_B}};
|
// .action_handler = &fw_upgrade_hotkey_handler_B}};
|
||||||
|
|
||||||
/* ============================================================ *
|
/* ============================================================ *
|
||||||
* Detect if any hotkeys were pressed
|
* Detect if any hotkeys were pressed
|
||||||
|
|
|
@ -60,8 +60,8 @@ void core1_main() {
|
||||||
[0] = {.exec = &usb_host_task, .frequency = _TOP()}, // .-> USB host task, needs to run as often as possible
|
[0] = {.exec = &usb_host_task, .frequency = _TOP()}, // .-> USB host task, needs to run as often as possible
|
||||||
[1] = {.exec = &packet_receiver_task, .frequency = _TOP()}, // | Receive data over serial from the other board
|
[1] = {.exec = &packet_receiver_task, .frequency = _TOP()}, // | Receive data over serial from the other board
|
||||||
[2] = {.exec = &led_blinking_task, .frequency = _HZ(30)}, // | Check if LED needs blinking
|
[2] = {.exec = &led_blinking_task, .frequency = _HZ(30)}, // | Check if LED needs blinking
|
||||||
[3] = {.exec = &screensaver_task, .frequency = _HZ(120)}, // | Handle "screensaver" movements
|
// [3] = {.exec = &screensaver_task, .frequency = _HZ(120)}, // | Handle "screensaver" movements
|
||||||
[4] = {.exec = &firmware_upgrade_task, .frequency = _HZ(4000)}, // | Send firmware to the other board if needed
|
// [4] = {.exec = &firmware_upgrade_task, .frequency = _HZ(4000)}, // | Send firmware to the other board if needed
|
||||||
[5] = {.exec = &heartbeat_output_task, .frequency = _HZ(1)}, // | Output periodic heartbeats
|
[5] = {.exec = &heartbeat_output_task, .frequency = _HZ(1)}, // | Output periodic heartbeats
|
||||||
}; // `----- then go back and repeat forever
|
}; // `----- then go back and repeat forever
|
||||||
const int NUM_TASKS = ARRAY_SIZE(tasks_core1);
|
const int NUM_TASKS = ARRAY_SIZE(tasks_core1);
|
||||||
|
|
24
src/mouse.c
24
src/mouse.c
|
@ -67,9 +67,9 @@ void update_mouse_position(device_t *state, mouse_values_t *values) {
|
||||||
output_t *current = &state->config.output[state->active_output];
|
output_t *current = &state->config.output[state->active_output];
|
||||||
uint8_t reduce_speed = 0;
|
uint8_t reduce_speed = 0;
|
||||||
|
|
||||||
/* Check if we are configured to move slowly */
|
// /* Check if we are configured to move slowly */
|
||||||
if (state->mouse_zoom)
|
// if (state->mouse_zoom)
|
||||||
reduce_speed = MOUSE_ZOOM_SCALING_FACTOR;
|
// reduce_speed = MOUSE_ZOOM_SCALING_FACTOR;
|
||||||
|
|
||||||
/* Calculate movement */
|
/* Calculate movement */
|
||||||
int offset_x = accelerate(values->move_x) * (current->speed_x >> reduce_speed);
|
int offset_x = accelerate(values->move_x) * (current->speed_x >> reduce_speed);
|
||||||
|
@ -191,9 +191,9 @@ void check_screen_switch(const mouse_values_t *values, device_t *state) {
|
||||||
|
|
||||||
int direction = jump_left ? LEFT : RIGHT;
|
int direction = jump_left ? LEFT : RIGHT;
|
||||||
|
|
||||||
/* No switching allowed if explicitly disabled or in gaming mode */
|
// /* No switching allowed if explicitly disabled or in gaming mode */
|
||||||
if (state->switch_lock || state->gaming_mode)
|
// if (state->switch_lock)
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
/* No jump condition met == nothing to do, return */
|
/* No jump condition met == nothing to do, return */
|
||||||
if (!jump_left && !jump_right)
|
if (!jump_left && !jump_right)
|
||||||
|
@ -252,12 +252,12 @@ mouse_report_t create_mouse_report(device_t *state, mouse_values_t *values) {
|
||||||
.mode = ABSOLUTE,
|
.mode = ABSOLUTE,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Workaround for Windows multiple desktops */
|
// /* Workaround for Windows multiple desktops */
|
||||||
if (state->relative_mouse || state->gaming_mode) {
|
// if (state->relative_mouse || state->gaming_mode) {
|
||||||
mouse_report.x = values->move_x;
|
// mouse_report.x = values->move_x;
|
||||||
mouse_report.y = values->move_y;
|
// mouse_report.y = values->move_y;
|
||||||
mouse_report.mode = RELATIVE;
|
// mouse_report.mode = RELATIVE;
|
||||||
}
|
// }
|
||||||
|
|
||||||
return mouse_report;
|
return mouse_report;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,15 +14,15 @@ const field_map_t api_field_map[] = {
|
||||||
{ 13, false, INT32, 4, offsetof(device_t, config.output[0].speed_y) },
|
{ 13, false, INT32, 4, offsetof(device_t, config.output[0].speed_y) },
|
||||||
{ 14, false, INT32, 4, offsetof(device_t, config.output[0].border.top) },
|
{ 14, false, INT32, 4, offsetof(device_t, config.output[0].border.top) },
|
||||||
{ 15, false, INT32, 4, offsetof(device_t, config.output[0].border.bottom) },
|
{ 15, false, INT32, 4, offsetof(device_t, config.output[0].border.bottom) },
|
||||||
{ 16, false, UINT8, 1, offsetof(device_t, config.output[0].os) },
|
// { 16, false, UINT8, 1, offsetof(device_t, config.output[0].os) },
|
||||||
{ 17, false, UINT8, 1, offsetof(device_t, config.output[0].pos) },
|
{ 17, false, UINT8, 1, offsetof(device_t, config.output[0].pos) },
|
||||||
{ 18, false, UINT8, 1, offsetof(device_t, config.output[0].mouse_park_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) },
|
// { 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) },
|
// { 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 */
|
/* 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) },
|
// { 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) },
|
// { 22, false, UINT64, 7, offsetof(device_t, config.output[0].screensaver.max_time_us) },
|
||||||
|
|
||||||
/* Output B */
|
/* Output B */
|
||||||
{ 40, false, UINT32, 4, offsetof(device_t, config.output[1].number) },
|
{ 40, false, UINT32, 4, offsetof(device_t, config.output[1].number) },
|
||||||
|
@ -31,13 +31,13 @@ const field_map_t api_field_map[] = {
|
||||||
{ 43, false, INT32, 4, offsetof(device_t, config.output[1].speed_y) },
|
{ 43, false, INT32, 4, offsetof(device_t, config.output[1].speed_y) },
|
||||||
{ 44, false, INT32, 4, offsetof(device_t, config.output[1].border.top) },
|
{ 44, false, INT32, 4, offsetof(device_t, config.output[1].border.top) },
|
||||||
{ 45, false, INT32, 4, offsetof(device_t, config.output[1].border.bottom) },
|
{ 45, false, INT32, 4, offsetof(device_t, config.output[1].border.bottom) },
|
||||||
{ 46, false, UINT8, 1, offsetof(device_t, config.output[1].os) },
|
// { 46, false, UINT8, 1, offsetof(device_t, config.output[1].os) },
|
||||||
{ 47, false, UINT8, 1, offsetof(device_t, config.output[1].pos) },
|
{ 47, false, UINT8, 1, offsetof(device_t, config.output[1].pos) },
|
||||||
{ 48, false, UINT8, 1, offsetof(device_t, config.output[1].mouse_park_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) },
|
// { 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) },
|
// { 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) },
|
// { 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) },
|
// { 52, false, UINT64, 7, offsetof(device_t, config.output[1].screensaver.max_time_us) },
|
||||||
|
|
||||||
/* Common config */
|
/* Common config */
|
||||||
{ 70, false, UINT32, 4, offsetof(device_t, config.version) },
|
{ 70, false, UINT32, 4, offsetof(device_t, config.version) },
|
||||||
|
@ -54,7 +54,7 @@ const field_map_t api_field_map[] = {
|
||||||
{ 79, true, UINT32, 4, offsetof(device_t, _running_fw.checksum) },
|
{ 79, true, UINT32, 4, offsetof(device_t, _running_fw.checksum) },
|
||||||
|
|
||||||
{ 80, true, UINT8, 1, offsetof(device_t, keyboard_connected) },
|
{ 80, true, UINT8, 1, offsetof(device_t, keyboard_connected) },
|
||||||
{ 81, true, UINT8, 1, offsetof(device_t, switch_lock) },
|
// { 81, true, UINT8, 1, offsetof(device_t, switch_lock) },
|
||||||
{ 82, true, UINT8, 1, offsetof(device_t, relative_mouse) },
|
{ 82, true, UINT8, 1, offsetof(device_t, relative_mouse) },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t *
|
||||||
global_state.fw.checksum = 0xffffffff;
|
global_state.fw.checksum = 0xffffffff;
|
||||||
|
|
||||||
/* Make sure nobody else touches the flash during this operation, otherwise we get empty pages */
|
/* Make sure nobody else touches the flash during this operation, otherwise we get empty pages */
|
||||||
global_state.fw.upgrade_in_progress = true;
|
// global_state.fw.upgrade_in_progress = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update checksum continuously as blocks are being received */
|
/* Update checksum continuously as blocks are being received */
|
||||||
|
|
184
src/tasks.c
184
src/tasks.c
|
@ -59,92 +59,92 @@ void usb_host_task(device_t *state) {
|
||||||
tuh_task();
|
tuh_task();
|
||||||
}
|
}
|
||||||
|
|
||||||
mouse_report_t *screensaver_pong(device_t *state) {
|
// mouse_report_t *screensaver_pong(device_t *state) {
|
||||||
static mouse_report_t report = {0};
|
// static mouse_report_t report = {0};
|
||||||
static int dx = 20, dy = 25;
|
// static int dx = 20, dy = 25;
|
||||||
|
|
||||||
/* Check if we are bouncing off the walls and reverse direction in that case. */
|
// /* Check if we are bouncing off the walls and reverse direction in that case. */
|
||||||
if (report.x + dx < MIN_SCREEN_COORD || report.x + dx > MAX_SCREEN_COORD)
|
// if (report.x + dx < MIN_SCREEN_COORD || report.x + dx > MAX_SCREEN_COORD)
|
||||||
dx = -dx;
|
// dx = -dx;
|
||||||
|
|
||||||
if (report.y + dy < MIN_SCREEN_COORD || report.y + dy > MAX_SCREEN_COORD)
|
// if (report.y + dy < MIN_SCREEN_COORD || report.y + dy > MAX_SCREEN_COORD)
|
||||||
dy = -dy;
|
// dy = -dy;
|
||||||
|
|
||||||
report.x += dx;
|
// report.x += dx;
|
||||||
report.y += dy;
|
// report.y += dy;
|
||||||
|
|
||||||
return &report;
|
// return &report;
|
||||||
}
|
// }
|
||||||
|
|
||||||
mouse_report_t *screensaver_jitter(device_t *state) {
|
// mouse_report_t *screensaver_jitter(device_t *state) {
|
||||||
const int16_t jitter_distance = 2;
|
// const int16_t jitter_distance = 2;
|
||||||
static mouse_report_t report = {
|
// static mouse_report_t report = {
|
||||||
.y = jitter_distance,
|
// .y = jitter_distance,
|
||||||
.mode = RELATIVE,
|
// .mode = RELATIVE,
|
||||||
};
|
// };
|
||||||
report.y = -report.y;
|
// report.y = -report.y;
|
||||||
|
|
||||||
return &report;
|
// return &report;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* Have something fun and entertaining when idle. */
|
// /* Have something fun and entertaining when idle. */
|
||||||
void screensaver_task(device_t *state) {
|
// void screensaver_task(device_t *state) {
|
||||||
const uint32_t delays[] = {
|
// const uint32_t delays[] = {
|
||||||
0, /* DISABLED, unused index 0 */
|
// 0, /* DISABLED, unused index 0 */
|
||||||
5000, /* PONG, move mouse every 5 ms for a high framerate */
|
// 5000, /* PONG, move mouse every 5 ms for a high framerate */
|
||||||
10000000, /* JITTER, once every 10 sec is more than enough */
|
// 10000000, /* JITTER, once every 10 sec is more than enough */
|
||||||
};
|
// };
|
||||||
static int last_pointer_move = 0;
|
// static int last_pointer_move = 0;
|
||||||
screensaver_t *screensaver = &state->config.output[BOARD_ROLE].screensaver;
|
// screensaver_t *screensaver = &state->config.output[BOARD_ROLE].screensaver;
|
||||||
uint64_t inactivity_period = time_us_64() - state->last_activity[BOARD_ROLE];
|
// uint64_t inactivity_period = time_us_64() - state->last_activity[BOARD_ROLE];
|
||||||
|
|
||||||
/* If we're not enabled, nothing to do here. */
|
// /* If we're not enabled, nothing to do here. */
|
||||||
if (screensaver->mode == DISABLED)
|
// if (screensaver->mode == DISABLED)
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
/* System is still not idle for long enough to activate or screensaver mode is not supported */
|
// /* System is still not idle for long enough to activate or screensaver mode is not supported */
|
||||||
if (inactivity_period < screensaver->idle_time_us || screensaver->mode > MAX_SS_VAL)
|
// if (inactivity_period < screensaver->idle_time_us || screensaver->mode > MAX_SS_VAL)
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
/* We exceeded the maximum permitted screensaver runtime */
|
// /* We exceeded the maximum permitted screensaver runtime */
|
||||||
if (screensaver->max_time_us
|
// if (screensaver->max_time_us
|
||||||
&& inactivity_period > (screensaver->max_time_us + screensaver->idle_time_us))
|
// && inactivity_period > (screensaver->max_time_us + screensaver->idle_time_us))
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
/* If we're the selected output and we can only run on inactive output, nothing to do here. */
|
// /* If we're the selected output and we can only run on inactive output, nothing to do here. */
|
||||||
if (screensaver->only_if_inactive && CURRENT_BOARD_IS_ACTIVE_OUTPUT)
|
// if (screensaver->only_if_inactive && CURRENT_BOARD_IS_ACTIVE_OUTPUT)
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
/* We're active! Now check if it's time to move the cursor yet. */
|
// /* We're active! Now check if it's time to move the cursor yet. */
|
||||||
if (time_us_32() - last_pointer_move < delays[screensaver->mode])
|
// if (time_us_32() - last_pointer_move < delays[screensaver->mode])
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
mouse_report_t *report;
|
// mouse_report_t *report;
|
||||||
switch (screensaver->mode) {
|
// switch (screensaver->mode) {
|
||||||
case PONG:
|
// case PONG:
|
||||||
report = screensaver_pong(state);
|
// report = screensaver_pong(state);
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case JITTER:
|
// case JITTER:
|
||||||
report = screensaver_jitter(state);
|
// report = screensaver_jitter(state);
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
default:
|
// default:
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* Move mouse pointer */
|
// /* Move mouse pointer */
|
||||||
queue_mouse_report(report, state);
|
// queue_mouse_report(report, state);
|
||||||
|
|
||||||
/* Update timer of the last pointer move */
|
// /* Update timer of the last pointer move */
|
||||||
last_pointer_move = time_us_32();
|
// last_pointer_move = time_us_32();
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* Periodically emit heartbeat packets */
|
/* Periodically emit heartbeat packets */
|
||||||
void heartbeat_output_task(device_t *state) {
|
void heartbeat_output_task(device_t *state) {
|
||||||
/* If firmware upgrade is in progress, don't touch flash_cs */
|
/* If firmware upgrade is in progress, don't touch flash_cs */
|
||||||
if (state->fw.upgrade_in_progress)
|
// if (state->fw.upgrade_in_progress)
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
if (state->config_mode_active) {
|
if (state->config_mode_active) {
|
||||||
/* Leave config mode if timeout expired and user didn't click exit */
|
/* Leave config mode if timeout expired and user didn't click exit */
|
||||||
|
@ -191,40 +191,40 @@ void process_hid_queue_task(device_t *state) {
|
||||||
queue_try_remove(&state->hid_queue_out, &packet);
|
queue_try_remove(&state->hid_queue_out, &packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Task that handles copying firmware from the other device to ours */
|
// /* Task that handles copying firmware from the other device to ours */
|
||||||
void firmware_upgrade_task(device_t *state) {
|
// void firmware_upgrade_task(device_t *state) {
|
||||||
if (!state->fw.upgrade_in_progress || !state->fw.byte_done)
|
// if (!state->fw.upgrade_in_progress || !state->fw.byte_done)
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
if (queue_is_full(&state->uart_tx_queue))
|
// if (queue_is_full(&state->uart_tx_queue))
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
/* End condition, when reached the process is completed. */
|
// /* End condition, when reached the process is completed. */
|
||||||
if (state->fw.address > STAGING_IMAGE_SIZE) {
|
// if (state->fw.address > STAGING_IMAGE_SIZE) {
|
||||||
state->fw.upgrade_in_progress = 0;
|
// state->fw.upgrade_in_progress = 0;
|
||||||
state->fw.checksum = ~state->fw.checksum;
|
// state->fw.checksum = ~state->fw.checksum;
|
||||||
|
|
||||||
/* Checksum mismatch, we wipe the stage 2 bootloader and rely on ROM recovery */
|
// /* Checksum mismatch, we wipe the stage 2 bootloader and rely on ROM recovery */
|
||||||
if(calculate_firmware_crc32() != state->fw.checksum) {
|
// if(calculate_firmware_crc32() != state->fw.checksum) {
|
||||||
flash_range_erase((uint32_t)ADDR_FW_RUNNING - XIP_BASE, FLASH_SECTOR_SIZE);
|
// flash_range_erase((uint32_t)ADDR_FW_RUNNING - XIP_BASE, FLASH_SECTOR_SIZE);
|
||||||
reset_usb_boot(1 << PICO_DEFAULT_LED_PIN, 0);
|
// reset_usb_boot(1 << PICO_DEFAULT_LED_PIN, 0);
|
||||||
}
|
// }
|
||||||
|
|
||||||
else {
|
// else {
|
||||||
state->_running_fw = _firmware_metadata;
|
// state->_running_fw = _firmware_metadata;
|
||||||
global_state.reboot_requested = true;
|
// global_state.reboot_requested = true;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* If we're on the last element of the current page, page is done - write it. */
|
// /* If we're on the last element of the current page, page is done - write it. */
|
||||||
if (TU_U32_BYTE0(state->fw.address) == 0x00) {
|
// if (TU_U32_BYTE0(state->fw.address) == 0x00) {
|
||||||
|
|
||||||
uint32_t page_start_addr = (state->fw.address - 1) & 0xFFFFFF00;
|
// uint32_t page_start_addr = (state->fw.address - 1) & 0xFFFFFF00;
|
||||||
write_flash_page((uint32_t)ADDR_FW_RUNNING + page_start_addr - XIP_BASE, state->page_buffer);
|
// write_flash_page((uint32_t)ADDR_FW_RUNNING + page_start_addr - XIP_BASE, state->page_buffer);
|
||||||
}
|
// }
|
||||||
|
|
||||||
request_byte(state, state->fw.address);
|
// request_byte(state, state->fw.address);
|
||||||
}
|
// }
|
||||||
|
|
||||||
void packet_receiver_task(device_t *state) {
|
void packet_receiver_task(device_t *state) {
|
||||||
uint32_t current_pointer
|
uint32_t current_pointer
|
||||||
|
|
12
src/uart.c
12
src/uart.c
|
@ -71,17 +71,17 @@ const uart_handler_t uart_handler[] = {
|
||||||
{.type = OUTPUT_SELECT_MSG, .handler = handle_output_select_msg},
|
{.type = OUTPUT_SELECT_MSG, .handler = handle_output_select_msg},
|
||||||
|
|
||||||
/* Box control */
|
/* Box control */
|
||||||
{.type = MOUSE_ZOOM_MSG, .handler = handle_mouse_zoom_msg},
|
// {.type = MOUSE_ZOOM_MSG, .handler = handle_mouse_zoom_msg},
|
||||||
{.type = KBD_SET_REPORT_MSG, .handler = handle_set_report_msg},
|
{.type = KBD_SET_REPORT_MSG, .handler = handle_set_report_msg},
|
||||||
{.type = SWITCH_LOCK_MSG, .handler = handle_switch_lock_msg},
|
// {.type = SWITCH_LOCK_MSG, .handler = handle_switch_lock_msg},
|
||||||
{.type = SYNC_BORDERS_MSG, .handler = handle_sync_borders_msg},
|
{.type = SYNC_BORDERS_MSG, .handler = handle_sync_borders_msg},
|
||||||
{.type = FLASH_LED_MSG, .handler = handle_flash_led_msg},
|
{.type = FLASH_LED_MSG, .handler = handle_flash_led_msg},
|
||||||
{.type = GAMING_MODE_MSG, .handler = handle_toggle_gaming_msg},
|
// {.type = GAMING_MODE_MSG, .handler = handle_toggle_gaming_msg},
|
||||||
{.type = CONSUMER_CONTROL_MSG, .handler = handle_consumer_control_msg},
|
{.type = CONSUMER_CONTROL_MSG, .handler = handle_consumer_control_msg},
|
||||||
{.type = SCREENSAVER_MSG, .handler = handle_screensaver_msg},
|
// {.type = SCREENSAVER_MSG, .handler = handle_screensaver_msg},
|
||||||
|
|
||||||
/* Config */
|
/* Config */
|
||||||
{.type = WIPE_CONFIG_MSG, .handler = handle_wipe_config_msg},
|
// {.type = WIPE_CONFIG_MSG, .handler = handle_wipe_config_msg},
|
||||||
{.type = SAVE_CONFIG_MSG, .handler = handle_save_config_msg},
|
{.type = SAVE_CONFIG_MSG, .handler = handle_save_config_msg},
|
||||||
{.type = REBOOT_MSG, .handler = handle_reboot_msg},
|
{.type = REBOOT_MSG, .handler = handle_reboot_msg},
|
||||||
{.type = GET_VAL_MSG, .handler = handle_api_msgs},
|
{.type = GET_VAL_MSG, .handler = handle_api_msgs},
|
||||||
|
@ -91,7 +91,7 @@ const uart_handler_t uart_handler[] = {
|
||||||
/* Firmware */
|
/* Firmware */
|
||||||
{.type = REQUEST_BYTE_MSG, .handler = handle_request_byte_msg},
|
{.type = REQUEST_BYTE_MSG, .handler = handle_request_byte_msg},
|
||||||
{.type = RESPONSE_BYTE_MSG, .handler = handle_response_byte_msg},
|
{.type = RESPONSE_BYTE_MSG, .handler = handle_response_byte_msg},
|
||||||
{.type = FIRMWARE_UPGRADE_MSG, .handler = handle_fw_upgrade_msg},
|
// {.type = FIRMWARE_UPGRADE_MSG, .handler = handle_fw_upgrade_msg},
|
||||||
|
|
||||||
{.type = HEARTBEAT_MSG, .handler = handle_heartbeat_msg},
|
{.type = HEARTBEAT_MSG, .handler = handle_heartbeat_msg},
|
||||||
{.type = PROXY_PACKET_MSG, .handler = handle_proxy_msg},
|
{.type = PROXY_PACKET_MSG, .handler = handle_proxy_msg},
|
||||||
|
|
12
src/utils.c
12
src/utils.c
|
@ -59,11 +59,11 @@ uint32_t calculate_firmware_crc32(void) {
|
||||||
* Flash and config functions
|
* Flash and config functions
|
||||||
* ================================================== */
|
* ================================================== */
|
||||||
|
|
||||||
void wipe_config(void) {
|
// void wipe_config(void) {
|
||||||
uint32_t ints = save_and_disable_interrupts();
|
// uint32_t ints = save_and_disable_interrupts();
|
||||||
flash_range_erase((uint32_t)ADDR_CONFIG - XIP_BASE, FLASH_SECTOR_SIZE);
|
// flash_range_erase((uint32_t)ADDR_CONFIG - XIP_BASE, FLASH_SECTOR_SIZE);
|
||||||
restore_interrupts(ints);
|
// restore_interrupts(ints);
|
||||||
}
|
// }
|
||||||
|
|
||||||
void write_flash_page(uint32_t target_addr, uint8_t *buffer) {
|
void write_flash_page(uint32_t target_addr, uint8_t *buffer) {
|
||||||
/* Start of sector == first 256-byte page in a 4096 byte block */
|
/* Start of sector == first 256-byte page in a 4096 byte block */
|
||||||
|
@ -197,7 +197,7 @@ bool validate_packet(uart_packet_t *packet) {
|
||||||
GET_VAL_MSG,
|
GET_VAL_MSG,
|
||||||
GET_ALL_VALS_MSG,
|
GET_ALL_VALS_MSG,
|
||||||
SET_VAL_MSG,
|
SET_VAL_MSG,
|
||||||
WIPE_CONFIG_MSG,
|
// WIPE_CONFIG_MSG,
|
||||||
SAVE_CONFIG_MSG,
|
SAVE_CONFIG_MSG,
|
||||||
REBOOT_MSG,
|
REBOOT_MSG,
|
||||||
PROXY_PACKET_MSG,
|
PROXY_PACKET_MSG,
|
||||||
|
|
Loading…
Reference in New Issue