1
0
Fork 0

[Keyboard] Bug fixes and improvements to PloopyCo devices (#10573)

Co-authored-by: Ryan <fauxpark@gmail.com>
This commit is contained in:
Drashna Jael're 2020-10-26 23:09:11 -07:00 committed by GitHub
parent 555b1640b2
commit 33074bcbad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 536 additions and 61 deletions

View file

@ -30,6 +30,19 @@
#ifndef OPT_SCALE
# define OPT_SCALE 1 // Multiplier for wheel
#endif
#ifndef PLOOPY_DPI_OPTIONS
# define PLOOPY_DPI_OPTIONS { 1200, 1600, 2400 }
# ifndef PLOOPY_DPI_DEFAULT
# define PLOOPY_DPI_DEFAULT 1
# endif
#endif
#ifndef PLOOPY_DPI_DEFAULT
# define PLOOPY_DPI_DEFAULT 0
#endif
keyboard_config_t keyboard_config;
uint16_t dpi_array[] = PLOOPY_DPI_OPTIONS;
#define DPI_OPTION_SIZE (sizeof(dpi_array) / sizeof(uint16_t))
// TODO: Implement libinput profiles
// https://wayland.freedesktop.org/libinput/doc/latest/pointer-acceleration.html
@ -137,11 +150,18 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
}
// Update Timer to prevent accidental scrolls
if ((record->event.key.col == 2) && (record->event.key.row == 0)) {
if ((record->event.key.col == 1) && (record->event.key.row == 0)) {
lastMidClick = timer_read();
is_scroll_clicked = record->event.pressed;
}
if (!process_record_user(keycode, record)) { return false; }
if (keycode == DPI_CONFIG && record->event.pressed) {
keyboard_config.dpi_config = (keyboard_config.dpi_config + 1) % DPI_OPTION_SIZE;
eeconfig_update_kb(keyboard_config.raw);
pmw_set_cpi(dpi_array[keyboard_config.dpi_config]);
}
/* If Mousekeys is disabled, then use handle the mouse button
* keycodes. This makes things simpler, and allows usage of
* the keycodes in a consistent manner. But only do this if
@ -174,10 +194,11 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
currentReport.buttons &= ~MOUSE_BTN5;
}
pointing_device_set_report(currentReport);
pointing_device_send();
}
#endif
return process_record_user(keycode, record);
return true;
}
// Hardware Setup
@ -190,10 +211,6 @@ void keyboard_pre_init_kb(void) {
setPinInput(OPT_ENC1);
setPinInput(OPT_ENC2);
// This is the debug LED.
setPinOutput(F7);
writePin(F7, debug_enable);
/* Ground all output pins connected to ground. This provides additional
* pathways to ground. If you're messing with this, know this: driving ANY
* of these pins high will cause a short. On the MCU. Ka-blooey.
@ -206,6 +223,13 @@ void keyboard_pre_init_kb(void) {
writePinLow(unused_pins[i]);
}
#endif
// This is the debug LED.
#if defined(DEBUG_LED_PIN)
setPinOutput(DEBUG_LED_PIN);
writePin(DEBUG_LED_PIN, debug_enable);
#endif
keyboard_pre_init_user();
}
@ -235,3 +259,24 @@ void pointing_device_task(void) {
pointing_device_send();
}
}
void eeconfig_init_kb(void) {
keyboard_config.dpi_config = PLOOPY_DPI_DEFAULT;
eeconfig_update_kb(keyboard_config.raw);
}
void matrix_init_kb(void) {
// is safe to just read DPI setting since matrix init
// comes before pointing device init.
keyboard_config.raw = eeconfig_read_kb();
if (keyboard_config.dpi_config > DPI_OPTION_SIZE) {
eeconfig_init_kb();
}
matrix_init_user();
}
void keyboard_post_init_kb(void) {
pmw_set_cpi(dpi_array[keyboard_config.dpi_config]);
keyboard_post_init_user();
}