Get rid of usb_device_hid_mouse_struct_t in favor of usb_mouse_report_t which now functions properly because of using __attribute__ ((packed))
This commit is contained in:
@@ -52,8 +52,8 @@
|
||||
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.1792027861"/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
|
||||
<listEntry value="/uhk-right"/></listAttribute>
|
||||
<listEntry value="/uhk-right"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
|
||||
@@ -11,35 +11,25 @@
|
||||
#include "usb_interface_mouse.h"
|
||||
#include "usb_descriptor_configuration.h"
|
||||
|
||||
static usb_device_hid_mouse_struct_t UsbMouseDevice;
|
||||
static usb_mouse_report_t UsbMouseReport;
|
||||
|
||||
static uint8_t scrollCounter = 0;
|
||||
static usb_status_t UsbMouseAction(void)
|
||||
static volatile usb_status_t UsbMouseAction(void)
|
||||
{
|
||||
usb_device_wheeled_mouse_struct_t *wheeledMouse = (usb_device_wheeled_mouse_struct_t*)&(UsbMouseDevice.buffer);
|
||||
UsbMouseDevice.buffer[0] = 0;
|
||||
UsbMouseDevice.buffer[1] = 0;
|
||||
UsbMouseDevice.buffer[2] = 0;
|
||||
UsbMouseDevice.buffer[3] = 0;
|
||||
UsbMouseDevice.buffer[4] = 0;
|
||||
UsbMouseDevice.buffer[5] = 0;
|
||||
UsbMouseDevice.buffer[6] = 0;
|
||||
UsbMouseReport.buttons = 0;
|
||||
UsbMouseReport.x = 0;
|
||||
UsbMouseReport.y = 0;
|
||||
UsbMouseReport.wheelX = 0;
|
||||
UsbMouseReport.wheelY = 0;
|
||||
|
||||
if (!GPIO_ReadPinInput(BOARD_SW2_GPIO, BOARD_SW2_GPIO_PIN)) {
|
||||
// UsbMouseDevice.buffer[0] = 1; // left click
|
||||
// UsbMouseDevice.buffer[1] = 1; // slow right
|
||||
// UsbMouseDevice.buffer[2] = 1; // fast right
|
||||
// UsbMouseDevice.buffer[3] = 1; // slow down
|
||||
// UsbMouseDevice.buffer[4] = 1; // fast down
|
||||
if (!(scrollCounter % 10)) {
|
||||
UsbMouseDevice.buffer[5] = 1; // scroll up
|
||||
//UsbMouseDevice.buffer[6] = 1; // scroll right
|
||||
UsbMouseReport.wheelX = -1;
|
||||
}
|
||||
//wheeledMouse->x = 32767;
|
||||
//wheeledMouse->y = 32767;
|
||||
}
|
||||
scrollCounter++;
|
||||
return USB_DeviceHidSend(UsbCompositeDevice.mouseHandle, USB_MOUSE_ENDPOINT_ID,
|
||||
UsbMouseDevice.buffer, USB_MOUSE_REPORT_LENGTH);
|
||||
(uint8_t*)&UsbMouseReport, USB_MOUSE_REPORT_LENGTH);
|
||||
}
|
||||
|
||||
usb_status_t UsbMouseCallback(class_handle_t handle, uint32_t event, void *param)
|
||||
|
||||
@@ -7,17 +7,13 @@
|
||||
|
||||
// Typedefs:
|
||||
|
||||
typedef struct usb_device_hid_mouse_struct {
|
||||
uint8_t buffer[USB_MOUSE_REPORT_LENGTH];
|
||||
} usb_device_hid_mouse_struct_t;
|
||||
|
||||
typedef struct usb_device_wheeled_mouse_struct {
|
||||
uint8_t button;
|
||||
typedef struct usb_mouse_report {
|
||||
uint8_t buttons;
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
int8_t verticalWheelMovement;
|
||||
int8_t horizontalWheelMovement;
|
||||
} usb_device_wheeled_mouse_struct_t;
|
||||
int8_t wheelX;
|
||||
int8_t wheelY;
|
||||
} __attribute__ ((packed)) usb_mouse_report_t;
|
||||
|
||||
// Functions:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user