Add utility functions for Pointing Device Auto Mouse feature (#23144)

* Make is_auto_mouse_active() available globally

* Add mouse key tracker functions for auto mouse layer
master
Drashna Jaelre 2024-03-09 21:34:41 -08:00 committed by GitHub
parent 9f4a9d5826
commit c0dbe9a336
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 2 deletions

View File

@ -780,6 +780,9 @@ There are several functions that allow for more advanced interaction with the au
| `get_auto_mouse_timeout(void)` | Return the current timeout for turing off the layer | | `uint16_t` |
| `set_auto_mouse_debounce(uint16_t timeout)` | Change/set the debounce for preventing layer activation | | `void`(None) |
| `get_auto_mouse_debounce(void)` | Return the current debounce for preventing layer activation | | `uint8_t` |
| `is_auto_mouse_active(void)` | Returns the active state of the auto mouse layer (eg if the layer has been triggered)| | `bool` |
| `get_auto_mouse_key_tracker(void)` | Gets the current count for the auto mouse key tracker. | | `int8_t` |
| `set_auto_mouse_key_tracker(int8_t key_tracker)` | Sets/Overrides the current count for the auto mouse key tracker. | | `void`(None) |
_NOTES:_
- _Due to the nature of how some functions work, the `auto_mouse_trigger_reset`, and `auto_mouse_layer_off` functions should never be called in the `layer_state_set_*` stack as this can cause indefinite loops._

View File

@ -45,7 +45,7 @@ static inline bool layer_hold_check(void) {
}
/* check all layer activation criteria */
static inline bool is_auto_mouse_active(void) {
bool is_auto_mouse_active(void) {
return auto_mouse_context.status.is_activated || auto_mouse_context.status.mouse_key_tracker || layer_hold_check();
}
@ -98,6 +98,15 @@ bool get_auto_mouse_toggle(void) {
return auto_mouse_context.status.is_toggled;
}
/**
* @brief get key tracker value
*
* @return bool of current layer_toggled state
*/
int8_t get_auto_mouse_key_tracker(void) {
return auto_mouse_context.status.mouse_key_tracker;
}
/**
* @brief Reset auto mouse context
*
@ -163,6 +172,15 @@ void set_auto_mouse_debounce(uint8_t debounce) {
auto_mouse_reset();
}
/**
* @brief Changes the timeout for the mouse auto layer to be disabled
*
* @param key_tracker
*/
void set_auto_mouse_key_tracker(int8_t key_tracker) {
auto_mouse_context.status.mouse_key_tracker = key_tracker;
}
/**
* @brief toggle mouse layer setting
*

View File

@ -81,9 +81,11 @@ void set_auto_mouse_timeout(uint16_t timeout); // set l
uint16_t get_auto_mouse_timeout(void); // get layer timeout
void set_auto_mouse_debounce(uint8_t debounce); // set debounce
uint8_t get_auto_mouse_debounce(void); // get debounce
void set_auto_mouse_key_tracker(int8_t key_tracker); // set key tracker
int8_t get_auto_mouse_key_tracker(void); // get key tracker
void auto_mouse_layer_off(void); // disable target layer if appropriate (DO NOT USE in layer_state_set stack!!)
layer_state_t remove_auto_mouse_layer(layer_state_t state, bool force); // remove auto mouse target layer from state if appropriate (can be forced)
bool is_auto_mouse_active(void); // check if target layer is active
/* ----------For custom pointing device activation----------------------------------------------------------- */
bool auto_mouse_activation(report_mouse_t mouse_report); // handles pointing device trigger conditions for target layer activation (overwritable)