Rename mouse and keyboard related callbacks and variables.
This commit is contained in:
@@ -8,13 +8,11 @@
|
||||
#include "composite.h"
|
||||
#include "hid_mouse.h"
|
||||
|
||||
static usb_status_t USB_DeviceHidMouseAction(void);
|
||||
|
||||
static usb_device_composite_struct_t *s_UsbDeviceComposite;
|
||||
static usb_device_hid_mouse_struct_t s_UsbDeviceHidMouse;
|
||||
static usb_device_composite_struct_t *UsbCompositeDevice;
|
||||
static usb_device_hid_mouse_struct_t UsbMouseDevice;
|
||||
|
||||
/* Update mouse pointer location: draw a rectangular rotation. */
|
||||
static usb_status_t USB_DeviceHidMouseAction(void)
|
||||
static usb_status_t UsbMouseAction(void)
|
||||
{
|
||||
static int8_t x = 0U;
|
||||
static int8_t y = 0U;
|
||||
@@ -29,8 +27,8 @@ static usb_status_t USB_DeviceHidMouseAction(void)
|
||||
switch (dir) {
|
||||
case RIGHT:
|
||||
/* Move right. Increase X value. */
|
||||
s_UsbDeviceHidMouse.buffer[1] = 1U;
|
||||
s_UsbDeviceHidMouse.buffer[2] = 0U;
|
||||
UsbMouseDevice.buffer[1] = 1U;
|
||||
UsbMouseDevice.buffer[2] = 0U;
|
||||
x++;
|
||||
if (x > 99U) {
|
||||
dir++;
|
||||
@@ -38,8 +36,8 @@ static usb_status_t USB_DeviceHidMouseAction(void)
|
||||
break;
|
||||
case DOWN:
|
||||
/* Move down. Increase Y value. */
|
||||
s_UsbDeviceHidMouse.buffer[1] = 0U;
|
||||
s_UsbDeviceHidMouse.buffer[2] = 1U;
|
||||
UsbMouseDevice.buffer[1] = 0U;
|
||||
UsbMouseDevice.buffer[2] = 1U;
|
||||
y++;
|
||||
if (y > 99U) {
|
||||
dir++;
|
||||
@@ -47,8 +45,8 @@ static usb_status_t USB_DeviceHidMouseAction(void)
|
||||
break;
|
||||
case LEFT:
|
||||
/* Move left. Discrease X value. */
|
||||
s_UsbDeviceHidMouse.buffer[1] = (uint8_t)(0xFFU);
|
||||
s_UsbDeviceHidMouse.buffer[2] = 0U;
|
||||
UsbMouseDevice.buffer[1] = (uint8_t)(0xFFU);
|
||||
UsbMouseDevice.buffer[2] = 0U;
|
||||
x--;
|
||||
if (x < 1U) {
|
||||
dir++;
|
||||
@@ -56,8 +54,8 @@ static usb_status_t USB_DeviceHidMouseAction(void)
|
||||
break;
|
||||
case UP:
|
||||
/* Move up. Discrease Y value. */
|
||||
s_UsbDeviceHidMouse.buffer[1] = 0U;
|
||||
s_UsbDeviceHidMouse.buffer[2] = (uint8_t)(0xFFU);
|
||||
UsbMouseDevice.buffer[1] = 0U;
|
||||
UsbMouseDevice.buffer[2] = (uint8_t)(0xFFU);
|
||||
y--;
|
||||
if (y < 1U) {
|
||||
dir = RIGHT;
|
||||
@@ -67,19 +65,19 @@ static usb_status_t USB_DeviceHidMouseAction(void)
|
||||
break;
|
||||
}
|
||||
|
||||
return USB_DeviceHidSend(s_UsbDeviceComposite->hidMouseHandle, USB_MOUSE_ENDPOINT_IN,
|
||||
s_UsbDeviceHidMouse.buffer, USB_MOUSE_REPORT_LENGTH);
|
||||
return USB_DeviceHidSend(UsbCompositeDevice->hidMouseHandle, USB_MOUSE_ENDPOINT_IN,
|
||||
UsbMouseDevice.buffer, USB_MOUSE_REPORT_LENGTH);
|
||||
}
|
||||
|
||||
usb_status_t USB_DeviceHidMouseCallback(class_handle_t handle, uint32_t event, void *param)
|
||||
usb_status_t UsbMouseCallback(class_handle_t handle, uint32_t event, void *param)
|
||||
{
|
||||
usb_status_t error = kStatus_USB_Error;
|
||||
|
||||
switch (event)
|
||||
{
|
||||
case kUSB_DeviceHidEventSendResponse:
|
||||
if (s_UsbDeviceComposite->attach) {
|
||||
return USB_DeviceHidMouseAction();
|
||||
if (UsbCompositeDevice->attach) {
|
||||
return UsbMouseAction();
|
||||
}
|
||||
break;
|
||||
case kUSB_DeviceHidEventGetReport:
|
||||
@@ -99,24 +97,24 @@ usb_status_t USB_DeviceHidMouseCallback(class_handle_t handle, uint32_t event, v
|
||||
return error;
|
||||
}
|
||||
|
||||
usb_status_t USB_DeviceHidMouseSetConfigure(class_handle_t handle, uint8_t configure)
|
||||
usb_status_t UsbMouseSetConfigure(class_handle_t handle, uint8_t configure)
|
||||
{
|
||||
if (USB_COMPOSITE_CONFIGURE_INDEX == configure) {
|
||||
return USB_DeviceHidMouseAction();
|
||||
return UsbMouseAction();
|
||||
}
|
||||
return kStatus_USB_Error;
|
||||
}
|
||||
|
||||
usb_status_t USB_DeviceHidMouseSetInterface(class_handle_t handle, uint8_t interface, uint8_t alternateSetting)
|
||||
usb_status_t UsbMouseSetInterface(class_handle_t handle, uint8_t interface, uint8_t alternateSetting)
|
||||
{
|
||||
if (USB_KEYBOARD_INTERFACE_INDEX == interface) {
|
||||
return USB_DeviceHidMouseAction();
|
||||
return UsbMouseAction();
|
||||
}
|
||||
return kStatus_USB_Error;
|
||||
}
|
||||
|
||||
usb_status_t USB_DeviceHidMouseInit(usb_device_composite_struct_t *deviceComposite)
|
||||
usb_status_t UsbMouseInit(usb_device_composite_struct_t *compositeDevice)
|
||||
{
|
||||
s_UsbDeviceComposite = deviceComposite;
|
||||
UsbCompositeDevice = compositeDevice;
|
||||
return kStatus_USB_Success;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user