summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoruser <user@node5.net>2024-01-02 06:31:20 +0100
committeruser <user@node5.net>2024-01-02 06:31:20 +0100
commit8cd0c5a6628d2fe950e7c621a68c0461df7df60f (patch)
tree8bc74a59109273408fde43512ae8c0c8009b54cb
parent164a497463fc65be48454f1a3182a00219286b90 (diff)
trackball change color to indicate currently selected cpi
-rw-r--r--keyboards/handwired/node5_1/keymaps/default/keymap.c54
1 files changed, 37 insertions, 17 deletions
diff --git a/keyboards/handwired/node5_1/keymaps/default/keymap.c b/keyboards/handwired/node5_1/keymaps/default/keymap.c
index fd600d5e90..4c4ceac58b 100644
--- a/keyboards/handwired/node5_1/keymaps/default/keymap.c
+++ b/keyboards/handwired/node5_1/keymaps/default/keymap.c
@@ -79,30 +79,48 @@ KC_LCTL, KC_LGUI, KC_LALT, KC_RALT, KC_SPACE, KC_BTN1, KC_BTN3, KC_B
*/
// Custom composite data type for holding colors
-struct color {
+typedef struct {
int red;
int green;
int blue;
-};
-
-const struct color trackball_normal_color = {
- .red = 255,
- .green = 74,
- .blue = 0
-};
+} color_type;
+// Used for middle mouse button logic
bool scrolled = false;
-// First one is the default
-int cpis[] = {20000, 40000};
+typedef struct {
+ color_type color;
+ int cpi;
+} cpi_type;
+
+// Trackball cpi. First one is the default This is also the default color
+cpi_type cpis[] = {
+ {
+ .color = {
+ .red = 0,
+ .green = 255,
+ .blue = 0
+ },
+ .cpi = 40000
+ },
+ {
+ .color = {
+ .red = 255,
+ .green = 0,
+ .blue = 0
+ },
+ .cpi = 20000
+ }
+};
+
int cpi_index = 0;
bool cpi_changed = false;
void set_trackball_normal_color(void) {
pimoroni_trackball_set_rgbw(
- trackball_normal_color.red,
- trackball_normal_color.green,
- trackball_normal_color.blue,
+ cpis[cpi_index].color.red,
+ cpis[cpi_index].color.green,
+ cpis[cpi_index].color.blue,
0
);
}
@@ -110,7 +128,7 @@ void set_trackball_normal_color(void) {
void keyboard_post_init_user(void) {
// Call the post init code.
set_trackball_normal_color();
- pointing_device_set_cpi(cpis[cpi_index]);
+ pointing_device_set_cpi(cpis[cpi_index].cpi);
debug_enable=true;
}
@@ -135,9 +153,11 @@ report_mouse_t pointing_device_task_user(report_mouse_t mouse_report) {
}
// Set CPI
- pointing_device_set_cpi(cpis[cpi_index]);
+ pointing_device_set_cpi(cpis[cpi_index].cpi);
+ // Sets color based on current selected cpi
+ set_trackball_normal_color();
- dprintf("CPI: %d\n", cpis[cpi_index]);
+ dprintf("CPI: %d\n", cpis[cpi_index].cpi);
}
}
@@ -174,7 +194,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
set_scrolling = false;
// Reset CPI
- pointing_device_set_cpi(cpis[cpi_index]);
+ pointing_device_set_cpi(cpis[cpi_index].cpi);
set_trackball_normal_color();
// Middle mouse button wasn't sent earlier,