mirror of
https://github.com/ApacheThunder/nCard_USB_Examples.git
synced 2025-06-19 03:35:35 -04:00

* Initial commit of modified source code. * Arm7 for both apps appears to be some form of template arm7 setup. Perhaps from the ancient version of libnds this used to use. I just used the default arm7 template code from current version of libnds...seems to do the job.
169 lines
5.7 KiB
C
169 lines
5.7 KiB
C
#include "usb.h"
|
|
#include "hid.h"
|
|
#include "usbcfg.h"
|
|
#include "usbdesc.h"
|
|
|
|
|
|
BYTE HID_ReportDescriptor[] = {
|
|
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
|
|
0x09, 0x05, // USAGE (Game Pad)
|
|
0xa1, 0x01, // COLLECTION (Application)
|
|
0x09, 0x01, // USAGE (Pointer)
|
|
0xa1, 0x00, // COLLECTION (Physical)
|
|
0x09, 0x30, // USAGE (X)
|
|
0x09, 0x31, // USAGE (Y)
|
|
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
|
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
|
|
0x75, 0x08, // REPORT_SIZE (8)
|
|
0x95, 0x02, // REPORT_COUNT (2)
|
|
0x81, 0x02, // INPUT (Data,Var,Abs)
|
|
0xc0, // END_COLLECTION
|
|
0x05, 0x09, // USAGE_PAGE (Button)
|
|
0x19, 0x01, // USAGE_MINIMUM (Button 1)
|
|
0x29, 0x08, // USAGE_MAXIMUM (Button 8)
|
|
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
|
0x25, 0x01, // LOGICAL_MAXIMUM (1)
|
|
0x75, 0x01, // REPORT_SIZE (1)
|
|
0x95, 0x08, // REPORT_COUNT (8)
|
|
0x81, 0x02, // INPUT (Data,Var,Abs)
|
|
0xc0 // END_COLLECTION
|
|
};
|
|
|
|
WORD HID_ReportDescSize = sizeof(HID_ReportDescriptor);
|
|
|
|
/* USB Standard Device Descriptor */
|
|
BYTE USB_DeviceDescriptor[] = {
|
|
USB_DEVICE_DESC_SIZE, /* bLength */
|
|
USB_DEVICE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
|
WBVAL(0x0110), /* 1.10 */ /* bcdUSB */
|
|
0x00, /* bDeviceClass */
|
|
0x00, /* bDeviceSubClass */
|
|
0x00, /* bDeviceProtocol */
|
|
64, /* bMaxPacketSize0 */
|
|
WBVAL(0x6666), /* idVendor */
|
|
WBVAL(0x1870), /* idProduct */
|
|
WBVAL(0x0100), /* 1.00 */ /* bcdDevice */
|
|
0x04, /* iManufacturer */
|
|
0x20, /* iProduct */
|
|
0x42, /* iSerialNumber */
|
|
0x01 /* bNumConfigurations */
|
|
};
|
|
|
|
/* USB Configuration Descriptor */
|
|
/* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
|
|
BYTE USB_ConfigDescriptor[] = {
|
|
/* Configuration 1 */
|
|
USB_CONFIGUARTION_DESC_SIZE, /* bLength */
|
|
USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */
|
|
WBVAL(( /* wTotalLength */
|
|
1*USB_CONFIGUARTION_DESC_SIZE +
|
|
1*USB_INTERFACE_DESC_SIZE +
|
|
1*HID_DESC_SIZE +
|
|
1*USB_ENDPOINT_DESC_SIZE
|
|
)),
|
|
0x01, /* bNumInterfaces */
|
|
0x01, /* bConfigurationValue */
|
|
0x00, /* iConfiguration */
|
|
USB_CONFIG_BUS_POWERED | /* bmAttributes */
|
|
USB_CONFIG_REMOTE_WAKEUP,
|
|
USB_CONFIG_POWER_MA(100), /* bMaxPower */
|
|
/* Interface 0, Alternate Setting 0, HID Class */
|
|
USB_INTERFACE_DESC_SIZE, /* bLength */
|
|
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
|
0x00, /* bInterfaceNumber */
|
|
0x00, /* bAlternateSetting */
|
|
0x01, /* bNumEndpoints */
|
|
USB_DEVICE_CLASS_HUMAN_INTERFACE, /* bInterfaceClass */
|
|
HID_SUBCLASS_NONE, /* bInterfaceSubClass */
|
|
HID_PROTOCOL_NONE, /* bInterfaceProtocol */
|
|
0x5C, /* iInterface */
|
|
/* HID Class Descriptor */
|
|
/* HID_DESC_OFFSET = 0x0012 */
|
|
HID_DESC_SIZE, /* bLength */
|
|
HID_HID_DESCRIPTOR_TYPE, /* bDescriptorType */
|
|
WBVAL(0x0100), /* 1.00 */ /* bcdHID */
|
|
0x00, /* bCountryCode */
|
|
0x01, /* bNumDescriptors */
|
|
HID_REPORT_DESCRIPTOR_TYPE, /* bDescriptorType */
|
|
WBVAL(HID_REPORT_DESC_SIZE), /* wDescriptorLength */
|
|
/* Endpoint, HID Interrupt In */
|
|
USB_ENDPOINT_DESC_SIZE, /* bLength */
|
|
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */
|
|
USB_ENDPOINT_IN(1), /* bEndpointAddress */
|
|
USB_ENDPOINT_TYPE_INTERRUPT, /* bmAttributes */
|
|
WBVAL(0x0004), /* wMaxPacketSize */
|
|
10, /* 10ms */ /* bInterval */
|
|
/* Terminator */
|
|
0 /* bLength */
|
|
};
|
|
|
|
/* USB String Descriptor (optional) */
|
|
BYTE USB_StringDescriptor[] = {
|
|
/* Index 0x00: LANGID Codes */
|
|
0x04, /* bLength */
|
|
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
|
|
WBVAL(0x0409), /* US English */ /* wLANGID */
|
|
/* Index 0x04: Manufacturer */
|
|
0x1C, /* bLength */
|
|
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
|
|
'N',0,
|
|
'D',0,
|
|
'S',0,
|
|
' ',0,
|
|
'G',0,
|
|
'A',0,
|
|
'M',0,
|
|
'E',0,
|
|
' ',0,
|
|
'P',0,
|
|
'A',0,
|
|
'D',0,
|
|
' ',0,
|
|
/* Index 0x20: Product */
|
|
0x28, /* bLength */
|
|
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
|
|
'U',0,
|
|
'S',0,
|
|
'B',0,
|
|
' ',0,
|
|
'N',0,
|
|
'D',0,
|
|
'S',0,
|
|
' ',0,
|
|
'G',0,
|
|
'A',0,
|
|
'M',0,
|
|
'E',0,
|
|
' ',0,
|
|
'P',0,
|
|
'A',0,
|
|
'D',0,
|
|
' ',0,
|
|
' ',0,
|
|
' ',0,
|
|
/* Index 0x48: Serial Number */
|
|
0x1A, /* bLength */
|
|
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
|
|
'U',0,
|
|
'S',0,
|
|
'B',0,
|
|
' ',0,
|
|
'G',0,
|
|
'A',0,
|
|
'O',0,
|
|
'J',0,
|
|
'I',0,
|
|
'A',0,
|
|
'N',0,
|
|
' ',0,
|
|
/* Index 0x62: Interface 0, Alternate Setting 0 */
|
|
0x0E, /* bLength */
|
|
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
|
|
'N',0,
|
|
'D',0,
|
|
'S',0,
|
|
'P',0,
|
|
'A',0,
|
|
'D',0,
|
|
};
|