summaryrefslogtreecommitdiff
path: root/keyboards/ploopyco
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/ploopyco')
-rw-r--r--keyboards/ploopyco/mouse/config.h13
-rw-r--r--keyboards/ploopyco/mouse/info.json8
-rw-r--r--keyboards/ploopyco/mouse/keymaps/drag_scroll/keymap.c2
-rw-r--r--keyboards/ploopyco/mouse/keymaps/drashna/config.h2
-rw-r--r--keyboards/ploopyco/mouse/keymaps/drashna/keymap.c19
-rw-r--r--keyboards/ploopyco/mouse/keymaps/drashna/rules.mk3
-rw-r--r--keyboards/ploopyco/mouse/mouse.c6
-rw-r--r--keyboards/ploopyco/opt_encoder.c11
-rw-r--r--keyboards/ploopyco/opt_encoder.h42
-rw-r--r--keyboards/ploopyco/opt_encoder_simple.c147
-rw-r--r--keyboards/ploopyco/trackball/config.h10
-rw-r--r--keyboards/ploopyco/trackball/info.json9
-rw-r--r--keyboards/ploopyco/trackball/rev1/config.h2
-rw-r--r--keyboards/ploopyco/trackball/rev1_005/config.h2
-rw-r--r--keyboards/ploopyco/trackball/trackball.c11
-rw-r--r--keyboards/ploopyco/trackball_mini/config.h6
-rw-r--r--keyboards/ploopyco/trackball_mini/info.json9
-rw-r--r--keyboards/ploopyco/trackball_mini/rev1_001/config.h2
-rw-r--r--keyboards/ploopyco/trackball_mini/rev1_002/config.h2
-rw-r--r--keyboards/ploopyco/trackball_mini/trackball_mini.c8
-rw-r--r--keyboards/ploopyco/trackball_nano/config.h6
-rw-r--r--keyboards/ploopyco/trackball_nano/info.json9
-rw-r--r--keyboards/ploopyco/trackball_nano/keymaps/lkbm/keymap.c167
-rw-r--r--keyboards/ploopyco/trackball_nano/keymaps/lkbm/readme.md2
-rw-r--r--keyboards/ploopyco/trackball_nano/keymaps/lkbm/rules.mk1
-rw-r--r--keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c4
-rw-r--r--keyboards/ploopyco/trackball_nano/rev1_001/config.h2
-rw-r--r--keyboards/ploopyco/trackball_nano/trackball_nano.c12
-rw-r--r--keyboards/ploopyco/trackball_nano/trackball_nano.h2
29 files changed, 415 insertions, 104 deletions
diff --git a/keyboards/ploopyco/mouse/config.h b/keyboards/ploopyco/mouse/config.h
index 98fc81bb05..6a6713557b 100644
--- a/keyboards/ploopyco/mouse/config.h
+++ b/keyboards/ploopyco/mouse/config.h
@@ -20,13 +20,6 @@
#include "config_common.h"
-/* USB Device descriptor parameter */
-#define VENDOR_ID 0x5043
-#define PRODUCT_ID 0x4D6F
-#define DEVICE_VER 0x0001
-#define MANUFACTURER PloopyCo
-#define PRODUCT Mouse
-
/* key matrix size */
#define MATRIX_ROWS 1
#define MATRIX_COLS 8
@@ -48,7 +41,7 @@
// These pins are not broken out, and cannot be used normally.
// They are set as output and pulled high, by default
-#define UNUSED_PINS \
+#define UNUSABLE_PINS \
{ B4, D6, F1, F5, F6, F7 }
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
@@ -77,5 +70,5 @@
// #define DEBUG_LED_PIN F7
-/* PMW3360 Settings */
-#define PMW3360_CS_PIN B0
+/* PMW33XX Settings */
+#define PMW33XX_CS_PIN B0
diff --git a/keyboards/ploopyco/mouse/info.json b/keyboards/ploopyco/mouse/info.json
index 593583176d..f672336c25 100644
--- a/keyboards/ploopyco/mouse/info.json
+++ b/keyboards/ploopyco/mouse/info.json
@@ -1,7 +1,13 @@
{
- "keyboard_name": "PloopyCo Mouse",
+ "keyboard_name": "Mouse",
+ "manufacturer": "PloopyCo",
"url": "www.ploopy.co",
"maintainer": "drashna",
+ "usb": {
+ "vid": "0x5043",
+ "pid": "0x4D6F",
+ "device_version": "0.0.1"
+ },
"layouts": {
"LAYOUT": {
"layout": [
diff --git a/keyboards/ploopyco/mouse/keymaps/drag_scroll/keymap.c b/keyboards/ploopyco/mouse/keymaps/drag_scroll/keymap.c
index da328fff04..a072dfceca 100644
--- a/keyboards/ploopyco/mouse/keymaps/drag_scroll/keymap.c
+++ b/keyboards/ploopyco/mouse/keymaps/drag_scroll/keymap.c
@@ -22,6 +22,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT(/* Base */
C(KC_C), KC_BTN1, KC_BTN3, LT(1, KC_BTN2), C(KC_V), KC_BTN4, KC_BTN5, DPI_CONFIG),
[1] = LAYOUT(/* Base */
- _______, DRAG_SCROLL, _______, _______, _______, _______, _______, RESET),
+ _______, DRAG_SCROLL, _______, _______, _______, _______, _______, QK_BOOT),
};
diff --git a/keyboards/ploopyco/mouse/keymaps/drashna/config.h b/keyboards/ploopyco/mouse/keymaps/drashna/config.h
index 9aa9a40769..1dc1b7695f 100644
--- a/keyboards/ploopyco/mouse/keymaps/drashna/config.h
+++ b/keyboards/ploopyco/mouse/keymaps/drashna/config.h
@@ -28,4 +28,4 @@
#define RGBLIGHT_EFFECT_TWINKLE
#define RGBLIGHT_SLEEP
-#define MOUSE_EXT_REPORT
+#define MOUSE_EXTENDED_REPORT
diff --git a/keyboards/ploopyco/mouse/keymaps/drashna/keymap.c b/keyboards/ploopyco/mouse/keymaps/drashna/keymap.c
index ee0f653dee..056a1f7903 100644
--- a/keyboards/ploopyco/mouse/keymaps/drashna/keymap.c
+++ b/keyboards/ploopyco/mouse/keymaps/drashna/keymap.c
@@ -19,20 +19,23 @@
// safe range starts at `PLOOPY_SAFE_RANGE` instead.
+// clang-format off
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
- [0] = LAYOUT(/* Base */
+ [0] = LAYOUT(
C(KC_C), KC_BTN1, KC_BTN3, KC_BTN2, MO(1), KC_BTN4, KC_BTN5, DPI_CONFIG),
- [1] = LAYOUT(/* Base */
+ [1] = LAYOUT(
RGB_HUI, RGB_MOD, RGB_TOG, RGB_RMOD, MO(1), KC_VOLU, KC_VOLD, QK_BOOT)
-
};
+// clang-format on
+#ifdef RGBLIGHT_ENABLE
void eeconkfig_init_user(void) {
rgblight_enable();
-#ifdef RGBLIGHT_EFFECT_TWINKLE
- rgblight_mode(RGBLIGHT_MODE_TWINKLE+5);
-#else
- rgblight_mode(RGBLIGHT_MODE_BREATHING+5);
-#endif
+# ifdef RGBLIGHT_EFFECT_TWINKLE
+ rgblight_mode(RGBLIGHT_MODE_TWINKLE + 5);
+# else
+ rgblight_mode(RGBLIGHT_MODE_BREATHING + 5);
+# endif
rgblight_sethsv(HSV_MAGENTA);
}
+#endif
diff --git a/keyboards/ploopyco/mouse/keymaps/drashna/rules.mk b/keyboards/ploopyco/mouse/keymaps/drashna/rules.mk
index 655dbfdfa0..bd3927a4b1 100644
--- a/keyboards/ploopyco/mouse/keymaps/drashna/rules.mk
+++ b/keyboards/ploopyco/mouse/keymaps/drashna/rules.mk
@@ -1,5 +1,6 @@
USER_NAME := not_drashna
+BOOTLOADER = qmk-hid
RGBLIGHT_ENABLE = yes
CONSOLE_ENABLE = no
-LTO_ENABLE = yes
+LTO_ENABLE = yes
diff --git a/keyboards/ploopyco/mouse/mouse.c b/keyboards/ploopyco/mouse/mouse.c
index 25ebd1ee2d..19bc17738e 100644
--- a/keyboards/ploopyco/mouse/mouse.c
+++ b/keyboards/ploopyco/mouse/mouse.c
@@ -111,7 +111,7 @@ void process_wheel(void) {
int dir = opt_encoder_handler(p1, p2);
if (dir == 0) return;
- encoder_update_kb(0, dir == 1);
+ encoder_update_kb(0, dir > 0);
}
report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) {
@@ -199,8 +199,8 @@ void keyboard_pre_init_kb(void) {
* 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.
*/
-#ifdef UNUSED_PINS
- const pin_t unused_pins[] = UNUSED_PINS;
+#ifdef UNUSABLE_PINS
+ const pin_t unused_pins[] = UNUSABLE_PINS;
for (uint8_t i = 0; i < (sizeof(unused_pins) / sizeof(pin_t)); i++) {
setPinOutput(unused_pins[i]);
diff --git a/keyboards/ploopyco/opt_encoder.c b/keyboards/ploopyco/opt_encoder.c
index 8698351c26..226db0a809 100644
--- a/keyboards/ploopyco/opt_encoder.c
+++ b/keyboards/ploopyco/opt_encoder.c
@@ -15,6 +15,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "opt_encoder.h"
+#include <stdbool.h>
+
+enum State { HIHI, HILO, LOLO, LOHI };
enum State state;
@@ -44,6 +47,12 @@ int arHighA[SCROLLER_AR_SIZE];
int arLowB[SCROLLER_AR_SIZE];
int arHighB[SCROLLER_AR_SIZE];
+void calculateThresholdA(int curA);
+void calculateThresholdB(int curB);
+int calculateThreshold(int cur, int* low, int* high, bool* cLow, bool* cHigh, int arLow[], int arHigh[], int* lowIndex, int* highIndex, bool* lowOverflow, bool* highOverflow);
+int thresholdEquation(int lo, int hi);
+void incrementIndex(int* index, bool* ovflw);
+
/* Setup function for the scroll wheel. Initializes
the relevant variables. */
void opt_encoder_init(void) {
@@ -70,7 +79,7 @@ void opt_encoder_init(void) {
scrollThresholdB = 0;
}
-int opt_encoder_handler(int curA, int curB) {
+int8_t opt_encoder_handler(uint16_t curA, uint16_t curB) {
if (lowOverflowA == false || highOverflowA == false) calculateThresholdA(curA);
if (lowOverflowB == false || highOverflowB == false) calculateThresholdB(curB);
diff --git a/keyboards/ploopyco/opt_encoder.h b/keyboards/ploopyco/opt_encoder.h
index 17c25bc86f..8e5159f91c 100644
--- a/keyboards/ploopyco/opt_encoder.h
+++ b/keyboards/ploopyco/opt_encoder.h
@@ -16,7 +16,7 @@
*/
#pragma once
-#include <stdbool.h>
+#include <stdint.h>
#ifndef SCROLLER_AR_SIZE
# define SCROLLER_AR_SIZE 31
@@ -26,41 +26,7 @@
# define SCROLL_THRESH_RANGE_LIM 10
#endif
-enum State { HIHI, HILO, LOLO, LOHI };
-
-extern enum State state;
-
-/* Variables used for scroll wheel functionality. */
-extern bool lohif;
-extern bool hilof;
-extern int lowA;
-extern int highA;
-extern bool cLowA;
-extern bool cHighA;
-extern int lowIndexA;
-extern int highIndexA;
-extern bool lowOverflowA;
-extern bool highOverflowA;
-extern int lowB;
-extern int highB;
-extern bool cLowB;
-extern bool cHighB;
-extern int lowIndexB;
-extern int highIndexB;
-extern bool lowOverflowB;
-extern bool highOverflowB;
-extern int scrollThresholdA;
-extern int scrollThresholdB;
-extern int arLowA[SCROLLER_AR_SIZE];
-extern int arHighA[SCROLLER_AR_SIZE];
-extern int arLowB[SCROLLER_AR_SIZE];
-extern int arHighB[SCROLLER_AR_SIZE];
-
-void calculateThresholdA(int curA);
-void calculateThresholdB(int curB);
-int calculateThreshold(int cur, int* low, int* high, bool* cLow, bool* cHigh, int arLow[], int arHigh[], int* lowIndex, int* highIndex, bool* lowOverflow, bool* highOverflow);
-int thresholdEquation(int lo, int hi);
-void incrementIndex(int* index, bool* ovflw);
-
void opt_encoder_init(void);
-int opt_encoder_handler(int curA, int curB);
+/* Return the rotation direction, positive value means clockwise, negative value
+ * means counter-clockwise */
+int8_t opt_encoder_handler(uint16_t curA, uint16_t curB);
diff --git a/keyboards/ploopyco/opt_encoder_simple.c b/keyboards/ploopyco/opt_encoder_simple.c
new file mode 100644
index 0000000000..c30deb9ca4
--- /dev/null
+++ b/keyboards/ploopyco/opt_encoder_simple.c
@@ -0,0 +1,147 @@
+/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ * Copyright 2020 Ploopy Corporation
+ * Copyright 2022 Leorize <leorize+oss@disroot.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include "opt_encoder.h"
+#include "util.h"
+#include <stdbool.h>
+#include <stdint.h>
+
+/* An alternative implementation for interpreting the encoder status:
+ *
+ * From graphing the phototransistor voltages, the peak and baseline appears to
+ * be rather stable. Therefore there is no need to average them out, and instead
+ * just simply store the min and max voltages of each phototransistor.
+ *
+ * This algorithm then distinguish between high and low states by employing an
+ * approach similar to a Schmitt trigger: a low and high threshold is defined
+ * for each phototransistor based on their min and max voltages.
+ *
+ * Currently, the thresholds are:
+ *
+ * * High threshold: The upper quarter of the voltage range.
+ * * Low threshold: The lower quarter of the voltage range.
+ *
+ * these thresholds are defined for each phototransistor.
+ *
+ * For a state to cross from high -> low, it must fall below the low threshold.
+ * Similarly, to cross from low -> high, the voltage must be higher than the
+ * high threshold.
+ *
+ * Having two distinct thresholds filters out the bulk of noise from the
+ * phototransistors.
+ *
+ * For converting the resulting high and low signals into rotation, a simple
+ * quadrature decoder is used.
+ */
+
+/* The minimum value returned by the ADC */
+#define ENCODER_MIN 0
+/* The maximum value returned by the ADC */
+#define ENCODER_MAX 1023
+
+/* Utilities for composing the encoder state */
+#define MAKE_STATE(HI_A, HI_B) (((uint8_t)((HI_A) & 0x1) << 1) | ((uint8_t)((HI_B) & 0x1)))
+#define STATE_A(st) ((st & 0x2) >> 1)
+#define STATE_B(st) (st & 0x1)
+#define LOLO MAKE_STATE(0, 0)
+#define HILO MAKE_STATE(1, 0)
+#define LOHI MAKE_STATE(0, 1)
+
+typedef enum {
+ CALIBRATION, /* Recalibrate encoder state by waiting for a 01 -> 00 or 10 -> 00 transistion */
+ DECODE /* Translate changes in the encoder state into movement */
+} encoder_state_t;
+
+static encoder_state_t mode;
+
+static uint8_t lastState;
+
+static uint16_t lowA;
+static uint16_t highA;
+static uint16_t lowB;
+static uint16_t highB;
+
+#define MOVE_UP 1
+#define MOVE_DOWN -1
+#define MOVE_NONE 0
+#define MOVE_ERR 0x7F
+static const uint8_t movement[] = {
+ // 00 -> 00, 01, 10, 11
+ MOVE_NONE, MOVE_DOWN, MOVE_UP, MOVE_ERR,
+ // 01 -> 00, 01, 10, 11
+ MOVE_UP, MOVE_NONE, MOVE_ERR, MOVE_DOWN,
+ // 10 -> 00, 01, 10, 11
+ MOVE_DOWN, MOVE_ERR, MOVE_NONE, MOVE_UP,
+ // 11 -> 00, 01, 10, 11
+ MOVE_ERR, MOVE_UP, MOVE_DOWN, MOVE_NONE
+};
+
+void opt_encoder_init(void) {
+ mode = CALIBRATION;
+ lastState = 0;
+
+ lowA = ENCODER_MAX;
+ lowB = ENCODER_MAX;
+ highA = ENCODER_MIN;
+ highB = ENCODER_MIN;
+}
+
+int8_t opt_encoder_handler(uint16_t encA, uint16_t encB) {
+ int8_t result = 0;
+
+ highA = MAX(encA, highA);
+ lowA = MIN(encA, lowA);
+ highB = MAX(encB, highB);
+ lowB = MIN(encB, lowB);
+
+ /* Only compute the thresholds after a large enough range is established */
+ if (highA - lowA > SCROLL_THRESH_RANGE_LIM && highB - lowB > SCROLL_THRESH_RANGE_LIM) {
+ const int16_t lowThresholdA = (highA + lowA) / 4;
+ const int16_t highThresholdA = (highA + lowA) - lowThresholdA;
+ const int16_t lowThresholdB = (highB + lowB) / 4;
+ const int16_t highThresholdB = (highB + lowB) - lowThresholdB;
+
+ uint8_t state = MAKE_STATE(
+ STATE_A(lastState) ? encA > lowThresholdA : encA > highThresholdA,
+ STATE_B(lastState) ? encB > lowThresholdB : encB > highThresholdB
+ );
+
+ switch (mode) {
+ case CALIBRATION:
+ if ((lastState == HILO && state == LOLO)
+ || (lastState == LOHI && state == LOLO))
+ mode = DECODE;
+ else
+ mode = CALIBRATION;
+ break;
+
+ case DECODE:
+ result = movement[lastState * 4 + state];
+ /* If we detect a state change that should not be possible,
+ * then the wheel might have moved too fast and we need to
+ * recalibrate the encoder position. */
+ mode = result == MOVE_ERR ? CALIBRATION : mode;
+ result = result == MOVE_ERR ? MOVE_NONE : result;
+
+ break;
+ }
+
+ lastState = state;
+ }
+
+ return result;
+}
diff --git a/keyboards/ploopyco/trackball/config.h b/keyboards/ploopyco/trackball/config.h
index dd068e4838..54a301b0d2 100644
--- a/keyboards/ploopyco/trackball/config.h
+++ b/keyboards/ploopyco/trackball/config.h
@@ -20,12 +20,6 @@
#include "config_common.h"
-/* USB Device descriptor parameter */
-#define VENDOR_ID 0x5043
-#define PRODUCT_ID 0x5442
-#define DEVICE_VER 0x0001
-#define PRODUCT Trackball
-
/* key matrix size */
#define MATRIX_ROWS 1
#define MATRIX_COLS 5
@@ -53,6 +47,6 @@
// If board has a debug LED, you can enable it by defining this
// #define DEBUG_LED_PIN F7
-/* PMW3360 Settings */
-#define PMW3360_CS_PIN B0
+/* PMW33XX Settings */
+#define PMW33XX_CS_PIN B0
#define POINTING_DEVICE_INVERT_Y
diff --git a/keyboards/ploopyco/trackball/info.json b/keyboards/ploopyco/trackball/info.json
index d144261c96..feb458e1c5 100644
--- a/keyboards/ploopyco/trackball/info.json
+++ b/keyboards/ploopyco/trackball/info.json
@@ -1,8 +1,13 @@
{
- "keyboard_name": "PloopyCo Trackball",
+ "keyboard_name": "Trackball",
+ "manufacturer": "PloopyCo",
"url": "www.ploopy.co",
"maintainer": "drashna",
- "manufacturer": "Ploopy Corporation",
+ "usb": {
+ "vid": "0x5043",
+ "pid": "0x5442",
+ "device_version": "0.0.1"
+ },
"layouts": {
"LAYOUT": {
"layout": [
diff --git a/keyboards/ploopyco/trackball/rev1/config.h b/keyboards/ploopyco/trackball/rev1/config.h
index 2908f09602..3db085baf2 100644
--- a/keyboards/ploopyco/trackball/rev1/config.h
+++ b/keyboards/ploopyco/trackball/rev1/config.h
@@ -35,7 +35,7 @@
// These pins are not broken out, and cannot be used normally.
// They are set as output and pulled high, by default
-#define UNUSED_PINS \
+#define UNUSABLE_PINS \
{ D1, D3, B4, B6, B7, D6, C7, F6, F5, F3, F7 }
// If board has a debug LED, you can enable it by defining this
diff --git a/keyboards/ploopyco/trackball/rev1_005/config.h b/keyboards/ploopyco/trackball/rev1_005/config.h
index 83e70181de..321e3004d1 100644
--- a/keyboards/ploopyco/trackball/rev1_005/config.h
+++ b/keyboards/ploopyco/trackball/rev1_005/config.h
@@ -35,7 +35,7 @@
// These pins are not broken out, and cannot be used normally.
// They are set as output and pulled high, by default
-#define UNUSED_PINS \
+#define UNUSABLE_PINS \
{ D1, D3, B4, B7, D6, C7, F6, F5, F3, F7 }
// If board has a debug LED, you can enable it by defining this
diff --git a/keyboards/ploopyco/trackball/trackball.c b/keyboards/ploopyco/trackball/trackball.c
index f819958734..786b40f9e8 100644
--- a/keyboards/ploopyco/trackball/trackball.c
+++ b/keyboards/ploopyco/trackball/trackball.c
@@ -112,14 +112,19 @@ void process_wheel(void) {
int dir = opt_encoder_handler(p1, p2);
if (dir == 0) return;
- encoder_update_kb(0, dir == 1);
+ encoder_update_kb(0, dir > 0);
}
report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) {
process_wheel();
if (is_drag_scroll) {
+#ifdef PLOOPY_DRAGSCROLL_H_INVERT
+ // Invert horizontal scroll direction
+ mouse_report.h = -mouse_report.x;
+#else
mouse_report.h = mouse_report.x;
+#endif
#ifdef PLOOPY_DRAGSCROLL_INVERT
// Invert vertical scroll direction
mouse_report.v = -mouse_report.y;
@@ -199,8 +204,8 @@ void keyboard_pre_init_kb(void) {
* 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.
*/
-#ifdef UNUSED_PINS
- const pin_t unused_pins[] = UNUSED_PINS;
+#ifdef UNUSABLE_PINS
+ const pin_t unused_pins[] = UNUSABLE_PINS;
for (uint8_t i = 0; i < (sizeof(unused_pins) / sizeof(pin_t)); i++) {
setPinOutput(unused_pins[i]);
diff --git a/keyboards/ploopyco/trackball_mini/config.h b/keyboards/ploopyco/trackball_mini/config.h
index 9c53f1f501..bf7570f364 100644
--- a/keyboards/ploopyco/trackball_mini/config.h
+++ b/keyboards/ploopyco/trackball_mini/config.h
@@ -21,12 +21,6 @@
#include "config_common.h"
-/* USB Device descriptor parameter */
-#define VENDOR_ID 0x5043
-#define PRODUCT_ID 0x1EAB
-#define DEVICE_VER 0x0001
-#define PRODUCT Trackball Mini
-
/* key matrix size */
#define MATRIX_ROWS 1
#define MATRIX_COLS 5
diff --git a/keyboards/ploopyco/trackball_mini/info.json b/keyboards/ploopyco/trackball_mini/info.json
index 67d62cc2b9..f465a7a21e 100644
--- a/keyboards/ploopyco/trackball_mini/info.json
+++ b/keyboards/ploopyco/trackball_mini/info.json
@@ -1,8 +1,13 @@
{
- "keyboard_name": "Ploopy Trackball Mini",
+ "keyboard_name": "Trackball Mini",
+ "manufacturer": "PloopyCo",
"url": "www.ploopy.co",
"maintainer": "ploopyco",
- "manufacturer": "Ploopy Corporation",
+ "usb": {
+ "vid": "0x5043",
+ "pid": "0x1EAB",
+ "device_version": "0.0.1"
+ },
"layouts": {
"LAYOUT": {
"layout": [
diff --git a/keyboards/ploopyco/trackball_mini/rev1_001/config.h b/keyboards/ploopyco/trackball_mini/rev1_001/config.h
index 06720b8fdf..d4c9d23bec 100644
--- a/keyboards/ploopyco/trackball_mini/rev1_001/config.h
+++ b/keyboards/ploopyco/trackball_mini/rev1_001/config.h
@@ -36,5 +36,5 @@
// These pins are not broken out, and cannot be used normally.
// They are set as output and pulled high, by default
-#define UNUSED_PINS \
+#define UNUSABLE_PINS \
{ B5, C7, D0, D1, D3, D5, D6, F1, F3, F5, F6, F7 }
diff --git a/keyboards/ploopyco/trackball_mini/rev1_002/config.h b/keyboards/ploopyco/trackball_mini/rev1_002/config.h
index 06720b8fdf..d4c9d23bec 100644
--- a/keyboards/ploopyco/trackball_mini/rev1_002/config.h
+++ b/keyboards/ploopyco/trackball_mini/rev1_002/config.h
@@ -36,5 +36,5 @@
// These pins are not broken out, and cannot be used normally.
// They are set as output and pulled high, by default
-#define UNUSED_PINS \
+#define UNUSABLE_PINS \
{ B5, C7, D0, D1, D3, D5, D6, F1, F3, F5, F6, F7 }
diff --git a/keyboards/ploopyco/trackball_mini/trackball_mini.c b/keyboards/ploopyco/trackball_mini/trackball_mini.c
index e4b4a47c2b..df13912af4 100644
--- a/keyboards/ploopyco/trackball_mini/trackball_mini.c
+++ b/keyboards/ploopyco/trackball_mini/trackball_mini.c
@@ -111,10 +111,10 @@ void process_wheel(void) {
if (debug_encoder) dprintf("OPT1: %d, OPT2: %d\n", p1, p2);
- uint8_t dir = opt_encoder_handler(p1, p2);
+ int8_t dir = opt_encoder_handler(p1, p2);
if (dir == 0) return;
- encoder_update_kb(0, dir == 1);
+ encoder_update_kb(0, dir > 0);
}
void pointing_device_init_kb(void) {
@@ -200,8 +200,8 @@ void keyboard_pre_init_kb(void) {
* 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.
*/
-#ifdef UNUSED_PINS
- const pin_t unused_pins[] = UNUSED_PINS;
+#ifdef UNUSABLE_PINS
+ const pin_t unused_pins[] = UNUSABLE_PINS;
for (uint8_t i = 0; i < (sizeof(unused_pins) / sizeof(pin_t)); i++) {
setPinOutput(unused_pins[i]);
diff --git a/keyboards/ploopyco/trackball_nano/config.h b/keyboards/ploopyco/trackball_nano/config.h
index 985ddc09ba..fb340a4ec3 100644
--- a/keyboards/ploopyco/trackball_nano/config.h
+++ b/keyboards/ploopyco/trackball_nano/config.h
@@ -21,12 +21,6 @@
#include "config_common.h"
-/* USB Device descriptor parameter */
-#define VENDOR_ID 0x5043
-#define PRODUCT_ID 0x54A3
-#define DEVICE_VER 0x0001
-#define PRODUCT Trackball Nano
-
/* key matrix size */
#define MATRIX_ROWS 1
#define MATRIX_COLS 1
diff --git a/keyboards/ploopyco/trackball_nano/info.json b/keyboards/ploopyco/trackball_nano/info.json
index a788ce9eb1..cf9b78a4f3 100644
--- a/keyboards/ploopyco/trackball_nano/info.json
+++ b/keyboards/ploopyco/trackball_nano/info.json
@@ -1,8 +1,13 @@
{
- "keyboard_name": "Ploopy Trackball Nano",
+ "keyboard_name": "Trackball Nano",
+ "manufacturer": "PloopyCo",
"url": "www.ploopy.co",
"maintainer": "ploopyco",
- "manufacturer": "Ploopy Corporation",
+ "usb": {
+ "vid": "0x5043",
+ "pid": "0x54A3",
+ "device_version": "0.0.1"
+ },
"layouts": {
"LAYOUT": {
"layout": [
diff --git a/keyboards/ploopyco/trackball_nano/keymaps/lkbm/keymap.c b/keyboards/ploopyco/trackball_nano/keymaps/lkbm/keymap.c
new file mode 100644
index 0000000000..6c3a38d127
--- /dev/null
+++ b/keyboards/ploopyco/trackball_nano/keymaps/lkbm/keymap.c
@@ -0,0 +1,167 @@
+/* Copyright 2022 Aidan Gauland
+ * Copyright 2021 Colin Lam (Ploopy Corporation)
+ * Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
+ * Copyright 2019 Sunjun Kim
+ * Copyright 2019 Hiroyuki Okada
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include QMK_KEYBOARD_H
+#include "print.h"
+
+#define NUM_LOCK_BITMASK 0b01
+#define CAPS_LOCK_BITMASK 0b10
+
+// World record for fastest index finger tapping is 1092 taps per minute, which
+// is 55ms for a single tap.
+// https://recordsetter.com/world-record/index-finger-taps-minute/46066
+#define LED_CMD_TIMEOUT 25
+#define DELTA_X_THRESHOLD 60
+#define DELTA_Y_THRESHOLD 15
+
+typedef enum {
+ // You could theoretically define 0b00 and send it by having a macro send
+ // the second tap after LED_CMD_TIMEOUT has elapsed.
+ // CMD_EXTRA = 0b00,
+ TG_SCROLL = 0b01,
+ CYC_DPI = 0b10,
+ CMD_RESET = 0b11 // CMD_ prefix to avoid clash with QMK macro
+} led_cmd_t;
+
+// State
+static bool scroll_enabled = false;
+static bool num_lock_state = false;
+static bool caps_lock_state = false;
+static bool in_cmd_window = false;
+static int8_t delta_x = 0;
+static int8_t delta_y = 0;
+
+typedef struct {
+ led_cmd_t led_cmd;
+ uint8_t num_lock_count;
+ uint8_t caps_lock_count;
+} cmd_window_state_t;
+
+// Dummy
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {{{KC_NO}}};
+
+report_mouse_t pointing_device_task_user(report_mouse_t mouse_report) {
+ if (scroll_enabled) {
+ delta_x += mouse_report.x;
+ delta_y += mouse_report.y;
+
+ 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 > 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) {
+ num_lock_state = host_keyboard_led_state().num_lock;
+ caps_lock_state = host_keyboard_led_state().caps_lock;
+}
+
+uint32_t command_timeout(uint32_t trigger_time, void *cb_arg) {
+ cmd_window_state_t *cmd_window_state = (cmd_window_state_t *)cb_arg;
+# ifdef CONSOLE_ENABLE
+ uprintf("Received command 0b%02b (", cmd_window_state->led_cmd);
+# endif
+ switch (cmd_window_state->led_cmd) {
+ case TG_SCROLL:
+# ifdef CONSOLE_ENABLE
+ uprint("TG_SCROLL)\n");
+# endif
+ scroll_enabled = !scroll_enabled;
+ break;
+ case CYC_DPI:
+# ifdef CONSOLE_ENABLE
+ uprint("CYC_DPI)\n");
+# endif
+ cycle_dpi();
+ break;
+ case CMD_RESET:
+# ifdef CONSOLE_ENABLE
+ uprint("QK_BOOT)\n");
+# endif
+ reset_keyboard();
+ break;
+ default:
+# ifdef CONSOLE_ENABLE
+ uprint("unknown)\n");
+# endif
+ // Ignore unrecognised commands.
+ break;
+ }
+ cmd_window_state->led_cmd = 0;
+ cmd_window_state->num_lock_count = 0;
+ cmd_window_state->caps_lock_count = 0;
+ in_cmd_window = false;
+
+ return 0; // Don't repeat
+}
+
+bool led_update_user(led_t led_state) {
+ static cmd_window_state_t cmd_window_state = {
+ .led_cmd = 0b00,
+ .num_lock_count = 0,
+ .caps_lock_count = 0
+ };
+
+ // Start timer to end command window if we are not already in the middle of
+ // one.
+ if (!in_cmd_window) {
+ in_cmd_window = true;
+ defer_exec(LED_CMD_TIMEOUT, command_timeout, &cmd_window_state);
+ }
+
+ // Set num lock and caps lock bits when each is toggled on and off within
+ // the window.
+ if (led_state.num_lock != num_lock_state) {
+ cmd_window_state.num_lock_count++;
+
+ if (cmd_window_state.num_lock_count == 2) {
+ cmd_window_state.led_cmd |= NUM_LOCK_BITMASK;
+ cmd_window_state.num_lock_count = 0;
+ }
+ }
+
+ if (led_state.caps_lock != caps_lock_state) {
+ cmd_window_state.caps_lock_count++;
+
+ if (cmd_window_state.caps_lock_count == 2) {
+ cmd_window_state.led_cmd |= CAPS_LOCK_BITMASK;
+ cmd_window_state.caps_lock_count = 0;
+ }
+ }
+
+ // Keep our copy of the LED states in sync with the host.
+ num_lock_state = led_state.num_lock;
+ caps_lock_state = led_state.caps_lock;
+ return true;
+}
diff --git a/keyboards/ploopyco/trackball_nano/keymaps/lkbm/readme.md b/keyboards/ploopyco/trackball_nano/keymaps/lkbm/readme.md
new file mode 100644
index 0000000000..3b2f698e52
--- /dev/null
+++ b/keyboards/ploopyco/trackball_nano/keymaps/lkbm/readme.md
@@ -0,0 +1,2 @@
+# The keymap that takes commands as LED-Key BitMasks (lkbm)
+Based on [maddie](../maddie), this keymap lets you send a 2-bit command by having a macro on your keyboard tap `KC_NUM_LOCK` and `KC_CAPS_LOCK` on and off within a very short window (25ms by default) to represent bits 1 and 2 respectively. The keymap uses this to allow toggling between sending mouse-movement events and scrolling events; cycling DPI presets, and resetting to the bootloader, so you can reflash without having to unscrew your Ploopy Nano.
diff --git a/keyboards/ploopyco/trackball_nano/keymaps/lkbm/rules.mk b/keyboards/ploopyco/trackball_nano/keymaps/lkbm/rules.mk
new file mode 100644
index 0000000000..199bad85f3
--- /dev/null
+++ b/keyboards/ploopyco/trackball_nano/keymaps/lkbm/rules.mk
@@ -0,0 +1 @@
+DEFERRED_EXEC_ENABLE = yes
diff --git a/keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c b/keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c
index 14a7804cc2..5e9b3e8e19 100644
--- a/keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c
+++ b/keyboards/ploopyco/trackball_nano/keymaps/maddie/keymap.c
@@ -27,6 +27,10 @@
bool scroll_enabled = false;
bool lock_state = false;
+// State
+static int8_t delta_x = 0;
+static int8_t delta_y = 0;
+
// Dummy
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {{{ KC_NO }}};
diff --git a/keyboards/ploopyco/trackball_nano/rev1_001/config.h b/keyboards/ploopyco/trackball_nano/rev1_001/config.h
index 6d265d7233..3bde88487a 100644
--- a/keyboards/ploopyco/trackball_nano/rev1_001/config.h
+++ b/keyboards/ploopyco/trackball_nano/rev1_001/config.h
@@ -33,5 +33,5 @@
// These pins are not broken out, and cannot be used normally.
// They are set as output and pulled high, by default
-#define UNUSED_PINS \
+#define UNUSABLE_PINS \
{ B5, B6, C7, D0, D1, D2, D3, D4, D5, D6, D7, E6, F1, F3, F5, F6, F7 }
diff --git a/keyboards/ploopyco/trackball_nano/trackball_nano.c b/keyboards/ploopyco/trackball_nano/trackball_nano.c
index e208a728cb..eb1d8e10b0 100644
--- a/keyboards/ploopyco/trackball_nano/trackball_nano.c
+++ b/keyboards/ploopyco/trackball_nano/trackball_nano.c
@@ -52,6 +52,14 @@ keyboard_config_t keyboard_config;
uint16_t dpi_array[] = PLOOPY_DPI_OPTIONS;
#define DPI_OPTION_SIZE (sizeof(dpi_array) / sizeof(uint16_t))
+void cycle_dpi(void) {
+ keyboard_config.dpi_config = (keyboard_config.dpi_config + 1) % DPI_OPTION_SIZE;
+ pointing_device_set_cpi(dpi_array[keyboard_config.dpi_config]);
+#ifdef CONSOLE_ENABLE
+ uprintf("DPI is now %d\n", dpi_array[keyboard_config.dpi_config]);
+#endif
+}
+
// TODO: Implement libinput profiles
// https://wayland.freedesktop.org/libinput/doc/latest/pointer-acceleration.html
// Compile time accel selection
@@ -78,8 +86,8 @@ void keyboard_pre_init_kb(void) {
* 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.
*/
-#ifdef UNUSED_PINS
- const pin_t unused_pins[] = UNUSED_PINS;
+#ifdef UNUSABLE_PINS
+ const pin_t unused_pins[] = UNUSABLE_PINS;
for (uint8_t i = 0; i < (sizeof(unused_pins) / sizeof(pin_t)); i++) {
setPinOutput(unused_pins[i]);
diff --git a/keyboards/ploopyco/trackball_nano/trackball_nano.h b/keyboards/ploopyco/trackball_nano/trackball_nano.h
index 5f16e96c41..d971627fc6 100644
--- a/keyboards/ploopyco/trackball_nano/trackball_nano.h
+++ b/keyboards/ploopyco/trackball_nano/trackball_nano.h
@@ -36,3 +36,5 @@ enum ploopy_keycodes {
DPI_CONFIG = SAFE_RANGE,
PLOOPY_SAFE_RANGE,
};
+
+void cycle_dpi(void);