diff options
-rw-r--r-- | drivers/oled/oled_driver.c | 2 | ||||
-rw-r--r-- | drivers/oled/oled_driver.h | 2 | ||||
-rw-r--r-- | keyboards/handwired/onekey/keymaps/joystick/config.h | 2 | ||||
-rw-r--r-- | keyboards/handwired/onekey/keymaps/joystick/rules.mk | 2 | ||||
-rw-r--r-- | quantum/process_keycode/process_auto_shift.c | 35 | ||||
-rw-r--r-- | quantum/process_keycode/process_combo.c | 4 | ||||
-rw-r--r-- | quantum/process_keycode/process_joystick.c | 42 | ||||
-rw-r--r-- | quantum/rgblight.c | 12 | ||||
-rw-r--r-- | tmk_core/common/action_layer.h | 7 | ||||
-rw-r--r-- | tmk_core/common/mousekey.c | 19 | ||||
-rw-r--r-- | tmk_core/common/progmem.h | 2 | ||||
-rw-r--r-- | tmk_core/protocol/chibios/usb_main.c | 28 | ||||
-rw-r--r-- | tmk_core/protocol/lufa/adafruit_ble.h | 4 | ||||
-rw-r--r-- | tmk_core/protocol/lufa/lufa.c | 28 |
14 files changed, 93 insertions, 96 deletions
diff --git a/drivers/oled/oled_driver.c b/drivers/oled/oled_driver.c index bbf010a09..9ae737ca2 100644 --- a/drivers/oled/oled_driver.c +++ b/drivers/oled/oled_driver.c @@ -447,7 +447,7 @@ void oled_pan(bool left) { oled_buffer_reader_t oled_read_raw(uint16_t start_index) { if (start_index > OLED_MATRIX_SIZE) start_index = OLED_MATRIX_SIZE; oled_buffer_reader_t ret_reader; - ret_reader.current_element = &oled_buffer[start_index]; + ret_reader.current_element = &oled_buffer[start_index]; ret_reader.remaining_element_count = OLED_MATRIX_SIZE - start_index; return ret_reader; } diff --git a/drivers/oled/oled_driver.h b/drivers/oled/oled_driver.h index 7ec00d66a..9a4b98d2f 100644 --- a/drivers/oled/oled_driver.h +++ b/drivers/oled/oled_driver.h @@ -155,7 +155,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #endif typedef struct __attribute__((__packed__)) { - uint8_t *current_element; + uint8_t *current_element; uint16_t remaining_element_count; } oled_buffer_reader_t; diff --git a/keyboards/handwired/onekey/keymaps/joystick/config.h b/keyboards/handwired/onekey/keymaps/joystick/config.h index ac09aa7cf..a3b5858ad 100644 --- a/keyboards/handwired/onekey/keymaps/joystick/config.h +++ b/keyboards/handwired/onekey/keymaps/joystick/config.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #define JOYSTICK_AXES_COUNT 2 #define JOYSTICK_BUTTON_COUNT 1 diff --git a/keyboards/handwired/onekey/keymaps/joystick/rules.mk b/keyboards/handwired/onekey/keymaps/joystick/rules.mk index cf0348173..b910bdbe6 100644 --- a/keyboards/handwired/onekey/keymaps/joystick/rules.mk +++ b/keyboards/handwired/onekey/keymaps/joystick/rules.mk @@ -1 +1 @@ -JOYSTICK_ENABLE = analog +JOYSTICK_ENABLE = analog diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index 330037cef..b1267922c 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c @@ -41,34 +41,34 @@ void autoshift_flush(void) { } void autoshift_on(uint16_t keycode) { - autoshift_time = timer_read(); - autoshift_lastkey = keycode; + autoshift_time = timer_read(); + autoshift_lastkey = keycode; } void autoshift_toggle(void) { - if (autoshift_enabled) { - autoshift_enabled = false; - autoshift_flush(); - } else { - autoshift_enabled = true; - } + if (autoshift_enabled) { + autoshift_enabled = false; + autoshift_flush(); + } else { + autoshift_enabled = true; + } } void autoshift_enable(void) { autoshift_enabled = true; } void autoshift_disable(void) { - autoshift_enabled = false; - autoshift_flush(); + autoshift_enabled = false; + autoshift_flush(); } -#ifndef AUTO_SHIFT_NO_SETUP +# ifndef AUTO_SHIFT_NO_SETUP void autoshift_timer_report(void) { - char display[8]; + char display[8]; - snprintf(display, 8, "\n%d\n", autoshift_timeout); + snprintf(display, 8, "\n%d\n", autoshift_timeout); - send_string((const char *)display); + send_string((const char *)display); } -#endif +# endif bool get_autoshift_state(void) { return autoshift_enabled; } @@ -79,7 +79,6 @@ void set_autoshift_timeout(uint16_t timeout) { autoshift_timeout = timeout; } bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { switch (keycode) { - case KC_ASTG: autoshift_toggle(); return true; @@ -92,10 +91,10 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { return true; # ifndef AUTO_SHIFT_NO_SETUP - case KC_ASUP: + case KC_ASUP: autoshift_timeout += 5; return true; - case KC_ASDN: + case KC_ASDN: autoshift_timeout -= 5; return true; diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c index 1f715f43b..f38d7d47a 100644 --- a/quantum/process_keycode/process_combo.c +++ b/quantum/process_keycode/process_combo.c @@ -27,7 +27,7 @@ extern int COMBO_LEN; __attribute__((weak)) void process_combo_event(uint16_t combo_index, bool pressed) {} static uint16_t timer = 0; -static uint16_t current_combo_index = 0; +static uint16_t current_combo_index = 0; static bool drop_buffer = false; static bool is_active = false; static bool b_combo_enable = true; // defaults to enabled @@ -82,7 +82,7 @@ static inline void dump_key_buffer(bool emit) { } while (0) static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *record) { - uint8_t count = 0; + uint8_t count = 0; uint16_t index = -1; /* Find index of keycode and number of combo keys */ for (const uint16_t *keys = combo->keys;; ++count) { diff --git a/quantum/process_keycode/process_joystick.c b/quantum/process_keycode/process_joystick.c index c12f75685..5778a7434 100644 --- a/quantum/process_keycode/process_joystick.c +++ b/quantum/process_keycode/process_joystick.c @@ -17,8 +17,7 @@ bool process_joystick(uint16_t keycode, keyrecord_t *record) { return true; } -__attribute__((weak)) -void joystick_task(void) { +__attribute__((weak)) void joystick_task(void) { if (process_joystick_analogread() && (joystick_status.status & JS_UPDATED)) { send_joystick_packet(&joystick_status); joystick_status.status &= ~JS_UPDATED; @@ -47,16 +46,11 @@ uint16_t savePinState(pin_t pin) { return ((PORTx_ADDRESS(pin) >> pinNumber) & 0x1) << 1 | ((DDRx_ADDRESS(pin) >> pinNumber) & 0x1); #elif defined(PROTOCOL_CHIBIOS) /* - The pin configuration is backed up in the following format : + The pin configuration is backed up in the following format : bit 15 9 8 7 6 5 4 3 2 1 0 |unused|ODR|IDR|PUPDR|OSPEEDR|OTYPER|MODER| */ - return (( PAL_PORT(pin)->MODER >> (2*PAL_PAD(pin))) & 0x3) - | (((PAL_PORT(pin)->OTYPER >> (1*PAL_PAD(pin))) & 0x1) << 2) - | (((PAL_PORT(pin)->OSPEEDR >> (2*PAL_PAD(pin))) & 0x3) << 3) - | (((PAL_PORT(pin)->PUPDR >> (2*PAL_PAD(pin))) & 0x3) << 5) - | (((PAL_PORT(pin)->IDR >> (1*PAL_PAD(pin))) & 0x1) << 7) - | (((PAL_PORT(pin)->ODR >> (1*PAL_PAD(pin))) & 0x1) << 8); + return ((PAL_PORT(pin)->MODER >> (2 * PAL_PAD(pin))) & 0x3) | (((PAL_PORT(pin)->OTYPER >> (1 * PAL_PAD(pin))) & 0x1) << 2) | (((PAL_PORT(pin)->OSPEEDR >> (2 * PAL_PAD(pin))) & 0x3) << 3) | (((PAL_PORT(pin)->PUPDR >> (2 * PAL_PAD(pin))) & 0x3) << 5) | (((PAL_PORT(pin)->IDR >> (1 * PAL_PAD(pin))) & 0x1) << 7) | (((PAL_PORT(pin)->ODR >> (1 * PAL_PAD(pin))) & 0x1) << 8); #else return 0; #endif @@ -68,12 +62,12 @@ void restorePinState(pin_t pin, uint16_t restoreState) { PORTx_ADDRESS(pin) = (PORTx_ADDRESS(pin) & ~_BV(pinNumber)) | (((restoreState >> 1) & 0x1) << pinNumber); DDRx_ADDRESS(pin) = (DDRx_ADDRESS(pin) & ~_BV(pinNumber)) | ((restoreState & 0x1) << pinNumber); #elif defined(PROTOCOL_CHIBIOS) - PAL_PORT(pin)->MODER = (PAL_PORT(pin)->MODER & ~(0x3<< (2*PAL_PAD(pin)))) | (restoreState & 0x3) << (2*PAL_PAD(pin)); - PAL_PORT(pin)->OTYPER = (PAL_PORT(pin)->OTYPER & ~(0x1<< (1*PAL_PAD(pin)))) | ((restoreState>>2) & 0x1) << (1*PAL_PAD(pin)); - PAL_PORT(pin)->OSPEEDR= (PAL_PORT(pin)->OSPEEDR & ~(0x3<< (2*PAL_PAD(pin)))) | ((restoreState>>3) & 0x3) << (2*PAL_PAD(pin)); - PAL_PORT(pin)->PUPDR = (PAL_PORT(pin)->PUPDR & ~(0x3<< (2*PAL_PAD(pin)))) | ((restoreState>>5) & 0x3) << (2*PAL_PAD(pin)); - PAL_PORT(pin)->IDR = (PAL_PORT(pin)->IDR & ~(0x1<< (1*PAL_PAD(pin)))) | ((restoreState>>7) & 0x1) << (1*PAL_PAD(pin)); - PAL_PORT(pin)->ODR = (PAL_PORT(pin)->ODR & ~(0x1<< (1*PAL_PAD(pin)))) | ((restoreState>>8) & 0x1) << (1*PAL_PAD(pin)); + PAL_PORT(pin)->MODER = (PAL_PORT(pin)->MODER & ~(0x3 << (2 * PAL_PAD(pin)))) | (restoreState & 0x3) << (2 * PAL_PAD(pin)); + PAL_PORT(pin)->OTYPER = (PAL_PORT(pin)->OTYPER & ~(0x1 << (1 * PAL_PAD(pin)))) | ((restoreState >> 2) & 0x1) << (1 * PAL_PAD(pin)); + PAL_PORT(pin)->OSPEEDR = (PAL_PORT(pin)->OSPEEDR & ~(0x3 << (2 * PAL_PAD(pin)))) | ((restoreState >> 3) & 0x3) << (2 * PAL_PAD(pin)); + PAL_PORT(pin)->PUPDR = (PAL_PORT(pin)->PUPDR & ~(0x3 << (2 * PAL_PAD(pin)))) | ((restoreState >> 5) & 0x3) << (2 * PAL_PAD(pin)); + PAL_PORT(pin)->IDR = (PAL_PORT(pin)->IDR & ~(0x1 << (1 * PAL_PAD(pin)))) | ((restoreState >> 7) & 0x1) << (1 * PAL_PAD(pin)); + PAL_PORT(pin)->ODR = (PAL_PORT(pin)->ODR & ~(0x1 << (1 * PAL_PAD(pin)))) | ((restoreState >> 8) & 0x1) << (1 * PAL_PAD(pin)); #else return; #endif @@ -132,21 +126,21 @@ bool process_joystick_analogread_quantum() { int16_t axis_val = joystick_axes[axis_index].mid_digit; # endif - //test the converted value against the lower range - int32_t ref = joystick_axes[axis_index].mid_digit; - int32_t range = joystick_axes[axis_index].min_digit; - int32_t ranged_val = ((axis_val - ref) * -127) / (range - ref) ; + // test the converted value against the lower range + int32_t ref = joystick_axes[axis_index].mid_digit; + int32_t range = joystick_axes[axis_index].min_digit; + int32_t ranged_val = ((axis_val - ref) * -127) / (range - ref); if (ranged_val > 0) { - //the value is in the higher range - range = joystick_axes[axis_index].max_digit; + // the value is in the higher range + range = joystick_axes[axis_index].max_digit; ranged_val = ((axis_val - ref) * 127) / (range - ref); } - - //clamp the result in the valid range + + // clamp the result in the valid range ranged_val = ranged_val < -127 ? -127 : ranged_val; ranged_val = ranged_val > 127 ? 127 : ranged_val; - + if (ranged_val != joystick_status.axes[axis_index]) { joystick_status.axes[axis_index] = ranged_val; joystick_status.status |= JS_UPDATED; diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 52d8da181..211ec975a 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c @@ -407,7 +407,6 @@ void rgblight_decrease_val_helper(bool write_to_eeprom) { void rgblight_decrease_val_noeeprom(void) { rgblight_decrease_val_helper(false); } void rgblight_decrease_val(void) { rgblight_decrease_val_helper(true); } - void rgblight_increase_speed_helper(bool write_to_eeprom) { if (rgblight_config.speed < 3) rgblight_config.speed++; // RGBLIGHT_SPLIT_SET_CHANGE_HSVS; // NEED? @@ -428,7 +427,6 @@ void rgblight_decrease_speed_helper(bool write_to_eeprom) { void rgblight_decrease_speed(void) { rgblight_decrease_speed_helper(true); } void rgblight_decrease_speed_noeeprom(void) { rgblight_decrease_speed_helper(false); } - void rgblight_sethsv_noeeprom_old(uint8_t hue, uint8_t sat, uint8_t val) { if (rgblight_config.enable) { LED_TYPE tmp_led; @@ -1170,17 +1168,17 @@ void rgblight_effect_knight(animation_status_t *anim) { */ void rgblight_effect_christmas(animation_status_t *anim) { static int8_t increment = 1; - const uint8_t max_pos = 32; + const uint8_t max_pos = 32; const uint8_t hue_green = 85; uint32_t xa; - uint8_t hue, val; - uint8_t i; + uint8_t hue, val; + uint8_t i; // The effect works by animating anim->pos from 0 to 32 and back to 0. // The pos is used in a cubic bezier formula to ease-in-out between red and green, leaving the interpolated colors visible as short as possible. - xa = CUBED((uint32_t) anim->pos); - hue = ((uint32_t) hue_green) * xa / (xa + CUBED((uint32_t) (max_pos - anim->pos))); + xa = CUBED((uint32_t)anim->pos); + hue = ((uint32_t)hue_green) * xa / (xa + CUBED((uint32_t)(max_pos - anim->pos))); // Additionally, these interpolated colors get shown with a slightly darker value, to make them less prominent than the main colors. val = 255 - (3 * (hue < hue_green / 2 ? hue : hue_green - hue) / 2); diff --git a/tmk_core/common/action_layer.h b/tmk_core/common/action_layer.h index 9b9173c33..f9f686112 100644 --- a/tmk_core/common/action_layer.h +++ b/tmk_core/common/action_layer.h @@ -82,9 +82,9 @@ void layer_on(uint8_t layer); void layer_off(uint8_t layer); void layer_invert(uint8_t layer); /* bitwise operation */ -void layer_or(layer_state_t state); -void layer_and(layer_state_t state); -void layer_xor(layer_state_t state); +void layer_or(layer_state_t state); +void layer_and(layer_state_t state); +void layer_xor(layer_state_t state); layer_state_t layer_state_set_user(layer_state_t state); layer_state_t layer_state_set_kb(layer_state_t state); #else @@ -107,7 +107,6 @@ layer_state_t layer_state_set_kb(layer_state_t state); # define layer_state_set_user(state) (void)state #endif - /* pressed actions cache */ #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE) diff --git a/tmk_core/common/mousekey.c b/tmk_core/common/mousekey.c index 390c74e0f..ef18bcf1a 100644 --- a/tmk_core/common/mousekey.c +++ b/tmk_core/common/mousekey.c @@ -33,8 +33,8 @@ inline int8_t times_inv_sqrt2(int8_t x) { static report_mouse_t mouse_report = {0}; static void mousekey_debug(void); -static uint8_t mousekey_accel = 0; -static uint8_t mousekey_repeat = 0; +static uint8_t mousekey_accel = 0; +static uint8_t mousekey_repeat = 0; static uint8_t mousekey_wheel_repeat = 0; #ifndef MK_3_SPEED @@ -225,7 +225,6 @@ void mousekey_on(uint8_t code) { mousekey_accel |= (1 << 1); else if (code == KC_MS_ACCEL2) mousekey_accel |= (1 << 2); - } void mousekey_off(uint8_t code) { @@ -284,10 +283,10 @@ uint16_t w_intervals[mkspd_COUNT] = {MK_W_INTERVAL_UNMOD, MK_W_INTERVAL_0 void mousekey_task(void) { // report cursor and scroll movement independently report_mouse_t const tmpmr = mouse_report; - mouse_report.x = 0; - mouse_report.y = 0; - mouse_report.v = 0; - mouse_report.h = 0; + mouse_report.x = 0; + mouse_report.y = 0; + mouse_report.v = 0; + mouse_report.h = 0; if ((tmpmr.x || tmpmr.y) && timer_elapsed(last_timer_c) > c_intervals[mk_speed]) { mouse_report.x = tmpmr.x; @@ -421,10 +420,10 @@ void mousekey_send(void) { } void mousekey_clear(void) { - mouse_report = (report_mouse_t){}; - mousekey_repeat = 0; + mouse_report = (report_mouse_t){}; + mousekey_repeat = 0; mousekey_wheel_repeat = 0; - mousekey_accel = 0; + mousekey_accel = 0; } static void mousekey_debug(void) { diff --git a/tmk_core/common/progmem.h b/tmk_core/common/progmem.h index 41b5b537c..c8863d3ad 100644 --- a/tmk_core/common/progmem.h +++ b/tmk_core/common/progmem.h @@ -4,7 +4,7 @@ # include <avr/pgmspace.h> #else # define PROGMEM -# define PGM_P const char * +# define PGM_P const char* # define memcpy_P(dest, src, n) memcpy(dest, src, n) # define pgm_read_byte(address_short) *((uint8_t*)(address_short)) # define pgm_read_word(address_short) *((uint16_t*)(address_short)) diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index 68c61cf55..ae33e86a7 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -888,39 +888,43 @@ void virtser_task(void) { void send_joystick_packet(joystick_t *joystick) { joystick_report_t rep = { # if JOYSTICK_AXES_COUNT > 0 - .axes = {joystick->axes[0], + .axes = + { + joystick->axes[0], # if JOYSTICK_AXES_COUNT >= 2 - joystick->axes[1], + joystick->axes[1], # endif # if JOYSTICK_AXES_COUNT >= 3 - joystick->axes[2], + joystick->axes[2], # endif # if JOYSTICK_AXES_COUNT >= 4 - joystick->axes[3], + joystick->axes[3], # endif # if JOYSTICK_AXES_COUNT >= 5 - joystick->axes[4], + joystick->axes[4], # endif # if JOYSTICK_AXES_COUNT >= 6 - joystick->axes[5], + joystick->axes[5], # endif - }, + }, # endif // JOYSTICK_AXES_COUNT>0 # if JOYSTICK_BUTTON_COUNT > 0 - .buttons = {joystick->buttons[0], + .buttons = + { + joystick->buttons[0], # if JOYSTICK_BUTTON_COUNT > 8 - joystick->buttons[1], + joystick->buttons[1], # endif # if JOYSTICK_BUTTON_COUNT > 16 - joystick->buttons[2], + joystick->buttons[2], # endif # if JOYSTICK_BUTTON_COUNT > 24 - joystick->buttons[3], + joystick->buttons[3], # endif - } + } # endif // JOYSTICK_BUTTON_COUNT>0 }; diff --git a/tmk_core/protocol/lufa/adafruit_ble.h b/tmk_core/protocol/lufa/adafruit_ble.h index aebded7b3..9dfc9b435 100644 --- a/tmk_core/protocol/lufa/adafruit_ble.h +++ b/tmk_core/protocol/lufa/adafruit_ble.h @@ -41,12 +41,12 @@ extern bool adafruit_ble_send_keys(uint8_t hid_modifier_mask, uint8_t *keys, uin * (milliseconds) */ extern bool adafruit_ble_send_consumer_key(uint16_t keycode, int hold_duration); -# ifdef MOUSE_ENABLE +#ifdef MOUSE_ENABLE /* Send a mouse/wheel movement report. * The parameters are signed and indicate positive of negative direction * change. */ extern bool adafruit_ble_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan, uint8_t buttons); -# endif +#endif /* Compute battery voltage by reading an analog pin. * Returns the integer number of millivolts */ diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 09ba0bacf..cec004402 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -316,39 +316,43 @@ void send_joystick_packet(joystick_t *joystick) { joystick_report_t r = { # if JOYSTICK_AXES_COUNT > 0 - .axes = {joystick->axes[0], + .axes = + { + joystick->axes[0], # if JOYSTICK_AXES_COUNT >= 2 - joystick->axes[1], + joystick->axes[1], # endif # if JOYSTICK_AXES_COUNT >= 3 - joystick->axes[2], + joystick->axes[2], # endif # if JOYSTICK_AXES_COUNT >= 4 - joystick->axes[3], + joystick->axes[3], # endif # if JOYSTICK_AXES_COUNT >= 5 - joystick->axes[4], + joystick->axes[4], # endif # if JOYSTICK_AXES_COUNT >= 6 - joystick->axes[5], + joystick->axes[5], # endif - }, + }, # endif // JOYSTICK_AXES_COUNT>0 # if JOYSTICK_BUTTON_COUNT > 0 - .buttons = {joystick->buttons[0], + .buttons = + { + joystick->buttons[0], # if JOYSTICK_BUTTON_COUNT > 8 - joystick->buttons[1], + joystick->buttons[1], # endif # if JOYSTICK_BUTTON_COUNT > 16 - joystick->buttons[2], + joystick->buttons[2], # endif # if JOYSTICK_BUTTON_COUNT > 24 - joystick->buttons[3], + joystick->buttons[3], # endif - } + } # endif // JOYSTICK_BUTTON_COUNT>0 }; |