mirror of
https://github.com/qmk/qmk_firmware.git
synced 2024-11-25 12:46:41 +00:00
Merge remote-tracking branch 'origin/develop' into xap
This commit is contained in:
commit
84d5af3157
@ -12,23 +12,23 @@ static bool PIXEL_RAIN(effect_params_t* params) {
|
||||
return 500 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16);
|
||||
}
|
||||
|
||||
void rain_pixel(uint8_t i, effect_params_t * params, bool off) {
|
||||
if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) {
|
||||
inline void rain_pixel(uint8_t led_index) {
|
||||
if (!HAS_ANY_FLAGS(g_led_config.flags[led_index], params->flags)) {
|
||||
return;
|
||||
}
|
||||
if (off) {
|
||||
rgb_matrix_set_color(i, 0, 0, 0);
|
||||
if (random8() & 2) {
|
||||
rgb_matrix_set_color(led_index, 0, 0, 0);
|
||||
} else {
|
||||
HSV hsv = {random8(), random8_min_max(127, 255), rgb_matrix_config.hsv.v};
|
||||
RGB rgb = rgb_matrix_hsv_to_rgb(hsv);
|
||||
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
|
||||
rgb_matrix_set_color(led_index, rgb.r, rgb.g, rgb.b);
|
||||
}
|
||||
wait_timer = g_rgb_timer + interval();
|
||||
}
|
||||
|
||||
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
||||
if (g_rgb_timer > wait_timer) {
|
||||
rain_pixel(random8_max(RGB_MATRIX_LED_COUNT), params, random8() & 2);
|
||||
rain_pixel(random8_max(RGB_MATRIX_LED_COUNT));
|
||||
}
|
||||
return rgb_matrix_check_finished_leds(led_max);
|
||||
}
|
||||
|
@ -874,65 +874,48 @@ uint8_t keyboard_leds(void) {
|
||||
return keyboard_led_state;
|
||||
}
|
||||
|
||||
void send_report(uint8_t endpoint, void *report, size_t size) {
|
||||
osalSysLock();
|
||||
if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) {
|
||||
osalSysUnlock();
|
||||
return;
|
||||
}
|
||||
|
||||
if (usbGetTransmitStatusI(&USB_DRIVER, endpoint)) {
|
||||
/* Need to either suspend, or loop and call unlock/lock during
|
||||
* every iteration - otherwise the system will remain locked,
|
||||
* no interrupts served, so USB not going through as well.
|
||||
* Note: for suspend, need USB_USE_WAIT == TRUE in halconf.h */
|
||||
if (osalThreadSuspendTimeoutS(&(&USB_DRIVER)->epc[endpoint]->in_state->thread, TIME_MS2I(10)) == MSG_TIMEOUT) {
|
||||
osalSysUnlock();
|
||||
return;
|
||||
}
|
||||
}
|
||||
usbStartTransmitI(&USB_DRIVER, endpoint, report, size);
|
||||
osalSysUnlock();
|
||||
}
|
||||
|
||||
/* prepare and start sending a report IN
|
||||
* not callable from ISR or locked state */
|
||||
void send_keyboard(report_keyboard_t *report) {
|
||||
osalSysLock();
|
||||
if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) {
|
||||
goto unlock;
|
||||
}
|
||||
uint8_t ep = KEYBOARD_IN_EPNUM;
|
||||
size_t size = KEYBOARD_REPORT_SIZE;
|
||||
|
||||
/* If we're in Boot Protocol, don't send any report ID or other funky fields */
|
||||
if (!keyboard_protocol) {
|
||||
send_report(ep, &report->mods, 8);
|
||||
} else {
|
||||
#ifdef NKRO_ENABLE
|
||||
if (keymap_config.nkro && keyboard_protocol) { /* NKRO protocol */
|
||||
/* need to wait until the previous packet has made it through */
|
||||
/* can rewrite this using the synchronous API, then would wait
|
||||
* until *after* the packet has been transmitted. I think
|
||||
* this is more efficient */
|
||||
/* busy wait, should be short and not very common */
|
||||
if (usbGetTransmitStatusI(&USB_DRIVER, SHARED_IN_EPNUM)) {
|
||||
/* Need to either suspend, or loop and call unlock/lock during
|
||||
* every iteration - otherwise the system will remain locked,
|
||||
* no interrupts served, so USB not going through as well.
|
||||
* Note: for suspend, need USB_USE_WAIT == TRUE in halconf.h */
|
||||
osalThreadSuspendS(&(&USB_DRIVER)->epc[SHARED_IN_EPNUM]->in_state->thread);
|
||||
if (keymap_config.nkro) {
|
||||
ep = SHARED_IN_EPNUM;
|
||||
size = sizeof(struct nkro_report);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* after osalThreadSuspendS returns USB status might have changed */
|
||||
if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) {
|
||||
goto unlock;
|
||||
}
|
||||
}
|
||||
usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)report, sizeof(struct nkro_report));
|
||||
} else
|
||||
#endif /* NKRO_ENABLE */
|
||||
{ /* regular protocol */
|
||||
/* need to wait until the previous packet has made it through */
|
||||
/* busy wait, should be short and not very common */
|
||||
if (usbGetTransmitStatusI(&USB_DRIVER, KEYBOARD_IN_EPNUM)) {
|
||||
/* Need to either suspend, or loop and call unlock/lock during
|
||||
* every iteration - otherwise the system will remain locked,
|
||||
* no interrupts served, so USB not going through as well.
|
||||
* Note: for suspend, need USB_USE_WAIT == TRUE in halconf.h */
|
||||
osalThreadSuspendS(&(&USB_DRIVER)->epc[KEYBOARD_IN_EPNUM]->in_state->thread);
|
||||
|
||||
/* after osalThreadSuspendS returns USB status might have changed */
|
||||
if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) {
|
||||
goto unlock;
|
||||
}
|
||||
}
|
||||
uint8_t *data, size;
|
||||
if (keyboard_protocol) {
|
||||
data = (uint8_t *)report;
|
||||
size = KEYBOARD_REPORT_SIZE;
|
||||
} else { /* boot protocol */
|
||||
data = &report->mods;
|
||||
size = 8;
|
||||
}
|
||||
usbStartTransmitI(&USB_DRIVER, KEYBOARD_IN_EPNUM, data, size);
|
||||
send_report(ep, report, size);
|
||||
}
|
||||
keyboard_report_sent = *report;
|
||||
|
||||
unlock:
|
||||
osalSysUnlock();
|
||||
keyboard_report_sent = *report;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------
|
||||
@ -940,35 +923,13 @@ unlock:
|
||||
* ---------------------------------------------------------
|
||||
*/
|
||||
|
||||
void send_mouse(report_mouse_t *report) {
|
||||
#ifdef MOUSE_ENABLE
|
||||
void send_mouse(report_mouse_t *report) {
|
||||
osalSysLock();
|
||||
if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) {
|
||||
osalSysUnlock();
|
||||
return;
|
||||
}
|
||||
|
||||
if (usbGetTransmitStatusI(&USB_DRIVER, MOUSE_IN_EPNUM)) {
|
||||
/* Need to either suspend, or loop and call unlock/lock during
|
||||
* every iteration - otherwise the system will remain locked,
|
||||
* no interrupts served, so USB not going through as well.
|
||||
* Note: for suspend, need USB_USE_WAIT == TRUE in halconf.h */
|
||||
if (osalThreadSuspendTimeoutS(&(&USB_DRIVER)->epc[MOUSE_IN_EPNUM]->in_state->thread, TIME_MS2I(10)) == MSG_TIMEOUT) {
|
||||
osalSysUnlock();
|
||||
return;
|
||||
}
|
||||
}
|
||||
usbStartTransmitI(&USB_DRIVER, MOUSE_IN_EPNUM, (uint8_t *)report, sizeof(report_mouse_t));
|
||||
send_report(MOUSE_IN_EPNUM, report, sizeof(report_mouse_t));
|
||||
mouse_report_sent = *report;
|
||||
osalSysUnlock();
|
||||
#endif
|
||||
}
|
||||
|
||||
#else /* MOUSE_ENABLE */
|
||||
void send_mouse(report_mouse_t *report) {
|
||||
(void)report;
|
||||
}
|
||||
#endif /* MOUSE_ENABLE */
|
||||
|
||||
/* ---------------------------------------------------------
|
||||
* Extrakey functions
|
||||
* ---------------------------------------------------------
|
||||
@ -976,97 +937,25 @@ void send_mouse(report_mouse_t *report) {
|
||||
|
||||
void send_extra(report_extra_t *report) {
|
||||
#ifdef EXTRAKEY_ENABLE
|
||||
osalSysLock();
|
||||
if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) {
|
||||
osalSysUnlock();
|
||||
return;
|
||||
}
|
||||
|
||||
if (usbGetTransmitStatusI(&USB_DRIVER, SHARED_IN_EPNUM)) {
|
||||
/* Need to either suspend, or loop and call unlock/lock during
|
||||
* every iteration - otherwise the system will remain locked,
|
||||
* no interrupts served, so USB not going through as well.
|
||||
* Note: for suspend, need USB_USE_WAIT == TRUE in halconf.h */
|
||||
if (osalThreadSuspendTimeoutS(&(&USB_DRIVER)->epc[SHARED_IN_EPNUM]->in_state->thread, TIME_MS2I(10)) == MSG_TIMEOUT) {
|
||||
osalSysUnlock();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)report, sizeof(report_extra_t));
|
||||
osalSysUnlock();
|
||||
send_report(SHARED_IN_EPNUM, report, sizeof(report_extra_t));
|
||||
#endif
|
||||
}
|
||||
|
||||
void send_programmable_button(report_programmable_button_t *report) {
|
||||
#ifdef PROGRAMMABLE_BUTTON_ENABLE
|
||||
osalSysLock();
|
||||
if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) {
|
||||
osalSysUnlock();
|
||||
return;
|
||||
}
|
||||
|
||||
if (usbGetTransmitStatusI(&USB_DRIVER, SHARED_IN_EPNUM)) {
|
||||
/* Need to either suspend, or loop and call unlock/lock during
|
||||
* every iteration - otherwise the system will remain locked,
|
||||
* no interrupts served, so USB not going through as well.
|
||||
* Note: for suspend, need USB_USE_WAIT == TRUE in halconf.h */
|
||||
if (osalThreadSuspendTimeoutS(&(&USB_DRIVER)->epc[SHARED_IN_EPNUM]->in_state->thread, TIME_MS2I(10)) == MSG_TIMEOUT) {
|
||||
osalSysUnlock();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)report, sizeof(report_programmable_button_t));
|
||||
osalSysUnlock();
|
||||
send_report(SHARED_IN_EPNUM, report, sizeof(report_programmable_button_t));
|
||||
#endif
|
||||
}
|
||||
|
||||
void send_joystick(report_joystick_t *report) {
|
||||
#ifdef JOYSTICK_ENABLE
|
||||
osalSysLock();
|
||||
if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) {
|
||||
osalSysUnlock();
|
||||
return;
|
||||
}
|
||||
|
||||
if (usbGetTransmitStatusI(&USB_DRIVER, JOYSTICK_IN_EPNUM)) {
|
||||
/* Need to either suspend, or loop and call unlock/lock during
|
||||
* every iteration - otherwise the system will remain locked,
|
||||
* no interrupts served, so USB not going through as well.
|
||||
* Note: for suspend, need USB_USE_WAIT == TRUE in halconf.h */
|
||||
if (osalThreadSuspendTimeoutS(&(&USB_DRIVER)->epc[JOYSTICK_IN_EPNUM]->in_state->thread, TIME_MS2I(10)) == MSG_TIMEOUT) {
|
||||
osalSysUnlock();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
usbStartTransmitI(&USB_DRIVER, JOYSTICK_IN_EPNUM, (uint8_t *)report, sizeof(report_joystick_t));
|
||||
osalSysUnlock();
|
||||
send_report(JOYSTICK_IN_EPNUM, report, sizeof(report_joystick_t));
|
||||
#endif
|
||||
}
|
||||
|
||||
void send_digitizer(report_digitizer_t *report) {
|
||||
#ifdef DIGITIZER_ENABLE
|
||||
osalSysLock();
|
||||
if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) {
|
||||
osalSysUnlock();
|
||||
return;
|
||||
}
|
||||
|
||||
if (usbGetTransmitStatusI(&USB_DRIVER, DIGITIZER_IN_EPNUM)) {
|
||||
/* Need to either suspend, or loop and call unlock/lock during
|
||||
* every iteration - otherwise the system will remain locked,
|
||||
* no interrupts served, so USB not going through as well.
|
||||
* Note: for suspend, need USB_USE_WAIT == TRUE in halconf.h */
|
||||
if (osalThreadSuspendTimeoutS(&(&USB_DRIVER)->epc[DIGITIZER_IN_EPNUM]->in_state->thread, TIME_MS2I(10)) == MSG_TIMEOUT) {
|
||||
osalSysUnlock();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
usbStartTransmitI(&USB_DRIVER, DIGITIZER_IN_EPNUM, (uint8_t *)report, sizeof(report_digitizer_t));
|
||||
osalSysUnlock();
|
||||
send_report(DIGITIZER_IN_EPNUM, report, sizeof(report_digitizer_t));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user