[Keymap] Drashna Code Cleanup (#10656)

* Add Launchpad keymap

Note: RGB and Audio won't work when using B pins for audio

* Add support for rgb matrix on launchpad

* Update config for launchpag

* Disable wait on layer change

* Update config for ErgoDox EZ

* Fixup rgb light userspace code

* Move Corne layout to community layouts folder

* Update config for corne to support community layouts

* Add license header to files

* Minor cleanup of userspace config

* Update Pimironi Trackball code

* Increase debounce time on ergodox

* Fix keymap handling

* Enable wait for USB for moonlander

* Update/add license headers

* fix review issues
This commit is contained in:
Drashna Jaelre 2020-10-17 11:46:57 -07:00 committed by GitHub
parent aa1c1c3865
commit 855dd2d218
Failed to generate hash of commit
48 changed files with 1054 additions and 521 deletions

View file

@ -1,3 +1,19 @@
/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
*
* 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 "pimoroni_trackball.h"
#include "i2c_master.h"
@ -6,7 +22,7 @@ static int16_t x_offset = 0;
static int16_t y_offset = 0;
static int16_t h_offset = 0;
static int16_t v_offset = 0;
static float precisionSpeed = 1;
static float precisionSpeed = 1;
#ifndef I2C_TIMEOUT
# define I2C_TIMEOUT 100
@ -47,17 +63,37 @@ __attribute__((weak)) void trackball_check_click(bool pressed, report_mouse_t* m
}
}
float trackball_get_precision(void) { return precisionSpeed; }
void trackball_set_precision(float precision) { precisionSpeed = precision; }
bool trackball_is_scrolling(void) { return scrolling; }
void trackball_set_scrolling(bool scroll) { scrolling = scroll; }
void trackball_register_button(bool pressed, enum mouse_buttons button) {
report_mouse_t currentReport = pointing_device_get_report();
if (pressed) {
currentReport.buttons |= button;
} else {
currentReport.buttons &= ~button;
}
pointing_device_set_report(currentReport);
}
__attribute__((weak)) void pointing_device_init(void) { trackball_set_rgbw(0x00,0x00,0x00,0x4F); }
float trackball_get_precision(void) { return precisionSpeed; }
void trackball_set_precision(float precision) { precisionSpeed = precision; }
bool trackball_is_scrolling(void) { return scrolling; }
void trackball_set_scrolling(bool scroll) { scrolling = scroll; }
bool has_report_changed (report_mouse_t first, report_mouse_t second) {
return !(
(!first.buttons && first.buttons == second.buttons) &&
(!first.x && first.x == second.x) &&
(!first.y && first.y == second.y) &&
(!first.h && first.h == second.h) &&
(!first.v && first.v == second.v) );
}
__attribute__((weak)) void pointing_device_init(void) { trackball_set_rgbw(0x00, 0x00, 0x00, 0x4F); }
void pointing_device_task(void) {
static bool debounce;
static bool debounce;
static uint16_t debounce_timer;
uint8_t state[5] = {};
uint8_t state[5] = {};
if (i2c_readReg(TRACKBALL_WRITE, 0x04, state, 5, I2C_TIMEOUT) == I2C_STATUS_SUCCESS) {
if (!state[4] && !debounce) {
if (scrolling) {
@ -85,7 +121,7 @@ void pointing_device_task(void) {
}
} else {
if (state[4]) {
debounce = true;
debounce = true;
debounce_timer = timer_read();
}
}
@ -97,7 +133,6 @@ void pointing_device_task(void) {
trackball_check_click(state[4] & (1 << 7), &mouse);
#ifndef PIMORONI_TRACKBALL_ROTATE
update_member(&mouse.x, &x_offset);
update_member(&mouse.y, &y_offset);
@ -110,5 +145,7 @@ void pointing_device_task(void) {
update_member(&mouse.v, &h_offset);
#endif
pointing_device_set_report(mouse);
pointing_device_send();
if (has_report_changed(mouse, pointing_device_get_report())) {
pointing_device_send();
}
}