Stubs for ENCODER_MAP
This commit is contained in:
parent
1306d58774
commit
4d895892e5
3 changed files with 100 additions and 14 deletions
|
@ -81,7 +81,6 @@
|
|||
name: Keycode
|
||||
}
|
||||
]
|
||||
return_type: u8
|
||||
return_execute: dynamic_keymap_set_keycode
|
||||
}
|
||||
}
|
||||
|
@ -109,6 +108,57 @@
|
|||
return_purpose: capabilities
|
||||
return_constant: XAP_ROUTE_DYNAMIC_ENCODER_CAPABILITIES
|
||||
}
|
||||
0x02: {
|
||||
type: command
|
||||
name: Get Keycode
|
||||
define: GET_ENCODER_KEYCODE
|
||||
description: TODO
|
||||
request_type: struct
|
||||
request_struct_length: 3
|
||||
request_struct_members: [
|
||||
{
|
||||
type: u8
|
||||
name: Layer
|
||||
},
|
||||
{
|
||||
type: u8
|
||||
name: Encoder
|
||||
},
|
||||
{
|
||||
type: u8
|
||||
name: Clockwise
|
||||
}
|
||||
]
|
||||
return_type: u16
|
||||
return_execute: dynamic_encoder_get_keycode
|
||||
}
|
||||
0x03: {
|
||||
type: command
|
||||
name: Set Keycode
|
||||
define: SET_ENCODER_KEYCODE
|
||||
description: TODO
|
||||
request_type: struct
|
||||
request_struct_length: 5
|
||||
request_struct_members: [
|
||||
{
|
||||
type: u8
|
||||
name: Layer
|
||||
},
|
||||
{
|
||||
type: u8
|
||||
name: Encoder
|
||||
},
|
||||
{
|
||||
type: u8
|
||||
name: Clockwise
|
||||
},
|
||||
{
|
||||
type: u16
|
||||
name: Keycode
|
||||
}
|
||||
]
|
||||
return_execute: dynamic_encoder_set_keycode
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -157,26 +157,34 @@ def _list_devices():
|
|||
print_dotted_output(data)
|
||||
|
||||
|
||||
def xap_doit():
|
||||
print("xap_doit")
|
||||
def xap_dump_keymap(device):
|
||||
# get layer count
|
||||
# layers = _xap_transaction(device, 0x04, 0x01)
|
||||
# layers = int.from_bytes(layers, "little")
|
||||
# print(f'layers:{layers}')
|
||||
layers = _xap_transaction(device, 0x04, 0x01)
|
||||
layers = int.from_bytes(layers, "little")
|
||||
print(f'layers:{layers}')
|
||||
|
||||
# get keycode [layer:0, row:0, col:0]
|
||||
# keycode = _xap_transaction(device, 0x04, 0x02, b"\x00\x00\x00")
|
||||
# keycode = int.from_bytes(keycode, "little")
|
||||
# keycode_map = {
|
||||
# # TODO: this should be data driven...
|
||||
# 0x04: 'KC_A',
|
||||
# 0x05: 'KC_B',
|
||||
# 0x29: 'KC_ESCAPE'
|
||||
# }
|
||||
# print('keycode:' + keycode_map.get(keycode, 'unknown'))
|
||||
|
||||
# get encoder [layer:0, index:0, clockwise:0]
|
||||
keycode = _xap_transaction(device, 0x05, 0x02, b"\x00\x00\x00")
|
||||
|
||||
keycode = int.from_bytes(keycode, "little")
|
||||
keycode_map = {
|
||||
# TODO: this should be data driven...
|
||||
0x04: 'KC_A',
|
||||
0x05: 'KC_B',
|
||||
0x29: 'KC_ESCAPE',
|
||||
0xF9: 'KC_MS_WH_UP',
|
||||
}
|
||||
print(f'keycode:{keycode_map.get(keycode, "unknown")}')
|
||||
|
||||
|
||||
def xap_doit():
|
||||
print("xap_doit")
|
||||
# Reboot
|
||||
# _xap_transaction(device, 0x01, 0x07)
|
||||
exit(1)
|
||||
|
||||
|
||||
def xap_broadcast_listen(device):
|
||||
|
@ -227,6 +235,9 @@ def xap(cli):
|
|||
xap_unlock(device)
|
||||
cli.log.info("Done")
|
||||
|
||||
elif cli.args.action == 'dump':
|
||||
xap_dump_keymap(device)
|
||||
|
||||
elif cli.args.action == 'listen':
|
||||
xap_broadcast_listen(device)
|
||||
|
||||
|
|
|
@ -128,3 +128,28 @@ bool xap_respond_dynamic_keymap_set_keycode(xap_token_t token, const void *data,
|
|||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ((defined(ENCODER_MAP_ENABLE)))
|
||||
bool xap_respond_dynamic_encoder_get_keycode(xap_token_t token, const void *data, size_t length) {
|
||||
if (length != sizeof(xap_route_dynamic_encoder_get_encoder_keycode_arg_t)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
xap_route_dynamic_encoder_get_encoder_keycode_arg_t *arg = (xap_route_dynamic_encoder_get_encoder_keycode_arg_t *)data;
|
||||
|
||||
uint16_t keycode = dynamic_keymap_get_encoder(arg->layer, arg->encoder, arg->clockwise);
|
||||
return xap_respond_data(token, &keycode, sizeof(keycode));
|
||||
}
|
||||
|
||||
bool xap_respond_dynamic_encoder_set_keycode(xap_token_t token, const void *data, size_t length) {
|
||||
if (length != sizeof(xap_route_dynamic_encoder_set_encoder_keycode_arg_t)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
xap_route_dynamic_encoder_set_encoder_keycode_arg_t *arg = (xap_route_dynamic_encoder_set_encoder_keycode_arg_t *)data;
|
||||
|
||||
dynamic_keymap_set_encoder(arg->layer, arg->encoder, arg->clockwise, arg->keycode);
|
||||
xap_respond_success(token);
|
||||
return true;
|
||||
}
|
||||
#endif
|
Loading…
Reference in a new issue