diff options
Diffstat (limited to 'quantum')
-rw-r--r-- | quantum/action.c | 83 | ||||
-rw-r--r-- | quantum/action.h | 2 | ||||
-rw-r--r-- | quantum/backlight/backlight_avr.c | 8 | ||||
-rw-r--r-- | quantum/dynamic_keymap.c | 1 | ||||
-rw-r--r-- | quantum/encoder.c | 6 | ||||
-rw-r--r-- | quantum/joystick.h | 2 | ||||
-rw-r--r-- | quantum/keymap_extras/keymap_lithuanian_azerty.h | 2 | ||||
-rw-r--r-- | quantum/keymap_extras/keymap_slovak.h | 9 | ||||
-rw-r--r-- | quantum/keymap_extras/sendstring_canadian_multilingual.h | 2 | ||||
-rw-r--r-- | quantum/keymap_extras/sendstring_lithuanian_azerty.h | 4 | ||||
-rw-r--r-- | quantum/keymap_extras/sendstring_slovak.h | 2 | ||||
-rw-r--r-- | quantum/led_matrix/animations/solid_reactive_wide.h | 4 | ||||
-rw-r--r-- | quantum/matrix.c | 15 | ||||
-rw-r--r-- | quantum/process_keycode/process_joystick.c | 5 | ||||
-rw-r--r-- | quantum/quantum.c | 1 | ||||
-rw-r--r-- | quantum/rgb_matrix/rgb_matrix.c | 8 |
16 files changed, 81 insertions, 73 deletions
diff --git a/quantum/action.c b/quantum/action.c index 5e81efb671..7a330b05cd 100644 --- a/quantum/action.c +++ b/quantum/action.c @@ -834,10 +834,9 @@ void register_code(uint8_t code) { } #endif - else if - IS_KEY(code) { - // TODO: should push command_proc out of this block? - if (command_proc(code)) return; + else if IS_KEY (code) { + // TODO: should push command_proc out of this block? + if (command_proc(code)) return; #ifndef NO_ACTION_ONESHOT /* TODO: remove @@ -854,35 +853,33 @@ void register_code(uint8_t code) { } else */ #endif - { - // Force a new key press if the key is already pressed - // without this, keys with the same keycode, but different - // modifiers will be reported incorrectly, see issue #1708 - if (is_key_pressed(keyboard_report, code)) { - del_key(code); - send_keyboard_report(); - } - add_key(code); + { + // Force a new key press if the key is already pressed + // without this, keys with the same keycode, but different + // modifiers will be reported incorrectly, see issue #1708 + if (is_key_pressed(keyboard_report, code)) { + del_key(code); send_keyboard_report(); } - } - else if - IS_MOD(code) { - add_mods(MOD_BIT(code)); + add_key(code); send_keyboard_report(); } + } else if IS_MOD (code) { + add_mods(MOD_BIT(code)); + send_keyboard_report(); + } #ifdef EXTRAKEY_ENABLE - else if - IS_SYSTEM(code) { host_system_send(KEYCODE2SYSTEM(code)); } - else if - IS_CONSUMER(code) { host_consumer_send(KEYCODE2CONSUMER(code)); } + else if IS_SYSTEM (code) { + host_system_send(KEYCODE2SYSTEM(code)); + } else if IS_CONSUMER (code) { + host_consumer_send(KEYCODE2CONSUMER(code)); + } #endif #ifdef MOUSEKEY_ENABLE - else if - IS_MOUSEKEY(code) { - mousekey_on(code); - mousekey_send(); - } + else if IS_MOUSEKEY (code) { + mousekey_on(code); + mousekey_send(); + } #endif } @@ -927,26 +924,22 @@ void unregister_code(uint8_t code) { } #endif - else if - IS_KEY(code) { - del_key(code); - send_keyboard_report(); - } - else if - IS_MOD(code) { - del_mods(MOD_BIT(code)); - send_keyboard_report(); - } - else if - IS_SYSTEM(code) { host_system_send(0); } - else if - IS_CONSUMER(code) { host_consumer_send(0); } + else if IS_KEY (code) { + del_key(code); + send_keyboard_report(); + } else if IS_MOD (code) { + del_mods(MOD_BIT(code)); + send_keyboard_report(); + } else if IS_SYSTEM (code) { + host_system_send(0); + } else if IS_CONSUMER (code) { + host_consumer_send(0); + } #ifdef MOUSEKEY_ENABLE - else if - IS_MOUSEKEY(code) { - mousekey_off(code); - mousekey_send(); - } + else if IS_MOUSEKEY (code) { + mousekey_off(code); + mousekey_send(); + } #endif } diff --git a/quantum/action.h b/quantum/action.h index b562f18c5b..8a357ded87 100644 --- a/quantum/action.h +++ b/quantum/action.h @@ -88,7 +88,7 @@ extern bool disable_action_cache; /* Code for handling one-handed key modifiers. */ #ifdef SWAP_HANDS_ENABLE -extern bool swap_hands; +extern bool swap_hands; extern const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS]; # if (MATRIX_COLS <= 8) typedef uint8_t swap_state_row_t; diff --git a/quantum/backlight/backlight_avr.c b/quantum/backlight/backlight_avr.c index 67b551dc3c..9c972ae02e 100644 --- a/quantum/backlight/backlight_avr.c +++ b/quantum/backlight/backlight_avr.c @@ -232,19 +232,19 @@ ISR(TIMERx_OVF_vect) { // See http://jared.geek.nz/2013/feb/linear-led-pwm static uint16_t cie_lightness(uint16_t v) { - if (v <= ICRx / 12) // If the value is less than or equal to ~8% of max + if (v <= (uint32_t)ICRx / 12) // If the value is less than or equal to ~8% of max { return v / 9; // Same as dividing by 900% } else { // In the next two lines values are bit-shifted. This is to avoid loosing decimals in integer math. - uint32_t y = (((uint32_t)v + ICRx / 6) << 5) / (ICRx / 6 + ICRx); // If above 8%, add ~16% of max, and normalize with (max + ~16% max) - uint32_t out = (y * y * y * ICRx) >> 15; // Cube it and undo the bit-shifting. (which is now three times as much due to the cubing) + uint32_t y = (((uint32_t)v + (uint32_t)ICRx / 6) << 5) / ((uint32_t)ICRx / 6 + ICRx); // If above 8%, add ~16% of max, and normalize with (max + ~16% max) + uint32_t out = (y * y * y * ICRx) >> 15; // Cube it and undo the bit-shifting. (which is now three times as much due to the cubing) if (out > ICRx) // Avoid overflows { out = ICRx; } - return out; + return (uint16_t)out; } } diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c index f5525576d8..19a6bea59a 100644 --- a/quantum/dynamic_keymap.c +++ b/quantum/dynamic_keymap.c @@ -14,7 +14,6 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "config.h" #include "keymap.h" // to get keymaps[][][] #include "eeprom.h" #include "progmem.h" // to read default from flash diff --git a/quantum/encoder.c b/quantum/encoder.c index 8fb87281c2..ecbc0c1615 100644 --- a/quantum/encoder.c +++ b/quantum/encoder.c @@ -59,6 +59,8 @@ static uint8_t thisHand, thatHand; static uint8_t encoder_value[NUMBER_OF_ENCODERS] = {0}; #endif +__attribute__((weak)) void encoder_wait_pullup_charge(void) { wait_us(100); } + __attribute__((weak)) bool encoder_update_user(uint8_t index, bool clockwise) { return true; } __attribute__((weak)) bool encoder_update_kb(uint8_t index, bool clockwise) { return encoder_update_user(index, clockwise); } @@ -84,7 +86,9 @@ void encoder_init(void) { for (int i = 0; i < NUMBER_OF_ENCODERS; i++) { setPinInputHigh(encoders_pad_a[i]); setPinInputHigh(encoders_pad_b[i]); - + } + encoder_wait_pullup_charge(); + for (int i = 0; i < NUMBER_OF_ENCODERS; i++) { encoder_state[i] = (readPin(encoders_pad_a[i]) << 0) | (readPin(encoders_pad_b[i]) << 1); } diff --git a/quantum/joystick.h b/quantum/joystick.h index 87dbc24aff..9156491aca 100644 --- a/quantum/joystick.h +++ b/quantum/joystick.h @@ -50,7 +50,7 @@ extern joystick_config_t joystick_axes[JOYSTICK_AXES_COUNT]; enum joystick_status { JS_INITIALIZED = 1, JS_UPDATED = 2 }; typedef struct { - uint8_t buttons[JOYSTICK_BUTTON_COUNT / 8 + 1]; + uint8_t buttons[(JOYSTICK_BUTTON_COUNT - 1) / 8 + 1]; int16_t axes[JOYSTICK_AXES_COUNT]; uint8_t status : 2; diff --git a/quantum/keymap_extras/keymap_lithuanian_azerty.h b/quantum/keymap_extras/keymap_lithuanian_azerty.h index 8ca38129e3..6f47b16702 100644 --- a/quantum/keymap_extras/keymap_lithuanian_azerty.h +++ b/quantum/keymap_extras/keymap_lithuanian_azerty.h @@ -138,7 +138,7 @@ #define LT_CIRC ALGR(LT_COMM) // ^ #define LT_AMPR ALGR(LT_DOT) // & #define LT_ASTR ALGR(LT_EQL) // * -#define LT_LBRC ALGR(LT_LRPN) // [ +#define LT_LBRC ALGR(LT_LPRN) // [ #define LT_RBRC ALGR(LT_RPRN) // ] #define LT_QUOT ALGR(LT_QUES) // ' #define LT_PERC ALGR(LT_X) // % diff --git a/quantum/keymap_extras/keymap_slovak.h b/quantum/keymap_extras/keymap_slovak.h index 71344c07ff..bf0b7275ce 100644 --- a/quantum/keymap_extras/keymap_slovak.h +++ b/quantum/keymap_extras/keymap_slovak.h @@ -102,10 +102,10 @@ // Row 1 #define SK_RNGA S(SK_SCLN) // ° (dead) #define SK_1 S(SK_PLUS) // 1 -#define SK_2 S(SK_LACU) // 2 +#define SK_2 S(SK_LCAR) // 2 #define SK_3 S(SK_SCAR) // 3 #define SK_4 S(SK_CCAR) // 4 -#define SK_5 S(SK_TACU) // 5 +#define SK_5 S(SK_TCAR) // 5 #define SK_6 S(SK_ZCAR) // 6 #define SK_7 S(SK_YACU) // 7 #define SK_8 S(SK_AACU) // 8 @@ -141,9 +141,8 @@ */ // Row 1 #define SK_TILD ALGR(SK_PLUS) // ~ -#define SK_CIRC ALGR(SK_LCAR) // ^ (dead) -#define SK_BREV ALGR(SK_SCAR) // ˘ (dead) -#define SK_RNGA ALGR(SK_CCAR) // ° (dead) +#define SK_CIRC ALGR(SK_SCAR) // ^ (dead) +#define SK_BREV ALGR(SK_CCAR) // ˘ (dead) #define SK_OGON ALGR(SK_TCAR) // ˛ (dead) #define SK_GRV ALGR(SK_ZCAR) // ` #define SK_DOTA ALGR(SK_YACU) // ˙ (dead) diff --git a/quantum/keymap_extras/sendstring_canadian_multilingual.h b/quantum/keymap_extras/sendstring_canadian_multilingual.h index c3fcc62c37..3679a98c14 100644 --- a/quantum/keymap_extras/sendstring_canadian_multilingual.h +++ b/quantum/keymap_extras/sendstring_canadian_multilingual.h @@ -80,7 +80,7 @@ const uint8_t ascii_to_keycode_lut[128] PROGMEM = { // 0 1 2 3 4 5 6 7 CA_0, CA_1, CA_2, CA_3, CA_4, CA_5, CA_6, CA_7, // 8 9 : ; < = > ? - CA_8, CA_9, CA_SCLN, CA_SCLN, CA_DOT, CA_EQL, CA_COMM, CA_6, + CA_8, CA_9, CA_SCLN, CA_SCLN, CA_COMM, CA_EQL, CA_DOT, CA_6, // @ A B C D E F G CA_2, CA_A, CA_B, CA_C, CA_D, CA_E, CA_F, CA_G, // H I J K L M N O diff --git a/quantum/keymap_extras/sendstring_lithuanian_azerty.h b/quantum/keymap_extras/sendstring_lithuanian_azerty.h index 7498a3dc4d..a886411143 100644 --- a/quantum/keymap_extras/sendstring_lithuanian_azerty.h +++ b/quantum/keymap_extras/sendstring_lithuanian_azerty.h @@ -76,9 +76,9 @@ const uint8_t ascii_to_keycode_lut[128] PROGMEM = { // ! " # $ % & ' KC_SPC, LT_EXLM, LT_EDOT, LT_SLSH, LT_SCLN, LT_X, LT_DOT, LT_QUES, // ( ) * + , - . / - LT_LRPN, LT_RPRN, LT_EQL, LT_QUES, LT_COMM, LT_MINS, LT_DOT, LT_SLSH, + LT_LPRN, LT_RPRN, LT_EQL, LT_QUES, LT_COMM, LT_MINS, LT_DOT, LT_SLSH, // 0 1 2 3 4 5 6 7 - LT_RPRN, LT_EXLM, LT_MINS, LT_SLSH, LT_SLCN, LT_COLN, LT_COMM, LT_DOT, + LT_RPRN, LT_EXLM, LT_MINS, LT_SLSH, LT_SCLN, LT_COLN, LT_COMM, LT_DOT, // 8 9 : ; < = > ? LT_EQL, LT_LPRN, LT_COLN, LT_SCLN, LT_LABK, LT_EQL, LT_LABK, LT_QUES, // @ A B C D E F G diff --git a/quantum/keymap_extras/sendstring_slovak.h b/quantum/keymap_extras/sendstring_slovak.h index 72eeb86a53..f48d30dcb1 100644 --- a/quantum/keymap_extras/sendstring_slovak.h +++ b/quantum/keymap_extras/sendstring_slovak.h @@ -78,7 +78,7 @@ const uint8_t ascii_to_keycode_lut[128] PROGMEM = { // ( ) * + , - . / SK_ADIA, SK_NCAR, SK_AMPR, SK_PLUS, SK_COMM, SK_MINS, SK_DOT, SK_UACU, // 0 1 2 3 4 5 6 7 - SK_EACU, SK_PLUS, SK_LACU, SK_SCAR, SK_CCAR, SK_TACU, SK_ZCAR, SK_YACU, + SK_EACU, SK_PLUS, SK_LCAR, SK_SCAR, SK_CCAR, SK_TCAR, SK_ZCAR, SK_YACU, // 8 9 : ; < = > ? SK_AACU, SK_IACU, SK_DOT, SK_SCLN, SK_AMPR, SK_EQL, SK_Y, SK_COMM, // @ A B C D E F G diff --git a/quantum/led_matrix/animations/solid_reactive_wide.h b/quantum/led_matrix/animations/solid_reactive_wide.h index 3aa88063a7..9f039c45d4 100644 --- a/quantum/led_matrix/animations/solid_reactive_wide.h +++ b/quantum/led_matrix/animations/solid_reactive_wide.h @@ -1,5 +1,5 @@ #ifdef LED_MATRIX_KEYREACTIVE_ENABLED -# if !defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_WIDE) || defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE) +# if defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_WIDE) || defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE) # ifdef ENABLE_LED_MATRIX_SOLID_REACTIVE_WIDE LED_MATRIX_EFFECT(SOLID_REACTIVE_WIDE) @@ -26,5 +26,5 @@ bool SOLID_REACTIVE_MULTIWIDE(effect_params_t* params) { return effect_runner_re # endif # endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS -# endif // !defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_WIDE) || !defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE) +# endif // defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_WIDE) || defined(ENABLE_LED_MATRIX_SOLID_REACTIVE_MULTIWIDE) #endif // LED_MATRIX_KEYREACTIVE_ENABLED diff --git a/quantum/matrix.c b/quantum/matrix.c index 483d518ecc..8596c2eabd 100644 --- a/quantum/matrix.c +++ b/quantum/matrix.c @@ -82,6 +82,13 @@ static inline void setPinOutput_writeLow(pin_t pin) { } } +static inline void setPinOutput_writeHigh(pin_t pin) { + ATOMIC_BLOCK_FORCEON { + setPinOutput(pin); + writePinHigh(pin); + } +} + static inline void setPinInputHigh_atomic(pin_t pin) { ATOMIC_BLOCK_FORCEON { setPinInputHigh(pin); } } @@ -141,7 +148,11 @@ static bool select_row(uint8_t row) { static void unselect_row(uint8_t row) { pin_t pin = row_pins[row]; if (pin != NO_PIN) { +# ifdef MATRIX_UNSELECT_DRIVE_HIGH + setPinOutput_writeHigh(pin); +# else setPinInputHigh_atomic(pin); +# endif } } @@ -200,7 +211,11 @@ static bool select_col(uint8_t col) { static void unselect_col(uint8_t col) { pin_t pin = col_pins[col]; if (pin != NO_PIN) { +# ifdef MATRIX_UNSELECT_DRIVE_HIGH + setPinOutput_writeHigh(pin); +# else setPinInputHigh_atomic(pin); +# endif } } diff --git a/quantum/process_keycode/process_joystick.c b/quantum/process_keycode/process_joystick.c index 3ffaf42bf8..fa9c2c1dbc 100644 --- a/quantum/process_keycode/process_joystick.c +++ b/quantum/process_keycode/process_joystick.c @@ -28,10 +28,11 @@ bool process_joystick_buttons(uint16_t keycode, keyrecord_t *record) { if (keycode < JS_BUTTON0 || keycode > JS_BUTTON_MAX) { return true; } else { + uint8_t button_idx = (keycode - JS_BUTTON0); if (record->event.pressed) { - joystick_status.buttons[(keycode - JS_BUTTON0) / 8] |= 1 << (keycode % 8); + joystick_status.buttons[button_idx / 8] |= 1 << (button_idx % 8); } else { - joystick_status.buttons[(keycode - JS_BUTTON0) / 8] &= ~(1 << (keycode % 8)); + joystick_status.buttons[button_idx / 8] &= ~(1 << (button_idx % 8)); } joystick_status.status |= JS_UPDATED; diff --git a/quantum/quantum.c b/quantum/quantum.c index 35b6351e9d..be43faaf6b 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -488,6 +488,7 @@ __attribute__((weak)) void suspend_power_down_user(void) {} __attribute__((weak)) void suspend_power_down_kb(void) { suspend_power_down_user(); } void suspend_power_down_quantum(void) { + suspend_power_down_kb(); #ifndef NO_SUSPEND_POWER_DOWN // Turn off backlight # ifdef BACKLIGHT_ENABLE diff --git a/quantum/rgb_matrix/rgb_matrix.c b/quantum/rgb_matrix/rgb_matrix.c index 558c7bd41a..51e9554e2d 100644 --- a/quantum/rgb_matrix/rgb_matrix.c +++ b/quantum/rgb_matrix/rgb_matrix.c @@ -275,12 +275,8 @@ static void rgb_task_timers(void) { // Update double buffer timers #if RGB_DISABLE_TIMEOUT > 0 - if (rgb_anykey_timer < UINT32_MAX) { - if (UINT32_MAX - deltaTime < rgb_anykey_timer) { - rgb_anykey_timer = UINT32_MAX; - } else { - rgb_anykey_timer += deltaTime; - } + if (rgb_anykey_timer + deltaTime <= UINT32_MAX) { + rgb_anykey_timer += deltaTime; } #endif // RGB_DISABLE_TIMEOUT > 0 |