diff options
author | Alex Ong <the.onga@gmail.com> | 2019-01-26 11:36:28 +1100 |
---|---|---|
committer | Alex Ong <the.onga@gmail.com> | 2019-01-26 11:36:28 +1100 |
commit | d977daa8dc9136746425f9e1414e1f93cb161877 (patch) | |
tree | 209ab8082580e5fdf37f1a8b7c1169250b7548c0 /keyboards/1upkeyboards/sweet16/keymaps/switchtester/switches.c | |
parent | 47c91fc7f75ae0a477e55b687aa0fc30da0a283c (diff) | |
parent | 0306e487e2cd6a77ad840d0a441b478747b7ccd0 (diff) | |
download | qmk_firmware-d977daa8dc9136746425f9e1414e1f93cb161877.tar.gz |
Merge branch 'master' of https://github.com/qmk/qmk_firmware
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); +} |