USB joystick support for 9xrpro (#5776)
* hid-mouse example added * cmake script and sources fixed * massstorage is turned off (it is still not used) * first test (mouse instead of joystick) * mouse renamed to joystick one more time * it works * refactoring * useless files removed * usbJoystickUpdate() moved to appropriate place * masstorage removed for sky9x * "keyboard" -> "joystick" * productDescriptor changed to "SKY9X Joystick" * attempt to fix travis * joystick.cpp moved to FIRMWARE_TARGET_SRC * meaningless if removed * code style fixed for opentx/radio/src/targets/sky9x/joystick.cpp * Revert "masstorage removed for sky9x" This reverts commit 426726283fa9930a2742aad86b6163bd9930c446. * opentx/radio/src/targets/sky9x/usb_driver.cpp added * useless include removed
This commit is contained in:
committed by
Bertrand Songis
parent
fc34d0a995
commit
59d3f2d16f
@@ -0,0 +1,356 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Headers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include "HIDDJoystickDriver.h"
|
||||
#include "HIDDJoystickDriverDescriptors.h"
|
||||
#include <usb/common/core/USBGetDescriptorRequest.h>
|
||||
#include <usb/common/hid/HIDGenericDescriptor.h>
|
||||
#include <usb/common/hid/HIDDescriptor.h>
|
||||
#include <usb/common/hid/HIDGenericRequest.h>
|
||||
#include <usb/common/hid/HIDReportRequest.h>
|
||||
#include <usb/common/hid/HIDIdleRequest.h>
|
||||
#include <usb/device/core/USBD.h>
|
||||
#include <usb/device/core/USBDDriver.h>
|
||||
#include <string.h>
|
||||
|
||||
#define TRACE_INFO(...) { }
|
||||
#define TRACE_WARNING(...) { }
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Driver structure for an HID device implementing joystick functionalities.
|
||||
//------------------------------------------------------------------------------
|
||||
typedef struct {
|
||||
|
||||
/// Standard USB device driver instance.
|
||||
USBDDriver usbdDriver;
|
||||
/// Idle rate (in milliseconds) of the input report.
|
||||
unsigned char inputReportIdleRate;
|
||||
///
|
||||
unsigned char inputProtocol;
|
||||
/// Input report instance.
|
||||
HIDDJoystickInputReport inputReport;
|
||||
|
||||
} HIDDJoystickDriver;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Internal variables
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/// Static instance of the HID joystick device driver.
|
||||
static HIDDJoystickDriver hiddJoystickDriver;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Internal functions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Returns the descriptor requested by the host.
|
||||
/// \param type Descriptor type.
|
||||
/// \param length Maximum number of bytes to send.
|
||||
/// \return 1 if the request has been handled by this function, otherwise 0.
|
||||
//------------------------------------------------------------------------------
|
||||
static unsigned char HIDDJoystickDriver_GetDescriptor(unsigned char type,
|
||||
unsigned char length)
|
||||
{
|
||||
extern int hiddReportDescriptorSize;
|
||||
|
||||
const USBConfigurationDescriptor *pConfiguration;
|
||||
HIDDescriptor *hidDescriptor;
|
||||
|
||||
switch (type) {
|
||||
|
||||
case HIDGenericDescriptor_REPORT:
|
||||
TRACE_INFO("Report ");
|
||||
|
||||
// Adjust length and send report descriptor
|
||||
if (length > hiddReportDescriptorSize) {
|
||||
|
||||
length = hiddReportDescriptorSize;
|
||||
}
|
||||
USBD_Write(0, &hiddReportDescriptor, length, 0, 0);
|
||||
break;
|
||||
|
||||
case HIDGenericDescriptor_HID:
|
||||
TRACE_INFO("HID ");
|
||||
|
||||
// Configuration descriptor is different depending on configuration
|
||||
if (USBD_IsHighSpeed()) {
|
||||
|
||||
pConfiguration =
|
||||
hiddJoystickDriver.usbdDriver.pDescriptors->pHsConfiguration;
|
||||
}
|
||||
else {
|
||||
|
||||
pConfiguration =
|
||||
hiddJoystickDriver.usbdDriver.pDescriptors->pFsConfiguration;
|
||||
}
|
||||
|
||||
// Parse the device configuration to get the HID descriptor
|
||||
USBConfigurationDescriptor_Parse(pConfiguration, 0, 0,
|
||||
(USBGenericDescriptor **) &hidDescriptor);
|
||||
|
||||
// Adjust length and send HID descriptor
|
||||
if (length > sizeof(HIDDescriptor)) {
|
||||
|
||||
length = sizeof(HIDDescriptor);
|
||||
}
|
||||
USBD_Write(0, hidDescriptor, length, 0, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Sends the current Idle rate of the input report to the host.
|
||||
//------------------------------------------------------------------------------
|
||||
static void HIDDJoystickDriver_GetIdle()
|
||||
{
|
||||
TRACE_INFO("gIdle ");
|
||||
|
||||
USBD_Write(0, &(hiddJoystickDriver.inputReportIdleRate), 1, 0, 0);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Retrieves the new idle rate of the input report from the USB host.
|
||||
/// \param idleRate New input report idle rate.
|
||||
//------------------------------------------------------------------------------
|
||||
static void HIDDJoystickDriver_SetIdle(unsigned char idleRate)
|
||||
{
|
||||
TRACE_INFO("sIdle(%d) ", idleRate);
|
||||
|
||||
hiddJoystickDriver.inputReportIdleRate = idleRate;
|
||||
USBD_Write(0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Sends the requested report to the host.
|
||||
/// \param type Report type.
|
||||
/// \param length Maximum number of bytes to send.
|
||||
//------------------------------------------------------------------------------
|
||||
static void HIDDJoystickDriver_GetReport(unsigned char type,
|
||||
unsigned short length)
|
||||
{
|
||||
TRACE_INFO("gReport ");
|
||||
|
||||
// Check report type
|
||||
switch (type) {
|
||||
|
||||
case HIDReportRequest_INPUT:
|
||||
TRACE_INFO("In ");
|
||||
|
||||
// Adjust size and send report
|
||||
if (length > sizeof(HIDDJoystickInputReport)) {
|
||||
|
||||
length = sizeof(HIDDJoystickInputReport);
|
||||
}
|
||||
USBD_Write(0, // Endpoint #0
|
||||
&(hiddJoystickDriver.inputReport),
|
||||
length,
|
||||
0, // No callback
|
||||
0);
|
||||
break;
|
||||
|
||||
default:
|
||||
USBD_Stall(0);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Retrieves the new value of a report from the host and saves it.
|
||||
/// \param type Report type.
|
||||
/// \param length Report length.
|
||||
//------------------------------------------------------------------------------
|
||||
static void HIDDJoystickDriver_SetReport(unsigned char type,
|
||||
unsigned short length)
|
||||
{
|
||||
TRACE_INFO("sReport ");
|
||||
|
||||
// Check report type
|
||||
switch (type) {
|
||||
|
||||
case HIDReportRequest_INPUT:
|
||||
// SET_REPORT requests on input reports are ignored
|
||||
USBD_Stall(0);
|
||||
break;
|
||||
|
||||
default:
|
||||
USBD_Stall(0);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Optional RequestReceived() callback re-implementation
|
||||
//------------------------------------------------------------------------------
|
||||
#if !defined(NOAUTOCALLBACK)
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Callback function when new request receivce from host
|
||||
/// \param request Pointer to the USBGenericRequest instance
|
||||
//------------------------------------------------------------------------------
|
||||
//void USBDCallbacks_RequestReceived(const USBGenericRequest *request)
|
||||
//{
|
||||
// HIDDJoystickDriver_RequestHandler(request);
|
||||
//}
|
||||
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// ConfigurationChanged() callback re-implementation
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Callback function when configureation changed
|
||||
/// \param cfgnum New configuration number
|
||||
//------------------------------------------------------------------------------
|
||||
//void USBDDriverCallbacks_ConfigurationChanged(unsigned char cfgnum)
|
||||
//{
|
||||
// (void)cfgnum;
|
||||
//}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Exported functions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Initializes the HID Joystick %device driver.
|
||||
//------------------------------------------------------------------------------
|
||||
void HIDDJoystickDriver_Initialize()
|
||||
{
|
||||
hiddJoystickDriver.inputReportIdleRate = 0;
|
||||
HIDDJoystickInputReport_Initialize(&(hiddJoystickDriver.inputReport));
|
||||
USBDDriver_Initialize(&(hiddJoystickDriver.usbdDriver),
|
||||
&hiddJoystickDriverDescriptors,
|
||||
0); // Multiple interface settings not supported
|
||||
USBD_Init();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Handles HID-specific SETUP request sent by the host.
|
||||
/// \param request Pointer to a USBGenericRequest instance
|
||||
//------------------------------------------------------------------------------
|
||||
void HIDDJoystickDriver_RequestHandler(const USBGenericRequest *request)
|
||||
{
|
||||
TRACE_INFO("NewReq ");
|
||||
|
||||
// Check if this is a standard request
|
||||
if (USBGenericRequest_GetType(request) == USBGenericRequest_STANDARD) {
|
||||
|
||||
// This is a standard request
|
||||
switch (USBGenericRequest_GetRequest(request)) {
|
||||
|
||||
case USBGenericRequest_GETDESCRIPTOR:
|
||||
// Check if this is a HID descriptor, otherwise forward it to
|
||||
// the standard driver
|
||||
if (!HIDDJoystickDriver_GetDescriptor(
|
||||
USBGetDescriptorRequest_GetDescriptorType(request),
|
||||
USBGenericRequest_GetLength(request))) {
|
||||
|
||||
USBDDriver_RequestHandler(&(hiddJoystickDriver.usbdDriver),
|
||||
request);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
USBDDriver_RequestHandler(&(hiddJoystickDriver.usbdDriver),
|
||||
request);
|
||||
}
|
||||
}
|
||||
// Check if this is a class request
|
||||
else if (USBGenericRequest_GetType(request) == USBGenericRequest_CLASS) {
|
||||
|
||||
// This is a class-specific request
|
||||
switch (USBGenericRequest_GetRequest(request)) {
|
||||
|
||||
case HIDGenericRequest_GETIDLE:
|
||||
HIDDJoystickDriver_GetIdle();
|
||||
break;
|
||||
|
||||
case HIDGenericRequest_SETIDLE:
|
||||
HIDDJoystickDriver_SetIdle(HIDIdleRequest_GetIdleRate(request));
|
||||
break;
|
||||
|
||||
case HIDGenericRequest_GETREPORT:
|
||||
HIDDJoystickDriver_GetReport(
|
||||
HIDReportRequest_GetReportType(request),
|
||||
USBGenericRequest_GetLength(request));
|
||||
break;
|
||||
|
||||
case HIDGenericRequest_SETREPORT:
|
||||
HIDDJoystickDriver_SetReport(
|
||||
HIDReportRequest_GetReportType(request),
|
||||
USBGenericRequest_GetLength(request));
|
||||
break;
|
||||
|
||||
case HIDGenericRequest_GETPROTOCOL:
|
||||
USBD_Write(0, &hiddJoystickDriver.inputProtocol, 1, 0, 0);
|
||||
break;
|
||||
|
||||
case HIDGenericRequest_SETPROTOCOL:
|
||||
hiddJoystickDriver.inputProtocol = request->wValue;
|
||||
USBD_Write(0, 0, 0, 0, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
TRACE_WARNING(
|
||||
"HIDDJoystickDriver_RequestHandler: Unknown request 0x%02X\n\r",
|
||||
USBGenericRequest_GetRequest(request));
|
||||
USBD_Stall(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
// Vendor request ?
|
||||
USBD_Stall(0);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Update the Joystick state via input report
|
||||
/// to host
|
||||
/// \param report Pointer to a HIDDJoystickInputReport instance
|
||||
//------------------------------------------------------------------------------
|
||||
unsigned char HIDDJoystickDriver_ChangeJoystickState(const HIDDJoystickInputReport *report)
|
||||
{
|
||||
memcpy(&(hiddJoystickDriver.inputReport), report, sizeof(HIDDJoystickInputReport));
|
||||
|
||||
// Send input report through the interrupt IN endpoint
|
||||
return USBD_Write(HIDDJoystickDriverDescriptors_INTERRUPTIN,
|
||||
&(hiddJoystickDriver.inputReport),
|
||||
sizeof(HIDDJoystickInputReport),
|
||||
0,
|
||||
0);
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
\unit
|
||||
|
||||
!!!Purpose
|
||||
|
||||
Definition of methods for using a HID joystick device driver.
|
||||
|
||||
!!!Usage
|
||||
|
||||
-# Re-implement the USBDCallbacks_RequestReceived callback to forward
|
||||
requests to HIDDJoystickDriver_RequestHandler. This is done
|
||||
automatically unless the NOAUTOCALLBACK symbol is defined during
|
||||
compilation.
|
||||
-# Initialize the driver using HIDDJoystickDriver_Initialize. The
|
||||
USB driver is automatically initialized by this method.
|
||||
-# Call the HIDDJoystickDriver_ChangePoints method when one or more
|
||||
keys are pressed/released.
|
||||
*/
|
||||
|
||||
#ifndef HIDDJOYSTICKDRIVER_H
|
||||
#define HIDDJOYSTICKDRIVER_H
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Headers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include <usb/common/core/USBGenericRequest.h>
|
||||
#include "HIDDJoystickInputReport.h"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Exported functions
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Function: HIDDJoystickDriver_Initialize
|
||||
Initializes the HID joystick device driver.
|
||||
*/
|
||||
extern void HIDDJoystickDriver_Initialize();
|
||||
|
||||
/*
|
||||
Function: HIDDJoystickDriver_RequestHandler
|
||||
Handles HID-specific SETUP request sent by the host.
|
||||
|
||||
Parameters:
|
||||
request - Pointer to a USBGenericRequest instance.
|
||||
*/
|
||||
extern void HIDDJoystickDriver_RequestHandler(const USBGenericRequest *request);
|
||||
|
||||
extern unsigned char HIDDJoystickDriver_ChangeJoystickState(const HIDDJoystickInputReport *report);
|
||||
|
||||
#endif //#ifndef HIDDJOYSTICKDRIVER_H
|
||||
|
||||
@@ -0,0 +1,297 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
Title: HIDDJoystickDriverDescriptors
|
||||
|
||||
About: Purpose
|
||||
Declaration of the descriptors used by the HID device joystick driver.
|
||||
*/
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Headers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include "HIDDJoystickDriverDescriptors.h"
|
||||
#include "HIDDJoystickInputReport.h"
|
||||
#include <usb/common/core/USBDeviceDescriptor.h>
|
||||
#include <usb/common/core/USBConfigurationDescriptor.h>
|
||||
#include <usb/common/core/USBInterfaceDescriptor.h>
|
||||
#include <usb/common/core/USBEndpointDescriptor.h>
|
||||
#include <usb/common/core/USBStringDescriptor.h>
|
||||
#include <usb/common/hid/HIDGenericDescriptor.h>
|
||||
#include <usb/common/hid/HIDDeviceDescriptor.h>
|
||||
#include <usb/common/hid/HIDInterfaceDescriptor.h>
|
||||
#include <usb/common/hid/HIDDescriptor.h>
|
||||
#include <usb/common/hid/HIDReport.h>
|
||||
#include <usb/common/hid/HIDGenericDesktop.h>
|
||||
#include <usb/common/hid/HIDButton.h>
|
||||
#include <usb/device/core/USBDDriverDescriptors.h>
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// \page "HID Joystick Device Descriptor IDs"
|
||||
/// ...
|
||||
///
|
||||
/// !IDs
|
||||
/// - HIDDJoystickDriverDescriptors_PRODUCTID
|
||||
/// - HIDDJoystickDriverDescriptors_VENDORID
|
||||
/// - HIDDJoystickDriverDescriptors_RELEASE
|
||||
|
||||
/// Device product ID.
|
||||
#define HIDDJoystickDriverDescriptors_PRODUCTID 0x6200
|
||||
/// Device vendor ID.
|
||||
#define HIDDJoystickDriverDescriptors_VENDORID 0x03EB
|
||||
/// Device release number.
|
||||
#define HIDDJoystickDriverDescriptors_RELEASE 0x0100
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Internal types
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// List of descriptors that make up the configuration descriptors of a
|
||||
/// %device using the HID Joystick driver.
|
||||
//------------------------------------------------------------------------------
|
||||
typedef struct {
|
||||
|
||||
/// Configuration descriptor.
|
||||
USBConfigurationDescriptor configuration;
|
||||
/// Interface descriptor.
|
||||
USBInterfaceDescriptor interface;
|
||||
/// HID descriptor.
|
||||
HIDDescriptor hid;
|
||||
/// Interrupt IN endpoint descriptor.
|
||||
USBEndpointDescriptor interruptIn;
|
||||
|
||||
} __attribute__ ((packed)) HIDDJoystickDriverConfigurationDescriptors;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Internal variables
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#define BOARD_USB_ENDPOINTS_MAXPACKETSIZE(i) (((i == 0)||(i == 3)||(i == 4)) ? 64 :\
|
||||
(((i == 1) || (i == 2)) ? 512 : 1024))
|
||||
|
||||
/// Device descriptor.
|
||||
static const USBDeviceDescriptor deviceDescriptor = {
|
||||
|
||||
sizeof(USBDeviceDescriptor),
|
||||
USBGenericDescriptor_DEVICE,
|
||||
USBDeviceDescriptor_USB2_00,
|
||||
HIDDeviceDescriptor_CLASS,
|
||||
HIDDeviceDescriptor_SUBCLASS,
|
||||
HIDDeviceDescriptor_PROTOCOL,
|
||||
BOARD_USB_ENDPOINTS_MAXPACKETSIZE(0),
|
||||
HIDDJoystickDriverDescriptors_VENDORID,
|
||||
HIDDJoystickDriverDescriptors_PRODUCTID,
|
||||
HIDDJoystickDriverDescriptors_RELEASE,
|
||||
1, // Index of manufacturer description
|
||||
2, // Index of product description
|
||||
3, // Index of serial number description
|
||||
1 // One possible configuration
|
||||
};
|
||||
|
||||
/// Report descriptor used by the driver.
|
||||
const unsigned char hiddReportDescriptor[] = {
|
||||
|
||||
HIDReport_GLOBAL_USAGEPAGE + 1, HIDGenericDesktop_PAGEID, // USAGE_PAGE (Generic Desktop)
|
||||
HIDReport_LOCAL_USAGE + 1, HIDGenericDesktop_GAMEPAD, // USAGE (Game Pad)
|
||||
HIDReport_COLLECTION + 1, HIDReport_COLLECTION_APPLICATION, // COLLECTION (Application)
|
||||
HIDReport_COLLECTION + 1, HIDReport_COLLECTION_PHYSICAL, // COLLECTION (Physical)
|
||||
HIDReport_GLOBAL_USAGEPAGE + 1, HIDButton_PAGEID, // USAGE_PAGE (Button)
|
||||
HIDReport_LOCAL_USAGEMINIMUM + 1, 1, // USAGE_MINIMUM (Button 1)
|
||||
HIDReport_LOCAL_USAGEMAXIMUM + 1, 24, // USAGE_MAXIMUM (Button 24)
|
||||
HIDReport_GLOBAL_LOGICALMINIMUM + 1, 0, // LOGICAL_MINIMUM (0)
|
||||
HIDReport_GLOBAL_LOGICALMAXIMUM + 1, 1, // LOGICAL_MAXIMUM (1)
|
||||
HIDReport_GLOBAL_REPORTCOUNT + 1, 24, // REPORT_COUNT (24)
|
||||
HIDReport_GLOBAL_REPORTSIZE + 1, 1, // REPORT_SIZE (1)
|
||||
HIDReport_INPUT + 1, HIDReport_VARIABLE, // INPUT (Data,Var,Abs)
|
||||
HIDReport_GLOBAL_USAGEPAGE + 1, HIDGenericDesktop_PAGEID, // USAGE_PAGE (Generic Desktop)
|
||||
HIDReport_LOCAL_USAGE + 1, HIDGenericDesktop_X_AXIS, // USAGE (X)
|
||||
HIDReport_LOCAL_USAGE + 1, HIDGenericDesktop_Y_AXIS, // USAGE (Y)
|
||||
HIDReport_LOCAL_USAGE + 1, HIDGenericDesktop_Z_AXIS, // USAGE (Z)
|
||||
HIDReport_LOCAL_USAGE + 1, HIDGenericDesktop_X_ROTATION, // USAGE (Rx)
|
||||
HIDReport_LOCAL_USAGE + 1, HIDGenericDesktop_Y_ROTATION, // USAGE (Ry)
|
||||
HIDReport_LOCAL_USAGE + 1, HIDGenericDesktop_Z_ROTATION, // USAGE (Rz)
|
||||
HIDReport_LOCAL_USAGE + 1, HIDGenericDesktop_SLIDER, // USAGE (Slider)
|
||||
HIDReport_LOCAL_USAGE + 1, HIDGenericDesktop_SLIDER, // USAGE (Slider)
|
||||
HIDReport_GLOBAL_LOGICALMINIMUM + 1, (unsigned char) -127, // LOGICAL_MINIMUM (-127)
|
||||
HIDReport_GLOBAL_LOGICALMAXIMUM + 1, 127, // LOGICAL_MAXIMUM (127)
|
||||
HIDReport_GLOBAL_REPORTSIZE + 1, 8, // REPORT_SIZE (8)
|
||||
HIDReport_GLOBAL_REPORTCOUNT + 1, 8, // REPORT_COUNT (8)
|
||||
HIDReport_INPUT + 1, HIDReport_VARIABLE, // INPUT (Data,Var,Abs)
|
||||
HIDReport_ENDCOLLECTION, // END_COLLECTION
|
||||
HIDReport_ENDCOLLECTION // END_COLLECTION
|
||||
};
|
||||
int hiddReportDescriptorSize = sizeof(hiddReportDescriptor);
|
||||
|
||||
/// Configuration descriptor.
|
||||
static const HIDDJoystickDriverConfigurationDescriptors configurationDescriptors = {
|
||||
|
||||
// Configuration descriptor
|
||||
{
|
||||
sizeof(USBConfigurationDescriptor),
|
||||
USBGenericDescriptor_CONFIGURATION,
|
||||
sizeof(HIDDJoystickDriverConfigurationDescriptors),
|
||||
1, // One interface in this configuration
|
||||
1, // This is configuration #1
|
||||
0, // No associated string descriptor
|
||||
BOARD_USB_BMATTRIBUTES,
|
||||
USBConfigurationDescriptor_POWER(100)
|
||||
},
|
||||
// Interface descriptor
|
||||
{
|
||||
sizeof(USBInterfaceDescriptor),
|
||||
USBGenericDescriptor_INTERFACE,
|
||||
0, // This is interface #0
|
||||
0, // This is alternate setting #0
|
||||
1, // One endpoints used
|
||||
HIDInterfaceDescriptor_CLASS,
|
||||
HIDInterfaceDescriptor_SUBCLASS_NONE,
|
||||
HIDInterfaceDescriptor_PROTOCOL_NONE,
|
||||
0 // No associated string descriptor
|
||||
},
|
||||
// HID descriptor
|
||||
{
|
||||
sizeof(HIDDescriptor),
|
||||
HIDGenericDescriptor_HID,
|
||||
HIDDescriptor_HID1_11,
|
||||
0, // Device is not localized, no country code
|
||||
1, // One HID-specific descriptor (apart from this one)
|
||||
HIDGenericDescriptor_REPORT,
|
||||
sizeof(hiddReportDescriptor),
|
||||
},
|
||||
// Interrupt IN endpoint descriptor
|
||||
{
|
||||
sizeof(USBEndpointDescriptor),
|
||||
USBGenericDescriptor_ENDPOINT, // 5
|
||||
USBEndpointDescriptor_ADDRESS(
|
||||
USBEndpointDescriptor_IN,
|
||||
HIDDJoystickDriverDescriptors_INTERRUPTIN),
|
||||
USBEndpointDescriptor_INTERRUPT,
|
||||
sizeof(HIDDJoystickInputReport),
|
||||
HIDDJoystickDriverDescriptors_INTERRUPTIN_POLLING
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
Variables: String descriptors
|
||||
languageIdDescriptor - Language ID string descriptor.
|
||||
manufacturerDescriptor - Manufacturer name.
|
||||
productDescriptor - Product name.
|
||||
serialNumberDescriptor - Product serial number.
|
||||
stringDescriptors - Array of pointers to string descriptors.
|
||||
*/
|
||||
static const unsigned char languageIdDescriptor[] = {
|
||||
|
||||
USBStringDescriptor_LENGTH(1),
|
||||
USBGenericDescriptor_STRING,
|
||||
USBStringDescriptor_ENGLISH_US
|
||||
};
|
||||
|
||||
static const unsigned char manufacturerDescriptor[] = {
|
||||
|
||||
USBStringDescriptor_LENGTH(5),
|
||||
USBGenericDescriptor_STRING,
|
||||
USBStringDescriptor_UNICODE('A'),
|
||||
USBStringDescriptor_UNICODE('T'),
|
||||
USBStringDescriptor_UNICODE('M'),
|
||||
USBStringDescriptor_UNICODE('E'),
|
||||
USBStringDescriptor_UNICODE('L')
|
||||
};
|
||||
|
||||
static const unsigned char productDescriptor[] = {
|
||||
|
||||
USBStringDescriptor_LENGTH(14),
|
||||
USBGenericDescriptor_STRING,
|
||||
USBStringDescriptor_UNICODE('S'),
|
||||
USBStringDescriptor_UNICODE('K'),
|
||||
USBStringDescriptor_UNICODE('Y'),
|
||||
USBStringDescriptor_UNICODE('9'),
|
||||
USBStringDescriptor_UNICODE('X'),
|
||||
USBStringDescriptor_UNICODE(' '),
|
||||
USBStringDescriptor_UNICODE('J'),
|
||||
USBStringDescriptor_UNICODE('o'),
|
||||
USBStringDescriptor_UNICODE('y'),
|
||||
USBStringDescriptor_UNICODE('s'),
|
||||
USBStringDescriptor_UNICODE('t'),
|
||||
USBStringDescriptor_UNICODE('i'),
|
||||
USBStringDescriptor_UNICODE('c'),
|
||||
USBStringDescriptor_UNICODE('k'),
|
||||
};
|
||||
|
||||
static const unsigned char serialNumberDescriptor[] = {
|
||||
|
||||
USBStringDescriptor_LENGTH(12),
|
||||
USBGenericDescriptor_STRING,
|
||||
USBStringDescriptor_UNICODE('0'),
|
||||
USBStringDescriptor_UNICODE('1'),
|
||||
USBStringDescriptor_UNICODE('2'),
|
||||
USBStringDescriptor_UNICODE('3'),
|
||||
USBStringDescriptor_UNICODE('4'),
|
||||
USBStringDescriptor_UNICODE('5'),
|
||||
USBStringDescriptor_UNICODE('6'),
|
||||
USBStringDescriptor_UNICODE('7'),
|
||||
USBStringDescriptor_UNICODE('8'),
|
||||
USBStringDescriptor_UNICODE('9'),
|
||||
USBStringDescriptor_UNICODE('A'),
|
||||
USBStringDescriptor_UNICODE('F')
|
||||
};
|
||||
|
||||
static const unsigned char *stringDescriptors[] = {
|
||||
|
||||
languageIdDescriptor,
|
||||
manufacturerDescriptor,
|
||||
productDescriptor,
|
||||
serialNumberDescriptor
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Exported variables
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/// List of descriptors used by the HID joystick driver.
|
||||
USBDDriverDescriptors hiddJoystickDriverDescriptors = {
|
||||
|
||||
&deviceDescriptor,
|
||||
(USBConfigurationDescriptor *) &configurationDescriptors,
|
||||
0, // No full-speed device qualifier descriptor
|
||||
0, // No full-speed other speed configuration
|
||||
0, // No high-speed device descriptor
|
||||
0, // No high-speed configuration descriptor
|
||||
0, // No high-speed device qualifier descriptor
|
||||
0, // No high-speed other speed configuration descriptor
|
||||
stringDescriptors,
|
||||
4 // Four string descriptors in list
|
||||
};
|
||||
@@ -0,0 +1,79 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
\unit
|
||||
|
||||
!!!Purpose
|
||||
|
||||
Definitions of the descriptors required by the HID device joystick
|
||||
driver.
|
||||
|
||||
!!!Usage
|
||||
-# Use the hiddJoystickDriverDescriptors variable to initialize a
|
||||
USBDDriver instance.
|
||||
-# Send hiddReportDescriptor to the host when a GET_DESCRIPTOR request
|
||||
for the report descriptor is received.
|
||||
*/
|
||||
|
||||
#ifndef HIDDJOYSTICKDRIVERDESCRIPTORS_H
|
||||
#define HIDDJOYSTICKDRIVERDESCRIPTORS_H
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Headers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include <usb/device/core/USBDDriverDescriptors.h>
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Constants: Endpoints
|
||||
HIDDJoystickDriverDescriptors_INTERRUPTIN - Interrupt IN endpoint number.
|
||||
HIDDJoystickDriverDescriptors_INTERRUPTIN_POLLING - Interrupt IN endpoint
|
||||
polling rate (in milliseconds).
|
||||
*/
|
||||
#define HIDDJoystickDriverDescriptors_INTERRUPTIN 1
|
||||
#define HIDDJoystickDriverDescriptors_INTERRUPTIN_POLLING 10
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Exported variables
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
Variables: HID joystick driver descriptors
|
||||
hiddJoystickDriverDescriptors - List of descriptors used by the HID
|
||||
joystick driver.
|
||||
hiddReportDescriptor - Report descriptor used by the driver.
|
||||
*/
|
||||
extern USBDDriverDescriptors hiddJoystickDriverDescriptors;
|
||||
extern const unsigned char hiddReportDescriptor[];
|
||||
|
||||
#endif //#ifndef HIDDJOYSTICKDRIVERDESCRIPTORS_H
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
Title: HIDDJoystickInputReport implementation
|
||||
|
||||
About: Purpose
|
||||
Implementation of the HIDDJoystickInputReport class.
|
||||
*/
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Headers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include "HIDDJoystickInputReport.h"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Exported functions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// Initializes a joystick input report instance.
|
||||
/// \param report Pointer to a HIDDJoystickInputReport instance.
|
||||
//------------------------------------------------------------------------------
|
||||
void HIDDJoystickInputReport_Initialize(HIDDJoystickInputReport *report)
|
||||
{
|
||||
report->buttons1 = 0;
|
||||
report->buttons2 = 0;
|
||||
report->buttons3 = 0;
|
||||
report->X = 0;
|
||||
report->Y = 0;
|
||||
report->Z = 0;
|
||||
report->Rx = 0;
|
||||
report->Ry = 0;
|
||||
report->Rz = 0;
|
||||
report->S1 = 0;
|
||||
report->S2 = 0;
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
\unit
|
||||
|
||||
!!!Purpose
|
||||
|
||||
Class for manipulating HID Joystick input reports.
|
||||
|
||||
!!!Usage
|
||||
|
||||
-# Initialize a newly created input report with
|
||||
HIDDJoystickInputReport_Initialize
|
||||
*/
|
||||
|
||||
#ifndef HIDDJOYSTICKINPUTREPORT_H
|
||||
#define HIDDJOYSTICKINPUTREPORT_H
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Types
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#ifdef __ICCARM__ // IAR
|
||||
#pragma pack(1) // IAR
|
||||
#define __attribute__(...) // IAR
|
||||
#endif // IAR
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// HID input report structure used by the Joystick driver to notify the
|
||||
/// host of pressed keys.
|
||||
//------------------------------------------------------------------------------
|
||||
typedef struct {
|
||||
|
||||
unsigned char buttons1; // bit 0 - button 1, bit 1 - button 2, ..., mapped to channels 9-16, on if channel > 0
|
||||
unsigned char buttons2; // mapped to channels 17-24, on if channel > 0
|
||||
unsigned char buttons3; // mapped to channels 25-32, on if channel > 0
|
||||
unsigned char X; // analog value, mapped to channel 1
|
||||
unsigned char Y; // analog value, mapped to channel 2
|
||||
unsigned char Z; // analog value, mapped to channel 3
|
||||
unsigned char Rx; // analog value, mapped to channel 4
|
||||
unsigned char Ry; // analog value, mapped to channel 5
|
||||
unsigned char Rz; // analog value, mapped to channel 6
|
||||
unsigned char S1; // analog value, mapped to channel 7
|
||||
unsigned char S2; // analog value, mapped to channel 8
|
||||
|
||||
} __attribute__ ((packed)) HIDDJoystickInputReport; // GCC
|
||||
|
||||
#ifdef __ICCARM__ // IAR
|
||||
#pragma pack() // IAR
|
||||
#endif // IAR
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Exported functions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
extern void HIDDJoystickInputReport_Initialize(HIDDJoystickInputReport *report);
|
||||
|
||||
#endif //#ifndef HIDDJOYSTICKINPUTREPORT_H
|
||||
|
||||
@@ -76,23 +76,23 @@ static void MSDDriver_Reset(void)
|
||||
/// request to the Mass Storage device driver handler function.
|
||||
/// \param request Pointer to a USBGenericRequest instance.
|
||||
//-----------------------------------------------------------------------------
|
||||
void USBDCallbacks_RequestReceived(const USBGenericRequest *request)
|
||||
{
|
||||
MSDDriver_RequestHandler(request);
|
||||
}
|
||||
//void USBDCallbacks_RequestReceived(const USBGenericRequest *request)
|
||||
//{
|
||||
// MSDDriver_RequestHandler(request);
|
||||
//}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/// Invoked when the configuration of the device changes. Resets the mass
|
||||
/// storage driver.
|
||||
/// \param cfgnum New configuration number.
|
||||
//-----------------------------------------------------------------------------
|
||||
void USBDDriverCallbacks_ConfigurationChanged(unsigned char cfgnum)
|
||||
{
|
||||
if (cfgnum > 0) {
|
||||
//void USBDDriverCallbacks_ConfigurationChanged(unsigned char cfgnum)
|
||||
//{
|
||||
// if (cfgnum > 0) {
|
||||
|
||||
MSDDriver_Reset();
|
||||
}
|
||||
}
|
||||
// MSDDriver_Reset();
|
||||
// }
|
||||
//}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Driver functions
|
||||
|
||||
Reference in New Issue
Block a user