Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playground #192

Merged
merged 4 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions keyboards/keychron/common/keychron_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,7 @@ __attribute__((weak)) void keyboard_post_init_kb(void) {
}
}
#endif

void restart_usb_driver(USBDriver *usbp) {
// Do nothing. Restarting the USB driver on these boards breaks it.
}
4 changes: 2 additions & 2 deletions keyboards/keychron/x0/ansi/red/keymaps/keychron/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_LCTL, KC_LALT, MO(WIN_FN), MO(WIN_FN), KC_SPC),

[WIN_FN] = LAYOUT(
_______, KC_BRID, KC_BRIU, KC_TASK, KC_FLXP, _______,
_______, _______, _______, _______, _______, _______, _______,
_______, KC_BRID, KC_BRIU, KC_TASK, KC_PSCR, KC_CRTA,
_______, KC_7, KC_8, KC_9, KC_0, _______, _______,
BL_TOGG, BL_STEP, BL_UP, _______, _______, _______,
_______, _______, BL_DOWN, _______, _______, _______,
_______, _______, _______, _______, NK_TOGG,
Expand Down
2 changes: 1 addition & 1 deletion keyboards/keychron/x0/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
#define EECONFIG_USER_DATA_SIZE 1

/* Factory test keys */
#define F_RESET_KEY1 KC_6
#define F_RESET_KEY1 KC_X
#define FN_KEY1 MO(1)
5 changes: 0 additions & 5 deletions keyboards/keychron/x1/x1.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
win_lock_state = !win_lock_state;
eeconfig_update_user_datablock(&win_lock_state);
if (win_lock_state) {
SET_LED_WIN_LOCK_ON;
} else {
SET_LED_WIN_LOCK_OFF;
}
}
return true;
default:
Expand Down
2 changes: 1 addition & 1 deletion keyboards/keychron/x2/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

/* Winlock indicator */
#define LED_WIN_LOCK_PIN A5
#define LED_PIN_ON_STATE 1
#define LED_WIN_LOCK_PIN_ON_STATE 1

/* User used eeprom */
#define EECONFIG_USER_DATA_SIZE 1
Expand Down
9 changes: 2 additions & 7 deletions keyboards/keychron/x2/x2.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

static uint8_t win_lock_state = 0;

#define SET_LED_WIN_LOCK_ON writePin(LED_WIN_LOCK_PIN, LED_PIN_ON_STATE)
#define SET_LED_WIN_LOCK_OFF writePin(LED_WIN_LOCK_PIN, !LED_PIN_ON_STATE)
#define SET_LED_WIN_LOCK_ON writePin(LED_WIN_LOCK_PIN, LED_WIN_LOCK_PIN_ON_STATE)
#define SET_LED_WIN_LOCK_OFF writePin(LED_WIN_LOCK_PIN, !LED_WIN_LOCK_PIN_ON_STATE)

