summaryrefslogtreecommitdiff
path: root/keyboards/ploopyco/trackball_mini
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2024-02-18 21:17:15 +1100
committerGitHub <noreply@github.com>2024-02-18 21:17:15 +1100
commit9d9cdaaa2d035787b0b50c26f2975695fdbc16f4 (patch)
tree1a9f5d16ffc0e3bd27bc14791c25405a79ccd069 /keyboards/ploopyco/trackball_mini
parent2eb9ff8efd1df2c98724481c71c8ab8a5b62e31e (diff)
Add encoder abstraction. (#21548)
Diffstat (limited to 'keyboards/ploopyco/trackball_mini')
-rw-r--r--keyboards/ploopyco/trackball_mini/config.h3
-rw-r--r--keyboards/ploopyco/trackball_mini/info.json6
-rw-r--r--keyboards/ploopyco/trackball_mini/rules.mk3
-rw-r--r--keyboards/ploopyco/trackball_mini/trackball_mini.c20
4 files changed, 18 insertions, 14 deletions
diff --git a/keyboards/ploopyco/trackball_mini/config.h b/keyboards/ploopyco/trackball_mini/config.h
index 789deb5a5f..6b92563fa9 100644
--- a/keyboards/ploopyco/trackball_mini/config.h
+++ b/keyboards/ploopyco/trackball_mini/config.h
@@ -32,3 +32,6 @@
#define ADNS5050_CS_PIN B4
#define POINTING_DEVICE_ROTATION_270
+
+/* Custom encoder needs to specify just how many encoders we have */
+#define NUM_ENCODERS 1
diff --git a/keyboards/ploopyco/trackball_mini/info.json b/keyboards/ploopyco/trackball_mini/info.json
index 301c8d18ec..0e7b12d20d 100644
--- a/keyboards/ploopyco/trackball_mini/info.json
+++ b/keyboards/ploopyco/trackball_mini/info.json
@@ -14,6 +14,12 @@
},
"processor": "atmega32u4",
"bootloader": "atmel-dfu",
+ "features": {
+ "encoder": true
+ },
+ "encoder": {
+ "driver": "custom"
+ },
"layouts": {
"LAYOUT": {
"layout": [
diff --git a/keyboards/ploopyco/trackball_mini/rules.mk b/keyboards/ploopyco/trackball_mini/rules.mk
index bcede0676c..d2bacc3974 100644
--- a/keyboards/ploopyco/trackball_mini/rules.mk
+++ b/keyboards/ploopyco/trackball_mini/rules.mk
@@ -13,9 +13,6 @@ POINTING_DEVICE_ENABLE = yes
POINTING_DEVICE_DRIVER = adns5050
MOUSEKEY_ENABLE = yes # Mouse keys
-ENCODER_ENABLE := no
-OPTS_DEF += -DENCODER_ENABLE
-
ANALOG_DRIVER_REQUIRED = yes
SRC += opt_encoder.c
diff --git a/keyboards/ploopyco/trackball_mini/trackball_mini.c b/keyboards/ploopyco/trackball_mini/trackball_mini.c
index 8bc0ab99c2..8517a54e70 100644
--- a/keyboards/ploopyco/trackball_mini/trackball_mini.c
+++ b/keyboards/ploopyco/trackball_mini/trackball_mini.c
@@ -74,8 +74,6 @@ uint8_t OptLowPin = OPT_ENC1;
bool debug_encoder = false;
bool is_drag_scroll = false;
-__attribute__((weak)) bool encoder_update_user(uint8_t index, bool clockwise) { return true; }
-
bool encoder_update_kb(uint8_t index, bool clockwise) {
if (!encoder_update_user(index, clockwise)) {
return false;
@@ -91,7 +89,14 @@ bool encoder_update_kb(uint8_t index, bool clockwise) {
return true;
}
-void process_wheel(void) {
+void encoder_driver_init(void) {
+ setPinInput(OPT_ENC1);
+ setPinInput(OPT_ENC2);
+
+ opt_encoder_init();
+}
+
+void encoder_driver_task(void) {
uint16_t p1 = adc_read(OPT_ENC1_MUX);
uint16_t p2 = adc_read(OPT_ENC2_MUX);
@@ -113,21 +118,17 @@ void process_wheel(void) {
}
if (dir == 0) return;
- encoder_update_kb(0, dir > 0);
+ encoder_queue_event(0, dir == 1);
lastScroll = timer_read();
}
void pointing_device_init_kb(void) {
- opt_encoder_init();
-
// set the DPI.
pointing_device_set_cpi(dpi_array[keyboard_config.dpi_config]);
}
report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) {
- process_wheel();
-
if (is_drag_scroll) {
mouse_report.h = mouse_report.x;
#ifdef PLOOPY_DRAGSCROLL_INVERT
@@ -180,9 +181,6 @@ void keyboard_pre_init_kb(void) {
// debug_mouse = true;
// debug_encoder = true;
- setPinInput(OPT_ENC1);
- setPinInput(OPT_ENC2);
-
/* 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.