hid mouse working
This commit is contained in:
parent
8f57cb6ccb
commit
b8b92e1202
|
@ -80,7 +80,7 @@ ATTR_ALIGNED(4) const uint8_t HID_KeyboardReportDescriptor[] = {
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CFG_USB_HID_MOUSE
|
#ifdef CFG_CLASS_HID_MOUSE
|
||||||
ATTR_ALIGNED(4) const uint8_t HID_MouseReportDescriptor[] = {
|
ATTR_ALIGNED(4) const uint8_t HID_MouseReportDescriptor[] = {
|
||||||
HID_UsagePage ( HID_USAGE_PAGE_GENERIC ),
|
HID_UsagePage ( HID_USAGE_PAGE_GENERIC ),
|
||||||
HID_Usage ( HID_USAGE_GENERIC_MOUSE ),
|
HID_Usage ( HID_USAGE_GENERIC_MOUSE ),
|
||||||
|
@ -316,7 +316,7 @@ ATTR_ALIGNED(4) const USB_FS_CONFIGURATION_DESCRIPTOR USB_FsConfigDescriptor =
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CFG_USB_HID_MOUSE
|
#ifdef CFG_CLASS_HID_MOUSE
|
||||||
.HID_MouseInterface =
|
.HID_MouseInterface =
|
||||||
{
|
{
|
||||||
.bLength = sizeof(USB_INTERFACE_DESCRIPTOR),
|
.bLength = sizeof(USB_INTERFACE_DESCRIPTOR),
|
||||||
|
|
|
@ -102,7 +102,7 @@ typedef PRE_PACK struct POST_PACK _USB_INTERFACE_ASSOCIATION_DESCRIPTOR
|
||||||
#define INTERFACES_OF_HID_KEYBOARD 0
|
#define INTERFACES_OF_HID_KEYBOARD 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CFG_USB_HID_MOUSE
|
#ifdef CFG_CLASS_HID_MOUSE
|
||||||
#define INTERFACES_OF_HID_MOUSE 1
|
#define INTERFACES_OF_HID_MOUSE 1
|
||||||
#else
|
#else
|
||||||
#define INTERFACES_OF_HID_MOUSE 0
|
#define INTERFACES_OF_HID_MOUSE 0
|
||||||
|
@ -164,7 +164,7 @@ typedef struct
|
||||||
USB_ENDPOINT_DESCRIPTOR HID_KeyboardEndpoint;
|
USB_ENDPOINT_DESCRIPTOR HID_KeyboardEndpoint;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CFG_USB_HID_MOUSE
|
#ifdef CFG_CLASS_HID_MOUSE
|
||||||
//Mouse HID Interface
|
//Mouse HID Interface
|
||||||
USB_INTERFACE_DESCRIPTOR HID_MouseInterface;
|
USB_INTERFACE_DESCRIPTOR HID_MouseInterface;
|
||||||
HID_DESCRIPTOR HID_MouseHID;
|
HID_DESCRIPTOR HID_MouseHID;
|
||||||
|
|
|
@ -48,7 +48,7 @@ int main(void)
|
||||||
usb_hid_keyboard_sendKeys(0x00, keys, 1);
|
usb_hid_keyboard_sendKeys(0x00, keys, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CFG_USB_HID_MOUSE
|
#ifdef CFG_CLASS_HID_MOUSE
|
||||||
usb_hid_mouse_send(0, 10, 10);
|
usb_hid_mouse_send(0, 10, 10);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "hid.h"
|
#include "hid.h"
|
||||||
//#include "../systick/systick.h"
|
|
||||||
|
|
||||||
#ifdef CLASS_HID
|
#ifdef CLASS_HID
|
||||||
|
|
||||||
|
@ -45,7 +44,7 @@ USB_HID_KeyboardReport_t hid_keyboard_report;
|
||||||
volatile static bool bKeyChanged = false;
|
volatile static bool bKeyChanged = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CFG_USB_HID_MOUSE
|
#ifdef CFG_CLASS_HID_MOUSE
|
||||||
USB_HID_MouseReport_t hid_mouse_report;
|
USB_HID_MouseReport_t hid_mouse_report;
|
||||||
volatile static bool bMouseChanged = false;
|
volatile static bool bMouseChanged = false;
|
||||||
#endif
|
#endif
|
||||||
|
@ -78,7 +77,7 @@ ErrorCode_t HID_GetReport( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CFG_USB_HID_MOUSE
|
#ifdef CFG_CLASS_HID_MOUSE
|
||||||
case HID_PROTOCOL_MOUSE:
|
case HID_PROTOCOL_MOUSE:
|
||||||
*pBuffer = (uint8_t*) &hid_mouse_report;
|
*pBuffer = (uint8_t*) &hid_mouse_report;
|
||||||
*plength = sizeof(USB_HID_MouseReport_t);
|
*plength = sizeof(USB_HID_MouseReport_t);
|
||||||
|
@ -139,7 +138,7 @@ ErrorCode_t HID_EpIn_Hdlr (USBD_HANDLE_T hUsb, void* data, uint32_t event)
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CFG_USB_HID_MOUSE
|
#ifdef CFG_CLASS_HID_MOUSE
|
||||||
case HID_PROTOCOL_MOUSE:
|
case HID_PROTOCOL_MOUSE:
|
||||||
if (!bMouseChanged)
|
if (!bMouseChanged)
|
||||||
{
|
{
|
||||||
|
@ -213,7 +212,7 @@ TUSB_Error_t usb_hid_init(USBD_HANDLE_T hUsb, USB_INTERFACE_DESCRIPTOR const *co
|
||||||
*mem_base += (*mem_size - hid_param.mem_size);
|
*mem_base += (*mem_size - hid_param.mem_size);
|
||||||
*mem_size = hid_param.mem_size;
|
*mem_size = hid_param.mem_size;
|
||||||
|
|
||||||
return LPC_OK;
|
return tERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
@ -227,7 +226,7 @@ TUSB_Error_t usb_hid_configured(USBD_HANDLE_T hUsb)
|
||||||
USBD_API->hw->WriteEP(hUsb , HID_KEYBOARD_EP_IN , (uint8_t* ) &hid_keyboard_report , sizeof(USB_HID_KeyboardReport_t) ); // initial packet for IN endpoint , will not work if omitted
|
USBD_API->hw->WriteEP(hUsb , HID_KEYBOARD_EP_IN , (uint8_t* ) &hid_keyboard_report , sizeof(USB_HID_KeyboardReport_t) ); // initial packet for IN endpoint , will not work if omitted
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CFG_USB_HID_MOUSE
|
#ifdef CFG_CLASS_HID_MOUSE
|
||||||
USBD_API->hw->WriteEP(hUsb , HID_MOUSE_EP_IN , (uint8_t* ) &hid_mouse_report , sizeof(USB_HID_MouseReport_t) ); // initial packet for IN endpoint, will not work if omitted
|
USBD_API->hw->WriteEP(hUsb , HID_MOUSE_EP_IN , (uint8_t* ) &hid_mouse_report , sizeof(USB_HID_MouseReport_t) ); // initial packet for IN endpoint, will not work if omitted
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -292,11 +291,11 @@ TUSB_Error_t usb_hid_keyboard_sendKeys(uint8_t modifier, uint8_t keycodes[], uin
|
||||||
|
|
||||||
bKeyChanged = true;
|
bKeyChanged = true;
|
||||||
|
|
||||||
return LPC_OK;
|
return tERROR_NONE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CFG_USB_HID_MOUSE
|
#ifdef CFG_CLASS_HID_MOUSE
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
@brief Send the supplied mouse event out via HID USB mouse emulation
|
@brief Send the supplied mouse event out via HID USB mouse emulation
|
||||||
|
@ -341,7 +340,7 @@ TUSB_Error_t usb_hid_mouse_send(uint8_t buttons, int8_t x, int8_t y)
|
||||||
|
|
||||||
bMouseChanged = true;
|
bMouseChanged = true;
|
||||||
|
|
||||||
return LPC_OK;
|
return tERROR_NONE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -38,19 +38,10 @@
|
||||||
#ifndef _TUSB_HID_H_
|
#ifndef _TUSB_HID_H_
|
||||||
#define _TUSB_HID_H_
|
#define _TUSB_HID_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// TODO refractor
|
// TODO refractor
|
||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
#include "device/dcd.h"
|
#include "device/dcd.h"
|
||||||
|
|
||||||
TUSB_Error_t usb_hid_init(USBD_HANDLE_T hUsb, USB_INTERFACE_DESCRIPTOR const *const pIntfDesc, uint8_t const * const pHIDReportDesc, uint32_t ReportDescLength, uint32_t* mem_base, uint32_t* mem_size) ATTR_NON_NULL;
|
|
||||||
TUSB_Error_t usb_hid_configured(USBD_HANDLE_T hUsb);
|
|
||||||
|
|
||||||
TUSB_Error_t usb_hid_keyboard_sendKeys(uint8_t modifier, uint8_t keycodes[], uint8_t numkey) ATTR_NON_NULL;
|
|
||||||
TUSB_Error_t usb_hid_mouse_send(uint8_t buttons, int8_t x, int8_t y);
|
|
||||||
|
|
||||||
/** \brief Standard HID Boot Protocol Mouse Report.
|
/** \brief Standard HID Boot Protocol Mouse Report.
|
||||||
*
|
*
|
||||||
|
@ -135,6 +126,16 @@ enum USB_HID_LOCAL_CODE
|
||||||
HID_Local_Turkish_F
|
HID_Local_Turkish_F
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TUSB_Error_t usb_hid_init(USBD_HANDLE_T hUsb, USB_INTERFACE_DESCRIPTOR const *const pIntfDesc, uint8_t const * const pHIDReportDesc, uint32_t ReportDescLength, uint32_t* mem_base, uint32_t* mem_size) ATTR_NON_NULL;
|
||||||
|
TUSB_Error_t usb_hid_configured(USBD_HANDLE_T hUsb);
|
||||||
|
|
||||||
|
TUSB_Error_t usb_hid_keyboard_sendKeys(uint8_t modifier, uint8_t keycodes[], uint8_t numkey) ATTR_NON_NULL;
|
||||||
|
TUSB_Error_t usb_hid_mouse_send(uint8_t buttons, int8_t x, int8_t y);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -51,17 +51,20 @@
|
||||||
#ifndef _TUSB_ARCH_H_
|
#ifndef _TUSB_ARCH_H_
|
||||||
#define _TUSB_ARCH_H_
|
#define _TUSB_ARCH_H_
|
||||||
|
|
||||||
#define ARCH_LPC134X 1
|
#define ARCH_LPC134X
|
||||||
#define ARCH_LPC43XX 2
|
//#define ARCH_LPC11XX
|
||||||
#define ARCH ARCH_LPC134X
|
|
||||||
|
|
||||||
#define ENDIAN_LITTLE ///< MCU Endian
|
#define ENDIAN_LITTLE ///< MCU Endian
|
||||||
#define ALIGNMENT (4) ///< MCU Alignment
|
#define ALIGNMENT (4) ///< MCU Alignment
|
||||||
|
|
||||||
#if ARCH == ARCH_LPC134X
|
#if defined ARCH_LPC134X
|
||||||
#include "arch_lpc134x.h"
|
#include "arch_lpc134x.h"
|
||||||
#elif ARCH == ARCH_LPC43XX
|
#elif defined ARCH_LPC43XX
|
||||||
|
#include "arch_lpc43xx.h"
|
||||||
|
#elif defined ARCH_LPC11XX
|
||||||
|
#include "arch_lpc11xx.h"
|
||||||
|
#else
|
||||||
|
#error Arch is not found
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* _TUSB_ARCH_H_ */
|
#endif /* _TUSB_ARCH_H_ */
|
||||||
|
|
|
@ -49,12 +49,13 @@
|
||||||
#ifndef _TUSB_ARCH_LPC134_X_H_
|
#ifndef _TUSB_ARCH_LPC134_X_H_
|
||||||
#define _TUSB_ARCH_LPC134_X_H_
|
#define _TUSB_ARCH_LPC134_X_H_
|
||||||
|
|
||||||
|
#define ARM_M3
|
||||||
|
#define DEVICE_ROMDRIVER
|
||||||
|
|
||||||
#include "arm_mx.h"
|
#include "arm_mx.h"
|
||||||
#include "LPC13Uxx.h"
|
#include "LPC13Uxx.h"
|
||||||
|
|
||||||
#define ARM_M3
|
|
||||||
|
|
||||||
#define DEVICE_ROMDRIVER
|
|
||||||
|
|
||||||
#endif /* _TUSB_ARCH_LPC134_X_H_ */
|
#endif /* _TUSB_ARCH_LPC134_X_H_ */
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,8 @@
|
||||||
#ifndef _TUSB_ARM_MX_H_
|
#ifndef _TUSB_ARM_MX_H_
|
||||||
#define _TUSB_ARM_MX_H_
|
#define _TUSB_ARM_MX_H_
|
||||||
|
|
||||||
|
// #ifdef ARM_M3 ARM_M4 ARM_M0
|
||||||
|
|
||||||
#define ENDIAN_LITTLE
|
#define ENDIAN_LITTLE
|
||||||
#define ALIGNMENT (4)
|
#define ALIGNMENT (4)
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,8 @@
|
||||||
|
|
||||||
#include "dcd.h"
|
#include "dcd.h"
|
||||||
|
|
||||||
|
#ifdef CFG_TUSB_DEVICE
|
||||||
|
|
||||||
// TODO refractor later
|
// TODO refractor later
|
||||||
#include "descriptors.h"
|
#include "descriptors.h"
|
||||||
#include <cr_section_macros.h>
|
#include <cr_section_macros.h>
|
||||||
|
@ -160,3 +162,5 @@ void USB_IRQHandler(void)
|
||||||
{
|
{
|
||||||
USBD_API->hw->ISR(g_hUsb);
|
USBD_API->hw->ISR(g_hUsb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -37,9 +37,13 @@
|
||||||
|
|
||||||
#include "hcd.h"
|
#include "hcd.h"
|
||||||
|
|
||||||
|
#ifdef CFG_TUSB_HOST
|
||||||
|
|
||||||
TUSB_Error_t hcd_init()
|
TUSB_Error_t hcd_init()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
return tERROR_NONE;
|
return tERROR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -61,7 +61,10 @@
|
||||||
/// Enable HID Keyboard support
|
/// Enable HID Keyboard support
|
||||||
#define CFG_CLASS_HID_KEYBOARD
|
#define CFG_CLASS_HID_KEYBOARD
|
||||||
|
|
||||||
#define CLASS_HID (defined CFG_CLASS_HID_KEYBOARD)
|
/// Enable HID Mouse support
|
||||||
|
#define CFG_CLASS_HID_MOUSE
|
||||||
|
|
||||||
|
#define CLASS_HID ( (defined CFG_CLASS_HID_KEYBOARD) || (defined CFG_CLASS_HID_MOUSE) )
|
||||||
|
|
||||||
// TODO APP
|
// TODO APP
|
||||||
#define USB_MAX_IF_NUM 8
|
#define USB_MAX_IF_NUM 8
|
||||||
|
|
Loading…
Reference in New Issue