diff options
Diffstat (limited to 'users')
| -rw-r--r-- | users/bcat/config.h | 2 | ||||
| -rw-r--r-- | users/bocaj/config.h | 2 | ||||
| -rw-r--r-- | users/curry/config.h | 2 | ||||
| -rw-r--r-- | users/drashna/config.h | 2 | ||||
| -rw-r--r-- | users/drashna/drashna.h | 2 | ||||
| -rw-r--r-- | users/drashna/pimoroni_trackball.c | 151 | ||||
| -rw-r--r-- | users/drashna/pimoroni_trackball.h | 35 | ||||
| -rw-r--r-- | users/drashna/rules.mk | 2 | ||||
| -rw-r--r-- | users/spidey3/config.h | 4 | ||||
| -rw-r--r-- | users/tominabox1/config.h | 2 |
10 files changed, 9 insertions, 195 deletions
diff --git a/users/bcat/config.h b/users/bcat/config.h index 16188950e..5bb93f383 100644 --- a/users/bcat/config.h +++ b/users/bcat/config.h | |||
| @@ -33,7 +33,7 @@ | |||
| 33 | 33 | ||
| 34 | #if defined(RGB_MATRIX_ENABLE) | 34 | #if defined(RGB_MATRIX_ENABLE) |
| 35 | /* Turn off per-key RGB when the host goes to sleep. */ | 35 | /* Turn off per-key RGB when the host goes to sleep. */ |
| 36 | # define RGB_DISABLE_WHEN_USB_SUSPENDED true | 36 | # define RGB_DISABLE_WHEN_USB_SUSPENDED |
| 37 | 37 | ||
| 38 | /* Keep per-key RGB increments consistent across keyboards. */ | 38 | /* Keep per-key RGB increments consistent across keyboards. */ |
| 39 | # undef RGB_MATRIX_HUE_STEP | 39 | # undef RGB_MATRIX_HUE_STEP |
diff --git a/users/bocaj/config.h b/users/bocaj/config.h index 2a44aabfc..ecfb09c6f 100644 --- a/users/bocaj/config.h +++ b/users/bocaj/config.h | |||
| @@ -28,7 +28,7 @@ | |||
| 28 | // # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (not recommened) | 28 | // # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (not recommened) |
| 29 | # define RGB_MATRIX_FRAMEBUFFER_EFFECTS | 29 | # define RGB_MATRIX_FRAMEBUFFER_EFFECTS |
| 30 | // # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects | 30 | // # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects |
| 31 | # define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended | 31 | # define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended |
| 32 | // # define RGB_MATRIX_MAXIMUM_BRIGHTNESS 200 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255 | 32 | // # define RGB_MATRIX_MAXIMUM_BRIGHTNESS 200 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255 |
| 33 | // # define EECONFIG_RGB_MATRIX (uint32_t *)16 | 33 | // # define EECONFIG_RGB_MATRIX (uint32_t *)16 |
| 34 | 34 | ||
diff --git a/users/curry/config.h b/users/curry/config.h index b982dab03..e3c0a103e 100644 --- a/users/curry/config.h +++ b/users/curry/config.h | |||
| @@ -17,7 +17,7 @@ | |||
| 17 | #if defined(RGB_MATRIX_ENABLE) | 17 | #if defined(RGB_MATRIX_ENABLE) |
| 18 | # define RGB_MATRIX_KEYPRESSES | 18 | # define RGB_MATRIX_KEYPRESSES |
| 19 | # define RGB_MATRIX_FRAMEBUFFER_EFFECTS | 19 | # define RGB_MATRIX_FRAMEBUFFER_EFFECTS |
| 20 | # define RGB_DISABLE_WHEN_USB_SUSPENDED true | 20 | # define RGB_DISABLE_WHEN_USB_SUSPENDED |
| 21 | 21 | ||
| 22 | # define DISABLE_RGB_MATRIX_ALPHAS_MODS | 22 | # define DISABLE_RGB_MATRIX_ALPHAS_MODS |
| 23 | # define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN | 23 | # define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN |
diff --git a/users/drashna/config.h b/users/drashna/config.h index 5f7c32ff3..796485689 100644 --- a/users/drashna/config.h +++ b/users/drashna/config.h | |||
| @@ -65,7 +65,7 @@ | |||
| 65 | // # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (not recommened) | 65 | // # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (not recommened) |
| 66 | # define RGB_MATRIX_FRAMEBUFFER_EFFECTS | 66 | # define RGB_MATRIX_FRAMEBUFFER_EFFECTS |
| 67 | // # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects | 67 | // # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects |
| 68 | # define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended | 68 | # define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended |
| 69 | // # define RGB_MATRIX_MAXIMUM_BRIGHTNESS 200 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255 | 69 | // # define RGB_MATRIX_MAXIMUM_BRIGHTNESS 200 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255 |
| 70 | // # define EECONFIG_RGB_MATRIX (uint32_t *)16 | 70 | // # define EECONFIG_RGB_MATRIX (uint32_t *)16 |
| 71 | 71 | ||
diff --git a/users/drashna/drashna.h b/users/drashna/drashna.h index e66f10657..e37c73bb2 100644 --- a/users/drashna/drashna.h +++ b/users/drashna/drashna.h | |||
| @@ -33,7 +33,7 @@ | |||
| 33 | # include "oled_stuff.h" | 33 | # include "oled_stuff.h" |
| 34 | #endif | 34 | #endif |
| 35 | #if defined(PIMORONI_TRACKBALL_ENABLE) | 35 | #if defined(PIMORONI_TRACKBALL_ENABLE) |
| 36 | # include "pimoroni_trackball.h" | 36 | # include "drivers/sensors/pimoroni_trackball.h" |
| 37 | #endif | 37 | #endif |
| 38 | 38 | ||
| 39 | /* Define layer names */ | 39 | /* Define layer names */ |
diff --git a/users/drashna/pimoroni_trackball.c b/users/drashna/pimoroni_trackball.c deleted file mode 100644 index a6ca6c996..000000000 --- a/users/drashna/pimoroni_trackball.c +++ /dev/null | |||
| @@ -1,151 +0,0 @@ | |||
| 1 | /* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com> | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include "pimoroni_trackball.h" | ||
| 18 | #include "i2c_master.h" | ||
| 19 | |||
| 20 | static uint8_t scrolling = 0; | ||
| 21 | static int16_t x_offset = 0; | ||
| 22 | static int16_t y_offset = 0; | ||
| 23 | static int16_t h_offset = 0; | ||
| 24 | static int16_t v_offset = 0; | ||
| 25 | static float precisionSpeed = 1; | ||
| 26 | |||
| 27 | #ifndef I2C_TIMEOUT | ||
| 28 | # define I2C_TIMEOUT 100 | ||
| 29 | #endif | ||
| 30 | #ifndef MOUSE_DEBOUNCE | ||
| 31 | # define MOUSE_DEBOUNCE 5 | ||
| 32 | #endif | ||
| 33 | |||
| 34 | void trackball_set_rgbw(uint8_t red, uint8_t green, uint8_t blue, uint8_t white) { | ||
| 35 | uint8_t data[] = {0x00, red, green, blue, white}; | ||
| 36 | i2c_transmit(TRACKBALL_ADDRESS << 1, data, sizeof(data), I2C_TIMEOUT); | ||
| 37 | } | ||
| 38 | |||
| 39 | int16_t mouse_offset(uint8_t positive, uint8_t negative, int16_t scale) { | ||
| 40 | int16_t offset = (int16_t)positive - (int16_t)negative; | ||
| 41 | int16_t magnitude = (int16_t)(scale * offset * offset * precisionSpeed); | ||
| 42 | return offset < 0 ? -magnitude : magnitude; | ||
| 43 | } | ||
| 44 | |||
| 45 | void update_member(int8_t* member, int16_t* offset) { | ||
| 46 | if (*offset > 127) { | ||
| 47 | *member = 127; | ||
| 48 | *offset -= 127; | ||
| 49 | } else if (*offset < -127) { | ||
| 50 | *member = -127; | ||
| 51 | *offset += 127; | ||
| 52 | } else { | ||
| 53 | *member = *offset; | ||
| 54 | *offset = 0; | ||
| 55 | } | ||
| 56 | } | ||
| 57 | |||
| 58 | __attribute__((weak)) void trackball_check_click(bool pressed, report_mouse_t* mouse) { | ||
| 59 | if (pressed) { | ||
| 60 | mouse->buttons |= MOUSE_BTN1; | ||
| 61 | } else { | ||
| 62 | mouse->buttons &= ~MOUSE_BTN1; | ||
| 63 | } | ||
| 64 | } | ||
| 65 | |||
| 66 | void trackball_register_button(bool pressed, enum mouse_buttons button) { | ||
| 67 | report_mouse_t currentReport = pointing_device_get_report(); | ||
| 68 | if (pressed) { | ||
| 69 | currentReport.buttons |= button; | ||
| 70 | } else { | ||
| 71 | currentReport.buttons &= ~button; | ||
| 72 | } | ||
| 73 | pointing_device_set_report(currentReport); | ||
| 74 | } | ||
| 75 | |||
| 76 | float trackball_get_precision(void) { return precisionSpeed; } | ||
| 77 | void trackball_set_precision(float precision) { precisionSpeed = precision; } | ||
| 78 | bool trackball_is_scrolling(void) { return scrolling; } | ||
| 79 | void trackball_set_scrolling(bool scroll) { scrolling = scroll; } | ||
| 80 | |||
| 81 | bool has_report_changed (report_mouse_t first, report_mouse_t second) { | ||
| 82 | return !( | ||
| 83 | (!first.buttons && first.buttons == second.buttons) && | ||
| 84 | (!first.x && first.x == second.x) && | ||
| 85 | (!first.y && first.y == second.y) && | ||
| 86 | (!first.h && first.h == second.h) && | ||
| 87 | (!first.v && first.v == second.v) ); | ||
| 88 | } | ||
| 89 | |||
| 90 | |||
| 91 | __attribute__((weak)) void pointing_device_init(void) { trackball_set_rgbw(0x00, 0x00, 0x00, 0x4F); } | ||
| 92 | |||
| 93 | void pointing_device_task(void) { | ||
| 94 | static bool debounce; | ||
| 95 | static uint16_t debounce_timer; | ||
| 96 | uint8_t state[5] = {}; | ||
| 97 | if (i2c_readReg(TRACKBALL_ADDRESS << 1, 0x04, state, 5, I2C_TIMEOUT) == I2C_STATUS_SUCCESS) { | ||
| 98 | if (!state[4] && !debounce) { | ||
| 99 | if (scrolling) { | ||
| 100 | #ifdef PIMORONI_TRACKBALL_INVERT_X | ||
| 101 | h_offset += mouse_offset(state[2], state[3], 1); | ||
| 102 | #else | ||
| 103 | h_offset -= mouse_offset(state[2], state[3], 1); | ||
| 104 | #endif | ||
| 105 | #ifdef PIMORONI_TRACKBALL_INVERT_Y | ||
| 106 | v_offset += mouse_offset(state[1], state[0], 1); | ||
| 107 | #else | ||
| 108 | v_offset -= mouse_offset(state[1], state[0], 1); | ||
| 109 | #endif | ||
| 110 | } else { | ||
| 111 | #ifdef PIMORONI_TRACKBALL_INVERT_X | ||
| 112 | x_offset -= mouse_offset(state[2], state[3], 5); | ||
| 113 | #else | ||
| 114 | x_offset += mouse_offset(state[2], state[3], 5); | ||
| 115 | #endif | ||
| 116 | #ifdef PIMORONI_TRACKBALL_INVERT_Y | ||
| 117 | y_offset -= mouse_offset(state[1], state[0], 5); | ||
| 118 | #else | ||
| 119 | y_offset += mouse_offset(state[1], state[0], 5); | ||
| 120 | #endif | ||
| 121 | } | ||
| 122 | } else { | ||
| 123 | if (state[4]) { | ||
| 124 | debounce = true; | ||
| 125 | debounce_timer = timer_read(); | ||
| 126 | } | ||
| 127 | } | ||
| 128 | } | ||
| 129 | |||
| 130 | if (timer_elapsed(debounce_timer) > MOUSE_DEBOUNCE) debounce = false; | ||
| 131 | |||
| 132 | report_mouse_t mouse = pointing_device_get_report(); | ||
| 133 | |||
| 134 | trackball_check_click(state[4] & (1 << 7), &mouse); | ||
| 135 | |||
| 136 | #ifndef PIMORONI_TRACKBALL_ROTATE | ||
| 137 | update_member(&mouse.x, &x_offset); | ||
| 138 | update_member(&mouse.y, &y_offset); | ||
| 139 | update_member(&mouse.h, &h_offset); | ||
| 140 | update_member(&mouse.v, &v_offset); | ||
| 141 | #else | ||
| 142 | update_member(&mouse.x, &y_offset); | ||
| 143 | update_member(&mouse.y, &x_offset); | ||
| 144 | update_member(&mouse.h, &v_offset); | ||
| 145 | update_member(&mouse.v, &h_offset); | ||
| 146 | #endif | ||
| 147 | pointing_device_set_report(mouse); | ||
| 148 | if (has_report_changed(mouse, pointing_device_get_report())) { | ||
| 149 | pointing_device_send(); | ||
| 150 | } | ||
| 151 | } | ||
diff --git a/users/drashna/pimoroni_trackball.h b/users/drashna/pimoroni_trackball.h deleted file mode 100644 index a30fb0bb8..000000000 --- a/users/drashna/pimoroni_trackball.h +++ /dev/null | |||
| @@ -1,35 +0,0 @@ | |||
| 1 | /* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com> | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #pragma once | ||
| 18 | |||
| 19 | #include "quantum.h" | ||
| 20 | #include "pointing_device.h" | ||
| 21 | |||
| 22 | #ifndef TRACKBALL_ADDRESS | ||
| 23 | # define TRACKBALL_ADDRESS 0x0A | ||
| 24 | #endif | ||
| 25 | #define TRACKBALL_WRITE ((TRACKBALL_ADDRESS << 1) | I2C_WRITE) | ||
| 26 | #define TRACKBALL_READ ((TRACKBALL_ADDRESS << 1) | I2C_READ) | ||
| 27 | |||
| 28 | void trackball_set_rgbw(uint8_t red, uint8_t green, uint8_t blue, uint8_t white); | ||
| 29 | void trackball_check_click(bool pressed, report_mouse_t *mouse); | ||
| 30 | void trackball_register_button(bool pressed, enum mouse_buttons button); | ||
| 31 | |||
| 32 | float trackball_get_precision(void); | ||
| 33 | void trackball_set_precision(float precision); | ||
| 34 | bool trackball_is_scrolling(void); | ||
| 35 | void trackball_set_scrolling(bool scroll); | ||
diff --git a/users/drashna/rules.mk b/users/drashna/rules.mk index b79051508..fa4fb2420 100644 --- a/users/drashna/rules.mk +++ b/users/drashna/rules.mk | |||
| @@ -74,7 +74,7 @@ endif | |||
| 74 | ifeq ($(strip $(PIMORONI_TRACKBALL_ENABLE)), yes) | 74 | ifeq ($(strip $(PIMORONI_TRACKBALL_ENABLE)), yes) |
| 75 | POINTING_DEVICE_ENABLE := yes | 75 | POINTING_DEVICE_ENABLE := yes |
| 76 | OPT_DEFS += -DPIMORONI_TRACKBALL_ENABLE | 76 | OPT_DEFS += -DPIMORONI_TRACKBALL_ENABLE |
| 77 | SRC += pimoroni_trackball.c | 77 | SRC += drivers/sensors/pimoroni_trackball.c |
| 78 | QUANTUM_LIB_SRC += i2c_master.c | 78 | QUANTUM_LIB_SRC += i2c_master.c |
| 79 | endif | 79 | endif |
| 80 | 80 | ||
diff --git a/users/spidey3/config.h b/users/spidey3/config.h index 7062fde03..f5f5e07f0 100644 --- a/users/spidey3/config.h +++ b/users/spidey3/config.h | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #pragma once | 1 | #pragma once |
| 2 | 2 | ||
| 3 | #define LED_DISABLE_WHEN_USB_SUSPENDED true | 3 | #define LED_DISABLE_WHEN_USB_SUSPENDED |
| 4 | #define RGB_DISABLE_WHEN_USB_SUSPENDED true | 4 | #define RGB_DISABLE_WHEN_USB_SUSPENDED |
| 5 | #define RGBLIGHT_LAYERS | 5 | #define RGBLIGHT_LAYERS |
| 6 | #define RGBLIGHT_MAX_LAYERS 17 | 6 | #define RGBLIGHT_MAX_LAYERS 17 |
| 7 | #define RGBLIGHT_LAYER_BLINK | 7 | #define RGBLIGHT_LAYER_BLINK |
diff --git a/users/tominabox1/config.h b/users/tominabox1/config.h index 2a8c1e943..004f58ab5 100644 --- a/users/tominabox1/config.h +++ b/users/tominabox1/config.h | |||
| @@ -31,7 +31,7 @@ | |||
| 31 | // RGB_Matrix settings | 31 | // RGB_Matrix settings |
| 32 | #ifdef RGB_MATRIX_ENABLE | 32 | #ifdef RGB_MATRIX_ENABLE |
| 33 | #define RGB_MATRIX_KEYPRESSES // reacts to keypresses | 33 | #define RGB_MATRIX_KEYPRESSES // reacts to keypresses |
| 34 | #define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended | 34 | #define RGB_DISABLE_WHEN_USB_SUSPENDED // turn off effects when suspended |
| 35 | #define RGB_MATRIX_LED_FLUSH_LIMIT 16 // limits in milliseconds how frequently an animation will update the LEDs. 16 (16ms) is equivalent to limiting to 60fps (increases keyboard responsiveness) | 35 | #define RGB_MATRIX_LED_FLUSH_LIMIT 16 // limits in milliseconds how frequently an animation will update the LEDs. 16 (16ms) is equivalent to limiting to 60fps (increases keyboard responsiveness) |
| 36 | #define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash. | 36 | #define RGB_MATRIX_MAXIMUM_BRIGHTNESS 150 // limits maximum brightness of LEDs to 150 out of 255. Higher may cause the controller to crash. |
| 37 | #define RGB_MATRIX_HUE_STEP 8 | 37 | #define RGB_MATRIX_HUE_STEP 8 |
