forked from kofal.net/zmk
feat(behaviors): Add key position to key events
Extended the virtual key position system from combos so that each sensor also gets a virtual key position. This allows sensor behaviors to use the behavior queue API.
This commit is contained in:
committed by
Pete Johanson
parent
83a151890c
commit
e7a6e4016d
@@ -26,6 +26,7 @@ typedef int (*behavior_keymap_binding_callback_t)(struct zmk_behavior_binding *b
|
||||
struct zmk_behavior_binding_event event);
|
||||
typedef int (*behavior_sensor_keymap_binding_callback_t)(struct zmk_behavior_binding *binding,
|
||||
const struct device *sensor,
|
||||
uint32_t virtual_key_position,
|
||||
int64_t timestamp);
|
||||
|
||||
enum behavior_locality {
|
||||
@@ -150,21 +151,23 @@ static inline int z_impl_behavior_keymap_binding_released(struct zmk_behavior_bi
|
||||
|
||||
/**
|
||||
* @brief Handle the a sensor keymap binding being triggered
|
||||
* @param dev Pointer to the device structure for the driver instance.
|
||||
* @param binding Sensor keymap binding which was triggered.
|
||||
* @param sensor Pointer to the sensor device structure for the sensor driver instance.
|
||||
* @param param1 User parameter specified at time of behavior binding.
|
||||
* @param param2 User parameter specified at time of behavior binding.
|
||||
* @param virtual_key_position ZMK_KEYMAP_LEN + sensor number
|
||||
* @param timestamp Time at which the binding was triggered.
|
||||
*
|
||||
* @retval 0 If successful.
|
||||
* @retval Negative errno code if failure.
|
||||
*/
|
||||
__syscall int behavior_sensor_keymap_binding_triggered(struct zmk_behavior_binding *binding,
|
||||
const struct device *sensor,
|
||||
uint32_t virtual_key_position,
|
||||
int64_t timestamp);
|
||||
|
||||
static inline int
|
||||
z_impl_behavior_sensor_keymap_binding_triggered(struct zmk_behavior_binding *binding,
|
||||
const struct device *sensor, int64_t timestamp) {
|
||||
const struct device *sensor,
|
||||
uint32_t virtual_key_position, int64_t timestamp) {
|
||||
const struct device *dev = device_get_binding(binding->behavior_dev);
|
||||
|
||||
if (dev == NULL) {
|
||||
@@ -177,7 +180,7 @@ z_impl_behavior_sensor_keymap_binding_triggered(struct zmk_behavior_binding *bin
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
return api->sensor_binding_triggered(binding, sensor, timestamp);
|
||||
return api->sensor_binding_triggered(binding, sensor, virtual_key_position, timestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user