Instead of scanning the keyboard matrix from the main loop and utilizing busy loops, try to use a PIT interrupt handler to do the same thing, scanning one row per interrupt call without busy loops.
For some reason, this makes the movement of the mouse pointer very slow and makes it jump from time to time, so I ended up adding INTERRUPT_KEY_SCANNER and disabling the timer interrupt. Also double bufferred the mouse report just like the others. Unfortunately this does not affect this issue.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include "i2c.h"
|
||||
#include "peripherals/reset_button.h"
|
||||
#include "key_action.h"
|
||||
#include "usb_protocol_handler.h"
|
||||
|
||||
static usb_device_endpoint_struct_t UsbMouseEndpoints[USB_MOUSE_ENDPOINT_COUNT] = {{
|
||||
USB_MOUSE_ENDPOINT_INDEX | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),
|
||||
@@ -37,12 +38,33 @@ usb_device_class_struct_t UsbMouseClass = {
|
||||
USB_DEVICE_CONFIGURATION_COUNT,
|
||||
};
|
||||
|
||||
usb_mouse_report_t UsbMouseReport;
|
||||
usb_mouse_report_t usbMouseReports[2];
|
||||
usb_mouse_report_t* ActiveUsbMouseReport = usbMouseReports;
|
||||
bool IsUsbMouseReportSent = false;
|
||||
|
||||
usb_mouse_report_t* getInactiveUsbMouseReport(void)
|
||||
{
|
||||
return ActiveUsbMouseReport == usbMouseReports ? usbMouseReports+1 : usbMouseReports;
|
||||
}
|
||||
|
||||
void SwitchActiveUsbMouseReport(void)
|
||||
{
|
||||
ActiveUsbMouseReport = getInactiveUsbMouseReport();
|
||||
}
|
||||
|
||||
void ResetActiveUsbMouseReport(void)
|
||||
{
|
||||
bzero(ActiveUsbMouseReport, USB_MOUSE_REPORT_LENGTH);
|
||||
}
|
||||
|
||||
static volatile usb_status_t usbMouseAction(void)
|
||||
{
|
||||
usb_mouse_report_t *mouseReport = getInactiveUsbMouseReport();
|
||||
*((uint16_t*)(UsbDebugInfo+16)) = mouseReport->x;
|
||||
*((uint16_t*)(UsbDebugInfo+18)) = mouseReport->y;
|
||||
IsUsbMouseReportSent = true;
|
||||
return USB_DeviceHidSend(UsbCompositeDevice.mouseHandle, USB_MOUSE_ENDPOINT_INDEX,
|
||||
(uint8_t*)&UsbMouseReport, USB_MOUSE_REPORT_LENGTH);
|
||||
(uint8_t*)mouseReport, USB_MOUSE_REPORT_LENGTH);
|
||||
}
|
||||
|
||||
usb_status_t UsbMouseCallback(class_handle_t handle, uint32_t event, void *param)
|
||||
|
||||
Reference in New Issue
Block a user