Cleaned up descriptors

xbox_descriptors
NepEgor 3 years ago
parent 268447b152
commit 50d194fa70

@ -13,4 +13,4 @@ https://github.com/NepEgor/ps2elantech
Credits:
* hid_def: https://github.com/katyo/hid_def
* xinput descriptors: https://github.com/zlittell/MSF-XINPUT

@ -9,7 +9,23 @@
class USB_Device
{
private:
USBD_HID_Joystick_Report report;
struct __attribute__((packed)) XinputReport
{
uint8_t msg_type:8; // byte 0
uint8_t msg_len:8; // byte 1
uint16_t buttons:16; // bytes 2 and 3
uint8_t trigger_left:8; // byte 4
uint8_t trigger_right:8; // byte 5
int16_t lx:16; // byte 6
int16_t ly:16; // byte 7
int16_t rx:16; // byte 8
int16_t ry:16; // byte 9
//uint32_t unused0:32; // not send due to endpoint size issue
//uint16_t unused1:16; // not send due to endpoint size issue
} xinput_report;
public:

@ -4,10 +4,7 @@
#include <stdint.h>
#define USB_HID_CUSTOM_CONFIG_DESC_SIZ 153U
#define USB_HID_CUSTOM_DESC_SIZ 9U
#define USB_LEN_DEV_QUALIFIER_DESC 0x0AU
#define HID_DESCRIPTOR_TYPE 0x21
#define USB_HID_CUSTOM_DEVICE_DESC_SIZ 18U
#ifndef HID_HS_BINTERVAL
#define HID_HS_BINTERVAL 0x07U
@ -21,19 +18,10 @@
#define HID_CUSTOM_EPIN_ADDR 0x81U
#define HID_CUSTOM_EPIN_SIZE 0x10U
// USB HID device descriptor
extern uint8_t USBD_Custom_Class_DeviceDesc[USB_HID_CUSTOM_DEVICE_DESC_SIZ];
// USB HID device FS Configuration Descriptor
extern uint8_t USBD_HID_CUSTOM_CfgFSDesc[USB_HID_CUSTOM_CONFIG_DESC_SIZ];
/*
// USB HID device HS Configuration Descriptor
extern uint8_t USBD_HID_CUSTOM_CfgHSDesc[USB_HID_CUSTOM_CONFIG_DESC_SIZ];
// USB HID device Other Speed Configuration Descriptor
extern uint8_t USBD_HID_CUSTOM_OtherSpeedCfgDesc[USB_HID_CUSTOM_CONFIG_DESC_SIZ];
// USB HID device Configuration Descriptor
extern uint8_t USBD_HID_CUSTOM_Desc[USB_HID_CUSTOM_DESC_SIZ];
// USB Standard Device Descriptor
extern uint8_t USBD_HID_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC];
*/
#endif

@ -3,39 +3,6 @@
#include <stdint.h>
#define HID_JOYSTICK_REPORT_DESC_SIZE 104U
// USB Joystick Report Descriptor
//extern uint8_t USBD_HID_Joystick_ReportDesc[HID_JOYSTICK_REPORT_DESC_SIZE];
/*
struct __attribute__((packed)) USBD_HID_Joystick_Report
{
uint8_t reportID = 20;
uint32_t buttons;
unsigned hat:4;
unsigned trigger_left:10;
unsigned trigger_right:10;
unsigned x:10;
unsigned y:10;
unsigned rx:10;
unsigned ry:10;
};
*/
struct __attribute__((packed)) USBD_HID_Joystick_Report
{
uint8_t msg_type:8; // byte 0
uint8_t msg_len:8; // byte 1
uint16_t buttons:16; // bytes 2 and 3
uint8_t trigger_left:8; // byte 4
uint8_t trigger_right:8; // byte 5
int16_t x:16; // byte 6
int16_t y:16; // byte 7
int16_t rx:16; // byte 8
int16_t ry:16; // byte 9
//uint32_t unused0:32;
//uint16_t unused1:16;
};
// keyboard and mouse reports will be here
#endif

@ -6,16 +6,19 @@ void USB_Device::begin()
{
HID_Custom_Init();
report.msg_type = 0x00;
report.msg_len = 0x14;
report.buttons = 0;
//report.hat = 15;
report.x = usb_joystick_x;
report.y = usb_joystick_y;
report.rx = usb_joystick_x;
report.ry = usb_joystick_y;
report.trigger_left = 0;
report.trigger_right = 0;
xinput_report.msg_type = 0x00;
xinput_report.msg_len = 0x14;
xinput_report.buttons = 0;
xinput_report.lx = usb_joystick_x;
xinput_report.ly = usb_joystick_y;
xinput_report.rx = usb_joystick_x;
xinput_report.ry = usb_joystick_y;
xinput_report.trigger_left = 0;
xinput_report.trigger_right = 0;
}
void USB_Device::end()
@ -25,49 +28,49 @@ void USB_Device::end()
void USB_Device::buttons(uint32_t buttons)
{
report.buttons = buttons;
xinput_report.buttons = buttons;
}
void USB_Device::button(uint8_t button, bool val)
{
if (val)
{
report.buttons |= (1u << button);
xinput_report.buttons |= (1u << button);
}
else
{
report.buttons &= ~(1u << button);
xinput_report.buttons &= ~(1u << button);
}
}
void USB_Device::dpad(uint8_t dir)
{
//report.hat = dir;
xinput_report.buttons = dir & 0b1111;
}
void USB_Device::joystick_left(int16_t x, int16_t y)
{
report.x = x;
report.y = y;
xinput_report.lx = x;
xinput_report.ly = y;
}
void USB_Device::joystick_right(int16_t x, int16_t y)
{
report.rx = x;
report.ry = y;
xinput_report.rx = x;
xinput_report.ry = y;
}
void USB_Device::trigger_left(uint8_t val)
{
report.trigger_left = val & 0xFF;
xinput_report.trigger_left = val & 0xFF;
}
void USB_Device::trigger_right(uint8_t val)
{
report.trigger_right = val & 0xFF;
xinput_report.trigger_right = val & 0xFF;
}
void USB_Device::sendReport()
{
HID_Custom_sendReport((uint8_t*)(&report), sizeof(report));
HID_Custom_sendReport((uint8_t*)(&xinput_report), sizeof(xinput_report));
}

@ -4,13 +4,35 @@
#include "usbd_def.h"
// USB HID device descriptor
__ALIGN_BEGIN uint8_t USBD_Custom_Class_DeviceDesc[] __ALIGN_END = {
0x12, // bLength
USB_DESC_TYPE_DEVICE, // bDescriptorType
0x00, // bcdUSB
0x02,
0xFF, // bDeviceClass
0xFF, // bDeviceSubClass
0xFF, // bDeviceProtocol
USB_MAX_EP0_SIZE, // bMaxPacketSize
LOBYTE(USBD_VID), // idVendor
HIBYTE(USBD_VID), // idVendor
LOBYTE(USBD_PID), // idProduct
HIBYTE(USBD_PID), // idProduct
0x14, // bcdDevice rel. 0.00
0x01,
USBD_IDX_MFC_STR, // Index of manufacturer string
USBD_IDX_PRODUCT_STR, // Index of product string
USBD_IDX_SERIAL_STR, // Index of serial number string
USBD_MAX_NUM_CONFIGURATION // bNumConfigurations
};
// USB HID device FS Configuration Descriptor
__ALIGN_BEGIN uint8_t USBD_HID_CUSTOM_CfgFSDesc[USB_HID_CUSTOM_CONFIG_DESC_SIZ] __ALIGN_END = {
__ALIGN_BEGIN uint8_t USBD_HID_CUSTOM_CfgFSDesc[] __ALIGN_END = {
0x09, // bLength: Configuration Descriptor size
USB_DESC_TYPE_CONFIGURATION, // bDescriptorType: Configuration
LOBYTE(USB_HID_CUSTOM_CONFIG_DESC_SIZ), // wTotalLength: Bytes returned
HIBYTE(USB_HID_CUSTOM_CONFIG_DESC_SIZ),
0x04, //bNumInterfaces: 2 interface
0x04, //bNumInterfaces: 4 interface
0x01, //bConfigurationValue: Configuration value
0x00, //iConfiguration: Index of string descriptor describing the configuration
0xA0, //bmAttributes: bus powered and no Support Remote Wake-up
@ -116,123 +138,3 @@ __ALIGN_BEGIN uint8_t USBD_HID_CUSTOM_CfgFSDesc[USB_HID_CUSTOM_CONFIG_DESC_SIZ]
//Another interface another Common Descriptor
6,65,0,1,1,3
};
/*
// USB HID device HS Configuration Descriptor
__ALIGN_BEGIN uint8_t USBD_HID_CUSTOM_CfgHSDesc[USB_HID_CUSTOM_CONFIG_DESC_SIZ] __ALIGN_END = {
0x09, // bLength: Configuration Descriptor size
USB_DESC_TYPE_CONFIGURATION, // bDescriptorType: Configuration
LOBYTE(USB_HID_CUSTOM_CONFIG_DESC_SIZ), // wTotalLength: Bytes returned
HIBYTE(USB_HID_CUSTOM_CONFIG_DESC_SIZ),
0x01, //bNumInterfaces: 2 interface
0x01, //bConfigurationValue: Configuration value
0x00, //iConfiguration: Index of string descriptor describing the configuration
0xC0, //bmAttributes: bus powered and no Support Remote Wake-up
0x32, //MaxPower 100 mA: this current is used for detecting Vbus
// ************* Descriptor of interface ***************
// 09
0x09, //bLength: Interface Descriptor size
USB_DESC_TYPE_INTERFACE,//bDescriptorType: Interface descriptor type
HID_CUSTOM_INTERFACE, //bInterfaceNumber: Number of Interface
0x00, //bAlternateSetting: Alternate setting
0x01, //bNumEndpoints
0x03, //bInterfaceClass: HID
0x00, //bInterfaceSubClass : 1=BOOT, 0=no boot
0x00, //nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse
0x00, //iInterface: Index of string descriptor
// ******************* Descriptor of Joystick Mouse HID *******************
// 18
0x09, //bLength: HID Descriptor size
HID_DESCRIPTOR_TYPE, //bDescriptorType: HID
0x11, //bcdHID: HID Class Spec release number
0x01,
0x00, //bCountryCode: Hardware target country
0x01, //bNumDescriptors: Number of HID class descriptors to follow
0x22, //bDescriptorType
HID_JOYSTICK_REPORT_DESC_SIZE,//wItemLength: Total length of Report descriptor
0x00,
// ******************* Descriptor of Mouse endpoint *******************
// 27
0x07, //bLength: Endpoint Descriptor size
USB_DESC_TYPE_ENDPOINT, //bDescriptorType:
HID_CUSTOM_EPIN_ADDR, //bEndpointAddress: Endpoint Address (IN)
0x03, //bmAttributes: Interrupt endpoint
HID_CUSTOM_EPIN_SIZE, //wMaxPacketSize: 4 Byte max
0x00,
HID_HS_BINTERVAL, //bInterval: Polling Interval
};
// USB HID device Other Speed Configuration Descriptor
__ALIGN_BEGIN uint8_t USBD_HID_CUSTOM_OtherSpeedCfgDesc[USB_HID_CUSTOM_CONFIG_DESC_SIZ] __ALIGN_END = {
0x09, // bLength: Configuration Descriptor size
USB_DESC_TYPE_CONFIGURATION, // bDescriptorType: Configuration
LOBYTE(USB_HID_CUSTOM_CONFIG_DESC_SIZ), // wTotalLength: Bytes returned
HIBYTE(USB_HID_CUSTOM_CONFIG_DESC_SIZ),
0x01, //bNumInterfaces: 2 interface
0x01, //bConfigurationValue: Configuration value
0x00, //iConfiguration: Index of string descriptor describing the configuration
0xC0, //bmAttributes: bus powered and no Support Remote Wake-up
0x32, //MaxPower 100 mA: this current is used for detecting Vbus
// ************* Descriptor of interface ***************
// 09
0x09, //bLength: Interface Descriptor size
USB_DESC_TYPE_INTERFACE,//bDescriptorType: Interface descriptor type
HID_CUSTOM_INTERFACE, //bInterfaceNumber: Number of Interface
0x00, //bAlternateSetting: Alternate setting
0x01, //bNumEndpoints
0x03, //bInterfaceClass: HID
0x00, //bInterfaceSubClass : 1=BOOT, 0=no boot
0x00, //nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse
0x00, //iInterface: Index of string descriptor
// ******************* Descriptor of Joystick Mouse HID *******************
// 18
0x09, //bLength: HID Descriptor size
HID_DESCRIPTOR_TYPE, //bDescriptorType: HID
0x11, //bcdHID: HID Class Spec release number
0x01,
0x00, //bCountryCode: Hardware target country
0x01, //bNumDescriptors: Number of HID class descriptors to follow
0x22, //bDescriptorType
HID_JOYSTICK_REPORT_DESC_SIZE,//wItemLength: Total length of Report descriptor
0x00,
// ******************* Descriptor of Mouse endpoint *******************
// 27
0x07, //bLength: Endpoint Descriptor size
USB_DESC_TYPE_ENDPOINT, //bDescriptorType:
HID_CUSTOM_EPIN_ADDR, //bEndpointAddress: Endpoint Address (IN)
0x03, //bmAttributes: Interrupt endpoint
HID_CUSTOM_EPIN_SIZE, //wMaxPacketSize: 4 Byte max
0x00,
HID_FS_BINTERVAL, //bInterval: Polling Interval
};
// USB HID device Configuration Descriptor
__ALIGN_BEGIN uint8_t USBD_HID_CUSTOM_Desc[USB_HID_CUSTOM_DESC_SIZ] __ALIGN_END = {
USB_HID_CUSTOM_DESC_SIZ, //bLength: HID Descriptor size
HID_DESCRIPTOR_TYPE, //bDescriptorType: HID
0x11, //bcdHID: HID Class Spec release number
0x01,
0x00, //bCountryCode: Hardware target country
0x01, //bNumDescriptors: Number of HID class descriptors to follow
0x22, //bDescriptorType
HID_JOYSTICK_REPORT_DESC_SIZE,//wItemLength: Total length of Report descriptor
0x00
};
// USB Standard Device Descriptor
__ALIGN_BEGIN uint8_t USBD_HID_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END = {
USB_LEN_DEV_QUALIFIER_DESC,
USB_DESC_TYPE_DEVICE_QUALIFIER,
0x00,
0x02,
0x00,
0x00,
0x00,
0x40,
0x01,
0x00,
};
*/

@ -8,14 +8,10 @@ static uint8_t USBD_HID_Init(USBD_HandleTypeDef* pdev, uint8_t cfgidx);
static uint8_t USBD_HID_DeInit(USBD_HandleTypeDef* pdev, uint8_t cfgidx);
static uint8_t USBD_CUSTOM_HID_Setup(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* req);
static uint8_t USBD_HID_JOYSTICK_Setup(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* req);
static uint8_t USBD_HID_XINPUT_EP81_Setup(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* req);
static uint8_t* USBD_HID_GetFSCfgDesc(uint16_t* length);
/*
static uint8_t* USBD_HID_GetHSCfgDesc(uint16_t* length);
static uint8_t* USBD_HID_GetOtherSpeedCfgDesc(uint16_t* length);
static uint8_t* USBD_HID_GetDeviceQualifierDesc(uint16_t* length);
*/
static uint8_t USBD_HID_DataIn(USBD_HandleTypeDef* pdev, uint8_t epnum);
USBD_ClassTypeDef USBD_CUSTOM_HID = {
@ -43,6 +39,9 @@ static uint8_t USBD_HID_Init(USBD_HandleTypeDef* pdev, uint8_t cfgidx)
// Open EP IN
USBD_LL_OpenEP(pdev, HID_CUSTOM_EPIN_ADDR, USBD_EP_TYPE_INTR, HID_CUSTOM_EPIN_SIZE);
pdev->ep_in[HID_CUSTOM_EPIN_ADDR & 0xFU].is_used = 1U;
// TODO open all end points for all interfaces
/*
// Open EP IN
USBD_LL_OpenEP(pdev,
@ -98,11 +97,11 @@ static uint8_t USBD_CUSTOM_HID_Setup(USBD_HandleTypeDef* pdev, USBD_SetupReqType
//}
//else
//{
return USBD_HID_JOYSTICK_Setup(pdev, req);
return USBD_HID_XINPUT_EP81_Setup(pdev, req);
//}
}
static uint8_t USBD_HID_JOYSTICK_Setup(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* req)
static uint8_t USBD_HID_XINPUT_EP81_Setup(USBD_HandleTypeDef* pdev, USBD_SetupReqTypedef* req)
{
USBD_HID_HandleTypeDef* hhid = (USBD_HID_HandleTypeDef*)pdev->pClassData;
uint16_t len = 0U;
@ -255,19 +254,7 @@ static uint8_t* USBD_HID_GetFSCfgDesc(uint16_t* length)
*length = sizeof(USBD_HID_CUSTOM_CfgFSDesc);
return USBD_HID_CUSTOM_CfgFSDesc;
}
/*
static uint8_t* USBD_HID_GetHSCfgDesc(uint16_t* length)
{
*length = sizeof(USBD_HID_CUSTOM_CfgHSDesc);
return USBD_HID_CUSTOM_CfgHSDesc;
}
static uint8_t* USBD_HID_GetOtherSpeedCfgDesc(uint16_t* length)
{
*length = sizeof(USBD_HID_CUSTOM_OtherSpeedCfgDesc);
return USBD_HID_CUSTOM_OtherSpeedCfgDesc;
}
*/
static uint8_t USBD_HID_DataIn(USBD_HandleTypeDef* pdev, uint8_t epnum)
{
// Ensure that the FIFO is empty before a new transfer, this condition could
@ -282,10 +269,3 @@ static uint8_t USBD_HID_DataIn(USBD_HandleTypeDef* pdev, uint8_t epnum)
//}
return USBD_OK;
}
/*
static uint8_t* USBD_HID_GetDeviceQualifierDesc(uint16_t* length)
{
*length = sizeof(USBD_HID_DeviceQualifierDesc);
return USBD_HID_DeviceQualifierDesc;
}
*/

@ -2,36 +2,17 @@
#include "usbd_hid_custom_if.h"
#include "usbd_hid_custom.h"
#include "usbd_descriptors.h"
USBD_HandleTypeDef hUSBD_Device_HID;
static bool HID_custom_initialized = false;
__ALIGN_BEGIN uint8_t USBD_Custom_Class_DeviceDesc[] __ALIGN_END = {
0x12, // bLength
USB_DESC_TYPE_DEVICE, // bDescriptorType
0x00, // bcdUSB
0x02,
0xFF, // bDeviceClass
0xFF, // bDeviceSubClass
0xFF, // bDeviceProtocol
USB_MAX_EP0_SIZE, // bMaxPacketSize
LOBYTE(USBD_VID), // idVendor
HIBYTE(USBD_VID), // idVendor
LOBYTE(USBD_PID), // idProduct
HIBYTE(USBD_PID), // idProduct
0x14, // bcdDevice rel. 0.00
0x01,
USBD_IDX_MFC_STR, // Index of manufacturer string
USBD_IDX_PRODUCT_STR, // Index of product string
USBD_IDX_SERIAL_STR, // Index of serial number string
USBD_MAX_NUM_CONFIGURATION // bNumConfigurations
};
uint8_t *USBD_Custom_Class_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
uint8_t* USBD_Custom_Class_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t* length)
{
UNUSED(speed);
*length = sizeof(USBD_Custom_Class_DeviceDesc);
return (uint8_t *)USBD_Custom_Class_DeviceDesc;
*length = USB_HID_CUSTOM_DEVICE_DESC_SIZ;
return (uint8_t*)USBD_Custom_Class_DeviceDesc;
}
void HID_Custom_Init()

@ -4,192 +4,5 @@
#include "usbd_def.h"
#include "hid_def.h"
/*
__ALIGN_BEGIN uint8_t USBD_HID_CUSTOM_ReportDesc[] __ALIGN_END = {
HID_USAGE_PAGE(GENERIC_DESKTOP),
HID_USAGE(JOYSTICK),
HID_COLLECTION(APPLICATION),
HID_COLLECTION(PHYSICAL),
HID_USAGE_PAGE(GENERIC_DESKTOP),
HID_USAGE(X),
HID_USAGE(Y),
HID_USAGE(Z),
HID_LOGICAL_MINIMUM(1, 0),
HID_LOGICAL_MAXIMUM(2, 1024),
HID_PHYSICAL_MINIMUM(1, 0),
HID_PHYSICAL_MAXIMUM(2, 1024),
HID_REPORT_SIZE(16),
HID_REPORT_COUNT(3),
HID_INPUT(DATA, VARIABLE, ABSOLUTE),
HID_END_COLLECTION(PHYSICAL),
HID_END_COLLECTION(APPLICATION)
};
*/
/*
__ALIGN_BEGIN uint8_t USBD_HID_Joystick_ReportDesc[] __ALIGN_END = {
HID_USAGE_PAGE(GENERIC_DESKTOP),
HID_USAGE(GAME_PAD),
HID_COLLECTION(APPLICATION),
HID_REPORT_ID(20), // HID Joystick Report ID
HID_USAGE_PAGE(BUTTON),
HID_USAGE_MINIMUM(1, 0),
HID_USAGE_MAXIMUM(1, 9),
HID_REPORT_SIZE(1),
HID_REPORT_COUNT(32),
HID_INPUT(DATA, VARIABLE, ABSOLUTE),
HID_USAGE_PAGE(GENERIC_DESKTOP),
HID_LOGICAL_MINIMUM(1, 0),
HID_LOGICAL_MAXIMUM(1, 7),
HID_PHYSICAL_MINIMUM(1, 0),
HID_PHYSICAL_MAXIMUM(2, 315),
HID_REPORT_SIZE(4),
HID_REPORT_COUNT(1),
HID_USAGE(HAT_SWITCH),
HID_INPUT(DATA, VARIABLE, ABSOLUTE),
HID_USAGE_PAGE(GENERIC_DESKTOP),
HID_COLLECTION(PHYSICAL),
HID_USAGE(Z),
HID_USAGE(RZ),
HID_LOGICAL_MINIMUM(1, 0),
HID_LOGICAL_MAXIMUM(2, 1022),
HID_REPORT_SIZE(10),
HID_REPORT_COUNT(2),
HID_INPUT(DATA, VARIABLE, ABSOLUTE),
HID_END_COLLECTION(PHYSICAL),
HID_USAGE_PAGE(GENERIC_DESKTOP),
HID_USAGE(POINTER),
HID_COLLECTION(PHYSICAL),
HID_USAGE(X),
HID_USAGE(Y),
HID_LOGICAL_MINIMUM(1, 0),
HID_LOGICAL_MAXIMUM(2, 1022),
HID_REPORT_SIZE(10),
HID_REPORT_COUNT(2),
HID_INPUT(DATA, VARIABLE, ABSOLUTE),
HID_END_COLLECTION(PHYSICAL),
HID_USAGE_PAGE(GENERIC_DESKTOP),
HID_USAGE(POINTER),
HID_COLLECTION(PHYSICAL),
HID_USAGE(RX),
HID_USAGE(RY),
HID_LOGICAL_MINIMUM(1, 0),
HID_LOGICAL_MAXIMUM(2, 1022),
HID_REPORT_SIZE(10),
HID_REPORT_COUNT(2),
HID_INPUT(DATA, VARIABLE, ABSOLUTE),
HID_END_COLLECTION(PHYSICAL),
HID_END_COLLECTION(APPLICATION)
};
*/
/*
__ALIGN_BEGIN uint8_t USBD_HID_Joystick_ReportDesc2[] __ALIGN_END = {
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x05, // USAGE (Game Pad)
0xa1, 0x01, // COLLECTION (Application)
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x3a, // USAGE (Counted Buffer)
0xa1, 0x02, // COLLECTION (Logical)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x02, // REPORT_COUNT (2)
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x3f, // USAGE (Reserved)
0x09, 0x3b, // USAGE (Byte Count)
0x81, 0x01, // INPUT (Cnst,Ary,Abs)
0x75, 0x01, // REPORT_SIZE (1)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x35, 0x00, // PHYSICAL_MINIMUM (0)
0x45, 0x01, // PHYSICAL_MAXIMUM (1)
0x95, 0x04, // REPORT_COUNT (4)
0x05, 0x09, // USAGE_PAGE (Button)
0x19, 0x0c, // USAGE_MINIMUM (Button 12)
0x29, 0x0f, // USAGE_MAXIMUM (Button 15)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x75, 0x01, // REPORT_SIZE (1)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x35, 0x00, // PHYSICAL_MINIMUM (0)
0x45, 0x01, // PHYSICAL_MAXIMUM (1)
0x95, 0x04, // REPORT_COUNT (4)
0x05, 0x09, // USAGE_PAGE (Button)
0x09, 0x09, // USAGE (Button 9)
0x09, 0x0a, // USAGE (Button 10)
0x09, 0x07, // USAGE (Button 7)
0x09, 0x08, // USAGE (Button 8)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x75, 0x01, // REPORT_SIZE (1)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x35, 0x00, // PHYSICAL_MINIMUM (0)
0x45, 0x01, // PHYSICAL_MAXIMUM (1)
0x95, 0x03, // REPORT_COUNT (3)
0x05, 0x09, // USAGE_PAGE (Button)
0x09, 0x05, // USAGE (Button 5)
0x09, 0x06, // USAGE (Button 6)
0x09, 0x0b, // USAGE (Button 11)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x75, 0x01, // REPORT_SIZE (1)
0x95, 0x01, // REPORT_COUNT (1)
0x81, 0x01, // INPUT (Cnst,Ary,Abs)
0x75, 0x01, // REPORT_SIZE (1)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x35, 0x00, // PHYSICAL_MINIMUM (0)
0x45, 0x01, // PHYSICAL_MAXIMUM (1)
0x95, 0x04, // REPORT_COUNT (4)
0x05, 0x09, // USAGE_PAGE (Button)
0x19, 0x01, // USAGE_MINIMUM (Button 1)
0x29, 0x04, // USAGE_MAXIMUM (Button 4)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x75, 0x08, // REPORT_SIZE (8)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
0x35, 0x00, // PHYSICAL_MINIMUM (0)
0x46, 0xff, 0x00, // PHYSICAL_MAXIMUM (255)
0x95, 0x02, // REPORT_COUNT (2)
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x32, // USAGE (Z)
0x09, 0x35, // USAGE (Rz)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x75, 0x10, // REPORT_SIZE (16)
0x16, 0x00, 0x80, // LOGICAL_MINIMUM (-32768)
0x26, 0xff, 0x7f, // LOGICAL_MAXIMUM (32767)
0x36, 0x00, 0x80, // PHYSICAL_MINIMUM (-32768)
0x46, 0xff, 0x7f, // PHYSICAL_MAXIMUM (32767)
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x01, // USAGE (Pointer)
0xa1, 0x00, // COLLECTION (Physical)
0x95, 0x02, // REPORT_COUNT (2)
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x30, // USAGE (X)
0x09, 0x31, // USAGE (Y)
0x81, 0x02, // INPUT (Data,Var,Abs)
0xc0, // END_COLLECTION
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x01, // USAGE (Pointer)
0xa1, 0x00, // COLLECTION (Physical)
0x95, 0x02, // REPORT_COUNT (2)
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x33, // USAGE (Rx)
0x09, 0x34, // USAGE (Ry)
0x81, 0x02, // INPUT (Data,Var,Abs)
0xc0, // END_COLLECTION
0xc0, // END_COLLECTION
0xc0 // END_COLLECTION
};
*/
// keyboard and mouse reports will be here

@ -64,7 +64,7 @@ void setup()
tjoystick_right.setDeadZoneInner(dead_zone_inner);
tjoystick_right.setDeadZoneOuter(dead_zone_outer);
tjoystick_right.setInvertX();
tjoystick_right.setInvertY();
//tjoystick_right.setInvertY();
pos_x = (62.5 - 20.636) * ppmX;
pos_y = 20.636 * ppmY;
@ -159,7 +159,7 @@ void loop()
//device.joystick_right(30000, 30000);
device.trigger_right(right_trigger);
device.button(2, right_tp_click);
device.button(7, right_tp_click); // R3
//buttons <<= 1;
//if (buttons >= 2048) buttons = 1u;

Loading…
Cancel
Save