diff options
| author | skullY <skullydazed@gmail.com> | 2019-08-30 11:19:03 -0700 |
|---|---|---|
| committer | skullydazed <skullydazed@users.noreply.github.com> | 2019-08-30 15:01:52 -0700 |
| commit | b624f32f944acdc59dcb130674c09090c5c404cb (patch) | |
| tree | bc13adbba137d122d9a2c2fb2fafcbb08ac10e25 /quantum/split_common/split_util.c | |
| parent | 61af76a10d00aba185b8338604171de490a13e3b (diff) | |
| download | qmk_firmware-b624f32f944acdc59dcb130674c09090c5c404cb.tar.gz qmk_firmware-b624f32f944acdc59dcb130674c09090c5c404cb.zip | |
clang-format changes
Diffstat (limited to 'quantum/split_common/split_util.c')
| -rw-r--r-- | quantum/split_common/split_util.c | 86 |
1 files changed, 37 insertions, 49 deletions
diff --git a/quantum/split_common/split_util.c b/quantum/split_common/split_util.c index d7ed6989f..5114b188e 100644 --- a/quantum/split_common/split_util.c +++ b/quantum/split_common/split_util.c | |||
| @@ -7,87 +7,75 @@ | |||
| 7 | #include "quantum.h" | 7 | #include "quantum.h" |
| 8 | 8 | ||
| 9 | #ifdef EE_HANDS | 9 | #ifdef EE_HANDS |
| 10 | # include "tmk_core/common/eeprom.h" | 10 | # include "tmk_core/common/eeprom.h" |
| 11 | # include "eeconfig.h" | 11 | # include "eeconfig.h" |
| 12 | #endif | 12 | #endif |
| 13 | 13 | ||
| 14 | #if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT) | 14 | #if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT) |
| 15 | #include "rgblight.h" | 15 | # include "rgblight.h" |
| 16 | #endif | 16 | #endif |
| 17 | 17 | ||
| 18 | volatile bool isLeftHand = true; | 18 | volatile bool isLeftHand = true; |
| 19 | 19 | ||
| 20 | __attribute__((weak)) | 20 | __attribute__((weak)) bool is_keyboard_left(void) { |
| 21 | bool is_keyboard_left(void) { | 21 | #if defined(SPLIT_HAND_PIN) |
| 22 | #if defined(SPLIT_HAND_PIN) | ||
| 23 | // Test pin SPLIT_HAND_PIN for High/Low, if low it's right hand | 22 | // Test pin SPLIT_HAND_PIN for High/Low, if low it's right hand |
| 24 | setPinInput(SPLIT_HAND_PIN); | 23 | setPinInput(SPLIT_HAND_PIN); |
| 25 | return readPin(SPLIT_HAND_PIN); | 24 | return readPin(SPLIT_HAND_PIN); |
| 26 | #elif defined(EE_HANDS) | 25 | #elif defined(EE_HANDS) |
| 27 | return eeprom_read_byte(EECONFIG_HANDEDNESS); | 26 | return eeprom_read_byte(EECONFIG_HANDEDNESS); |
| 28 | #elif defined(MASTER_RIGHT) | 27 | #elif defined(MASTER_RIGHT) |
| 29 | return !is_keyboard_master(); | 28 | return !is_keyboard_master(); |
| 30 | #endif | 29 | #endif |
| 31 | 30 | ||
| 32 | return is_keyboard_master(); | 31 | return is_keyboard_master(); |
| 33 | } | 32 | } |
| 34 | 33 | ||
| 35 | __attribute__((weak)) | 34 | __attribute__((weak)) bool is_keyboard_master(void) { |
| 36 | bool is_keyboard_master(void) | ||
| 37 | { | ||
| 38 | #ifdef __AVR__ | 35 | #ifdef __AVR__ |
| 39 | static enum { UNKNOWN, MASTER, SLAVE } usbstate = UNKNOWN; | 36 | static enum { UNKNOWN, MASTER, SLAVE } usbstate = UNKNOWN; |
| 40 | 37 | ||
| 41 | // only check once, as this is called often | 38 | // only check once, as this is called often |
| 42 | if (usbstate == UNKNOWN) | 39 | if (usbstate == UNKNOWN) { |
| 43 | { | 40 | USBCON |= (1 << OTGPADE); // enables VBUS pad |
| 44 | USBCON |= (1 << OTGPADE); // enables VBUS pad | 41 | wait_us(5); |
| 45 | wait_us(5); | ||
| 46 | 42 | ||
| 47 | usbstate = (USBSTA & (1 << VBUS)) ? MASTER : SLAVE; // checks state of VBUS | 43 | usbstate = (USBSTA & (1 << VBUS)) ? MASTER : SLAVE; // checks state of VBUS |
| 48 | } | 44 | } |
| 49 | 45 | ||
| 50 | return (usbstate == MASTER); | 46 | return (usbstate == MASTER); |
| 51 | #else | 47 | #else |
| 52 | return true; | 48 | return true; |
| 53 | #endif | 49 | #endif |
| 54 | } | 50 | } |
| 55 | 51 | ||
| 56 | static void keyboard_master_setup(void) { | 52 | static void keyboard_master_setup(void) { |
| 57 | #if defined(USE_I2C) || defined(EH) | 53 | #if defined(USE_I2C) || defined(EH) |
| 58 | #ifdef SSD1306OLED | 54 | # ifdef SSD1306OLED |
| 59 | matrix_master_OLED_init (); | 55 | matrix_master_OLED_init(); |
| 60 | #endif | 56 | # endif |
| 61 | #endif | 57 | #endif |
| 62 | transport_master_init(); | 58 | transport_master_init(); |
| 63 | } | 59 | } |
| 64 | 60 | ||
| 65 | static void keyboard_slave_setup(void) | 61 | static void keyboard_slave_setup(void) { transport_slave_init(); } |
| 66 | { | ||
| 67 | transport_slave_init(); | ||
| 68 | } | ||
| 69 | 62 | ||
| 70 | // this code runs before the usb and keyboard is initialized | 63 | // this code runs before the usb and keyboard is initialized |
| 71 | void matrix_setup(void) | 64 | void matrix_setup(void) { |
| 72 | { | 65 | isLeftHand = is_keyboard_left(); |
| 73 | isLeftHand = is_keyboard_left(); | ||
| 74 | 66 | ||
| 75 | #if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT) | 67 | #if defined(RGBLIGHT_ENABLE) && defined(RGBLED_SPLIT) |
| 76 | uint8_t num_rgb_leds_split[2] = RGBLED_SPLIT; | 68 | uint8_t num_rgb_leds_split[2] = RGBLED_SPLIT; |
| 77 | if (isLeftHand) { | 69 | if (isLeftHand) { |
| 78 | rgblight_set_clipping_range(0, num_rgb_leds_split[0]); | 70 | rgblight_set_clipping_range(0, num_rgb_leds_split[0]); |
| 79 | } | 71 | } else { |
| 80 | else { | 72 | rgblight_set_clipping_range(num_rgb_leds_split[0], num_rgb_leds_split[1]); |
| 81 | rgblight_set_clipping_range(num_rgb_leds_split[0], num_rgb_leds_split[1]); | 73 | } |
| 82 | } | ||
| 83 | #endif | 74 | #endif |
| 84 | 75 | ||
| 85 | if (is_keyboard_master()) | 76 | if (is_keyboard_master()) { |
| 86 | { | 77 | keyboard_master_setup(); |
| 87 | keyboard_master_setup(); | 78 | } else { |
| 88 | } | 79 | keyboard_slave_setup(); |
| 89 | else | 80 | } |
| 90 | { | ||
| 91 | keyboard_slave_setup(); | ||
| 92 | } | ||
| 93 | } | 81 | } |
