Skip to content

Commit

Permalink
Add Ploopyco functions for host state control (qmk#23953)
Browse files Browse the repository at this point in the history
  • Loading branch information
t4corun authored and ilham-agustiawan committed Nov 30, 2024
1 parent d48501c commit 098b6e0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
16 changes: 12 additions & 4 deletions keyboards/ploopyco/ploopyco.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@ void encoder_driver_task(void) {
}
#endif

void toggle_drag_scroll(void) {
is_drag_scroll ^= 1;
}

void cycle_dpi(void) {
keyboard_config.dpi_config = (keyboard_config.dpi_config + 1) % DPI_OPTION_SIZE;
eeconfig_update_kb(keyboard_config.raw);
pointing_device_set_cpi(dpi_array[keyboard_config.dpi_config]);
}

report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) {
if (is_drag_scroll) {
scroll_accumulated_h += (float)mouse_report.x / PLOOPY_DRAGSCROLL_DIVISOR_H;
Expand Down Expand Up @@ -174,17 +184,15 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
}

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);
pointing_device_set_cpi(dpi_array[keyboard_config.dpi_config]);
cycle_dpi();
}

if (keycode == DRAG_SCROLL) {
#ifdef PLOOPY_DRAGSCROLL_MOMENTARY
is_drag_scroll = record->event.pressed;
#else
if (record->event.pressed) {
is_drag_scroll ^= 1;
toggle_drag_scroll();
}
#endif
}
Expand Down
2 changes: 2 additions & 0 deletions keyboards/ploopyco/ploopyco.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ enum ploopy_keycodes {

bool encoder_update_user(uint8_t index, bool clockwise);
bool encoder_update_kb(uint8_t index, bool clockwise);
void toggle_drag_scroll(void);
void cycle_dpi(void);
10 changes: 5 additions & 5 deletions keyboards/ploopyco/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
# Customizing your PloopyCo Device

There are a number of behavioral settings that you can use to help customize your experience
| | | |
|---------------------------------|-------------------|-----------------------------------------------------------|
| `PLOOPY_IGNORE_SCROLL_CLICK` | *__not_defined__* | Ignores scroll wheel if it is pressed down. |
| `PLOOPY_SCROLL_DEBOUNCE` | `5` | Number of milliseconds between scroll events. |
| `PLOOPY_SCROLL_BUTTON_DEBOUNCE` | `100` | Time to ignore scroll events after pressing scroll wheel. |
|Define |Default Value|Description |
|-------------------------------|-------------|---------------------------------------------------------|
|`PLOOPY_IGNORE_SCROLL_CLICK` |*Not defined*|Ignores scroll wheel if it is pressed down. |
|`PLOOPY_SCROLL_DEBOUNCE` |`5` |Number of milliseconds between scroll events. |
|`PLOOPY_SCROLL_BUTTON_DEBOUNCE`|`100` |Time to ignore scroll events after pressing scroll wheel.|

## DPI

Expand Down

0 comments on commit 098b6e0

Please sign in to comment.