Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable trackball when typing #3

Open
bstiq opened this issue Sep 19, 2024 · 0 comments
Open

Disable trackball when typing #3

bstiq opened this issue Sep 19, 2024 · 0 comments

Comments

@bstiq
Copy link
Member

bstiq commented Sep 19, 2024

Requested feature.

Add a #define in the configuration that disables the trakball / trackpad when typing.

As per Dasky's code:

static uint32_t last_keyboard_keypress = 0;
static bool     mouse_button_held      = false;
extern void     last_pointing_device_activity_trigger(void);

bool process_record_keymap(uint16_t keycode, keyrecord_t* record) {
    if (!IS_MOUSE_KEYCODE(keycode) && !IS_KB_KEYCODE(keycode)) {
        last_keyboard_keypress = timer_read32();
        layer_off(_POINTING);
    } else {
        mouse_button_held = record->event.pressed;
        last_pointing_device_activity_trigger();
    }
    return true;
}

void housekeeping_task_keymap(void) {
    if (!mouse_button_held && IS_LAYER_ON(_POINTING) && last_pointing_device_activity_elapsed() > 900) {
        layer_off(_POINTING);
    }
}

report_mouse_t pointing_device_task_user(report_mouse_t mouse_report) {
    if (timer_elapsed32(last_keyboard_keypress) < 100) {
        mouse_report.x = 0;
        mouse_report.y = 0;
    }
    if (abs(mouse_report.x) > 2 || abs(mouse_report.y) > 2) {
        if (get_highest_layer(layer_state) == _QWERTY) {
            layer_on(_POINTING);
        }
    }
    return mouse_report;
}
@Bastardkb Bastardkb deleted a comment from ArthurMLi Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant