clang-format changes
This commit is contained in:
@ -37,25 +37,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include "version.h"
|
||||
|
||||
#ifdef MOUSEKEY_ENABLE
|
||||
#include "mousekey.h"
|
||||
# include "mousekey.h"
|
||||
#endif
|
||||
|
||||
#ifdef PROTOCOL_PJRC
|
||||
#include "usb_keyboard.h"
|
||||
#ifdef EXTRAKEY_ENABLE
|
||||
#include "usb_extra.h"
|
||||
#endif
|
||||
# include "usb_keyboard.h"
|
||||
# ifdef EXTRAKEY_ENABLE
|
||||
# include "usb_extra.h"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef PROTOCOL_VUSB
|
||||
#include "usbdrv.h"
|
||||
# include "usbdrv.h"
|
||||
#endif
|
||||
|
||||
#ifdef AUDIO_ENABLE
|
||||
#include "audio.h"
|
||||
# include "audio.h"
|
||||
#endif /* AUDIO_ENABLE */
|
||||
|
||||
|
||||
static bool command_common(uint8_t code);
|
||||
static void command_common_help(void);
|
||||
static void print_version(void);
|
||||
@ -69,16 +68,12 @@ static void mousekey_console_help(void);
|
||||
|
||||
static void switch_default_layer(uint8_t layer);
|
||||
|
||||
|
||||
command_state_t command_state = ONESHOT;
|
||||
|
||||
|
||||
bool command_proc(uint8_t code)
|
||||
{
|
||||
bool command_proc(uint8_t code) {
|
||||
switch (command_state) {
|
||||
case ONESHOT:
|
||||
if (!IS_COMMAND())
|
||||
return false;
|
||||
if (!IS_COMMAND()) return false;
|
||||
return (command_extra(code) || command_common(code));
|
||||
break;
|
||||
case CONSOLE:
|
||||
@ -101,86 +96,63 @@ bool command_proc(uint8_t code)
|
||||
|
||||
/* TODO: Refactoring is needed. */
|
||||
/* This allows to define extra commands. return false when not processed. */
|
||||
bool command_extra(uint8_t code) __attribute__ ((weak));
|
||||
bool command_extra(uint8_t code)
|
||||
{
|
||||
bool command_extra(uint8_t code) __attribute__((weak));
|
||||
bool command_extra(uint8_t code) {
|
||||
(void)code;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool command_console_extra(uint8_t code) __attribute__ ((weak));
|
||||
bool command_console_extra(uint8_t code)
|
||||
{
|
||||
bool command_console_extra(uint8_t code) __attribute__((weak));
|
||||
bool command_console_extra(uint8_t code) {
|
||||
(void)code;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************
|
||||
* Command common
|
||||
***********************************************************/
|
||||
static void command_common_help(void)
|
||||
{
|
||||
print( "\n\t- Magic -\n"
|
||||
STR(MAGIC_KEY_DEBUG ) ": Debug Message Toggle\n"
|
||||
STR(MAGIC_KEY_DEBUG_MATRIX) ": Matrix Debug Mode Toggle - Show keypresses in matrix grid\n"
|
||||
STR(MAGIC_KEY_DEBUG_KBD ) ": Keyboard Debug Toggle - Show keypress report\n"
|
||||
STR(MAGIC_KEY_DEBUG_MOUSE ) ": Debug Mouse Toggle\n"
|
||||
STR(MAGIC_KEY_VERSION ) ": Version\n"
|
||||
STR(MAGIC_KEY_STATUS ) ": Status\n"
|
||||
STR(MAGIC_KEY_CONSOLE ) ": Activate Console Mode\n"
|
||||
static void command_common_help(void) {
|
||||
print("\n\t- Magic -\n" STR(MAGIC_KEY_DEBUG) ": Debug Message Toggle\n" STR(MAGIC_KEY_DEBUG_MATRIX) ": Matrix Debug Mode Toggle - Show keypresses in matrix grid\n" STR(MAGIC_KEY_DEBUG_KBD) ": Keyboard Debug Toggle - Show keypress report\n" STR(MAGIC_KEY_DEBUG_MOUSE) ": Debug Mouse Toggle\n" STR(MAGIC_KEY_VERSION) ": Version\n" STR(MAGIC_KEY_STATUS) ": Status\n" STR(MAGIC_KEY_CONSOLE) ": Activate Console Mode\n"
|
||||
|
||||
#if MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM
|
||||
STR(MAGIC_KEY_LAYER0 ) ": Switch to Layer 0\n"
|
||||
STR(MAGIC_KEY_LAYER1 ) ": Switch to Layer 1\n"
|
||||
STR(MAGIC_KEY_LAYER2 ) ": Switch to Layer 2\n"
|
||||
STR(MAGIC_KEY_LAYER3 ) ": Switch to Layer 3\n"
|
||||
STR(MAGIC_KEY_LAYER4 ) ": Switch to Layer 4\n"
|
||||
STR(MAGIC_KEY_LAYER5 ) ": Switch to Layer 5\n"
|
||||
STR(MAGIC_KEY_LAYER6 ) ": Switch to Layer 6\n"
|
||||
STR(MAGIC_KEY_LAYER7 ) ": Switch to Layer 7\n"
|
||||
STR(MAGIC_KEY_LAYER8 ) ": Switch to Layer 8\n"
|
||||
STR(MAGIC_KEY_LAYER9 ) ": Switch to Layer 9\n"
|
||||
STR(MAGIC_KEY_LAYER0) ": Switch to Layer 0\n" STR(MAGIC_KEY_LAYER1) ": Switch to Layer 1\n" STR(MAGIC_KEY_LAYER2) ": Switch to Layer 2\n" STR(MAGIC_KEY_LAYER3) ": Switch to Layer 3\n" STR(MAGIC_KEY_LAYER4) ": Switch to Layer 4\n" STR(MAGIC_KEY_LAYER5) ": Switch to Layer 5\n" STR(MAGIC_KEY_LAYER6) ": Switch to Layer 6\n" STR(MAGIC_KEY_LAYER7) ": Switch to Layer 7\n" STR(MAGIC_KEY_LAYER8) ": Switch to Layer 8\n" STR(MAGIC_KEY_LAYER9) ": Switch to Layer 9\n"
|
||||
#endif
|
||||
|
||||
#if MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS
|
||||
"F1-F10: Switch to Layer 0-9 (F10 = L0)\n"
|
||||
"F1-F10: Switch to Layer 0-9 (F10 = L0)\n"
|
||||
#endif
|
||||
|
||||
#if MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS
|
||||
"0-9: Switch to Layer 0-9\n"
|
||||
"0-9: Switch to Layer 0-9\n"
|
||||
#endif
|
||||
|
||||
STR(MAGIC_KEY_LAYER0_ALT ) ": Switch to Layer 0 (alternate)\n"
|
||||
STR(MAGIC_KEY_LAYER0_ALT) ": Switch to Layer 0 (alternate)\n"
|
||||
|
||||
STR(MAGIC_KEY_BOOTLOADER ) ": Jump to Bootloader\n"
|
||||
STR(MAGIC_KEY_BOOTLOADER_ALT) ": Jump to Bootloader (alternate)\n"
|
||||
STR(MAGIC_KEY_BOOTLOADER) ": Jump to Bootloader\n" STR(MAGIC_KEY_BOOTLOADER_ALT) ": Jump to Bootloader (alternate)\n"
|
||||
|
||||
#ifdef KEYBOARD_LOCK_ENABLE
|
||||
STR(MAGIC_KEY_LOCK ) ": Lock Keyboard\n"
|
||||
STR(MAGIC_KEY_LOCK) ": Lock Keyboard\n"
|
||||
#endif
|
||||
|
||||
STR(MAGIC_KEY_EEPROM ) ": Print EEPROM Settings\n"
|
||||
STR(MAGIC_KEY_EEPROM_CLEAR) ": Clear EEPROM\n"
|
||||
STR(MAGIC_KEY_EEPROM) ": Print EEPROM Settings\n" STR(MAGIC_KEY_EEPROM_CLEAR) ": Clear EEPROM\n"
|
||||
|
||||
#ifdef NKRO_ENABLE
|
||||
STR(MAGIC_KEY_NKRO ) ": NKRO Toggle\n"
|
||||
STR(MAGIC_KEY_NKRO) ": NKRO Toggle\n"
|
||||
#endif
|
||||
|
||||
#ifdef SLEEP_LED_ENABLE
|
||||
STR(MAGIC_KEY_SLEEP_LED ) ": Sleep LED Test\n"
|
||||
STR(MAGIC_KEY_SLEEP_LED) ": Sleep LED Test\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
static void print_version(void)
|
||||
{
|
||||
// print version & information
|
||||
static void print_version(void) {
|
||||
// print version & information
|
||||
print("\n\t- Version -\n");
|
||||
print("DESC: " STR(DESCRIPTION) "\n");
|
||||
print("VID: " STR(VENDOR_ID) "(" STR(MANUFACTURER) ") "
|
||||
"PID: " STR(PRODUCT_ID) "(" STR(PRODUCT) ") "
|
||||
"VER: " STR(DEVICE_VER) "\n");
|
||||
"PID: " STR(PRODUCT_ID) "(" STR(PRODUCT) ") "
|
||||
"VER: " STR(DEVICE_VER) "\n");
|
||||
#ifdef SKIP_VERSION
|
||||
print("BUILD: (" __DATE__ ")\n");
|
||||
#else
|
||||
@ -191,51 +163,48 @@ static void print_version(void)
|
||||
print("OPTIONS:"
|
||||
|
||||
#ifdef PROTOCOL_PJRC
|
||||
" PJRC"
|
||||
" PJRC"
|
||||
#endif
|
||||
#ifdef PROTOCOL_LUFA
|
||||
" LUFA"
|
||||
" LUFA"
|
||||
#endif
|
||||
#ifdef PROTOCOL_VUSB
|
||||
" VUSB"
|
||||
" VUSB"
|
||||
#endif
|
||||
#ifdef BOOTMAGIC_ENABLE
|
||||
" BOOTMAGIC"
|
||||
" BOOTMAGIC"
|
||||
#endif
|
||||
#ifdef MOUSEKEY_ENABLE
|
||||
" MOUSEKEY"
|
||||
" MOUSEKEY"
|
||||
#endif
|
||||
#ifdef EXTRAKEY_ENABLE
|
||||
" EXTRAKEY"
|
||||
" EXTRAKEY"
|
||||
#endif
|
||||
#ifdef CONSOLE_ENABLE
|
||||
" CONSOLE"
|
||||
" CONSOLE"
|
||||
#endif
|
||||
#ifdef COMMAND_ENABLE
|
||||
" COMMAND"
|
||||
" COMMAND"
|
||||
#endif
|
||||
#ifdef NKRO_ENABLE
|
||||
" NKRO"
|
||||
" NKRO"
|
||||
#endif
|
||||
#ifdef KEYMAP_SECTION_ENABLE
|
||||
" KEYMAP_SECTION"
|
||||
" KEYMAP_SECTION"
|
||||
#endif
|
||||
|
||||
" " STR(BOOTLOADER_SIZE) "\n");
|
||||
" " STR(BOOTLOADER_SIZE) "\n");
|
||||
|
||||
print("GCC: " STR(__GNUC__) "." STR(__GNUC_MINOR__) "." STR(__GNUC_PATCHLEVEL__)
|
||||
#if defined(__AVR__)
|
||||
" AVR-LIBC: " __AVR_LIBC_VERSION_STRING__
|
||||
" AVR_ARCH: avr" STR(__AVR_ARCH__)
|
||||
" AVR-LIBC: " __AVR_LIBC_VERSION_STRING__ " AVR_ARCH: avr" STR(__AVR_ARCH__)
|
||||
#endif
|
||||
"\n");
|
||||
"\n");
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
static void print_status(void)
|
||||
{
|
||||
|
||||
static void print_status(void) {
|
||||
print("\n\t- Status -\n");
|
||||
|
||||
print_val_hex8(host_keyboard_leds());
|
||||
@ -258,67 +227,101 @@ static void print_status(void)
|
||||
#endif
|
||||
|
||||
#ifdef PROTOCOL_PJRC
|
||||
# if USB_COUNT_SOF
|
||||
# if USB_COUNT_SOF
|
||||
print_val_hex8(usbSofCount);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
static void print_eeconfig(void)
|
||||
{
|
||||
|
||||
static void print_eeconfig(void) {
|
||||
// Print these variables if NO_PRINT or USER_PRINT are not defined.
|
||||
#if !defined(NO_PRINT) && !defined(USER_PRINT)
|
||||
|
||||
print("default_layer: "); print_dec(eeconfig_read_default_layer()); print("\n");
|
||||
print("default_layer: ");
|
||||
print_dec(eeconfig_read_default_layer());
|
||||
print("\n");
|
||||
|
||||
debug_config_t dc;
|
||||
dc.raw = eeconfig_read_debug();
|
||||
print("debug_config.raw: "); print_hex8(dc.raw); print("\n");
|
||||
print(".enable: "); print_dec(dc.enable); print("\n");
|
||||
print(".matrix: "); print_dec(dc.matrix); print("\n");
|
||||
print(".keyboard: "); print_dec(dc.keyboard); print("\n");
|
||||
print(".mouse: "); print_dec(dc.mouse); print("\n");
|
||||
print("debug_config.raw: ");
|
||||
print_hex8(dc.raw);
|
||||
print("\n");
|
||||
print(".enable: ");
|
||||
print_dec(dc.enable);
|
||||
print("\n");
|
||||
print(".matrix: ");
|
||||
print_dec(dc.matrix);
|
||||
print("\n");
|
||||
print(".keyboard: ");
|
||||
print_dec(dc.keyboard);
|
||||
print("\n");
|
||||
print(".mouse: ");
|
||||
print_dec(dc.mouse);
|
||||
print("\n");
|
||||
|
||||
keymap_config_t kc;
|
||||
kc.raw = eeconfig_read_keymap();
|
||||
print("keymap_config.raw: "); print_hex8(kc.raw); print("\n");
|
||||
print(".swap_control_capslock: "); print_dec(kc.swap_control_capslock); print("\n");
|
||||
print(".capslock_to_control: "); print_dec(kc.capslock_to_control); print("\n");
|
||||
print(".swap_lctl_lgui: "); print_dec(kc.swap_lctl_lgui); print("\n");
|
||||
print(".swap_rctl_rgui: "); print_dec(kc.swap_rctl_rgui); print("\n");
|
||||
print(".swap_lalt_lgui: "); print_dec(kc.swap_lalt_lgui); print("\n");
|
||||
print(".swap_ralt_rgui: "); print_dec(kc.swap_ralt_rgui); print("\n");
|
||||
print(".no_gui: "); print_dec(kc.no_gui); print("\n");
|
||||
print(".swap_grave_esc: "); print_dec(kc.swap_grave_esc); print("\n");
|
||||
print(".swap_backslash_backspace: "); print_dec(kc.swap_backslash_backspace); print("\n");
|
||||
print(".nkro: "); print_dec(kc.nkro); print("\n");
|
||||
print("keymap_config.raw: ");
|
||||
print_hex8(kc.raw);
|
||||
print("\n");
|
||||
print(".swap_control_capslock: ");
|
||||
print_dec(kc.swap_control_capslock);
|
||||
print("\n");
|
||||
print(".capslock_to_control: ");
|
||||
print_dec(kc.capslock_to_control);
|
||||
print("\n");
|
||||
print(".swap_lctl_lgui: ");
|
||||
print_dec(kc.swap_lctl_lgui);
|
||||
print("\n");
|
||||
print(".swap_rctl_rgui: ");
|
||||
print_dec(kc.swap_rctl_rgui);
|
||||
print("\n");
|
||||
print(".swap_lalt_lgui: ");
|
||||
print_dec(kc.swap_lalt_lgui);
|
||||
print("\n");
|
||||
print(".swap_ralt_rgui: ");
|
||||
print_dec(kc.swap_ralt_rgui);
|
||||
print("\n");
|
||||
print(".no_gui: ");
|
||||
print_dec(kc.no_gui);
|
||||
print("\n");
|
||||
print(".swap_grave_esc: ");
|
||||
print_dec(kc.swap_grave_esc);
|
||||
print("\n");
|
||||
print(".swap_backslash_backspace: ");
|
||||
print_dec(kc.swap_backslash_backspace);
|
||||
print("\n");
|
||||
print(".nkro: ");
|
||||
print_dec(kc.nkro);
|
||||
print("\n");
|
||||
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
# ifdef BACKLIGHT_ENABLE
|
||||
backlight_config_t bc;
|
||||
bc.raw = eeconfig_read_backlight();
|
||||
print("backlight_config.raw: "); print_hex8(bc.raw); print("\n");
|
||||
print(".enable: "); print_dec(bc.enable); print("\n");
|
||||
print(".level: "); print_dec(bc.level); print("\n");
|
||||
#endif /* BACKLIGHT_ENABLE */
|
||||
print("backlight_config.raw: ");
|
||||
print_hex8(bc.raw);
|
||||
print("\n");
|
||||
print(".enable: ");
|
||||
print_dec(bc.enable);
|
||||
print("\n");
|
||||
print(".level: ");
|
||||
print_dec(bc.level);
|
||||
print("\n");
|
||||
# endif /* BACKLIGHT_ENABLE */
|
||||
|
||||
#endif /* !NO_PRINT */
|
||||
|
||||
}
|
||||
|
||||
static bool command_common(uint8_t code)
|
||||
{
|
||||
|
||||
static bool command_common(uint8_t code) {
|
||||
#ifdef KEYBOARD_LOCK_ENABLE
|
||||
static host_driver_t *host_driver = 0;
|
||||
#endif
|
||||
|
||||
switch (code) {
|
||||
|
||||
#ifdef SLEEP_LED_ENABLE
|
||||
|
||||
// test breathing sleep LED
|
||||
// test breathing sleep LED
|
||||
case MAGIC_KC(MAGIC_KEY_SLEEP_LED):
|
||||
print("Sleep LED Test\n");
|
||||
sleep_led_toggle();
|
||||
@ -326,21 +329,21 @@ static bool command_common(uint8_t code)
|
||||
break;
|
||||
#endif
|
||||
|
||||
// print stored eeprom config
|
||||
// print stored eeprom config
|
||||
case MAGIC_KC(MAGIC_KEY_EEPROM):
|
||||
print("eeconfig:\n");
|
||||
print_eeconfig();
|
||||
break;
|
||||
|
||||
// clear eeprom
|
||||
// clear eeprom
|
||||
case MAGIC_KC(MAGIC_KEY_EEPROM_CLEAR):
|
||||
print("Clearing EEPROM\n");
|
||||
eeconfig_init();
|
||||
eeconfig_init();
|
||||
break;
|
||||
|
||||
#ifdef KEYBOARD_LOCK_ENABLE
|
||||
|
||||
// lock/unlock keyboard
|
||||
// lock/unlock keyboard
|
||||
case MAGIC_KC(MAGIC_KEY_LOCK):
|
||||
if (host_get_driver()) {
|
||||
host_driver = host_get_driver();
|
||||
@ -354,13 +357,13 @@ static bool command_common(uint8_t code)
|
||||
break;
|
||||
#endif
|
||||
|
||||
// print help
|
||||
// print help
|
||||
case MAGIC_KC(MAGIC_KEY_HELP):
|
||||
case MAGIC_KC(MAGIC_KEY_HELP_ALT):
|
||||
command_common_help();
|
||||
break;
|
||||
|
||||
// activate console
|
||||
// activate console
|
||||
case MAGIC_KC(MAGIC_KEY_CONSOLE):
|
||||
debug_matrix = false;
|
||||
debug_keyboard = false;
|
||||
@ -374,15 +377,15 @@ static bool command_common(uint8_t code)
|
||||
// jump to bootloader
|
||||
case MAGIC_KC(MAGIC_KEY_BOOTLOADER):
|
||||
case MAGIC_KC(MAGIC_KEY_BOOTLOADER_ALT):
|
||||
clear_keyboard(); // clear to prevent stuck keys
|
||||
clear_keyboard(); // clear to prevent stuck keys
|
||||
print("\n\nJumping to bootloader... ");
|
||||
#ifdef AUDIO_ENABLE
|
||||
stop_all_notes();
|
||||
shutdown_user();
|
||||
#else
|
||||
wait_ms(1000);
|
||||
#endif
|
||||
bootloader_jump(); // not return
|
||||
#ifdef AUDIO_ENABLE
|
||||
stop_all_notes();
|
||||
shutdown_user();
|
||||
#else
|
||||
wait_ms(1000);
|
||||
#endif
|
||||
bootloader_jump(); // not return
|
||||
break;
|
||||
|
||||
// debug toggle
|
||||
@ -427,25 +430,25 @@ static bool command_common(uint8_t code)
|
||||
print("\nmouse: on\n");
|
||||
debug_enable = true;
|
||||
} else {
|
||||
print("\nmouse: off\n");
|
||||
print("\nmouse: off\n");
|
||||
}
|
||||
break;
|
||||
|
||||
// print version
|
||||
// print version
|
||||
case MAGIC_KC(MAGIC_KEY_VERSION):
|
||||
print_version();
|
||||
break;
|
||||
print_version();
|
||||
break;
|
||||
|
||||
// print status
|
||||
case MAGIC_KC(MAGIC_KEY_STATUS):
|
||||
print_status();
|
||||
// print status
|
||||
case MAGIC_KC(MAGIC_KEY_STATUS):
|
||||
print_status();
|
||||
break;
|
||||
|
||||
#ifdef NKRO_ENABLE
|
||||
|
||||
// NKRO toggle
|
||||
// NKRO toggle
|
||||
case MAGIC_KC(MAGIC_KEY_NKRO):
|
||||
clear_keyboard(); // clear to prevent stuck keys
|
||||
clear_keyboard(); // clear to prevent stuck keys
|
||||
keymap_config.nkro = !keymap_config.nkro;
|
||||
if (keymap_config.nkro) {
|
||||
print("NKRO: on\n");
|
||||
@ -455,56 +458,55 @@ static bool command_common(uint8_t code)
|
||||
break;
|
||||
#endif
|
||||
|
||||
// switch layers
|
||||
// switch layers
|
||||
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER0_ALT):
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER0_ALT):
|
||||
switch_default_layer(0);
|
||||
break;
|
||||
|
||||
#if MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM
|
||||
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER0):
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER0):
|
||||
switch_default_layer(0);
|
||||
break;
|
||||
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER1):
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER1):
|
||||
switch_default_layer(1);
|
||||
break;
|
||||
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER2):
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER2):
|
||||
switch_default_layer(2);
|
||||
break;
|
||||
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER3):
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER3):
|
||||
switch_default_layer(3);
|
||||
break;
|
||||
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER4):
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER4):
|
||||
switch_default_layer(4);
|
||||
break;
|
||||
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER5):
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER5):
|
||||
switch_default_layer(5);
|
||||
break;
|
||||
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER6):
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER6):
|
||||
switch_default_layer(6);
|
||||
break;
|
||||
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER7):
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER7):
|
||||
switch_default_layer(7);
|
||||
break;
|
||||
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER8):
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER8):
|
||||
switch_default_layer(8);
|
||||
break;
|
||||
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER9):
|
||||
case MAGIC_KC(MAGIC_KEY_LAYER9):
|
||||
switch_default_layer(9);
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
||||
#if MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS
|
||||
|
||||
case KC_F1 ... KC_F9:
|
||||
@ -532,12 +534,10 @@ static bool command_common(uint8_t code)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************
|
||||
* Command console
|
||||
***********************************************************/
|
||||
static void command_console_help(void)
|
||||
{
|
||||
static void command_console_help(void) {
|
||||
print("\n\t- Console -\n"
|
||||
"ESC/q: quit\n"
|
||||
#ifdef MOUSEKEY_ENABLE
|
||||
@ -546,8 +546,7 @@ static void command_console_help(void)
|
||||
);
|
||||
}
|
||||
|
||||
static bool command_console(uint8_t code)
|
||||
{
|
||||
static bool command_console(uint8_t code) {
|
||||
switch (code) {
|
||||
case KC_H:
|
||||
case KC_SLASH: /* ? */
|
||||
@ -572,32 +571,40 @@ static bool command_console(uint8_t code)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#ifdef MOUSEKEY_ENABLE
|
||||
/***********************************************************
|
||||
* Mousekey console
|
||||
***********************************************************/
|
||||
static uint8_t mousekey_param = 0;
|
||||
|
||||
static void mousekey_param_print(void)
|
||||
{
|
||||
static void mousekey_param_print(void) {
|
||||
// Print these variables if NO_PRINT or USER_PRINT are not defined.
|
||||
#if !defined(NO_PRINT) && !defined(USER_PRINT)
|
||||
# if !defined(NO_PRINT) && !defined(USER_PRINT)
|
||||
print("\n\t- Values -\n");
|
||||
print("1: delay(*10ms): "); pdec(mk_delay); print("\n");
|
||||
print("2: interval(ms): "); pdec(mk_interval); print("\n");
|
||||
print("3: max_speed: "); pdec(mk_max_speed); print("\n");
|
||||
print("4: time_to_max: "); pdec(mk_time_to_max); print("\n");
|
||||
print("5: wheel_max_speed: "); pdec(mk_wheel_max_speed); print("\n");
|
||||
print("6: wheel_time_to_max: "); pdec(mk_wheel_time_to_max); print("\n");
|
||||
#endif /* !NO_PRINT */
|
||||
|
||||
print("1: delay(*10ms): ");
|
||||
pdec(mk_delay);
|
||||
print("\n");
|
||||
print("2: interval(ms): ");
|
||||
pdec(mk_interval);
|
||||
print("\n");
|
||||
print("3: max_speed: ");
|
||||
pdec(mk_max_speed);
|
||||
print("\n");
|
||||
print("4: time_to_max: ");
|
||||
pdec(mk_time_to_max);
|
||||
print("\n");
|
||||
print("5: wheel_max_speed: ");
|
||||
pdec(mk_wheel_max_speed);
|
||||
print("\n");
|
||||
print("6: wheel_time_to_max: ");
|
||||
pdec(mk_wheel_time_to_max);
|
||||
print("\n");
|
||||
# endif /* !NO_PRINT */
|
||||
}
|
||||
|
||||
//#define PRINT_SET_VAL(v) print(#v " = "); print_dec(v); print("\n");
|
||||
#define PRINT_SET_VAL(v) xprintf(#v " = %d\n", (v))
|
||||
static void mousekey_param_inc(uint8_t param, uint8_t inc)
|
||||
{
|
||||
# define PRINT_SET_VAL(v) xprintf(# v " = %d\n", (v))
|
||||
static void mousekey_param_inc(uint8_t param, uint8_t inc) {
|
||||
switch (param) {
|
||||
case 1:
|
||||
if (mk_delay + inc < UINT8_MAX)
|
||||
@ -644,8 +651,7 @@ static void mousekey_param_inc(uint8_t param, uint8_t inc)
|
||||
}
|
||||
}
|
||||
|
||||
static void mousekey_param_dec(uint8_t param, uint8_t dec)
|
||||
{
|
||||
static void mousekey_param_dec(uint8_t param, uint8_t dec) {
|
||||
switch (param) {
|
||||
case 1:
|
||||
if (mk_delay > dec)
|
||||
@ -692,8 +698,7 @@ static void mousekey_param_dec(uint8_t param, uint8_t dec)
|
||||
}
|
||||
}
|
||||
|
||||
static void mousekey_console_help(void)
|
||||
{
|
||||
static void mousekey_console_help(void) {
|
||||
print("\n\t- Mousekey -\n"
|
||||
"ESC/q: quit\n"
|
||||
"1: delay(*10ms)\n"
|
||||
@ -712,11 +717,11 @@ static void mousekey_console_help(void)
|
||||
"\n"
|
||||
"speed = delta * max_speed * (repeat / time_to_max)\n");
|
||||
xprintf("where delta: cursor=%d, wheel=%d\n"
|
||||
"See http://en.wikipedia.org/wiki/Mouse_keys\n", MOUSEKEY_MOVE_DELTA, MOUSEKEY_WHEEL_DELTA);
|
||||
"See http://en.wikipedia.org/wiki/Mouse_keys\n",
|
||||
MOUSEKEY_MOVE_DELTA, MOUSEKEY_WHEEL_DELTA);
|
||||
}
|
||||
|
||||
static bool mousekey_console(uint8_t code)
|
||||
{
|
||||
static bool mousekey_console(uint8_t code) {
|
||||
switch (code) {
|
||||
case KC_H:
|
||||
case KC_SLASH: /* ? */
|
||||
@ -756,11 +761,11 @@ static bool mousekey_console(uint8_t code)
|
||||
mousekey_param_dec(mousekey_param, 10);
|
||||
break;
|
||||
case KC_D:
|
||||
mk_delay = MOUSEKEY_DELAY/10;
|
||||
mk_interval = MOUSEKEY_INTERVAL;
|
||||
mk_max_speed = MOUSEKEY_MAX_SPEED;
|
||||
mk_time_to_max = MOUSEKEY_TIME_TO_MAX;
|
||||
mk_wheel_max_speed = MOUSEKEY_WHEEL_MAX_SPEED;
|
||||
mk_delay = MOUSEKEY_DELAY / 10;
|
||||
mk_interval = MOUSEKEY_INTERVAL;
|
||||
mk_max_speed = MOUSEKEY_MAX_SPEED;
|
||||
mk_time_to_max = MOUSEKEY_TIME_TO_MAX;
|
||||
mk_wheel_max_speed = MOUSEKEY_WHEEL_MAX_SPEED;
|
||||
mk_wheel_time_to_max = MOUSEKEY_WHEEL_TIME_TO_MAX;
|
||||
print("set default\n");
|
||||
break;
|
||||
@ -771,36 +776,43 @@ static bool mousekey_console(uint8_t code)
|
||||
if (mousekey_param) {
|
||||
xprintf("M%d> ", mousekey_param);
|
||||
} else {
|
||||
print("M>" );
|
||||
print("M>");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/***********************************************************
|
||||
* Utilities
|
||||
***********************************************************/
|
||||
uint8_t numkey2num(uint8_t code)
|
||||
{
|
||||
uint8_t numkey2num(uint8_t code) {
|
||||
switch (code) {
|
||||
case KC_1: return 1;
|
||||
case KC_2: return 2;
|
||||
case KC_3: return 3;
|
||||
case KC_4: return 4;
|
||||
case KC_5: return 5;
|
||||
case KC_6: return 6;
|
||||
case KC_7: return 7;
|
||||
case KC_8: return 8;
|
||||
case KC_9: return 9;
|
||||
case KC_0: return 0;
|
||||
case KC_1:
|
||||
return 1;
|
||||
case KC_2:
|
||||
return 2;
|
||||
case KC_3:
|
||||
return 3;
|
||||
case KC_4:
|
||||
return 4;
|
||||
case KC_5:
|
||||
return 5;
|
||||
case KC_6:
|
||||
return 6;
|
||||
case KC_7:
|
||||
return 7;
|
||||
case KC_8:
|
||||
return 8;
|
||||
case KC_9:
|
||||
return 9;
|
||||
case KC_0:
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void switch_default_layer(uint8_t layer)
|
||||
{
|
||||
static void switch_default_layer(uint8_t layer) {
|
||||
xprintf("L%d\n", layer);
|
||||
default_layer_set(1UL<<layer);
|
||||
default_layer_set(1UL << layer);
|
||||
clear_keyboard();
|
||||
}
|
||||
|
Reference in New Issue
Block a user