summaryrefslogtreecommitdiffstats
path: root/keyboards/1upkeyboards/sweet16/keymaps/switchtester/switches.c
blob: ae3799544885ce435c365fae701449b54476c4f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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);
}