1 Commits

Author SHA1 Message Date
Eric Tang
aeaef7b788 Remove the semaphore 2018-08-16 13:54:20 -07:00
6 changed files with 4 additions and 31 deletions

View File

@@ -1,6 +1,5 @@
#include "led_display.h"
#include "usb_composite_device.h"
#include "usb_report_updater.h"
static usb_basic_keyboard_report_t usbBasicKeyboardReports[2];
uint32_t UsbBasicKeyboardActionCounter;
@@ -45,7 +44,6 @@ usb_status_t UsbBasicKeyboardCallback(class_handle_t handle, uint32_t event, voi
switch (event) {
// This event is received when the report has been sent
case kUSB_DeviceHidEventSendResponse:
UsbReportUpdateSemaphore &= ~(1 << USB_BASIC_KEYBOARD_INTERFACE_INDEX);
if (UsbCompositeDevice.attach) {
error = kStatus_USB_Success;
}

View File

@@ -1,5 +1,4 @@
#include "usb_composite_device.h"
#include "usb_report_updater.h"
uint32_t UsbMediaKeyboardActionCounter;
static usb_media_keyboard_report_t usbMediaKeyboardReports[2];
@@ -43,7 +42,6 @@ usb_status_t UsbMediaKeyboardCallback(class_handle_t handle, uint32_t event, voi
switch (event) {
// This event is received when the report has been sent
case kUSB_DeviceHidEventSendResponse:
UsbReportUpdateSemaphore &= ~(1 << USB_MEDIA_KEYBOARD_INTERFACE_INDEX);
if (UsbCompositeDevice.attach) {
error = kStatus_USB_Success;
}

View File

@@ -1,5 +1,4 @@
#include "usb_composite_device.h"
#include "usb_report_updater.h"
uint32_t UsbMouseActionCounter;
static usb_mouse_report_t usbMouseReports[2];
@@ -43,7 +42,6 @@ usb_status_t UsbMouseCallback(class_handle_t handle, uint32_t event, void *param
switch (event) {
// This event is received when the report has been sent
case kUSB_DeviceHidEventSendResponse:
UsbReportUpdateSemaphore &= ~(1 << USB_MOUSE_INTERFACE_INDEX);
if (UsbCompositeDevice.attach) {
error = kStatus_USB_Success;
}

View File

@@ -1,5 +1,4 @@
#include "usb_composite_device.h"
#include "usb_report_updater.h"
uint32_t UsbSystemKeyboardActionCounter;
static usb_system_keyboard_report_t usbSystemKeyboardReports[2];
@@ -43,7 +42,6 @@ usb_status_t UsbSystemKeyboardCallback(class_handle_t handle, uint32_t event, vo
switch (event) {
// This event is received when the report has been sent
case kUSB_DeviceHidEventSendResponse:
UsbReportUpdateSemaphore &= ~(1 << USB_SYSTEM_KEYBOARD_INTERFACE_INDEX);
if (UsbCompositeDevice.attach) {
error = kStatus_USB_Success;
}

View File

@@ -26,8 +26,6 @@ static uint16_t DoubleTapSwitchLayerReleaseTimeout = 200;
static bool activeMouseStates[ACTIVE_MOUSE_STATES_COUNT];
bool TestUsbStack = false;
volatile uint8_t UsbReportUpdateSemaphore = 0;
mouse_kinetic_state_t MouseMoveState = {
.isScroll = false,
.upState = SerializedMouseAction_MoveUp,
@@ -437,10 +435,6 @@ void UpdateUsbReports(void)
KeyStates[SlotId_RightKeyboardHalf][keyId].current = RightKeyMatrix.keyStates[keyId];
}
if (UsbReportUpdateSemaphore && !SleepModeActive) {
return;
}
UsbReportUpdateCounter++;
ResetActiveUsbBasicKeyboardReport();
@@ -456,32 +450,20 @@ void UpdateUsbReports(void)
bool HasUsbMouseReportChanged = memcmp(ActiveUsbMouseReport, GetInactiveUsbMouseReport(), sizeof(usb_mouse_report_t)) != 0;
if (HasUsbBasicKeyboardReportChanged) {
usb_status_t status = UsbBasicKeyboardAction();
if (status == kStatus_USB_Success) {
UsbReportUpdateSemaphore |= 1 << USB_BASIC_KEYBOARD_INTERFACE_INDEX;
}
UsbBasicKeyboardAction();
}
if (HasUsbMediaKeyboardReportChanged) {
usb_status_t status = UsbMediaKeyboardAction();
if (status == kStatus_USB_Success) {
UsbReportUpdateSemaphore |= 1 << USB_MEDIA_KEYBOARD_INTERFACE_INDEX;
}
UsbMediaKeyboardAction();
}
if (HasUsbSystemKeyboardReportChanged) {
usb_status_t status = UsbSystemKeyboardAction();
if (status == kStatus_USB_Success) {
UsbReportUpdateSemaphore |= 1 << USB_SYSTEM_KEYBOARD_INTERFACE_INDEX;
}
UsbSystemKeyboardAction();
}
// Send out the mouse position and wheel values continuously if the report is not zeros, but only send the mouse button states when they change.
if (HasUsbMouseReportChanged || ActiveUsbMouseReport->x || ActiveUsbMouseReport->y ||
ActiveUsbMouseReport->wheelX || ActiveUsbMouseReport->wheelY) {
usb_status_t status = UsbMouseAction();
if (status == kStatus_USB_Success) {
UsbReportUpdateSemaphore |= 1 << USB_MOUSE_INTERFACE_INDEX;
}
UsbMouseAction();
}
}

View File

@@ -70,7 +70,6 @@
extern mouse_kinetic_state_t MouseMoveState;
extern mouse_kinetic_state_t MouseScrollState;
extern uint32_t UsbReportUpdateCounter;
extern volatile uint8_t UsbReportUpdateSemaphore;
extern bool TestUsbStack;
// Functions: