diff options
author | gorbachev <tpp+github@iki.fi> | 2019-01-11 20:27:15 -0500 |
---|---|---|
committer | Drashna Jaelre <drashna@live.com> | 2019-01-11 17:27:15 -0800 |
commit | 81ad6cac7e850e1962fcc2c4057f5357a0056838 (patch) | |
tree | d0af908512950ccbbf01c817b0ca59fdd9e2c09a /keyboards/1upkeyboards/sweet16/keymaps/switchtester/switches.c | |
parent | 9c136e1168a1f6d0637f59164b6d9adb9ba0bdee (diff) | |
download | qmk_firmware-81ad6cac7e850e1962fcc2c4057f5357a0056838.tar.gz |
[Keymap] Sweet16 as a switch tester (#4822)
* Sweet16 as a switch tester
* pragma once
* QMK_KEYBOARD_H instead of sweet16.h
Diffstat (limited to 'keyboards/1upkeyboards/sweet16/keymaps/switchtester/switches.c')
-rw-r--r-- | keyboards/1upkeyboards/sweet16/keymaps/switchtester/switches.c | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/keyboards/1upkeyboards/sweet16/keymaps/switchtester/switches.c b/keyboards/1upkeyboards/sweet16/keymaps/switchtester/switches.c new file mode 100644 index 000000000..ae3799544 --- /dev/null +++ b/keyboards/1upkeyboards/sweet16/keymaps/switchtester/switches.c @@ -0,0 +1,99 @@ +#include <stdio.h> +#include <string.h> +#include "switches.h" + +static const char *BRAND_NAMES[] = { + "Kailh", + "Kailh Low Profile Choc", + "Gateron", + "Cherry MX", + "Cherry ML", + "Outemu", + "Greetech", + "Varmilo", + "MOD", + "Hako" +}; + +static const char *COLOR_NAMES[] = { + "", + "White", + "Black", + "Blue", + "Red", + "Yellow", + "Brown", + "Green", + "Clear", + "Silver", + "Nature White", + "Grey", + "Jade", + "Navy", + "Burnt Orange", + "Pale Blue", + "Dark Yellow", + "Gold", + "Chocolate White", + "Burgundy", + "Purple", + "Light Green", + "True", + "Berry", + "Plum", + "Sage", + "Violet", + "L", + "M", + "H", + "SH" +}; + +static const char *VARIANT_NAMES[] = { + "", + "BOX", + "BOX Thick", + "BOX Heavy", + "Silent", + "Tactile", + "Linear", + "Speed", + "Speed Heavy", + "Speed Thick Click", + "Pro", + "Pro Heavy", + "Royal", + "Thick Click", + "Heavy" +}; + +const char *brand_name(struct mechswitch ms) { + return BRAND_NAMES[ms.brand - 1]; +} + +const char *variant_name(struct mechswitch ms) { + return VARIANT_NAMES[ms.variant]; +} + +const char *color_name(struct mechswitch ms) { + return COLOR_NAMES[ms.color]; +} + +void switch_name(struct mechswitch ms, char *buf) { + const char *v_name = variant_name(ms); + const char *c_name = color_name(ms); + + snprintf(buf, MAX_SWITCH_NAME_LENGTH, "%s", brand_name(ms)); + strncat(buf, " ", MAX_SWITCH_NAME_LENGTH - strlen(buf)); + if (strlen(v_name) > 0) { + strncat(buf, v_name, MAX_SWITCH_NAME_LENGTH - strlen(buf)); + strncat(buf, " ", MAX_SWITCH_NAME_LENGTH - strlen(buf)); + } + if (strlen(c_name) > 0) { + strncat(buf, c_name, MAX_SWITCH_NAME_LENGTH - strlen(buf)); + } +} + +int bitfieldtoi(struct mechswitch ms) { + return ((ms.brand << 9) | (ms.variant << 5) | ms.color); +} |