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

Fix maddie layout for ploopy/trackball_nano #17213

Merged
merged 4 commits into from
Jun 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 28 additions & 27 deletions keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,42 @@
*/
#include QMK_KEYBOARD_H

// Configuration options
#define SCROLL_TIMEOUT 25
#define DELTA_X_THRESHOLD 60
#define DELTA_Y_THRESHOLD 15

// safe range starts at `PLOOPY_SAFE_RANGE` instead.
uint8_t scroll_enabled = 0;
uint8_t lock_state = 0;
int8_t delta_x = 0;
int8_t delta_y = 0;
bool scroll_enabled = false;
bool lock_state = false;

// Dummy
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {{{ KC_NO }}};

void process_mouse_user(report_mouse_t *mouse_report, int8_t x, int8_t y) {
report_mouse_t pointing_device_task_user(report_mouse_t mouse_report) {
if (scroll_enabled) {
delta_x += x;
delta_y += y;
delta_x += mouse_report.x;
delta_y += mouse_report.y;

if (delta_x > 60) {
mouse_report->h = 1;
delta_x = 0;
} else if (delta_x < -60) {
mouse_report->h = -1;
delta_x = 0;
}
if (delta_x > DELTA_X_THRESHOLD) {
mouse_report.h = 1;
delta_x = 0;
} else if (delta_x < -DELTA_X_THRESHOLD) {
mouse_report.h = -1;
delta_x = 0;
}

if (delta_y > 15) {
mouse_report->v = -1;
delta_y = 0;
} else if (delta_y < -15) {
mouse_report->v = 1;
delta_y = 0;
}
} else {
mouse_report->x = x;
mouse_report->y = y;
aidalgol marked this conversation as resolved.
Show resolved Hide resolved
if (delta_y > DELTA_Y_THRESHOLD) {
mouse_report.v = -1;
delta_y = 0;
} else if (delta_y < -DELTA_Y_THRESHOLD) {
mouse_report.v = 1;
delta_y = 0;
}
mouse_report.x = 0;
mouse_report.y = 0;
}
return mouse_report;
}

void keyboard_post_init_user(void) {
Expand All @@ -61,7 +64,7 @@ bool led_update_user(led_t led_state) {
static uint8_t lock_count = 0;
static uint16_t scroll_timer = 0;

if (timer_elapsed(scroll_timer) > 25) {
if (timer_elapsed(scroll_timer) > SCROLL_TIMEOUT) {
scroll_timer = timer_read();
lock_count = 0;
}
Expand All @@ -72,8 +75,6 @@ bool led_update_user(led_t led_state) {
if (lock_count == 2) {
scroll_enabled = !scroll_enabled;
lock_count = 0;
delta_x = 0;
delta_y = 0;
}
}

Expand Down