Skip to content

Disable trackball when typing #3

@bstiq

Description

@bstiq

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions