mirror of
https://github.com/qmk/qmk_firmware.git
synced 2024-11-24 04:12:56 +00:00
fced377ac0
* Branch point for 2020 May 30 Breaking Change * Migrate `ACTION_LAYER_TOGGLE` to `TG()` (#8954) * Migrate `ACTION_MODS_ONESHOT` to `OSM()` (#8957) * Migrate `ACTION_DEFAULT_LAYER_SET` to `DF()` (#8958) * Migrate `ACTION_LAYER_MODS` to `LM()` (#8959) * Migrate `ACTION_MODS_TAP_KEY` to `MT()` (#8968) * Convert V-USB usbdrv to a submodule (#8321) * Unify Tap Hold functions and documentation (#8348) * Changing board names to prevent confusion (#8412) * Move the Keyboardio Model01 to a keyboardio/ subdir (#8499) * Move spaceman keyboards (#8830) * Migrate miscellaneous `fn_actions` entries (#8977) * Migrate `ACTION_MODS_KEY` to chained mod keycodes (#8979) * Organizing my keyboards (plaid, tartan, ergoinu) (#8537) * Refactor Lily58 to use split_common (#6260) * Refactor zinc to use split_common (#7114) * Add a message if bin/qmk doesn't work (#9000) * Fix conflicting types for 'tfp_printf' (#8269) * Fixed RGB_DISABLE_AFTER_TIMEOUT to be seconds based & small internals cleanup (#6480) * Refactor and updates to TKC1800 code (#8472) * Switch to qmk forks for everything (#9019) * audio refactor: replace deprecated PLAY_NOTE_ARRAY (#8484) * Audio enable corrections (2/3) (#8903) * Split HHKB to ANSI and JP layouts and Add VIA support for each (#8582) * Audio enable corrections (Part 4) (#8974) * Fix typo from PR7114 (#9171) * Augment future branch Changelogs (#8978) * Revert "Branch point for 2020 May 30 Breaking Change"
57 lines
1.2 KiB
C
57 lines
1.2 KiB
C
#include <avr/io.h>
|
|
#include <avr/wdt.h>
|
|
#include <avr/power.h>
|
|
#include <avr/interrupt.h>
|
|
#include <util/delay.h>
|
|
#include <avr/eeprom.h>
|
|
#include "split_util.h"
|
|
#include "matrix.h"
|
|
#include "keyboard.h"
|
|
|
|
#include "serial.h"
|
|
|
|
volatile bool isLeftHand = true;
|
|
|
|
static void setup_handedness(void) {
|
|
#ifdef EE_HANDS
|
|
isLeftHand = eeprom_read_byte(EECONFIG_HANDEDNESS);
|
|
#else
|
|
// I2C_MASTER_RIGHT is deprecated, use MASTER_RIGHT instead, since this works for both serial and i2c
|
|
#if defined(I2C_MASTER_RIGHT) || defined(MASTER_RIGHT)
|
|
isLeftHand = !has_usb();
|
|
#else
|
|
isLeftHand = has_usb();
|
|
#endif
|
|
#endif
|
|
}
|
|
|
|
static void keyboard_master_setup(void) {
|
|
serial_master_init();
|
|
}
|
|
|
|
static void keyboard_slave_setup(void) {
|
|
serial_slave_init();
|
|
}
|
|
|
|
bool has_usb(void) {
|
|
USBCON |= (1 << OTGPADE); //enables VBUS pad
|
|
_delay_us(5);
|
|
return (USBSTA & (1<<VBUS)); //checks state of VBUS
|
|
}
|
|
|
|
void split_keyboard_setup(void) {
|
|
setup_handedness();
|
|
|
|
if (has_usb()) {
|
|
keyboard_master_setup();
|
|
} else {
|
|
keyboard_slave_setup();
|
|
}
|
|
sei();
|
|
}
|
|
|
|
// this code runs before the usb and keyboard is initialized
|
|
void matrix_setup(void) {
|
|
split_keyboard_setup();
|
|
}
|