parent
b9f3ff39a4
commit
80dc196031
@ -1,93 +0,0 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2012.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
* \brief LUFA Library Configuration Header File
|
||||
*
|
||||
* This header file is used to configure LUFA's compile time options,
|
||||
* as an alternative to the compile time constants supplied through
|
||||
* a makefile.
|
||||
*
|
||||
* For information on what each token does, refer to the LUFA
|
||||
* manual section "Summary of Compile Tokens".
|
||||
*/
|
||||
|
||||
#ifndef _LUFA_CONFIG_H_
|
||||
#define _LUFA_CONFIG_H_
|
||||
|
||||
#if (ARCH == ARCH_AVR8)
|
||||
|
||||
/* Non-USB Related Configuration Tokens: */
|
||||
// #define DISABLE_TERMINAL_CODES
|
||||
|
||||
/* USB Class Driver Related Tokens: */
|
||||
// #define HID_HOST_BOOT_PROTOCOL_ONLY
|
||||
// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here}
|
||||
// #define HID_USAGE_STACK_DEPTH {Insert Value Here}
|
||||
// #define HID_MAX_COLLECTIONS {Insert Value Here}
|
||||
// #define HID_MAX_REPORTITEMS {Insert Value Here}
|
||||
// #define HID_MAX_REPORT_IDS {Insert Value Here}
|
||||
// #define NO_CLASS_DRIVER_AUTOFLUSH
|
||||
|
||||
/* General USB Driver Related Tokens: */
|
||||
// #define ORDERED_EP_CONFIG
|
||||
#define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)
|
||||
#define USB_DEVICE_ONLY
|
||||
// #define USB_HOST_ONLY
|
||||
// #define USB_STREAM_TIMEOUT_MS {Insert Value Here}
|
||||
// #define NO_LIMITED_CONTROLLER_CONNECT
|
||||
// #define NO_SOF_EVENTS
|
||||
|
||||
/* USB Device Mode Driver Related Tokens: */
|
||||
// #define USE_RAM_DESCRIPTORS
|
||||
#define USE_FLASH_DESCRIPTORS
|
||||
// #define USE_EEPROM_DESCRIPTORS
|
||||
// #define NO_INTERNAL_SERIAL
|
||||
#define FIXED_CONTROL_ENDPOINT_SIZE 8
|
||||
// #define DEVICE_STATE_AS_GPIOR {Insert Value Here}
|
||||
#define FIXED_NUM_CONFIGURATIONS 1
|
||||
// #define CONTROL_ONLY_DEVICE
|
||||
// #define INTERRUPT_CONTROL_ENDPOINT
|
||||
// #define NO_DEVICE_REMOTE_WAKEUP
|
||||
// #define NO_DEVICE_SELF_POWER
|
||||
|
||||
/* USB Host Mode Driver Related Tokens: */
|
||||
// #define HOST_STATE_AS_GPIOR {Insert Value Here}
|
||||
// #define USB_HOST_TIMEOUT_MS {Insert Value Here}
|
||||
// #define HOST_DEVICE_SETTLE_DELAY_MS {Insert Value Here}
|
||||
// #define NO_AUTO_VBUS_MANAGEMENT
|
||||
// #define INVERTED_VBUS_ENABLE_LINE
|
||||
|
||||
#else
|
||||
|
||||
#error Unsupported architecture for this LUFA configuration file.
|
||||
|
||||
#endif
|
||||
#endif
|
@ -1,233 +0,0 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2012.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
||||
const USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||
{
|
||||
Header: {Size: sizeof(USB_Descriptor_Device_t), Type: DTYPE_Device},
|
||||
|
||||
USBSpecification: VERSION_BCD(01.10),
|
||||
Class: 0x00,
|
||||
SubClass: 0x00,
|
||||
Protocol: 0x00,
|
||||
|
||||
Endpoint0Size: 8,
|
||||
|
||||
VendorID: 0x03EB,
|
||||
ProductID: 0x2040,
|
||||
ReleaseNumber: VERSION_BCD(00.01),
|
||||
|
||||
ManufacturerStrIndex: 0x01,
|
||||
ProductStrIndex: 0x02,
|
||||
SerialNumStrIndex: 0x03,
|
||||
|
||||
NumberOfConfigurations: 1
|
||||
};
|
||||
|
||||
const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||
{
|
||||
.Config =
|
||||
{
|
||||
Header: {Size: sizeof(USB_Descriptor_Configuration_Header_t), Type: DTYPE_Configuration},
|
||||
|
||||
TotalConfigurationSize: sizeof(USB_Descriptor_Configuration_t),
|
||||
TotalInterfaces: 1,
|
||||
|
||||
ConfigurationNumber: 1,
|
||||
ConfigurationStrIndex: NO_DESCRIPTOR,
|
||||
|
||||
ConfigAttributes: (USB_CONFIG_ATTR_RESERVED | USB_CONFIG_ATTR_SELFPOWERED),
|
||||
|
||||
MaxPowerConsumption: USB_CONFIG_POWER_MA(100)
|
||||
},
|
||||
|
||||
.SSHOW_Interface =
|
||||
{
|
||||
Header: {Size: sizeof(USB_Descriptor_Interface_t), Type: DTYPE_Interface},
|
||||
|
||||
InterfaceNumber: 0,
|
||||
AlternateSetting: 0,
|
||||
|
||||
TotalEndpoints: 2,
|
||||
|
||||
Class: 0xFF,
|
||||
SubClass: 0x00,
|
||||
Protocol: 0x00,
|
||||
|
||||
InterfaceStrIndex: NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.SSHOW_DataInEndpoint =
|
||||
{
|
||||
Header: {Size: sizeof(USB_Descriptor_Endpoint_t), Type: DTYPE_Endpoint},
|
||||
|
||||
EndpointAddress: SIDESHOW_IN_EPADDR,
|
||||
Attributes: EP_TYPE_BULK,
|
||||
EndpointSize: SIDESHOW_IO_EPSIZE,
|
||||
PollingIntervalMS: 0x00
|
||||
},
|
||||
|
||||
.SSHOW_DataOutEndpoint =
|
||||
{
|
||||
Header: {Size: sizeof(USB_Descriptor_Endpoint_t), Type: DTYPE_Endpoint},
|
||||
|
||||
EndpointAddress: SIDESHOW_OUT_EPADDR,
|
||||
Attributes: EP_TYPE_BULK,
|
||||
EndpointSize: SIDESHOW_IO_EPSIZE,
|
||||
PollingIntervalMS: 0x00
|
||||
}
|
||||
};
|
||||
|
||||
const USB_Descriptor_String_t PROGMEM LanguageString =
|
||||
{
|
||||
Header: {Size: USB_STRING_LEN(1), Type: DTYPE_String},
|
||||
|
||||
UnicodeString: {LANGUAGE_ID_ENG}
|
||||
};
|
||||
|
||||
const USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||
{
|
||||
Header: {Size: USB_STRING_LEN(11), Type: DTYPE_String},
|
||||
|
||||
UnicodeString: L"Dean Camera"
|
||||
};
|
||||
|
||||
const USB_Descriptor_String_t PROGMEM ProductString =
|
||||
{
|
||||
Header: {Size: USB_STRING_LEN(22), Type: DTYPE_String},
|
||||
|
||||
UnicodeString: L"LUFA Sideshow Demo"
|
||||
};
|
||||
|
||||
const USB_Descriptor_String_t PROGMEM SerialNumberString =
|
||||
{
|
||||
Header: {Size: USB_STRING_LEN(12), Type: DTYPE_String},
|
||||
|
||||
UnicodeString: L"000000000000"
|
||||
};
|
||||
|
||||
const USB_OSDescriptor_t PROGMEM OSDescriptorString =
|
||||
{
|
||||
Header: {Size: sizeof(USB_OSDescriptor_t), Type: DTYPE_String},
|
||||
|
||||
Signature: L"MSFT100",
|
||||
VendorCode: REQ_GetOSFeatureDescriptor
|
||||
};
|
||||
|
||||
const USB_OSCompatibleIDDescriptor_t PROGMEM DevCompatIDs =
|
||||
{
|
||||
TotalLength: sizeof(USB_OSCompatibleIDDescriptor_t),
|
||||
Version: 0x0100,
|
||||
Index: EXTENDED_COMPAT_ID_DESCRIPTOR,
|
||||
TotalSections: 1,
|
||||
|
||||
SideshowCompatID: {FirstInterfaceNumber: 0x00,
|
||||
CompatibleID: "SIDESHW",
|
||||
SubCompatibleID: "UNIV1"}
|
||||
};
|
||||
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
const uint8_t wIndex,
|
||||
const void** const DescriptorAddress)
|
||||
{
|
||||
const uint8_t DescriptorType = (wValue >> 8);
|
||||
const uint8_t DescriptorNumber = (wValue & 0xFF);
|
||||
|
||||
const void* Address = NULL;
|
||||
uint16_t Size = NO_DESCRIPTOR;
|
||||
|
||||
switch (DescriptorType)
|
||||
{
|
||||
case DTYPE_Device:
|
||||
Address = &DeviceDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Device_t);
|
||||
break;
|
||||
case DTYPE_Configuration:
|
||||
Address = &ConfigurationDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||
break;
|
||||
case DTYPE_String:
|
||||
switch (DescriptorNumber)
|
||||
{
|
||||
case 0x00:
|
||||
Address = &LanguageString;
|
||||
Size = pgm_read_byte(&LanguageString.Header.Size);
|
||||
break;
|
||||
case 0x01:
|
||||
Address = &ManufacturerString;
|
||||
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
||||
break;
|
||||
case 0x02:
|
||||
Address = &ProductString;
|
||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||
break;
|
||||
case 0x03:
|
||||
Address = &SerialNumberString;
|
||||
Size = pgm_read_byte(&SerialNumberString.Header.Size);
|
||||
break;
|
||||
case 0xEE:
|
||||
/* A Microsoft-proprietary extension. String address 0xEE is used by Windows for
|
||||
"OS Descriptors", which in this case allows us to indicate that our device is
|
||||
Sideshow compatible regardless of VID/PID values. */
|
||||
Address = &OSDescriptorString;
|
||||
Size = pgm_read_byte(&OSDescriptorString.Header.Size);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
*DescriptorAddress = Address;
|
||||
return Size;
|
||||
}
|
||||
|
||||
uint16_t USB_GetOSFeatureDescriptor(const uint16_t wValue,
|
||||
const uint8_t wIndex,
|
||||
const void** const DescriptorAddress)
|
||||
{
|
||||
const void* Address = NULL;
|
||||
uint16_t Size = NO_DESCRIPTOR;
|
||||
|
||||
/* Check if a device level OS feature descriptor is being requested */
|
||||
if (wValue == 0x0000)
|
||||
{
|
||||
/* Only the Extended Device Compatibility descriptor is supported */
|
||||
if (wIndex == EXTENDED_COMPAT_ID_DESCRIPTOR)
|
||||
{
|
||||
Address = &DevCompatIDs;
|
||||
Size = sizeof(USB_OSCompatibleIDDescriptor_t);
|
||||
}
|
||||
}
|
||||
|
||||
*DescriptorAddress = Address;
|
||||
return Size;
|
||||
}
|
||||
|
@ -1,101 +0,0 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2012.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#ifndef _DESCRIPTORS_H_
|
||||
#define _DESCRIPTORS_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#include "Sideshow.h"
|
||||
|
||||
/* Macros: */
|
||||
#define SIDESHOW_IN_EPADDR 3
|
||||
#define SIDESHOW_OUT_EPADDR 4
|
||||
#define SIDESHOW_IO_EPSIZE 64
|
||||
|
||||
/* Type Defines: */
|
||||
typedef struct
|
||||
{
|
||||
USB_Descriptor_Configuration_Header_t Config;
|
||||
|
||||
// SideShow Interface
|
||||
USB_Descriptor_Interface_t SSHOW_Interface;
|
||||
USB_Descriptor_Endpoint_t SSHOW_DataInEndpoint;
|
||||
USB_Descriptor_Endpoint_t SSHOW_DataOutEndpoint;
|
||||
} USB_Descriptor_Configuration_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
USB_Descriptor_Header_t Header;
|
||||
|
||||
int Signature[7];
|
||||
uint16_t VendorCode;
|
||||
} USB_OSDescriptor_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t FirstInterfaceNumber;
|
||||
|
||||
uint8_t Reserved;
|
||||
|
||||
uint8_t CompatibleID[8];
|
||||
uint8_t SubCompatibleID[8];
|
||||
|
||||
uint8_t Reserved2[6];
|
||||
} USB_OSCompatibleSection_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t TotalLength;
|
||||
uint16_t Version;
|
||||
uint16_t Index;
|
||||
uint8_t TotalSections;
|
||||
|
||||
uint8_t Reserved[7];
|
||||
|
||||
USB_OSCompatibleSection_t SideshowCompatID;
|
||||
} USB_OSCompatibleIDDescriptor_t;
|
||||
|
||||
/* Function Prototypes: */
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
const uint8_t wIndex,
|
||||
const void** const DescriptorAddress)
|
||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||
|
||||
uint16_t USB_GetOSFeatureDescriptor(const uint16_t wValue,
|
||||
const uint8_t wIndex,
|
||||
const void** const DescriptorAddress)
|
||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||
|
||||
#endif
|
||||
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2012.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#include "SideshowApplications.h"
|
||||
|
||||
SideShow_Application_t InstalledApplications[MAX_APPLICATIONS];
|
||||
|
||||
|
||||
SideShow_Application_t* SideShow_GetFreeApplication(void)
|
||||
{
|
||||
for (uint8_t App = 0; App < ARRAY_ELEMENTS(InstalledApplications); App++)
|
||||
{
|
||||
if (!(InstalledApplications[App].InUse))
|
||||
return &InstalledApplications[App];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SideShow_Application_t* SideShow_GetApplicationFromGUID(GUID_t* const GUID)
|
||||
{
|
||||
for (uint8_t App = 0; App < ARRAY_ELEMENTS(InstalledApplications); App++)
|
||||
{
|
||||
if (InstalledApplications[App].InUse)
|
||||
{
|
||||
if (GUID_COMPARE(&InstalledApplications[App].ApplicationID, GUID))
|
||||
return &InstalledApplications[App];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2012.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#ifndef _SIDESHOW_APPLICATIONS_H_
|
||||
#define _SIDESHOW_APPLICATIONS_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "SideshowCommon.h"
|
||||
|
||||
/* Type Defines: */
|
||||
typedef struct
|
||||
{
|
||||
bool InUse;
|
||||
GUID_t ApplicationID;
|
||||
GUID_t EndpointID;
|
||||
UNICODE_STRING_t(50) ApplicationName;
|
||||
uint32_t CachePolicy;
|
||||
uint32_t OnlineOnly;
|
||||
bool HaveContent;
|
||||
uint32_t CurrentContentID;
|
||||
uint8_t CurrentContent[MAX_CONTENTBUFFER_PER_APP];
|
||||
} SideShow_Application_t;
|
||||
|
||||
/* External Variables: */
|
||||
extern SideShow_Application_t InstalledApplications[MAX_APPLICATIONS];
|
||||
|
||||
/* Function Prototypes: */
|
||||
SideShow_Application_t* SideShow_GetFreeApplication(void);
|
||||
SideShow_Application_t* SideShow_GetApplicationFromGUID(GUID_t* const GUID);
|
||||
|
||||
#endif
|
||||
|
@ -1,495 +0,0 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2012.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define INCLUDE_FROM_SIDESHOWCOMMANDS_H
|
||||
#include "SideshowCommands.h"
|
||||
|
||||
UNICODE_STRING_t(80) UserSID = {LengthInBytes: sizeof(SECURITY_INTERACTIVE_RID_SID),
|
||||
UnicodeString: SECURITY_INTERACTIVE_RID_SID};
|
||||
|
||||
Unicode_String_t DeviceName = {LengthInBytes: sizeof(L"LUFA Sideshow Device"),
|
||||
UnicodeString: L"LUFA Sideshow Device"};
|
||||
|
||||
Unicode_String_t Manufacturer = {LengthInBytes: sizeof(L"Dean Camera"),
|
||||
UnicodeString: L"Dean Camera"};
|
||||
|
||||
Unicode_String_t SupportedLanguage = {LengthInBytes: sizeof(L"en-US:1"),
|
||||
UnicodeString: L"en-US:1"};
|
||||
|
||||
void Sideshow_ProcessCommandPacket(void)
|
||||
{
|
||||
SideShow_PacketHeader_t PacketHeader;
|
||||
|
||||
Endpoint_SelectEndpoint(SIDESHOW_OUT_EPADDR);
|
||||
Endpoint_Read_Stream_LE(&PacketHeader, sizeof(SideShow_PacketHeader_t), NULL);
|
||||
|
||||
PacketHeader.Type.TypeFields.Response = true;
|
||||
|
||||
printf("\r\nCmd: %lX", (PacketHeader.Type.TypeLong & 0x00FFFFFF));
|
||||
|
||||
switch (PacketHeader.Type.TypeLong & 0x00FFFFFF)
|
||||
{
|
||||
case SIDESHOW_CMD_PING:
|
||||
SideShow_Ping(&PacketHeader);
|
||||
break;
|
||||
case SIDESHOW_CMD_SYNC:
|
||||
SideShow_Sync(&PacketHeader);
|
||||
break;
|
||||
case SIDESHOW_CMD_GET_CURRENT_USER:
|
||||
SideShow_GetCurrentUser(&PacketHeader);
|
||||
break;
|
||||
case SIDESHOW_CMD_SET_CURRENT_USER:
|
||||
SideShow_SetCurrentUser(&PacketHeader);
|
||||
break;
|
||||
case SIDESHOW_CMD_GET_CAPABILITIES:
|
||||
SideShow_GetCapabilities(&PacketHeader);
|
||||
break;
|
||||
case SIDESHOW_CMD_GET_DEVICE_NAME:
|
||||
SideShow_GetString(&PacketHeader, &DeviceName);
|
||||
break;
|
||||
case SIDESHOW_CMD_GET_MANUFACTURER:
|
||||
SideShow_GetString(&PacketHeader, &Manufacturer);
|
||||
break;
|
||||
case SIDESHOW_CMD_GET_APPLICATION_ORDER:
|
||||
SideShow_GetApplicationOrder(&PacketHeader);
|
||||
break;
|
||||
case SIDESHOW_CMD_GET_SUPPORTED_ENDPOINTS:
|
||||
SideShow_GetSupportedEndpoints(&PacketHeader);
|
||||
break;
|
||||
case SIDESHOW_CMD_ADD_APPLICATION:
|
||||
SideShow_AddApplication(&PacketHeader);
|
||||
break;
|
||||
case SIDESHOW_CMD_ADD_CONTENT:
|
||||
SideShow_AddContent(&PacketHeader);
|
||||
break;
|
||||
case SIDESHOW_CMD_DELETE_CONTENT:
|
||||
SideShow_DeleteContent(&PacketHeader);
|
||||
break;
|
||||
case SIDESHOW_CMD_DELETE_ALL_CONTENT:
|
||||
SideShow_DeleteAllContent(&PacketHeader);
|
||||
break;
|
||||
case SIDESHOW_CMD_DELETE_APPLICATION:
|
||||
SideShow_DeleteApplication(&PacketHeader);
|
||||
break;
|
||||
case SIDESHOW_CMD_DELETE_ALL_APPLICATIONS:
|
||||
SideShow_DeleteAllApplications(&PacketHeader);
|
||||
break;
|
||||
default:
|
||||
PacketHeader.Length -= sizeof(SideShow_PacketHeader_t);
|
||||
|
||||
Endpoint_Discard_Stream(PacketHeader.Length, NULL);
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
PacketHeader.Length = sizeof(SideShow_PacketHeader_t);
|
||||
PacketHeader.Type.TypeFields.NAK = true;
|
||||
|
||||
Endpoint_SelectEndpoint(SIDESHOW_IN_EPADDR);
|
||||
Endpoint_Write_Stream_LE(&PacketHeader, sizeof(SideShow_PacketHeader_t), NULL);
|
||||
Endpoint_ClearIN();
|
||||
|
||||
printf(" UNK");
|
||||
}
|
||||
}
|
||||
|
||||
static void SideShow_Ping(SideShow_PacketHeader_t* const PacketHeader)
|
||||
{
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
Endpoint_SelectEndpoint(SIDESHOW_IN_EPADDR);
|
||||
Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t), NULL);
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
static void SideShow_Sync(SideShow_PacketHeader_t* const PacketHeader)
|
||||
{
|
||||
GUID_t ProtocolGUID;
|
||||
|
||||
Endpoint_Read_Stream_LE(&ProtocolGUID, sizeof(GUID_t), NULL);
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
if (!(GUID_COMPARE(&ProtocolGUID, (uint32_t[])STANDARD_PROTOCOL_GUID)))
|
||||
PacketHeader->Type.TypeFields.NAK = true;
|
||||
|
||||
Endpoint_SelectEndpoint(SIDESHOW_IN_EPADDR);
|
||||
Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t), NULL);
|
||||
Endpoint_Write_Stream_LE(&ProtocolGUID, sizeof(GUID_t), NULL);
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
static void SideShow_GetCurrentUser(SideShow_PacketHeader_t* const PacketHeader)
|
||||
{
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
PacketHeader->Length = sizeof(SideShow_PacketHeader_t) + sizeof(uint32_t) + UserSID.LengthInBytes;
|
||||
|
||||
Endpoint_SelectEndpoint(SIDESHOW_IN_EPADDR);
|
||||
Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t), NULL);
|
||||
SideShow_Write_Unicode_String(&UserSID);
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
static void SideShow_SetCurrentUser(SideShow_PacketHeader_t* const PacketHeader)
|
||||
{
|
||||
SideShow_Read_Unicode_String(&UserSID, sizeof(UserSID.UnicodeString));
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
PacketHeader->Length = sizeof(SideShow_PacketHeader_t);
|
||||
|
||||
Endpoint_SelectEndpoint(SIDESHOW_IN_EPADDR);
|
||||
Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t), NULL);
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
static void SideShow_GetCapabilities(SideShow_PacketHeader_t* const PacketHeader)
|
||||
{
|
||||
SideShow_PropertyKey_t Property;
|
||||
SideShow_PropertyData_t PropertyData;
|
||||
|
||||
Endpoint_Read_Stream_LE(&Property, sizeof(SideShow_PropertyKey_t), NULL);
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
printf(" ID: %lu", Property.PropertyID);
|
||||
|
||||
PacketHeader->Length = sizeof(SideShow_PacketHeader_t);
|
||||
|
||||
if (GUID_COMPARE(&Property.PropertyGUID, (uint32_t[])SIDESHOW_PROPERTY_GUID))
|
||||
{
|
||||
switch (Property.PropertyID)
|
||||
{
|
||||
case PROPERTY_SIDESHOW_SCREENTYPE:
|
||||
PropertyData.DataType = VT_I4;
|
||||
PropertyData.Data.Data32 = ScreenText;
|
||||
PacketHeader->Length += sizeof(uint32_t);
|
||||
|
||||
break;
|
||||
case PROPERTY_SIDESHOW_SCREENWIDTH:
|
||||
case PROPERTY_SIDESHOW_CLIENTWIDTH:
|
||||
PropertyData.DataType = VT_UI2;
|
||||
PropertyData.Data.Data16 = 16;
|
||||
PacketHeader->Length += sizeof(uint16_t);
|
||||
|
||||
break;
|
||||
case PROPERTY_SIDESHOW_SCREENHEIGHT:
|
||||
case PROPERTY_SIDESHOW_CLIENTHEIGHT:
|
||||
PropertyData.DataType = VT_UI2;
|
||||
PropertyData.Data.Data16 = 2;
|
||||
PacketHeader->Length += sizeof(uint16_t);
|
||||
|
||||
break;
|
||||
case PROPERTY_SIDESHOW_COLORDEPTH:
|
||||
PropertyData.DataType = VT_UI2;
|
||||
PropertyData.Data.Data16 = 1;
|
||||
PacketHeader->Length += sizeof(uint16_t);
|
||||
|
||||
break;
|
||||
case PROPERTY_SIDESHOW_COLORTYPE:
|
||||
PropertyData.DataType = VT_UI2;
|
||||
PropertyData.Data.Data16 = BlackAndWhiteDisplay;
|
||||
PacketHeader->Length += sizeof(uint16_t);
|
||||
|
||||
break;
|
||||
case PROPERTY_SIDESHOW_DATACACHE:
|
||||
PropertyData.DataType = VT_BOOL;
|
||||
PropertyData.Data.Data16 = false;
|
||||
PacketHeader->Length += sizeof(uint16_t);
|
||||
|
||||
break;
|
||||
case PROPERTY_SIDESHOW_SUPPORTEDLANGS:
|
||||
case PROPERTY_SIDESHOW_CURRENTLANG:
|
||||
PropertyData.DataType = VT_LPWSTR;
|
||||
PropertyData.Data.DataPointer = &SupportedLanguage;
|
||||
PacketHeader->Length += SupportedLanguage.LengthInBytes;
|
||||
|
||||
break;
|
||||
default:
|
||||
PropertyData.DataType = VT_EMPTY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (GUID_COMPARE(&Property.PropertyGUID, (uint32_t[])DEVICE_PROPERTY_GUID))
|
||||
{
|
||||
switch (Property.PropertyID)
|
||||
{
|
||||
case PROPERTY_DEVICE_DEVICETYPE:
|
||||
PropertyData.DataType = VT_UI4;
|
||||
PropertyData.Data.Data32 = GenericDevice;
|
||||
PacketHeader->Length += sizeof(uint32_t);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PacketHeader->Type.TypeFields.NAK = true;
|
||||
|
||||
printf(" WRONG GUID");
|
||||
printf(" %lX %lX %lX %lX", Property.PropertyGUID.Chunks[0], Property.PropertyGUID.Chunks[1],
|
||||
Property.PropertyGUID.Chunks[2], Property.PropertyGUID.Chunks[3]);
|
||||
}
|
||||
|
||||
Endpoint_SelectEndpoint(SIDESHOW_IN_EPADDR);
|
||||
Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t), NULL);
|
||||
|
||||
if (!(PacketHeader->Type.TypeFields.NAK))
|
||||
{
|
||||
switch (PropertyData.DataType)
|
||||
{
|
||||
case VT_UI4:
|
||||
case VT_I4:
|
||||
Endpoint_Write_Stream_LE(&PropertyData.Data.Data32, sizeof(uint32_t), NULL);
|
||||
break;
|
||||
case VT_UI2:
|
||||
case VT_I2:
|
||||
case VT_BOOL:
|
||||
Endpoint_Write_Stream_LE(&PropertyData.Data.Data16, sizeof(uint16_t), NULL);
|
||||
break;
|
||||
case VT_LPWSTR:
|
||||
SideShow_Write_Unicode_String((Unicode_String_t*)PropertyData.Data.Data16);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Endpoint_ClearIN();
|
||||
return;
|
||||
}
|
||||
|
||||
static void SideShow_GetString(SideShow_PacketHeader_t* const PacketHeader,
|
||||
void* const UnicodeStruct)
|
||||
{
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
PacketHeader->Length = sizeof(SideShow_PacketHeader_t) +
|
||||
sizeof(uint32_t) + ((Unicode_String_t*)UnicodeStruct)->LengthInBytes;
|
||||
|
||||
Endpoint_SelectEndpoint(SIDESHOW_IN_EPADDR);
|
||||
Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t), NULL);
|
||||
SideShow_Write_Unicode_String(UnicodeStruct);
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
static void SideShow_GetApplicationOrder(SideShow_PacketHeader_t* const PacketHeader)
|
||||
{
|
||||
uint8_t TotalApplications = 0;
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
for (uint8_t App = 0; App < MAX_APPLICATIONS; App++)
|
||||
{
|
||||
if (InstalledApplications[App].InUse)
|
||||
TotalApplications++;
|
||||
}
|
||||
|
||||
PacketHeader->Length = sizeof(SideShow_PacketHeader_t) +
|
||||
sizeof(uint32_t) + (TotalApplications * sizeof(GUID_t));
|
||||
|
||||
Endpoint_SelectEndpoint(SIDESHOW_IN_EPADDR);
|
||||
Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t), NULL);
|
||||
Endpoint_Write_32_LE(TotalApplications);
|
||||
|
||||
for (uint8_t App = 0; App < MAX_APPLICATIONS; App++)
|
||||
{
|
||||
if (InstalledApplications[App].InUse)
|
||||
Endpoint_Write_Stream_LE(&InstalledApplications[App].ApplicationID, sizeof(GUID_t), NULL);
|
||||
}
|
||||
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
static void SideShow_GetSupportedEndpoints(SideShow_PacketHeader_t* const PacketHeader)
|
||||
{
|
||||
GUID_t SupportedEndpointGUID = (GUID_t){Chunks: SIMPLE_CONTENT_FORMAT_GUID};
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
PacketHeader->Length = sizeof(SideShow_PacketHeader_t) + sizeof(uint32_t) + sizeof(GUID_t);
|
||||
|
||||
Endpoint_SelectEndpoint(SIDESHOW_IN_EPADDR);
|
||||
Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t), NULL);
|
||||
Endpoint_Write_32_LE(1);
|
||||
Endpoint_Write_Stream_LE(&SupportedEndpointGUID, sizeof(GUID_t), NULL);
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
static void SideShow_AddApplication(SideShow_PacketHeader_t* const PacketHeader)
|
||||
{
|
||||
SideShow_Application_t* CurrApp;
|
||||
GUID_t ApplicationID;
|
||||
|
||||
Endpoint_Read_Stream_LE(&ApplicationID, sizeof(GUID_t), NULL);
|
||||
|
||||
CurrApp = SideShow_GetApplicationFromGUID(&ApplicationID);
|
||||
|
||||
if (CurrApp == NULL)
|
||||
CurrApp = SideShow_GetFreeApplication();
|
||||
|
||||
if (CurrApp == NULL)
|
||||
{
|
||||
PacketHeader->Length -= sizeof(SideShow_PacketHeader_t) + sizeof(GUID_t);
|
||||
|
||||
Endpoint_Discard_Stream(PacketHeader->Length, NULL);
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
PacketHeader->Type.TypeFields.NAK = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrApp->ApplicationID = ApplicationID;
|
||||
Endpoint_Read_Stream_LE(&CurrApp->EndpointID, sizeof(GUID_t), NULL);
|
||||
SideShow_Read_Unicode_String(&CurrApp->ApplicationName, sizeof(CurrApp->ApplicationName.UnicodeString));
|
||||
Endpoint_Read_Stream_LE(&CurrApp->CachePolicy, sizeof(uint32_t), NULL);
|
||||
Endpoint_Read_Stream_LE(&CurrApp->OnlineOnly, sizeof(uint32_t), NULL);
|
||||
SideShow_Discard_Byte_Stream();
|
||||
SideShow_Discard_Byte_Stream();
|
||||
SideShow_Discard_Byte_Stream();
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
CurrApp->InUse = true;
|
||||
CurrApp->HaveContent = false;
|
||||
CurrApp->CurrentContentID = 1;
|
||||
}
|
||||
|
||||
PacketHeader->Length = sizeof(SideShow_PacketHeader_t);
|
||||
|
||||
Endpoint_SelectEndpoint(SIDESHOW_IN_EPADDR);
|
||||
Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t), NULL);
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
static void SideShow_DeleteApplication(SideShow_PacketHeader_t* const PacketHeader)
|
||||
{
|
||||
GUID_t ApplicationGUID;
|
||||
|
||||
Endpoint_Read_Stream_LE(&ApplicationGUID, sizeof(GUID_t), NULL);
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
SideShow_Application_t* AppToDelete = SideShow_GetApplicationFromGUID(&ApplicationGUID);
|
||||
|
||||
if (AppToDelete != NULL)
|
||||
AppToDelete->InUse = false;
|
||||
else
|
||||
PacketHeader->Type.TypeFields.NAK = true;
|
||||
|
||||
PacketHeader->Length = sizeof(SideShow_PacketHeader_t);
|
||||
|
||||
Endpoint_SelectEndpoint(SIDESHOW_IN_EPADDR);
|
||||
Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t), NULL);
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
static void SideShow_DeleteAllApplications(SideShow_PacketHeader_t* const PacketHeader)
|
||||
{
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
for (uint8_t App = 0; App < MAX_APPLICATIONS; App++)
|
||||
InstalledApplications[App].InUse = false;
|
||||
|
||||
Endpoint_SelectEndpoint(SIDESHOW_IN_EPADDR);
|
||||
Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t), NULL);
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
static void SideShow_AddContent(SideShow_PacketHeader_t* const PacketHeader)
|
||||
{
|
||||
GUID_t ApplicationID;
|
||||
GUID_t EndpointID;
|
||||
SideShow_Application_t* Application;
|
||||
|
||||
Endpoint_Read_Stream_LE(&ApplicationID, sizeof(GUID_t), NULL);
|
||||
Endpoint_Read_Stream_LE(&EndpointID, sizeof(GUID_t), NULL);
|
||||
|
||||
Application = SideShow_GetApplicationFromGUID(&ApplicationID);
|
||||
|
||||
if (Application == NULL)
|
||||
{
|
||||
SideShow_Discard_Byte_Stream();
|
||||
PacketHeader->Type.TypeFields.NAK = true;
|
||||
}
|
||||
else if (!(SideShow_AddSimpleContent(PacketHeader, Application)))
|
||||
{
|
||||
PacketHeader->Type.TypeFields.NAK = true;
|
||||
}
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
PacketHeader->Length = sizeof(SideShow_PacketHeader_t);
|
||||
|
||||
Endpoint_SelectEndpoint(SIDESHOW_IN_EPADDR);
|
||||
Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t), NULL);
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
static void SideShow_DeleteContent(SideShow_PacketHeader_t* const PacketHeader)
|
||||
{
|
||||
GUID_t ApplicationID;
|
||||
GUID_t EndpointID;
|
||||
uint32_t ContentID;
|
||||
|
||||
Endpoint_Read_Stream_LE(&ApplicationID, sizeof(GUID_t), NULL);
|
||||
Endpoint_Read_Stream_LE(&EndpointID, sizeof(GUID_t), NULL);
|
||||
Endpoint_Read_Stream_LE(&ContentID, sizeof(uint32_t), NULL);
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
SideShow_Application_t* Application = SideShow_GetApplicationFromGUID(&ApplicationID);
|
||||
|
||||
if ((Application != NULL) && (Application->CurrentContentID == ContentID))
|
||||
Application->HaveContent = false;
|
||||
else
|
||||
PacketHeader->Type.TypeFields.NAK = true;
|
||||
|
||||
PacketHeader->Length = sizeof(SideShow_PacketHeader_t);
|
||||
|
||||
Endpoint_SelectEndpoint(SIDESHOW_IN_EPADDR);
|
||||
Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t), NULL);
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
static void SideShow_DeleteAllContent(SideShow_PacketHeader_t* const PacketHeader)
|
||||
{
|
||||
GUID_t ApplicationID;
|
||||
GUID_t EndpointID;
|
||||
|
||||
Endpoint_Read_Stream_LE(&ApplicationID, sizeof(GUID_t), NULL);
|
||||
Endpoint_Read_Stream_LE(&EndpointID, sizeof(GUID_t), NULL);
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
SideShow_Application_t* Application = SideShow_GetApplicationFromGUID(&ApplicationID);
|
||||
|
||||
if (Application != NULL)
|
||||
Application->HaveContent = false;
|
||||
else
|
||||
PacketHeader->Type.TypeFields.NAK = true;
|
||||
|
||||
PacketHeader->Length = sizeof(SideShow_PacketHeader_t);
|
||||
|
||||
Endpoint_SelectEndpoint(SIDESHOW_IN_EPADDR);
|
||||
Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t), NULL);
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
@ -1,167 +0,0 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2012.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#ifndef _SIDESHOW_COMMANDS_H_
|
||||
#define _SIDESHOW_COMMANDS_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../Sideshow.h"
|
||||
#include "SideshowCommon.h"
|
||||
#include "SideshowApplications.h"
|
||||
#include "SideshowContent.h"
|
||||
|
||||
/* Enumerations: */
|
||||
enum SideShow_PropertyKey_Types_t
|
||||
{
|
||||
VT_EMPTY = 0,
|
||||
VT_NULL = 1,
|
||||
VT_I2 = 2,
|
||||
VT_I4 = 3,
|
||||
VT_R4 = 4,
|
||||
VT_R8 = 5,
|
||||
VT_CY = 6,
|
||||
VT_DATE = 7,
|
||||
VT_BSTR = 8,
|
||||
VT_DISPATCH = 9,
|
||||
VT_ERROR = 10,
|
||||
VT_BOOL = 11,
|
||||
VT_VARIANT = 12,
|
||||
VT_UNKNOWN = 13,
|
||||
VT_UI1 = 17,
|
||||
VT_UI2 = 18,
|
||||
VT_UI4 = 19,
|
||||
VT_LPWSTR = 31,
|
||||
};
|
||||
|
||||
enum SideShow_ScreenTypeText_t
|
||||
{
|
||||
ScreenBitmap = 0,
|
||||
ScreenText = 1,
|
||||
};
|
||||
|
||||
enum SideShow_ColorTypes_t
|
||||
{
|
||||
ColorDisplay = 0,
|
||||
GrayscaleDisplay = 1,
|
||||
BlackAndWhiteDisplay = 2,
|
||||
};
|
||||
|
||||
enum SideShow_DeviceTypes_t
|
||||
{
|
||||
GenericDevice = 0,
|
||||
CameraDevice = 1,
|
||||
MediaPlayerDevice = 2,
|
||||
PhoneDevice = 3,
|
||||
VideoDevice = 4,
|
||||
PIMDevice = 5,
|
||||
AudioRecorderDevice = 6
|
||||
};
|
||||
|
||||
/* Type Defines: */
|
||||
typedef struct
|
||||
{
|
||||
GUID_t PropertyGUID;
|
||||
uint32_t PropertyID;
|
||||
} SideShow_PropertyKey_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t DataType;
|
||||
|
||||
union
|
||||
{
|
||||
void* DataPointer;
|
||||
uint8_t Data8;
|
||||
uint16_t Data16;
|
||||
uint32_t Data32;
|
||||
} Data;
|
||||
} SideShow_PropertyData_t;
|
||||
|
||||
/* Macros: */
|
||||
#define SIDESHOW_CMD_PING 0x001
|
||||
#define SIDESHOW_CMD_SET_CURRENT_USER 0x100
|
||||
#define SIDESHOW_CMD_GET_CURRENT_USER 0x101
|
||||
#define SIDESHOW_CMD_GET_CAPABILITIES 0x103
|
||||
#define SIDESHOW_CMD_GET_APPLICATION_ORDER 0x104
|
||||
#define SIDESHOW_CMD_ADD_APPLICATION 0x10D
|
||||
#define SIDESHOW_CMD_DELETE_APPLICATION 0x10E
|
||||
#define SIDESHOW_CMD_DELETE_ALL_APPLICATIONS 0x10F
|
||||
#define SIDESHOW_CMD_ADD_CONTENT 0x114
|
||||
#define SIDESHOW_CMD_DELETE_CONTENT 0x115
|
||||
#define SIDESHOW_CMD_DELETE_ALL_CONTENT 0x116
|
||||
#define SIDESHOW_CMD_GET_SUPPORTED_ENDPOINTS 0x117
|
||||
#define SIDESHOW_CMD_GET_DEVICE_NAME 0x500
|
||||
#define SIDESHOW_CMD_GET_MANUFACTURER 0x501
|
||||
#define SIDESHOW_CMD_SYNC 0x502
|
||||
|
||||
#define PROPERTY_SIDESHOW_DEVICEID 1
|
||||
#define PROPERTY_SIDESHOW_SCREENTYPE 2
|
||||
#define PROPERTY_SIDESHOW_SCREENWIDTH 3
|
||||
#define PROPERTY_SIDESHOW_SCREENHEIGHT 4
|
||||
#define PROPERTY_SIDESHOW_COLORDEPTH 5
|
||||
#define PROPERTY_SIDESHOW_COLORTYPE 6
|
||||
#define PROPERTY_SIDESHOW_DATACACHE 7
|
||||
#define PROPERTY_SIDESHOW_SUPPORTEDLANGS 8
|
||||
#define PROPERTY_SIDESHOW_CURRENTLANG 9
|
||||
#define PROPERTY_SIDESHOW_SUPPORTEDTHEMES 10
|
||||
#define PROPERTY_SIDESHOW_IMAGEFORMAT 14
|
||||
#define PROPERTY_SIDESHOW_CLIENTWIDTH 15
|
||||
#define PROPERTY_SIDESHOW_CLIENTHEIGHT 16
|
||||
#define PROPERTY_SIDESHOW_DEVICEICON 17
|
||||
|
||||
#define PROPERTY_DEVICE_DEVICETYPE 15
|
||||
|
||||
/* Function Prototypes: */
|
||||
void Sideshow_ProcessCommandPacket(void);
|
||||
|
||||
#if defined(INCLUDE_FROM_SIDESHOWCOMMANDS_H)
|
||||
static void SideShow_Ping(SideShow_PacketHeader_t* const PacketHeader);
|
||||
static void SideShow_Sync(SideShow_PacketHeader_t* const PacketHeader);
|
||||
static void SideShow_GetCurrentUser(SideShow_PacketHeader_t* const PacketHeader);
|
||||
static void SideShow_SetCurrentUser(SideShow_PacketHeader_t* const PacketHeader);
|
||||
static void SideShow_GetCapabilities(SideShow_PacketHeader_t* const PacketHeader);
|
||||
static void SideShow_GetString(SideShow_PacketHeader_t* const PacketHeader,
|
||||
void* const UnicodeStruct);
|
||||
static void SideShow_GetApplicationOrder(SideShow_PacketHeader_t* const PacketHeader);
|
||||
static void SideShow_GetSupportedEndpoints(SideShow_PacketHeader_t* const PacketHeader);
|
||||
static void SideShow_AddApplication(SideShow_PacketHeader_t* const PacketHeader);
|
||||
static void SideShow_DeleteApplication(SideShow_PacketHeader_t* const PacketHeader);
|
||||
static void SideShow_DeleteAllApplications(SideShow_PacketHeader_t* const PacketHeader);
|
||||
static void SideShow_AddContent(SideShow_PacketHeader_t* const PacketHeader);
|
||||
static void SideShow_DeleteContent(SideShow_PacketHeader_t* const PacketHeader);
|
||||
static void SideShow_DeleteAllContent(SideShow_PacketHeader_t* const PacketHeader);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -1,72 +0,0 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2012.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#include "SideshowCommon.h"
|
||||
|
||||
uint16_t SideShow_Read_Unicode_String(void* const UnicodeString,
|
||||
const uint16_t MaxBytes)
|
||||
{
|
||||
Unicode_String_t* const UnicodeStruct = (Unicode_String_t*)UnicodeString;
|
||||
uint32_t UnicodeCharsToRead;
|
||||
|
||||
Endpoint_Read_Stream_LE(&UnicodeCharsToRead, sizeof(uint32_t), NULL);
|
||||
|
||||
int UnicodeData[UnicodeCharsToRead];
|
||||
|
||||
UnicodeStruct->LengthInBytes = (UnicodeCharsToRead << 1);
|
||||
|
||||
Endpoint_Read_Stream_LE(&UnicodeData, UnicodeStruct->LengthInBytes, NULL);
|
||||
|
||||
if (UnicodeStruct->LengthInBytes > MaxBytes)
|
||||
UnicodeStruct->LengthInBytes = MaxBytes;
|
||||
|
||||
memcpy(&UnicodeStruct->UnicodeString, &UnicodeData, UnicodeStruct->LengthInBytes);
|
||||
|
||||
return ((UnicodeCharsToRead << 1) + sizeof(uint32_t));
|
||||
}
|
||||
|
||||
void SideShow_Write_Unicode_String(void* const UnicodeString)
|
||||
{
|
||||
Unicode_String_t* const UnicodeStruct = (Unicode_String_t*)UnicodeString;
|
||||
|
||||
uint32_t StringSizeInCharacters = (UnicodeStruct->LengthInBytes >> 1);
|
||||
|
||||
Endpoint_Write_Stream_LE(&StringSizeInCharacters, sizeof(uint32_t), NULL);
|
||||
Endpoint_Write_Stream_LE(&UnicodeStruct->UnicodeString, UnicodeStruct->LengthInBytes, NULL);
|
||||
}
|
||||
|
||||
void SideShow_Discard_Byte_Stream(void)
|
||||
{
|
||||
uint32_t StreamSize;
|
||||
|
||||
Endpoint_Read_Stream_LE(&StreamSize, sizeof(uint32_t), NULL);
|
||||
Endpoint_Discard_Stream(StreamSize, NULL);
|
||||
}
|
||||
|
@ -1,105 +0,0 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2012.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#ifndef _SIDESHOW_COMMON_H_
|
||||
#define _SIDESHOW_COMMON_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
/* Macros: */
|
||||
#define GUID_COMPARE(a, b) (memcmp(a, b, sizeof(GUID_t)) == 0)
|
||||
|
||||
#define ARRAY_ELEMENTS(x) (sizeof(x) / sizeof(x[0]))
|
||||
|
||||
#define UNICODE_STRING_t(x) struct \
|
||||
{ \
|
||||
uint16_t LengthInBytes; \
|
||||
int UnicodeString[x]; \
|
||||
}
|
||||
|
||||
// {A33F248B-882F-4531-82C2-ED3B90C5C520}
|
||||
#define STANDARD_PROTOCOL_GUID {0xA33F248B, 0x4531882F, 0x3BEDC282, 0x20C5C590}
|
||||
// {A9A5353F-2D4B-47CE-93EE-759F3A7DDA4F}
|
||||
#define SIMPLE_CONTENT_FORMAT_GUID {0xA9A5353F, 0x47CE2D4B, 0x9F75EE93, 0x4FDA7D3A}
|
||||
// {8ABC88A8-857B-4ad7-A35A-B5942F492B99}
|
||||
#define SIDESHOW_PROPERTY_GUID {0x8ABC88A8, 0x4AD7857B, 0x94B55AA3, 0x992B492F}
|
||||
// {26D4979A-E643-4626-9E2B-736DC0C92FDC}
|
||||
#define DEVICE_PROPERTY_GUID {0x26D4979A, 0x4626E643, 0x6D732B9E, 0xDC2FC9C0}
|
||||
|
||||
#define SECURITY_INTERACTIVE_RID_SID L"S-1-5-4"
|
||||
|
||||
#define MAX_APPLICATIONS 4
|
||||
#define MAX_CONTENTBUFFER_PER_APP 1024
|
||||
|
||||
/* Type Defines: */
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Chunks[4];
|
||||
} GUID_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t LengthInBytes;
|
||||
int UnicodeString[];
|
||||
} Unicode_String_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint32_t TypeLong;
|
||||
|
||||
struct
|
||||
{
|
||||
uint8_t TypeBytes[3];
|
||||
|
||||
unsigned ErrorCode : 6;
|
||||
unsigned NAK : 1;
|
||||
unsigned Response : 1;
|
||||
} TypeFields;
|
||||
} SideShowPacketType_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t Length;
|
||||
SideShowPacketType_t Type;
|
||||
uint16_t Number;
|
||||
} SideShow_PacketHeader_t;
|
||||
|
||||
/* Function Prototypes: */
|
||||
uint16_t SideShow_Read_Unicode_String(void* UnicodeString,
|
||||
const uint16_t MaxBytes);
|
||||
void SideShow_Write_Unicode_String(void* UnicodeString);
|
||||
void SideShow_Discard_Byte_Stream(void);
|
||||
|
||||
#endif
|
||||
|
@ -1,79 +0,0 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2012.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#define INCLUDE_FROM_SIDESHOWCONTENT_C
|
||||
#include "SideshowContent.h"
|
||||
|
||||
bool SideShow_AddSimpleContent(SideShow_PacketHeader_t* const PacketHeader,
|
||||
SideShow_Application_t* const Application)
|
||||
{
|
||||
uint32_t ContentSize;
|
||||
uint32_t ContentID;
|
||||
|
||||
Endpoint_Read_Stream_LE(&ContentID, sizeof(uint32_t), NULL);
|
||||
|
||||
PacketHeader->Length -= sizeof(uint32_t);
|
||||
|
||||
if (Application->CurrentContentID != ContentID)
|
||||
{
|
||||
Endpoint_Discard_Stream(PacketHeader->Length, NULL);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Endpoint_Read_Stream_LE(&ContentSize, sizeof(uint32_t), NULL);
|
||||
Endpoint_Read_Stream_LE(&Application->CurrentContent, (sizeof(XML_START_TAG) - 1), NULL);
|
||||
|
||||
PacketHeader->Length -= sizeof(uint32_t) + (sizeof(XML_START_TAG) - 1);
|
||||
|
||||
if (!(memcmp(&Application->CurrentContent, XML_START_TAG, (sizeof(XML_START_TAG) - 1))))
|
||||
{
|
||||
SideShow_ProcessXMLContent(&Application->CurrentContent, (ContentSize - (sizeof(XML_END_TAG) - 1)));
|
||||
|
||||
Endpoint_Discard_Stream((sizeof(XML_END_TAG) - 1), NULL);
|
||||
|
||||
Application->HaveContent = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf(" BINARY");
|
||||
Endpoint_Discard_Stream(ContentSize, NULL);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void SideShow_ProcessXMLContent(void* ContentData,
|
||||
uint32_t ContentSize)
|
||||
{
|
||||
printf(" XML");
|
||||
Endpoint_Discard_Stream(ContentSize, NULL);
|
||||
}
|
||||
|
@ -1,128 +0,0 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2012.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#ifndef _SIDESHOW_CONTENT_H_
|
||||
#define _SIDESHOW_CONTENT_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "SideshowCommon.h"
|
||||
#include "SideshowApplications.h"
|
||||
|
||||
/* Enums: */
|
||||
enum SideShow_ContentTypes_t
|
||||
{
|
||||
Content_Menu = 0,
|
||||
Content_Content = 1,
|
||||
Content_MenuItem = 2,
|
||||
Content_Button = 3,
|
||||
Content_Text = 4,
|
||||
Content_EndOfContent = 5
|
||||
};
|
||||
|
||||
enum SideShow_ActionTypes_t
|
||||
{
|
||||
TODO
|
||||
};
|
||||
|
||||
enum SideShow_AlignmentTypes_t
|
||||
{
|
||||
TODO2
|
||||
};
|
||||
|
||||
/* Type Defines: */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t ContentType;
|
||||
uint8_t ContentSize;
|
||||
} SideShow_Content_Header_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SideShow_Content_Header_t Header;
|
||||
|
||||
uint32_t ItemID;
|
||||
uint8_t ActionType;
|
||||
char Title[];
|
||||
} SideShow_Content_Menu_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SideShow_Content_Header_t Header;
|
||||
|
||||
uint32_t ItemID;
|
||||
uint32_t Target;
|
||||
bool IsSelected;
|
||||
char Text[];
|
||||
} SideShow_Content_MenuItem_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SideShow_Content_Header_t Header;
|
||||
|
||||
uint8_t Key;
|
||||
uint32_t Target;
|
||||
} SideShow_Content_Button_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SideShow_Content_Header_t Header;
|
||||
|
||||
uint32_t ItemID;
|
||||
uint32_t AssociatedMenuID;
|
||||
char Title[];
|
||||
} SideShow_Content_Content_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SideShow_Content_Header_t Header;
|
||||
|
||||
char Text[];
|
||||
} SideShow_Content_Text_t;
|
||||
|
||||
/* Defines: */
|
||||
#define XML_START_TAG "<body>"
|
||||
#define XML_END_TAG "</body>"
|
||||
|
||||
/* Function Prototypes: */
|
||||
bool SideShow_AddSimpleContent(SideShow_PacketHeader_t* const PacketHeader,
|
||||
SideShow_Application_t* const Application);
|
||||
|
||||
#if defined(INCLUDE_FROM_SIDESHOWCONTENT_C)
|
||||
static void SideShow_ProcessXMLContent(void* ContentData,
|
||||
uint32_t ContentSize);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -1,152 +0,0 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2012.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/*
|
||||
SideShow Class demonstration application. This give a reference
|
||||
for implementing Microsoft SideShow compatible devices in an
|
||||
embedded environment. SideShow allows for gadget data displayed
|
||||
on a Windows Vista or later machine to also be displayed on an
|
||||
externally connected interactive display. Upon enumeration, this will
|
||||
appear as a new SideShow device which can have gadgets loaded onto
|
||||
it.
|
||||
|
||||
Note that while the incoming content is buffered in packet struct
|
||||
form, the data is not actually displayed. It is left to the user to
|
||||
write sufficient code to read out the packed data for display to a
|
||||
screen.
|
||||
|
||||
Installed gadgets can be accessed through the InstalledApplications
|
||||
array, with entries that have their InUse flag set being active. As
|
||||
only the active content is displayed on the device due to memory
|
||||
constraints, new content can be requested as needed.
|
||||
*/
|
||||
|
||||
#include "Sideshow.h"
|
||||
|
||||
/** Main program entry point. This routine contains the overall program flow, including initial
|
||||
* setup of all components and the main program loop.
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
SetupHardware();
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
sei();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
SideShow_Task();
|
||||
USB_USBTask();
|
||||
}
|
||||
}
|
||||
|
||||
/** Configures the board hardware and chip peripherals for the demo's functionality. */
|
||||
void SetupHardware(void)
|
||||
{
|
||||
/* Disable watchdog if enabled by bootloader/fuses */
|
||||
MCUSR &= ~(1 << WDRF);
|
||||
wdt_disable();
|
||||
|
||||
/* Disable clock division */
|
||||
clock_prescale_set(clock_div_1);
|
||||
|
||||
/* Hardware Initialization */
|
||||
LEDs_Init();
|
||||
USB_Init();
|
||||
Serial_Init(9600, false);
|
||||
|
||||
/* Create a stdio stream for the serial port for stdin and stdout */
|
||||
Serial_CreateStream(NULL);
|
||||
}
|
||||
|
||||
void EVENT_USB_Device_Connect(void)
|
||||
{
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||
}
|
||||
|
||||
void EVENT_USB_Device_Disconnect(void)
|
||||
{
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
}
|
||||
|
||||
void EVENT_USB_Device_ConfigurationChanged(void)
|
||||
{
|
||||
bool ConfigSuccess = true;
|
||||
|
||||
/* Setup Sideshow Data Endpoints */
|
||||
ConfigSuccess &= Endpoint_ConfigureEndpoint(SIDESHOW_IN_EPADDR, EP_TYPE_BULK, SIDESHOW_IO_EPSIZE, 1);
|
||||
ConfigSuccess &= Endpoint_ConfigureEndpoint(SIDESHOW_OUT_EPADDR, EP_TYPE_BULK, SIDESHOW_IO_EPSIZE, 1);
|
||||
|
||||
/* Indicate endpoint configuration success or failure */
|
||||
LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR);
|
||||
}
|
||||
|
||||
void EVENT_USB_Device_ControlRequest(void)
|
||||
{
|
||||
switch (USB_ControlRequest.bRequest)
|
||||
{
|
||||
case REQ_GetOSFeatureDescriptor:
|
||||
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_VENDOR | REQREC_DEVICE))
|
||||
{
|
||||
const void* DescriptorPointer;
|
||||
uint16_t DescriptorSize = USB_GetOSFeatureDescriptor(USB_ControlRequest.wValue,
|
||||
USB_ControlRequest.wIndex,
|
||||
&DescriptorPointer);
|
||||
|
||||
if (DescriptorSize == NO_DESCRIPTOR)
|
||||
return;
|
||||
|
||||
Endpoint_ClearSETUP();
|
||||
|
||||
Endpoint_Write_Control_PStream_LE(DescriptorPointer, DescriptorSize);
|
||||
Endpoint_ClearOUT();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SideShow_Task(void)
|
||||
{
|
||||
/* Device must be connected and configured for the task to run */
|
||||
if (USB_DeviceState != DEVICE_STATE_Configured)
|
||||
return;
|
||||
|
||||
/* Select the SideShow data out endpoint */
|
||||
Endpoint_SelectEndpoint(SIDESHOW_OUT_EPADDR);
|
||||
|
||||
/* Check to see if a new SideShow message has been received */
|
||||
if (Endpoint_IsReadWriteAllowed())
|
||||
{
|
||||
/* Process the received SideShow message */
|
||||
Sideshow_ProcessCommandPacket();
|
||||
}
|
||||
}
|
||||
|
@ -1,78 +0,0 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2012.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
#ifndef _SIDESHOW_H_
|
||||
#define _SIDESHOW_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <avr/power.h>
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
#include "Descriptors.h"
|
||||
#include "Lib/SideshowCommands.h"
|
||||
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
#include <LUFA/Drivers/Peripheral/Serial.h>
|
||||
|
||||
/* Macros: */
|
||||
/** Device control request for used in the Microsoft OS Descriptor for retrieving the OS Feature
|
||||
* descriptors of the device.
|
||||
*/
|
||||
#define REQ_GetOSFeatureDescriptor 0x01
|
||||
|
||||
/** Descriptor index for a Microsoft Proprietary Extended Device Compatibility descriptor. */
|
||||
#define EXTENDED_COMPAT_ID_DESCRIPTOR 0x0004
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */
|
||||
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is ready. */
|
||||
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
|
||||
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
|
||||
|
||||
/* Function Prototypes: */
|
||||
void SetupHardware(void);
|
||||
void SideShow_Task(void);
|
||||
|
||||
void EVENT_USB_Device_Connect(void);
|
||||
void EVENT_USB_Device_Disconnect(void);
|
||||
void EVENT_USB_Device_ConfigurationChanged(void);
|
||||
void EVENT_USB_Device_ControlRequest(void);
|
||||
|
||||
#endif
|
||||
|
@ -1,39 +0,0 @@
|
||||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2012.
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.lufa-lib.org
|
||||
#
|
||||
# --------------------------------------
|
||||
# LUFA Project Makefile.
|
||||
# --------------------------------------
|
||||
|
||||
# Run "make help" for target help.
|
||||
|
||||
MCU = at90usb1287
|
||||
ARCH = AVR8
|
||||
BOARD = USBKEY
|
||||
F_CPU = 8000000
|
||||
F_USB = $(F_CPU)
|
||||
OPTIMIZATION = s
|
||||
TARGET = SideShow
|
||||
SRC = $(TARGET).c Descriptors.c Lib/SideshowApplications.c Lib/SideshowCommands.c \
|
||||
Lib/SideshowCommon.c Lib/SideshowContent.c $(LUFA_SRC_USB) $(LUFA_SRC_USBCLASS) $(LUFA_SRC_SERIAL)
|
||||
LUFA_PATH = ../../../../LUFA
|
||||
CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -IConfig/
|
||||
LD_FLAGS =
|
||||
|
||||
# Default target
|
||||
all:
|
||||
|
||||
# Include LUFA build script makefiles
|
||||
include $(LUFA_PATH)/Build/lufa_core.mk
|
||||
include $(LUFA_PATH)/Build/lufa_sources.mk
|
||||
include $(LUFA_PATH)/Build/lufa_build.mk
|
||||
include $(LUFA_PATH)/Build/lufa_cppcheck.mk
|
||||
include $(LUFA_PATH)/Build/lufa_doxygen.mk
|
||||
include $(LUFA_PATH)/Build/lufa_dfu.mk
|
||||
include $(LUFA_PATH)/Build/lufa_hid.mk
|
||||
include $(LUFA_PATH)/Build/lufa_avrdude.mk
|
||||
include $(LUFA_PATH)/Build/lufa_atprogram.mk
|
Loading…
Reference in new issue