static void set_led_win_lock_state(void) {
if (win_lock_state) {
Expand Down Expand Up @@ -64,11 +64,6 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
win_lock_state = !win_lock_state;
eeconfig_update_user_datablock(&win_lock_state);
if (win_lock_state) {
writePin(LED_WIN_LOCK_PIN, LED_PIN_ON_STATE);
} else {
writePin(LED_WIN_LOCK_PIN, !LED_PIN_ON_STATE);
}
}
return true;
default:
Expand Down
2 changes: 1 addition & 1 deletion keyboards/keychron/x3/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

/* Winlock indicator */
#define LED_WIN_LOCK_PIN A3
#define LED_PIN_ON_STATE 1
#define LED_WIN_LOCK_PIN_ON_STATE 1

/* User used eeprom */
#define EECONFIG_USER_DATA_SIZE 1
Expand Down
9 changes: 2 additions & 7 deletions keyboards/keychron/x3/x3.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

static uint8_t win_lock_state = 0;

#define SET_LED_WIN_LOCK_ON writePin(LED_WIN_LOCK_PIN, LED_PIN_ON_STATE)
#define SET_LED_WIN_LOCK_OFF writePin(LED_WIN_LOCK_PIN, !LED_PIN_ON_STATE)
#define SET_LED_WIN_LOCK_ON writePin(LED_WIN_LOCK_PIN, LED_WIN_LOCK_PIN_ON_STATE)
#define SET_LED_WIN_LOCK_OFF writePin(LED_WIN_LOCK_PIN, !LED_WIN_LOCK_PIN_ON_STATE)

static void set_led_win_lock_state(void) {
if (win_lock_state) {
Expand Down Expand Up @@ -64,11 +64,6 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
win_lock_state = !win_lock_state;
eeconfig_update_user_datablock(&win_lock_state);
if (win_lock_state) {
writePin(LED_WIN_LOCK_PIN, LED_PIN_ON_STATE);
} else {
writePin(LED_WIN_LOCK_PIN, !LED_PIN_ON_STATE);
}
}
return true;
default:
Expand Down
3 changes: 3 additions & 0 deletions keyboards/keychron/x4/ansi_encoder/red/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
# define LED_MATRIX_LED_COUNT 81

/* Winlock indicator */
# define LED_CAPS_LOCK_INDEX 44
# define DIM_CAPS_LOCK
# define LED_WIN_LOCK_INDEX 72

/* Scan phase of led driver set as MSKPHASE_6CHANNEL(defined as 0x03 in CKLED2001.h) */
Expand All @@ -46,4 +48,5 @@
/* Encoder Configuration*/
#ifdef ENCODER_ENABLE
# define ENCODER_DEFAULT_POS 0x3
# define ENCODER_MAP_KEY_DELAY 2
#endif
7 changes: 7 additions & 0 deletions keyboards/keychron/x4/x4.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,12 @@ bool led_matrix_indicators_kb(void) {
led_matrix_set_value(LED_WIN_LOCK_INDEX, 0);
}
}
#if defined(LED_CAPS_LOCK_INDEX)
if (host_keyboard_led_state().caps_lock) {
# if defined(DIM_CAPS_LOCK)
led_matrix_set_value(LED_CAPS_LOCK_INDEX, 0);
# endif
#endif
}
return true;
}
5 changes: 0 additions & 5 deletions keyboards/keychron/x6/x6.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
win_lock_state = !win_lock_state;
eeconfig_update_user_datablock(&win_lock_state);
if (win_lock_state) {
writePin(LED_WIN_LOCK_PIN, LED_WIN_LOCK_PIN_ON_STATE);
} else {
writePin(LED_WIN_LOCK_PIN, !LED_WIN_LOCK_PIN_ON_STATE);
}
}
return true;
default:
Expand Down
2 changes: 1 addition & 1 deletion lib/chibios
34 changes: 4 additions & 30 deletions tmk_core/protocol/chibios/chibios.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,35 +179,10 @@ void protocol_post_init(void) {
host_set_driver(driver);
}

#if defined(STM32_USB_USE_OTG1)
void protocol_pre_task(void) {
# if !defined(NO_USB_STARTUP_CHECK)
if (USB_DRIVER.state == USB_SUSPENDED) {
dprintln("suspending keyboard");
while (USB_DRIVER.state == USB_SUSPENDED) {
/* Do this in the suspended state */
suspend_power_down(); // on AVR this deep sleeps for 15ms
/* Remote wakeup */
if ((USB_DRIVER.status & USB_GETSTATUS_REMOTE_WAKEUP_ENABLED) && suspend_wakeup_condition()) {
usbWakeupHost(&USB_DRIVER);
wait_ms(300);
}
}
/* Woken up */
// variables has been already cleared by the wakeup hook
send_keyboard_report();
# ifdef MOUSEKEY_ENABLE
mousekey_send();
# endif /* MOUSEKEY_ENABLE */
}
# endif
usb_event_queue_task();
}
#else
void protocol_pre_task(void) {
usb_event_queue_task();

# if !defined(NO_USB_STARTUP_CHECK)
#if !defined(NO_USB_STARTUP_CHECK)
if (USB_DRIVER.state == USB_SUSPENDED) {
dprintln("suspending keyboard");
while (USB_DRIVER.state == USB_SUSPENDED) {
Expand All @@ -222,13 +197,12 @@ void protocol_pre_task(void) {
/* Woken up */
// variables has been already cleared by the wakeup hook
send_keyboard_report();
# ifdef MOUSEKEY_ENABLE
# ifdef MOUSEKEY_ENABLE
mousekey_send();
# endif /* MOUSEKEY_ENABLE */
# endif /* MOUSEKEY_ENABLE */
}
# endif
}
#endif
}

void protocol_post_task(void) {
#ifdef CONSOLE_ENABLE
Expand Down
Loading