Compare commits

...

3 commits

Author SHA1 Message Date
Zach White
9eaee65ac3 make custom keycodes actually work 2021-09-09 08:07:34 -07:00
Zach White
5b0b8ba654 move clueboard/2x1800/2019 to json custom keycodes 2021-09-08 23:16:13 -07:00
Zach White
0a33ce0659 wip: support for custom keycodes in json 2021-09-08 23:15:54 -07:00
6 changed files with 35 additions and 14 deletions

View file

@ -12,6 +12,12 @@
"minLength": 1, "minLength": 1,
"pattern": "^[0-9a-z_]*$" "pattern": "^[0-9a-z_]*$"
}, },
"keycode": {
"type": "string",
"minLength": 1,
"maxLength": 250,
"pattern": "^[A-Z_][0-9A-Z_()]*$"
},
"hex_number_2d": { "hex_number_2d": {
"type": "string", "type": "string",
"pattern": "^0x[0-9A-F]{2}$" "pattern": "^0x[0-9A-F]{2}$"

View file

@ -77,6 +77,10 @@
"lto": {"type": "boolean"}, "lto": {"type": "boolean"},
} }
}, },
"custom_keycodes": {
"type": "array",
"items": {"$ref": "qmk.definitions.v1#/keycode"}
},
"diode_direction": { "diode_direction": {
"type": "string", "type": "string",
"enum": ["COL2ROW", "ROW2COL"] "enum": ["COL2ROW", "ROW2COL"]

View file

@ -5,6 +5,11 @@
"type": "object", "type": "object",
"properties": { "properties": {
"author": {"type": "string"}, "author": {"type": "string"},
"config": {"$ref": "qmk.keyboard.v1"},
"custom_keycodes": {
"type": "array",
"items": {"$ref": "qmk.definitions.v1#/keycode"}
},
"keyboard": {"$ref": "qmk.definitions.v1#/text_identifier"}, "keyboard": {"$ref": "qmk.definitions.v1#/text_identifier"},
"keymap": {"$ref": "qmk.definitions.v1#/text_identifier"}, "keymap": {"$ref": "qmk.definitions.v1#/text_identifier"},
"layout": {"$ref": "qmk.definitions.v1#/layout_macro"}, "layout": {"$ref": "qmk.definitions.v1#/layout_macro"},
@ -12,10 +17,9 @@
"type": "array", "type": "array",
"items": { "items": {
"type": "array", "type": "array",
"items": {"type": "string"} "items": {"$ref": "qmk.definitions.v1#/keycode"}
} }
}, },
"config": {"$ref": "qmk.keyboard.v1"},
"notes": { "notes": {
"type": "string", "type": "string",
"description": "asdf" "description": "asdf"

View file

@ -17,17 +17,6 @@
#include "quantum.h" #include "quantum.h"
enum TWOx1800_keycodes {
ENC_BTN1 = SAFE_RANGE,
ENC_BTN2,
ENC_BTN3,
ENC_BTN4,
NEW_SAFE_RANGE
};
#undef SAFE_RANGE
#define SAFE_RANGE NEW_SAFE_RANGE
// Encoder update function that returns true/false // Encoder update function that returns true/false
bool encoder_update_keymap(uint8_t index, bool clockwise); bool encoder_update_keymap(uint8_t index, bool clockwise);

View file

@ -7,6 +7,7 @@
"debounce": 5, "debounce": 5,
"processor": "at90usb1286", "processor": "at90usb1286",
"bootloader": "halfkay", "bootloader": "halfkay",
"custom_keycodes": ["ENC_BTN1", "ENC_BTN2", "ENC_BTN3", "ENC_BTN4"],
"diode_direction": "ROW2COL", "diode_direction": "ROW2COL",
"features": { "features": {
"audio": true, "audio": true,

View file

@ -51,6 +51,23 @@ def generate_layouts(cli):
cli.log.error('%s: Invalid matrix config.', cli.config.generate_layouts.keyboard) cli.log.error('%s: Invalid matrix config.', cli.config.generate_layouts.keyboard)
return False return False
if 'custom_keycodes' in kb_info_json:
layouts_h_lines.append('\n#ifndef __ASSEMBLER__')
layouts_h_lines.append('\n#include "quantum_keycodes.h"')
layouts_h_lines.append('\nenum custom_keycodes {')
first = True
for keycode in kb_info_json['custom_keycodes']:
if first:
first = False
layouts_h_lines.append(f'\t{keycode} = SAFE_RANGE,')
else:
layouts_h_lines.append(f'\t{keycode},')
layouts_h_lines.append('\tNEW_SAFE_RANGE')
layouts_h_lines.append('};\n')
layouts_h_lines.append('#undef SAFE_RANGE')
layouts_h_lines.append('#define SAFE_RANGE NEW_SAFE_RANGE')
layouts_h_lines.append('#endif // __ASSEMBLER__')
for layout_name in kb_info_json['layouts']: for layout_name in kb_info_json['layouts']:
if kb_info_json['layouts'][layout_name]['c_macro']: if kb_info_json['layouts'][layout_name]['c_macro']:
continue continue