From 071e02c6b6b4837fa9cf0b6d4c749994e02638d7 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Sat, 8 May 2010 03:12:14 +0000 Subject: Add svn:eol-style property to source files, so that the line endings are correctly converted to the target system's native end of line style. --- .../Incomplete/Sideshow/Lib/SideshowApplications.c | 118 +-- .../Incomplete/Sideshow/Lib/SideshowApplications.h | 124 +-- .../Incomplete/Sideshow/Lib/SideshowCommands.c | 986 ++++++++++----------- .../Incomplete/Sideshow/Lib/SideshowCommands.h | 330 +++---- .../Incomplete/Sideshow/Lib/SideshowCommon.c | 140 +-- .../Incomplete/Sideshow/Lib/SideshowCommon.h | 204 ++--- .../Incomplete/Sideshow/Lib/SideshowContent.c | 152 ++-- .../Incomplete/Sideshow/Lib/SideshowContent.h | 248 +++--- 8 files changed, 1151 insertions(+), 1151 deletions(-) (limited to 'Demos/Device/Incomplete/Sideshow/Lib') diff --git a/Demos/Device/Incomplete/Sideshow/Lib/SideshowApplications.c b/Demos/Device/Incomplete/Sideshow/Lib/SideshowApplications.c index e7b0ad8bd..a6c529e69 100644 --- a/Demos/Device/Incomplete/Sideshow/Lib/SideshowApplications.c +++ b/Demos/Device/Incomplete/Sideshow/Lib/SideshowApplications.c @@ -1,59 +1,59 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2010. - - dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com -*/ - -/* - Copyright 2010 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* 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; -} +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 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* 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; +} diff --git a/Demos/Device/Incomplete/Sideshow/Lib/SideshowApplications.h b/Demos/Device/Incomplete/Sideshow/Lib/SideshowApplications.h index de8983ed2..ed885d40d 100644 --- a/Demos/Device/Incomplete/Sideshow/Lib/SideshowApplications.h +++ b/Demos/Device/Incomplete/Sideshow/Lib/SideshowApplications.h @@ -1,62 +1,62 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2010. - - dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com -*/ - -/* - Copyright 2010 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 - #include - #include - - #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* GUID); - -#endif +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 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 + #include + #include + + #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* GUID); + +#endif diff --git a/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommands.c b/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommands.c index c0f7096b2..5bce088c8 100644 --- a/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommands.c +++ b/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommands.c @@ -1,493 +1,493 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2010. - - dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com -*/ - -/* - Copyright 2010 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_EPNUM); - Endpoint_Read_Stream_LE(&PacketHeader, sizeof(SideShow_PacketHeader_t)); - - PacketHeader.Type.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); - Endpoint_ClearOUT(); - - PacketHeader.Length = sizeof(SideShow_PacketHeader_t); - PacketHeader.Type.NAK = true; - - Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); - Endpoint_Write_Stream_LE(&PacketHeader, sizeof(SideShow_PacketHeader_t)); - Endpoint_ClearIN(); - - printf(" UNK"); - } -} - -static void SideShow_Ping(SideShow_PacketHeader_t* const PacketHeader) -{ - Endpoint_ClearOUT(); - - Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); - Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); - Endpoint_ClearIN(); -} - -static void SideShow_Sync(SideShow_PacketHeader_t* const PacketHeader) -{ - GUID_t ProtocolGUID; - - Endpoint_Read_Stream_LE(&ProtocolGUID, sizeof(GUID_t)); - Endpoint_ClearOUT(); - - if (!(GUID_COMPARE(&ProtocolGUID, (uint32_t[])STANDARD_PROTOCOL_GUID))) - PacketHeader->Type.NAK = true; - - Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); - Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); - Endpoint_Write_Stream_LE(&ProtocolGUID, sizeof(GUID_t)); - 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_EPNUM); - Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); - 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_EPNUM); - Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); - 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)); - 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.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_EPNUM); - Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); - - if (!(PacketHeader->Type.NAK)) - { - switch (PropertyData.DataType) - { - case VT_UI4: - case VT_I4: - Endpoint_Write_Stream_LE(&PropertyData.Data.Data32, sizeof(uint32_t)); - break; - case VT_UI2: - case VT_I2: - case VT_BOOL: - Endpoint_Write_Stream_LE(&PropertyData.Data.Data16, sizeof(uint16_t)); - 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_EPNUM); - Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); - 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_EPNUM); - Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); - Endpoint_Write_DWord_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)); - } - - 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_EPNUM); - Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); - Endpoint_Write_DWord_LE(1); - Endpoint_Write_Stream_LE(&SupportedEndpointGUID, sizeof(GUID_t)); - 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)); - - 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); - Endpoint_ClearOUT(); - - PacketHeader->Type.NAK = true; - } - else - { - CurrApp->ApplicationID = ApplicationID; - Endpoint_Read_Stream_LE(&CurrApp->EndpointID, sizeof(GUID_t)); - SideShow_Read_Unicode_String(&CurrApp->ApplicationName, sizeof(CurrApp->ApplicationName.UnicodeString)); - Endpoint_Read_Stream_LE(&CurrApp->CachePolicy, sizeof(uint32_t)); - Endpoint_Read_Stream_LE(&CurrApp->OnlineOnly, sizeof(uint32_t)); - 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_EPNUM); - Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); - Endpoint_ClearIN(); -} - -static void SideShow_DeleteApplication(SideShow_PacketHeader_t* const PacketHeader) -{ - GUID_t ApplicationGUID; - - Endpoint_Read_Stream_LE(&ApplicationGUID, sizeof(GUID_t)); - Endpoint_ClearOUT(); - - SideShow_Application_t* AppToDelete = SideShow_GetApplicationFromGUID(&ApplicationGUID); - - if (AppToDelete != NULL) - AppToDelete->InUse = false; - else - PacketHeader->Type.NAK = true; - - PacketHeader->Length = sizeof(SideShow_PacketHeader_t); - - Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); - Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); - 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_EPNUM); - Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); - 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)); - Endpoint_Read_Stream_LE(&EndpointID, sizeof(GUID_t)); - - Application = SideShow_GetApplicationFromGUID(&ApplicationID); - - if (Application == NULL) - { - SideShow_Discard_Byte_Stream(); - PacketHeader->Type.NAK = true; - } - else if (!(SideShow_AddSimpleContent(PacketHeader, Application))) - { - PacketHeader->Type.NAK = true; - } - - Endpoint_ClearOUT(); - - PacketHeader->Length = sizeof(SideShow_PacketHeader_t); - - Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); - Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); - 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)); - Endpoint_Read_Stream_LE(&EndpointID, sizeof(GUID_t)); - Endpoint_Read_Stream_LE(&ContentID, sizeof(uint32_t)); - Endpoint_ClearOUT(); - - SideShow_Application_t* Application = SideShow_GetApplicationFromGUID(&ApplicationID); - - if ((Application != NULL) && (Application->CurrentContentID == ContentID)) - Application->HaveContent = false; - else - PacketHeader->Type.NAK = true; - - PacketHeader->Length = sizeof(SideShow_PacketHeader_t); - - Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); - Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); - 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)); - Endpoint_Read_Stream_LE(&EndpointID, sizeof(GUID_t)); - Endpoint_ClearOUT(); - - SideShow_Application_t* Application = SideShow_GetApplicationFromGUID(&ApplicationID); - - if (Application != NULL) - Application->HaveContent = false; - else - PacketHeader->Type.NAK = true; - - PacketHeader->Length = sizeof(SideShow_PacketHeader_t); - - Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); - Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); - Endpoint_ClearIN(); -} +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 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_EPNUM); + Endpoint_Read_Stream_LE(&PacketHeader, sizeof(SideShow_PacketHeader_t)); + + PacketHeader.Type.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); + Endpoint_ClearOUT(); + + PacketHeader.Length = sizeof(SideShow_PacketHeader_t); + PacketHeader.Type.NAK = true; + + Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); + Endpoint_Write_Stream_LE(&PacketHeader, sizeof(SideShow_PacketHeader_t)); + Endpoint_ClearIN(); + + printf(" UNK"); + } +} + +static void SideShow_Ping(SideShow_PacketHeader_t* const PacketHeader) +{ + Endpoint_ClearOUT(); + + Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); + Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); + Endpoint_ClearIN(); +} + +static void SideShow_Sync(SideShow_PacketHeader_t* const PacketHeader) +{ + GUID_t ProtocolGUID; + + Endpoint_Read_Stream_LE(&ProtocolGUID, sizeof(GUID_t)); + Endpoint_ClearOUT(); + + if (!(GUID_COMPARE(&ProtocolGUID, (uint32_t[])STANDARD_PROTOCOL_GUID))) + PacketHeader->Type.NAK = true; + + Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); + Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); + Endpoint_Write_Stream_LE(&ProtocolGUID, sizeof(GUID_t)); + 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_EPNUM); + Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); + 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_EPNUM); + Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); + 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)); + 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.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_EPNUM); + Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); + + if (!(PacketHeader->Type.NAK)) + { + switch (PropertyData.DataType) + { + case VT_UI4: + case VT_I4: + Endpoint_Write_Stream_LE(&PropertyData.Data.Data32, sizeof(uint32_t)); + break; + case VT_UI2: + case VT_I2: + case VT_BOOL: + Endpoint_Write_Stream_LE(&PropertyData.Data.Data16, sizeof(uint16_t)); + 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_EPNUM); + Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); + 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_EPNUM); + Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); + Endpoint_Write_DWord_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)); + } + + 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_EPNUM); + Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); + Endpoint_Write_DWord_LE(1); + Endpoint_Write_Stream_LE(&SupportedEndpointGUID, sizeof(GUID_t)); + 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)); + + 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); + Endpoint_ClearOUT(); + + PacketHeader->Type.NAK = true; + } + else + { + CurrApp->ApplicationID = ApplicationID; + Endpoint_Read_Stream_LE(&CurrApp->EndpointID, sizeof(GUID_t)); + SideShow_Read_Unicode_String(&CurrApp->ApplicationName, sizeof(CurrApp->ApplicationName.UnicodeString)); + Endpoint_Read_Stream_LE(&CurrApp->CachePolicy, sizeof(uint32_t)); + Endpoint_Read_Stream_LE(&CurrApp->OnlineOnly, sizeof(uint32_t)); + 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_EPNUM); + Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); + Endpoint_ClearIN(); +} + +static void SideShow_DeleteApplication(SideShow_PacketHeader_t* const PacketHeader) +{ + GUID_t ApplicationGUID; + + Endpoint_Read_Stream_LE(&ApplicationGUID, sizeof(GUID_t)); + Endpoint_ClearOUT(); + + SideShow_Application_t* AppToDelete = SideShow_GetApplicationFromGUID(&ApplicationGUID); + + if (AppToDelete != NULL) + AppToDelete->InUse = false; + else + PacketHeader->Type.NAK = true; + + PacketHeader->Length = sizeof(SideShow_PacketHeader_t); + + Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); + Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); + 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_EPNUM); + Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); + 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)); + Endpoint_Read_Stream_LE(&EndpointID, sizeof(GUID_t)); + + Application = SideShow_GetApplicationFromGUID(&ApplicationID); + + if (Application == NULL) + { + SideShow_Discard_Byte_Stream(); + PacketHeader->Type.NAK = true; + } + else if (!(SideShow_AddSimpleContent(PacketHeader, Application))) + { + PacketHeader->Type.NAK = true; + } + + Endpoint_ClearOUT(); + + PacketHeader->Length = sizeof(SideShow_PacketHeader_t); + + Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); + Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); + 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)); + Endpoint_Read_Stream_LE(&EndpointID, sizeof(GUID_t)); + Endpoint_Read_Stream_LE(&ContentID, sizeof(uint32_t)); + Endpoint_ClearOUT(); + + SideShow_Application_t* Application = SideShow_GetApplicationFromGUID(&ApplicationID); + + if ((Application != NULL) && (Application->CurrentContentID == ContentID)) + Application->HaveContent = false; + else + PacketHeader->Type.NAK = true; + + PacketHeader->Length = sizeof(SideShow_PacketHeader_t); + + Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); + Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); + 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)); + Endpoint_Read_Stream_LE(&EndpointID, sizeof(GUID_t)); + Endpoint_ClearOUT(); + + SideShow_Application_t* Application = SideShow_GetApplicationFromGUID(&ApplicationID); + + if (Application != NULL) + Application->HaveContent = false; + else + PacketHeader->Type.NAK = true; + + PacketHeader->Length = sizeof(SideShow_PacketHeader_t); + + Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); + Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); + Endpoint_ClearIN(); +} diff --git a/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommands.h b/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommands.h index 0d8727d29..6d4ad4c26 100644 --- a/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommands.h +++ b/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommands.h @@ -1,165 +1,165 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2010. - - dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com -*/ - -/* - Copyright 2010 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 - #include - #include - - #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 +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 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 + #include + #include + + #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 diff --git a/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommon.c b/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommon.c index 68a819509..29f768ecc 100644 --- a/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommon.c +++ b/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommon.c @@ -1,70 +1,70 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2010. - - dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com -*/ - -/* - Copyright 2010 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)); - - int UnicodeData[UnicodeCharsToRead]; - - UnicodeStruct->LengthInBytes = (UnicodeCharsToRead << 1); - - Endpoint_Read_Stream_LE(&UnicodeData, UnicodeStruct->LengthInBytes); - - 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)); - Endpoint_Write_Stream_LE(&UnicodeStruct->UnicodeString, UnicodeStruct->LengthInBytes); -} - -void SideShow_Discard_Byte_Stream(void) -{ - uint32_t StreamSize; - - Endpoint_Read_Stream_LE(&StreamSize, sizeof(uint32_t)); - Endpoint_Discard_Stream(StreamSize); -} +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 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)); + + int UnicodeData[UnicodeCharsToRead]; + + UnicodeStruct->LengthInBytes = (UnicodeCharsToRead << 1); + + Endpoint_Read_Stream_LE(&UnicodeData, UnicodeStruct->LengthInBytes); + + 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)); + Endpoint_Write_Stream_LE(&UnicodeStruct->UnicodeString, UnicodeStruct->LengthInBytes); +} + +void SideShow_Discard_Byte_Stream(void) +{ + uint32_t StreamSize; + + Endpoint_Read_Stream_LE(&StreamSize, sizeof(uint32_t)); + Endpoint_Discard_Stream(StreamSize); +} diff --git a/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommon.h b/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommon.h index 9bda6acaf..7c632b3c4 100644 --- a/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommon.h +++ b/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommon.h @@ -1,103 +1,103 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2010. - - dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com -*/ - -/* - Copyright 2010 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 - #include - - #include - - /* 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]; - - int ErrorCode : 6; - int NAK : 1; - int Response : 1; - }; - } 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); - +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 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 + #include + + #include + + /* 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]; + + int ErrorCode : 6; + int NAK : 1; + int Response : 1; + }; + } 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 \ No newline at end of file diff --git a/Demos/Device/Incomplete/Sideshow/Lib/SideshowContent.c b/Demos/Device/Incomplete/Sideshow/Lib/SideshowContent.c index d77dc4a4e..0d1dd80fb 100644 --- a/Demos/Device/Incomplete/Sideshow/Lib/SideshowContent.c +++ b/Demos/Device/Incomplete/Sideshow/Lib/SideshowContent.c @@ -1,76 +1,76 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2010. - - dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com -*/ - -/* - Copyright 2010 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)); - - PacketHeader->Length -= sizeof(uint32_t); - - if (Application->CurrentContentID != ContentID) - { - Endpoint_Discard_Stream(PacketHeader->Length); - - return false; - } - - Endpoint_Read_Stream_LE(&ContentSize, sizeof(uint32_t)); - Endpoint_Read_Stream_LE(&Application->CurrentContent, sizeof(XML_START_TAG) - 1); - - 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); - - Application->HaveContent = true; - } - else - { - printf(" BINARY"); - Endpoint_Discard_Stream(ContentSize); - } - - return true; -} - -static void SideShow_ProcessXMLContent(void* ContentData, uint32_t ContentSize) -{ - printf(" XML"); - Endpoint_Discard_Stream(ContentSize); -} +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 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)); + + PacketHeader->Length -= sizeof(uint32_t); + + if (Application->CurrentContentID != ContentID) + { + Endpoint_Discard_Stream(PacketHeader->Length); + + return false; + } + + Endpoint_Read_Stream_LE(&ContentSize, sizeof(uint32_t)); + Endpoint_Read_Stream_LE(&Application->CurrentContent, sizeof(XML_START_TAG) - 1); + + 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); + + Application->HaveContent = true; + } + else + { + printf(" BINARY"); + Endpoint_Discard_Stream(ContentSize); + } + + return true; +} + +static void SideShow_ProcessXMLContent(void* ContentData, uint32_t ContentSize) +{ + printf(" XML"); + Endpoint_Discard_Stream(ContentSize); +} diff --git a/Demos/Device/Incomplete/Sideshow/Lib/SideshowContent.h b/Demos/Device/Incomplete/Sideshow/Lib/SideshowContent.h index 47c15fb88..97a6bee81 100644 --- a/Demos/Device/Incomplete/Sideshow/Lib/SideshowContent.h +++ b/Demos/Device/Incomplete/Sideshow/Lib/SideshowContent.h @@ -1,125 +1,125 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2010. - - dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com -*/ - -/* - Copyright 2010 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 - #include - #include - #include - - #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 "" - #define XML_END_TAG "" - - /* 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 - +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 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 + #include + #include + #include + + #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 "" + #define XML_END_TAG "" + + /* 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 \ No newline at end of file -- cgit v1.2.3