mirror of
https://github.com/qmk/qmk_firmware.git
synced 2024-11-29 06:30:17 +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);
|
return 500 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rain_pixel(uint8_t i, effect_params_t * params, bool off) {
|
inline void rain_pixel(uint8_t led_index) {
|
||||||
if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) {
|
if (!HAS_ANY_FLAGS(g_led_config.flags[led_index], params->flags)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (off) {
|
if (random8() & 2) {
|
||||||
rgb_matrix_set_color(i, 0, 0, 0);
|
rgb_matrix_set_color(led_index, 0, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
HSV hsv = {random8(), random8_min_max(127, 255), rgb_matrix_config.hsv.v};
|
HSV hsv = {random8(), random8_min_max(127, 255), rgb_matrix_config.hsv.v};
|
||||||
RGB rgb = rgb_matrix_hsv_to_rgb(hsv);
|
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();
|
wait_timer = g_rgb_timer + interval();
|
||||||
}
|
}
|
||||||
|
|
||||||
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
||||||
if (g_rgb_timer > wait_timer) {
|
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);
|
return rgb_matrix_check_finished_leds(led_max);
|
||||||
}
|
}
|
||||||
|
@ -874,65 +874,48 @@ uint8_t keyboard_leds(void) {
|
|||||||
return keyboard_led_state;
|
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
|
/* prepare and start sending a report IN
|
||||||
* not callable from ISR or locked state */
|
* not callable from ISR or locked state */
|
||||||
void send_keyboard(report_keyboard_t *report) {
|
void send_keyboard(report_keyboard_t *report) {
|
||||||
osalSysLock();
|
uint8_t ep = KEYBOARD_IN_EPNUM;
|
||||||
if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) {
|
size_t size = KEYBOARD_REPORT_SIZE;
|
||||||
goto unlock;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/* 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
|
#ifdef NKRO_ENABLE
|
||||||
if (keymap_config.nkro && keyboard_protocol) { /* NKRO protocol */
|
if (keymap_config.nkro) {
|
||||||
/* need to wait until the previous packet has made it through */
|
ep = SHARED_IN_EPNUM;
|
||||||
/* can rewrite this using the synchronous API, then would wait
|
size = sizeof(struct nkro_report);
|
||||||
* until *after* the packet has been transmitted. I think
|
}
|
||||||
* this is more efficient */
|
#endif
|
||||||
/* 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);
|
|
||||||
|
|
||||||
/* after osalThreadSuspendS returns USB status might have changed */
|
send_report(ep, report, size);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
keyboard_report_sent = *report;
|
|
||||||
|
|
||||||
unlock:
|
keyboard_report_sent = *report;
|
||||||
osalSysUnlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------
|
/* ---------------------------------------------------------
|
||||||
@ -940,35 +923,13 @@ unlock:
|
|||||||
* ---------------------------------------------------------
|
* ---------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void send_mouse(report_mouse_t *report) {
|
||||||
#ifdef MOUSE_ENABLE
|
#ifdef MOUSE_ENABLE
|
||||||
void send_mouse(report_mouse_t *report) {
|
send_report(MOUSE_IN_EPNUM, report, sizeof(report_mouse_t));
|
||||||
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));
|
|
||||||
mouse_report_sent = *report;
|
mouse_report_sent = *report;
|
||||||
osalSysUnlock();
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* MOUSE_ENABLE */
|
|
||||||
void send_mouse(report_mouse_t *report) {
|
|
||||||
(void)report;
|
|
||||||
}
|
|
||||||
#endif /* MOUSE_ENABLE */
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------
|
/* ---------------------------------------------------------
|
||||||
* Extrakey functions
|
* Extrakey functions
|
||||||
* ---------------------------------------------------------
|
* ---------------------------------------------------------
|
||||||
@ -976,97 +937,25 @@ void send_mouse(report_mouse_t *report) {
|
|||||||
|
|
||||||
void send_extra(report_extra_t *report) {
|
void send_extra(report_extra_t *report) {
|
||||||
#ifdef EXTRAKEY_ENABLE
|
#ifdef EXTRAKEY_ENABLE
|
||||||
osalSysLock();
|
send_report(SHARED_IN_EPNUM, report, sizeof(report_extra_t));
|
||||||
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();
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void send_programmable_button(report_programmable_button_t *report) {
|
void send_programmable_button(report_programmable_button_t *report) {
|
||||||
#ifdef PROGRAMMABLE_BUTTON_ENABLE
|
#ifdef PROGRAMMABLE_BUTTON_ENABLE
|
||||||
osalSysLock();
|
send_report(SHARED_IN_EPNUM, report, sizeof(report_programmable_button_t));
|
||||||
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();
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void send_joystick(report_joystick_t *report) {
|
void send_joystick(report_joystick_t *report) {
|
||||||
#ifdef JOYSTICK_ENABLE
|
#ifdef JOYSTICK_ENABLE
|
||||||
osalSysLock();
|
send_report(JOYSTICK_IN_EPNUM, report, sizeof(report_joystick_t));
|
||||||
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();
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void send_digitizer(report_digitizer_t *report) {
|
void send_digitizer(report_digitizer_t *report) {
|
||||||
#ifdef DIGITIZER_ENABLE
|
#ifdef DIGITIZER_ENABLE
|
||||||
osalSysLock();
|
send_report(DIGITIZER_IN_EPNUM, report, sizeof(report_digitizer_t));
|
||||||
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();
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user