diff --git a/keyboards/keyball/keyball39/keymaps/default/config.h b/keyboards/keyball/keyball39/keymaps/default/config.h index a05a1cc5b9d5..35c90651b8c9 100644 --- a/keyboards/keyball/keyball39/keymaps/default/config.h +++ b/keyboards/keyball/keyball39/keymaps/default/config.h @@ -34,3 +34,5 @@ along with this program. If not, see . #endif #define TAP_CODE_DELAY 5 + +#define POINTING_DEVICE_AUTO_MOUSE_ENABLE diff --git a/keyboards/keyball/keyball39/keymaps/default/keymap.c b/keyboards/keyball/keyball39/keymaps/default/keymap.c index 176cfd43d5f3..57cc35cc5b57 100644 --- a/keyboards/keyball/keyball39/keymaps/default/keymap.c +++ b/keyboards/keyball/keyball39/keymaps/default/keymap.c @@ -45,7 +45,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ), [3] = LAYOUT_universal( - RGB_TOG , _______ , _______ , _______ , _______ , RGB_M_P , RGB_M_B , RGB_M_R , RGB_M_SW , RGB_M_SN , + RGB_TOG , AML_TO , AML_I50 , AML_D50 , _______ , RGB_M_P , RGB_M_B , RGB_M_R , RGB_M_SW , RGB_M_SN , RGB_MOD , RGB_HUI , RGB_SAI , RGB_VAI , SCRL_DVI , RGB_M_K , RGB_M_X , RGB_M_G , RGB_M_T , RGB_M_TW , RGB_RMOD , RGB_HUD , RGB_SAD , RGB_VAD , SCRL_DVD , CPI_D1K , CPI_D100 , CPI_I100 , CPI_I1K , KBC_SAVE , QK_BOOT , KBC_RST , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , KBC_RST , QK_BOOT diff --git a/keyboards/keyball/keyball39/keymaps/via/config.h b/keyboards/keyball/keyball39/keymaps/via/config.h index cb9ccf9eb97c..a44f9fee228d 100644 --- a/keyboards/keyball/keyball39/keymaps/via/config.h +++ b/keyboards/keyball/keyball39/keymaps/via/config.h @@ -34,3 +34,5 @@ along with this program. If not, see . #endif #define TAP_CODE_DELAY 5 + +#define POINTING_DEVICE_AUTO_MOUSE_ENABLE diff --git a/keyboards/keyball/keyball39/keymaps/via/keymap.c b/keyboards/keyball/keyball39/keymaps/via/keymap.c index 6ec255b3ac97..cb44bc605fc6 100644 --- a/keyboards/keyball/keyball39/keymaps/via/keymap.c +++ b/keyboards/keyball/keyball39/keymaps/via/keymap.c @@ -45,7 +45,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ), [3] = LAYOUT_universal( - RGB_TOG , _______ , _______ , _______ , _______ , RGB_M_P , RGB_M_B , RGB_M_R , RGB_M_SW , RGB_M_SN , + RGB_TOG , AML_TO , AML_I50 , AML_D50 , _______ , RGB_M_P , RGB_M_B , RGB_M_R , RGB_M_SW , RGB_M_SN , RGB_MOD , RGB_HUI , RGB_SAI , RGB_VAI , SCRL_DVI , RGB_M_K , RGB_M_X , RGB_M_G , RGB_M_T , RGB_M_TW , RGB_RMOD , RGB_HUD , RGB_SAD , RGB_VAD , SCRL_DVD , CPI_D1K , CPI_D100 , CPI_I100 , CPI_I1K , KBC_SAVE , QK_BOOT , KBC_RST , _______ , _______ , _______ , _______ , _______ , _______ , _______ , _______ , KBC_RST , QK_BOOT diff --git a/keyboards/keyball/keyball44/keymaps/default/config.h b/keyboards/keyball/keyball44/keymaps/default/config.h index a05a1cc5b9d5..35c90651b8c9 100644 --- a/keyboards/keyball/keyball44/keymaps/default/config.h +++ b/keyboards/keyball/keyball44/keymaps/default/config.h @@ -34,3 +34,5 @@ along with this program. If not, see . #endif #define TAP_CODE_DELAY 5 + +#define POINTING_DEVICE_AUTO_MOUSE_ENABLE diff --git a/keyboards/keyball/keyball44/keymaps/default/keymap.c b/keyboards/keyball/keyball44/keymaps/default/keymap.c index 3aca79bb7646..c6314542df03 100644 --- a/keyboards/keyball/keyball44/keymaps/default/keymap.c +++ b/keyboards/keyball/keyball44/keymaps/default/keymap.c @@ -45,7 +45,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ), [3] = LAYOUT_universal( - RGB_TOG , _______ , _______ , _______ , _______ , _______ , RGB_M_P , RGB_M_B , RGB_M_R , RGB_M_SW , RGB_M_SN , RGB_M_K , + RGB_TOG , AML_TO , AML_I50 , AML_D50 , _______ , _______ , RGB_M_P , RGB_M_B , RGB_M_R , RGB_M_SW , RGB_M_SN , RGB_M_K , RGB_MOD , RGB_HUI , RGB_SAI , RGB_VAI , _______ , SCRL_DVI , RGB_M_X , RGB_M_G , RGB_M_T , RGB_M_TW , _______ , _______ , RGB_RMOD , RGB_HUD , RGB_SAD , RGB_VAD , _______ , SCRL_DVD , CPI_D1K , CPI_D100 , CPI_I100 , CPI_I1K , _______ , KBC_SAVE , QK_BOOT , KBC_RST , _______ , _______ , _______ , _______ , _______ , _______ , KBC_RST , QK_BOOT diff --git a/keyboards/keyball/keyball44/keymaps/via/config.h b/keyboards/keyball/keyball44/keymaps/via/config.h index cb9ccf9eb97c..a44f9fee228d 100644 --- a/keyboards/keyball/keyball44/keymaps/via/config.h +++ b/keyboards/keyball/keyball44/keymaps/via/config.h @@ -34,3 +34,5 @@ along with this program. If not, see . #endif #define TAP_CODE_DELAY 5 + +#define POINTING_DEVICE_AUTO_MOUSE_ENABLE diff --git a/keyboards/keyball/keyball44/keymaps/via/keymap.c b/keyboards/keyball/keyball44/keymaps/via/keymap.c index d13b48449926..28bb0bf07fba 100644 --- a/keyboards/keyball/keyball44/keymaps/via/keymap.c +++ b/keyboards/keyball/keyball44/keymaps/via/keymap.c @@ -45,7 +45,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ), [3] = LAYOUT_universal( - RGB_TOG , _______ , _______ , _______ , _______ , _______ , RGB_M_P , RGB_M_B , RGB_M_R , RGB_M_SW , RGB_M_SN , RGB_M_K , + RGB_TOG , AML_TO , AML_I50 , AML_D50 , _______ , _______ , RGB_M_P , RGB_M_B , RGB_M_R , RGB_M_SW , RGB_M_SN , RGB_M_K , RGB_MOD , RGB_HUI , RGB_SAI , RGB_VAI , _______ , SCRL_DVI , RGB_M_X , RGB_M_G , RGB_M_T , RGB_M_TW , _______ , _______ , RGB_RMOD , RGB_HUD , RGB_SAD , RGB_VAD , _______ , SCRL_DVD , CPI_D1K , CPI_D100 , CPI_I100 , CPI_I1K , _______ , KBC_SAVE , QK_BOOT , KBC_RST , _______ , _______ , _______ , _______ , _______ , _______ , KBC_RST , QK_BOOT diff --git a/keyboards/keyball/keyball46/keymaps/default/config.h b/keyboards/keyball/keyball46/keymaps/default/config.h index 3c83e8bad5d6..e3e77177e187 100644 --- a/keyboards/keyball/keyball46/keymaps/default/config.h +++ b/keyboards/keyball/keyball46/keymaps/default/config.h @@ -37,3 +37,5 @@ along with this program. If not, see . #define PRODUCT_ID 0x0005 #define TAP_CODE_DELAY 5 + +#define POINTING_DEVICE_AUTO_MOUSE_ENABLE diff --git a/keyboards/keyball/keyball46/keymaps/default/keymap.c b/keyboards/keyball/keyball46/keymaps/default/keymap.c index ce187ed5fc88..bf9aa851dcc7 100644 --- a/keyboards/keyball/keyball46/keymaps/default/keymap.c +++ b/keyboards/keyball/keyball46/keymaps/default/keymap.c @@ -86,7 +86,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_BALL] = LAYOUT_right_ball( //,-----------------------------------------------------. ,-----------------------------------------------------. - RGB_TOG, _______, _______, _______, _______, _______, RGB_M_P, RGB_M_B, RGB_M_R,RGB_M_SW,RGB_M_SN, RGB_M_K, + RGB_TOG, AML_TO , AML_I50, AML_D50, _______, _______, RGB_M_P, RGB_M_B, RGB_M_R,RGB_M_SW,RGB_M_SN, RGB_M_K, //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| RGB_MOD, RGB_HUI, RGB_SAI, RGB_VAI, _______, _______, RGB_M_X, RGB_M_G, RGB_M_T,RGB_M_TW, _______, _______, //|--------+--------+--------+--------+--------+--------' |--------+--------+--------+--------+--------+--------| diff --git a/keyboards/keyball/keyball46/keymaps/via/config.h b/keyboards/keyball/keyball46/keymaps/via/config.h index 1d9f7ff79c3d..640a31db877b 100644 --- a/keyboards/keyball/keyball46/keymaps/via/config.h +++ b/keyboards/keyball/keyball46/keymaps/via/config.h @@ -34,3 +34,5 @@ along with this program. If not, see . #endif #define TAP_CODE_DELAY 5 + +#define POINTING_DEVICE_AUTO_MOUSE_ENABLE diff --git a/keyboards/keyball/keyball46/keymaps/via/keymap.c b/keyboards/keyball/keyball46/keymaps/via/keymap.c index ce187ed5fc88..bf9aa851dcc7 100644 --- a/keyboards/keyball/keyball46/keymaps/via/keymap.c +++ b/keyboards/keyball/keyball46/keymaps/via/keymap.c @@ -86,7 +86,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_BALL] = LAYOUT_right_ball( //,-----------------------------------------------------. ,-----------------------------------------------------. - RGB_TOG, _______, _______, _______, _______, _______, RGB_M_P, RGB_M_B, RGB_M_R,RGB_M_SW,RGB_M_SN, RGB_M_K, + RGB_TOG, AML_TO , AML_I50, AML_D50, _______, _______, RGB_M_P, RGB_M_B, RGB_M_R,RGB_M_SW,RGB_M_SN, RGB_M_K, //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| RGB_MOD, RGB_HUI, RGB_SAI, RGB_VAI, _______, _______, RGB_M_X, RGB_M_G, RGB_M_T,RGB_M_TW, _______, _______, //|--------+--------+--------+--------+--------+--------' |--------+--------+--------+--------+--------+--------| diff --git a/keyboards/keyball/keyball46/keymaps/via_Both/config.h b/keyboards/keyball/keyball46/keymaps/via_Both/config.h index be702e5bcc6f..00b8b7e38eb0 100644 --- a/keyboards/keyball/keyball46/keymaps/via_Both/config.h +++ b/keyboards/keyball/keyball46/keymaps/via_Both/config.h @@ -37,3 +37,5 @@ along with this program. If not, see . #define PRODUCT_ID 0x0003 #define TAP_CODE_DELAY 5 + +#define POINTING_DEVICE_AUTO_MOUSE_ENABLE diff --git a/keyboards/keyball/keyball46/keymaps/via_Both/keymap.c b/keyboards/keyball/keyball46/keymaps/via_Both/keymap.c index ed7692254092..6191773a0039 100644 --- a/keyboards/keyball/keyball46/keymaps/via_Both/keymap.c +++ b/keyboards/keyball/keyball46/keymaps/via_Both/keymap.c @@ -86,7 +86,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_BALL] = LAYOUT_double_balls( //,-----------------------------------------------------. ,-----------------------------------------------------. - RGB_TOG, _______, _______, _______, _______, _______, RGB_M_P, RGB_M_B, RGB_M_R,RGB_M_SW,RGB_M_SN, RGB_M_K, + RGB_TOG, AML_TO , AML_I50, AML_D50, _______, _______, RGB_M_P, RGB_M_B, RGB_M_R,RGB_M_SW,RGB_M_SN, RGB_M_K, //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| RGB_MOD, RGB_HUI, RGB_SAI, RGB_VAI, _______, _______, RGB_M_X, RGB_M_G, RGB_M_T,RGB_M_TW, _______, _______, //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| diff --git a/keyboards/keyball/keyball46/keymaps/via_Left/config.h b/keyboards/keyball/keyball46/keymaps/via_Left/config.h index 4332f3ff8b39..a9b798e69575 100644 --- a/keyboards/keyball/keyball46/keymaps/via_Left/config.h +++ b/keyboards/keyball/keyball46/keymaps/via_Left/config.h @@ -37,3 +37,5 @@ along with this program. If not, see . #define PRODUCT_ID 0x0002 #define TAP_CODE_DELAY 5 + +#define POINTING_DEVICE_AUTO_MOUSE_ENABLE diff --git a/keyboards/keyball/keyball46/keymaps/via_Left/keymap.c b/keyboards/keyball/keyball46/keymaps/via_Left/keymap.c index f115613158ad..b94d7cc329b0 100644 --- a/keyboards/keyball/keyball46/keymaps/via_Left/keymap.c +++ b/keyboards/keyball/keyball46/keymaps/via_Left/keymap.c @@ -86,7 +86,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_BALL] = LAYOUT_left_ball( //,-----------------------------------------------------. ,-----------------------------------------------------. - RGB_TOG, _______, _______, _______, _______, _______, RGB_M_P, RGB_M_B, RGB_M_R,RGB_M_SW,RGB_M_SN, RGB_M_K, + RGB_TOG, AML_TO , AML_I50, AML_D50, _______, _______, RGB_M_P, RGB_M_B, RGB_M_R,RGB_M_SW,RGB_M_SN, RGB_M_K, //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| RGB_MOD, RGB_HUI, RGB_SAI, RGB_VAI, _______, _______, RGB_M_X, RGB_M_G, RGB_M_T,RGB_M_TW, _______, _______, //|--------+--------+--------+--------+--------+--------| `--------+--------+--------+--------+--------+--------| diff --git a/keyboards/keyball/keyball61/keymaps/default/config.h b/keyboards/keyball/keyball61/keymaps/default/config.h index a05a1cc5b9d5..35c90651b8c9 100644 --- a/keyboards/keyball/keyball61/keymaps/default/config.h +++ b/keyboards/keyball/keyball61/keymaps/default/config.h @@ -34,3 +34,5 @@ along with this program. If not, see . #endif #define TAP_CODE_DELAY 5 + +#define POINTING_DEVICE_AUTO_MOUSE_ENABLE diff --git a/keyboards/keyball/keyball61/keymaps/default/keymap.c b/keyboards/keyball/keyball61/keymaps/default/keymap.c index b89085dc55f7..bf5663ad980d 100644 --- a/keyboards/keyball/keyball61/keymaps/default/keymap.c +++ b/keyboards/keyball/keyball61/keymaps/default/keymap.c @@ -47,7 +47,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ), [3] = LAYOUT_universal( - RGB_TOG , _______ , _______ , _______ , _______ , _______ , RGB_M_P , RGB_M_B , RGB_M_R , RGB_M_SW , RGB_M_SN , RGB_M_K , + RGB_TOG , AML_TO , AML_I50 , AML_D50 , _______ , _______ , RGB_M_P , RGB_M_B , RGB_M_R , RGB_M_SW , RGB_M_SN , RGB_M_K , RGB_MOD , RGB_HUI , RGB_SAI , RGB_VAI , _______ , _______ , RGB_M_X , RGB_M_G , RGB_M_T , RGB_M_TW , _______ , _______ , RGB_RMOD , RGB_HUD , RGB_SAD , RGB_VAD , _______ , _______ , CPI_D1K , CPI_D100 , CPI_I100 , CPI_I1K , KBC_SAVE , KBC_RST , _______ , _______ , SCRL_DVD , SCRL_DVI , SCRL_MO , SCRL_TO , EE_CLR , EE_CLR , KC_HOME , KC_PGDN , KC_PGUP , KC_END , _______ , _______ , diff --git a/keyboards/keyball/keyball61/keymaps/via/config.h b/keyboards/keyball/keyball61/keymaps/via/config.h index cb9ccf9eb97c..20e09572b991 100644 --- a/keyboards/keyball/keyball61/keymaps/via/config.h +++ b/keyboards/keyball/keyball61/keymaps/via/config.h @@ -25,7 +25,7 @@ along with this program. If not, see . # define RGBLIGHT_EFFECT_RAINBOW_MOOD # define RGBLIGHT_EFFECT_RAINBOW_SWIRL //# define RGBLIGHT_EFFECT_SNAKE -# define RGBLIGHT_EFFECT_KNIGHT +//# define RGBLIGHT_EFFECT_KNIGHT //# define RGBLIGHT_EFFECT_CHRISTMAS # define RGBLIGHT_EFFECT_STATIC_GRADIENT //# define RGBLIGHT_EFFECT_RGB_TEST @@ -34,3 +34,5 @@ along with this program. If not, see . #endif #define TAP_CODE_DELAY 5 + +#define POINTING_DEVICE_AUTO_MOUSE_ENABLE diff --git a/keyboards/keyball/keyball61/keymaps/via/keymap.c b/keyboards/keyball/keyball61/keymaps/via/keymap.c index b89085dc55f7..bf5663ad980d 100644 --- a/keyboards/keyball/keyball61/keymaps/via/keymap.c +++ b/keyboards/keyball/keyball61/keymaps/via/keymap.c @@ -47,7 +47,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ), [3] = LAYOUT_universal( - RGB_TOG , _______ , _______ , _______ , _______ , _______ , RGB_M_P , RGB_M_B , RGB_M_R , RGB_M_SW , RGB_M_SN , RGB_M_K , + RGB_TOG , AML_TO , AML_I50 , AML_D50 , _______ , _______ , RGB_M_P , RGB_M_B , RGB_M_R , RGB_M_SW , RGB_M_SN , RGB_M_K , RGB_MOD , RGB_HUI , RGB_SAI , RGB_VAI , _______ , _______ , RGB_M_X , RGB_M_G , RGB_M_T , RGB_M_TW , _______ , _______ , RGB_RMOD , RGB_HUD , RGB_SAD , RGB_VAD , _______ , _______ , CPI_D1K , CPI_D100 , CPI_I100 , CPI_I1K , KBC_SAVE , KBC_RST , _______ , _______ , SCRL_DVD , SCRL_DVI , SCRL_MO , SCRL_TO , EE_CLR , EE_CLR , KC_HOME , KC_PGDN , KC_PGUP , KC_END , _______ , _______ , diff --git a/keyboards/keyball/lib/keyball/keyball.c b/keyboards/keyball/lib/keyball/keyball.c index 2d8542963ff3..fd0ba6425024 100644 --- a/keyboards/keyball/lib/keyball/keyball.c +++ b/keyboards/keyball/lib/keyball/keyball.c @@ -28,6 +28,10 @@ along with this program. If not, see . const uint8_t CPI_DEFAULT = KEYBALL_CPI_DEFAULT / 100; const uint8_t CPI_MAX = pmw3360_MAXCPI + 1; const uint8_t SCROLL_DIV_MAX = 7; +#ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE +const uint16_t AML_TIMEOUT_DEFAULT = 9; +const uint16_t AML_TIMEOUT_MAX = 15; +#endif keyball_t keyball = { .this_have_ball = false, @@ -44,6 +48,11 @@ keyball_t keyball = { .scroll_div = 0, .pressing_keys = {' ', ' ', ' ', 0}, + +#ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE + .aml_enabled = 0, + .aml_timeout = 0, +#endif }; ////////////////////////////////////////////////////////////////////////////// @@ -122,6 +131,15 @@ static void add_scroll_div(int8_t delta) { keyball_set_scroll_div(v < 1 ? 1 : v); } + +#ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE +static void add_aml_timeout(int8_t delta) { + int8_t v = keyball_get_aml_timeout() + delta; + keyball_set_aml_timeout(v < 1 ? 1 : v); +} +#endif + + ////////////////////////////////////////////////////////////////////////////// // Pointing device driver @@ -147,6 +165,11 @@ void pointing_device_driver_init(void) { # endif #endif pmw3360_cpi_set(CPI_DEFAULT - 1); + pmw3360_reg_write(pmw3360_Motion_Burst, 0); + +#ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE + set_auto_mouse_layer(1); +#endif } } @@ -441,6 +464,24 @@ void keyball_oled_render_layerinfo(void) { #endif } +#ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE +void keyball_oled_render_amlinfo(void) { +#ifdef OLED_ENABLE + // Format: `AML:{AML state} {AML timeout}` + // + // Output example: + // + // AML:o 5 + // + oled_write_P(PSTR("AML:"), false); + oled_write_char((keyball.aml_enabled ? 'o' : 'x'), false); + oled_write_char(' ', false); + oled_write(format_4d(keyball.aml_timeout), false); + oled_write_P(PSTR(" "), false); +#endif +} +#endif + ////////////////////////////////////////////////////////////////////////////// // Public API functions @@ -478,6 +519,41 @@ void keyball_set_cpi(uint8_t cpi) { } } +#ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE +void keyball_set_aml_enabled(bool enabled) { + keyball.aml_enabled = enabled; + set_auto_mouse_enable(enabled); +} + +// This method returns current timeout value. +// It will return 1 to 15. +// +// 1=( 1-1)*50+250=250ms +// 2=( 2-1)*50+250=300ms +// ... +// 9=( 9-1)*50+250=650ms +// 10=(10-1)*50+250=700ms +// 11=(11-1)*50+250=750ms +// 12=(12-1)*50+250=800ms +// 13=(13-1)*50+250=850ms +// 14=(14-1)*50+250=900ms +// 15=(15-1)*50+250=950ms +uint8_t keyball_get_aml_timeout(void) { + return keyball.aml_timeout == 0 ? AML_TIMEOUT_DEFAULT : keyball.aml_timeout; +} + +void keyball_set_aml_timeout(uint8_t timeout) { + if (timeout > AML_TIMEOUT_MAX) { + timeout = AML_TIMEOUT_MAX; + } + keyball.aml_timeout = timeout; + if (timeout == 0) { + timeout = AML_TIMEOUT_DEFAULT; + } + set_auto_mouse_timeout((timeout-1)*50+250); +} +#endif + ////////////////////////////////////////////////////////////////////////////// // Keyboard hooks @@ -496,6 +572,10 @@ void keyboard_post_init_kb(void) { keyball_config_t c = {.raw = eeconfig_read_kb()}; keyball_set_cpi(c.cpi); keyball_set_scroll_div(c.sdiv); +#ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE + keyball_set_aml_enabled(c.amle); + keyball_set_aml_timeout(c.amlto); +#endif } keyball_on_adjust_layout(KEYBALL_ADJUST_PENDING); @@ -576,8 +656,12 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) { break; case KBC_SAVE: { keyball_config_t c = { - .cpi = keyball.cpi_value, - .sdiv = keyball.scroll_div, + .cpi = keyball.cpi_value, + .sdiv = keyball.scroll_div, +#ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE + .amle = keyball.aml_enabled, + .amlto = keyball.aml_timeout, +#endif }; eeconfig_update_kb(c.raw); } break; @@ -605,6 +689,18 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) { add_scroll_div(-1); break; +#ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE + case AML_TO: + keyball_set_aml_enabled(!keyball.aml_enabled); + break; + case AML_I50: + add_aml_timeout(1); + break; + case AML_D50: + add_aml_timeout(-1); + break; +#endif + default: return true; } diff --git a/keyboards/keyball/lib/keyball/keyball.h b/keyboards/keyball/lib/keyball/keyball.h index 9c6669e28683..20ef4dcdad75 100644 --- a/keyboards/keyball/lib/keyball/keyball.h +++ b/keyboards/keyball/lib/keyball/keyball.h @@ -95,6 +95,12 @@ enum keyball_keycodes { SCRL_DVI = QK_KB_8, // Increment scroll divider SCRL_DVD = QK_KB_9, // Decrement scroll divider +#ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE + AML_TO = QK_KB_10, // Toggle automatic mouse layer + AML_I50 = QK_KB_11, // Increment automatic mouse layer timeout + AML_D50 = QK_KB_12, // Decrement automatic mouse layer timeout +#endif + // User customizable 32 keycodes. KEYBALL_SAFE_RANGE = QK_USER_0, }; @@ -103,7 +109,11 @@ typedef union { uint32_t raw; struct { uint8_t cpi : 7; - uint8_t sdiv : 3; // scroll divider + uint8_t sdiv : 3; // scroll divider +#ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE + uint8_t amle : 1; // automatic mouse layer enabled + uint8_t amlto : 4; // automatic mouse layer timeout +#endif }; } keyball_config_t; @@ -136,6 +146,11 @@ typedef struct { uint32_t scroll_snap_last; int8_t scroll_snap_tension_h; +#ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE + bool aml_enabled; + uint8_t aml_timeout; +#endif + uint16_t last_kc; keypos_t last_pos; report_mouse_t last_mouse; @@ -171,6 +186,12 @@ void keyball_oled_render_keyinfo(void); /// inactive layers. void keyball_oled_render_layerinfo(void); +#ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE +/// keyball_oled_render_amlinfo renders automatic mouse layer information to +/// OLED. +void keyball_oled_render_amlinfo(void); +#endif + /// keyball_get_scroll_mode gets current scroll mode. bool keyball_get_scroll_mode(void); @@ -188,3 +209,20 @@ uint8_t keyball_get_cpi(void); // TODO: document void keyball_set_cpi(uint8_t cpi); + +#ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE +// This function is used to enable or disable the automatic mouse layer (AML). +// When it is enabled (true), the mouse layer will be activated automatically based on a set timeout. +// When it is disabled (false), the user will need to manually activate the mouse layer. +void keyball_set_aml_enabled(bool enabled); + +// This function is used to get the current timeout value for the automatic mouse layer (AML). +// The returned value is the number of milliseconds the system will wait before automatically activating the mouse layer. +// The return value is a number between 0 and 15, which corresponds to a range between 250ms and 950ms in intervals of 50ms. +uint8_t keyball_get_aml_timeout(void); + +// This function is used to set the automatic mouse layer (AML) timeout value. +// The argument is a number between 0 and 15, which corresponds to a range between 250ms and 950ms in intervals of 50ms. +// This value sets how long (in milliseconds) the system should wait before automatically activating the mouse layer when a key is pressed. +void keyball_set_aml_timeout(uint8_t timeout); +#endif diff --git a/keyboards/keyball/lib/keyball/keycodes.md b/keyboards/keyball/lib/keyball/keycodes.md index ab32f15846fa..24d7932f76e2 100644 --- a/keyboards/keyball/lib/keyball/keycodes.md +++ b/keyboards/keyball/lib/keyball/keycodes.md @@ -18,6 +18,9 @@ | `SCRL_MO` | `Kb 7` | `0x7e07` | Enable scroll mode when pressing | | `SCRL_DVI` | `Kb 8` | `0x7e08` | Increase scroll divider (max D7 = 1/128) <- Most Scroll slow | | `SCRL_DVD` | `Kb 9` | `0x7e09` | Decrease scroll divider (min 0 = 1/1) <- Most Scroll fast | +| `AML_TO` | `Kb 10` | `0x7e0a` | Toggle automatic mouse layer | +| `AML_I50` | `Kb 11` | `0x7e0b` | Increase 50ms automatic mouse layer timeout(max 15=950ms) | +| `AML_D50` | `Kb 12` | `0x7e0c` | Decrease 50ms automatic mouse layer timeout(min 1=250ms) | ## 特殊キーコード @@ -34,3 +37,7 @@ | `SCRL_MO` | `Kb 7` | `0x7e07` | キーを押している間、スクロールモードになります | | `SCRL_DVI` | `Kb 8` | `0x7e08` | スクロール除数を1つ上げます(max D7 = 1/128)←最もスクロール遅い | | `SCRL_DVD` | `Kb 9` | `0x7e09` | スクロール除数を1つ下げます(min D0 = 1/1)←最もスクロール速い | +| `AML_TO` | `Kb 10` | `0x7e0a` | 自動マウスレイヤーをトグルします。 | +| `AML_I50` | `Kb 11` | `0x7e0b` | 自動マウスレイヤーのタイムアウトを50msec増やします(max 15=950ms) | +| `AML_D50` | `Kb 12` | `0x7e0c` | 自動マウスレイヤーのタイムアウトを50msec減らします(min 1=250ms) | +