diff options
Diffstat (limited to 'lib/python/qmk/keymap.py')
| -rw-r--r-- | lib/python/qmk/keymap.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/python/qmk/keymap.py b/lib/python/qmk/keymap.py index 4cf07f59d6..0ac04f6f73 100644 --- a/lib/python/qmk/keymap.py +++ b/lib/python/qmk/keymap.py | |||
| @@ -32,6 +32,7 @@ __INCLUDES__ | |||
| 32 | 32 | ||
| 33 | __KEYMAP_GOES_HERE__ | 33 | __KEYMAP_GOES_HERE__ |
| 34 | __ENCODER_MAP_GOES_HERE__ | 34 | __ENCODER_MAP_GOES_HERE__ |
| 35 | __DIP_SWITCH_MAP_GOES_HERE__ | ||
| 35 | __MACRO_OUTPUT_GOES_HERE__ | 36 | __MACRO_OUTPUT_GOES_HERE__ |
| 36 | 37 | ||
| 37 | #ifdef OTHER_KEYMAP_C | 38 | #ifdef OTHER_KEYMAP_C |
| @@ -66,6 +67,19 @@ def _generate_encodermap_table(keymap_json): | |||
| 66 | return lines | 67 | return lines |
| 67 | 68 | ||
| 68 | 69 | ||
| 70 | def _generate_dipswitchmap_table(keymap_json): | ||
| 71 | lines = [ | ||
| 72 | '#if defined(DIP_SWITCH_ENABLE) && defined(DIP_SWITCH_MAP_ENABLE)', | ||
| 73 | 'const uint16_t PROGMEM dip_switch_map[NUM_DIP_SWITCHES][NUM_DIP_STATES] = {', | ||
| 74 | ] | ||
| 75 | for index, switch in enumerate(keymap_json['dip_switches']): | ||
| 76 | if index != 0: | ||
| 77 | lines[-1] = lines[-1] + ',' | ||
| 78 | lines.append(f' DIP_SWITCH_OFF_ON({_strip_any(switch["off"])}, {_strip_any(switch["on"])})') | ||
| 79 | lines.extend(['};', '#endif // defined(DIP_SWITCH_ENABLE) && defined(DIP_SWITCH_MAP_ENABLE)']) | ||
| 80 | return lines | ||
| 81 | |||
| 82 | |||
| 69 | def _generate_macros_function(keymap_json): | 83 | def _generate_macros_function(keymap_json): |
| 70 | macro_txt = [ | 84 | macro_txt = [ |
| 71 | 'bool process_record_user(uint16_t keycode, keyrecord_t *record) {', | 85 | 'bool process_record_user(uint16_t keycode, keyrecord_t *record) {', |
| @@ -286,6 +300,12 @@ def generate_c(keymap_json): | |||
| 286 | encodermap = '\n'.join(encoder_txt) | 300 | encodermap = '\n'.join(encoder_txt) |
| 287 | new_keymap = new_keymap.replace('__ENCODER_MAP_GOES_HERE__', encodermap) | 301 | new_keymap = new_keymap.replace('__ENCODER_MAP_GOES_HERE__', encodermap) |
| 288 | 302 | ||
| 303 | dipswitchmap = '' | ||
| 304 | if 'dip_switches' in keymap_json and keymap_json['dip_switches'] is not None: | ||
| 305 | dip_txt = _generate_dipswitchmap_table(keymap_json) | ||
| 306 | dipswitchmap = '\n'.join(dip_txt) | ||
| 307 | new_keymap = new_keymap.replace('__DIP_SWITCH_MAP_GOES_HERE__', dipswitchmap) | ||
| 308 | |||
| 289 | macros = '' | 309 | macros = '' |
| 290 | if 'macros' in keymap_json and keymap_json['macros'] is not None: | 310 | if 'macros' in keymap_json and keymap_json['macros'] is not None: |
| 291 | macro_txt = _generate_macros_function(keymap_json) | 311 | macro_txt = _generate_macros_function(keymap_json) |
