diff options
author | Pete Batard <pbatard@gmail.com> | 2011-03-09 00:12:32 +0000 |
---|---|---|
committer | Pete Batard <pbatard@gmail.com> | 2011-03-09 00:12:32 +0000 |
commit | 870b24bee3946c59cea5672868c7eaa9d405347a (patch) | |
tree | dd604b3ee3ec90df996aefe74c90c5998d3b3176 | |
parent | 677ea16f4489033a21c0d6dae862fb9437bfa71f (diff) | |
download | libusb-870b24bee3946c59cea5672868c7eaa9d405347a.tar.gz |
removed the smuc sample
-rw-r--r-- | _libusb_2008.sln | 127 | ||||
-rw-r--r-- | examples/_smuc_2008.vcproj | 319 | ||||
-rw-r--r-- | examples/smuc.c | 238 |
3 files changed, 57 insertions, 627 deletions
diff --git a/_libusb_2008.sln b/_libusb_2008.sln index 5235f2a..e3f7b48 100644 --- a/_libusb_2008.sln +++ b/_libusb_2008.sln @@ -1,70 +1,57 @@ -Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual Studio 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (static)", "_libusb_static_2008.vcproj", "{349EE8F9-7D25-4909-AAF5-FF3FADE72187}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (dll)", "_libusb_dll_2008.vcproj", "{349EE8FA-7D25-4909-AAF5-FF3FADE72187}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lsusb", "examples\_lsusb_2008.vcproj", "{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}"
- ProjectSection(ProjectDependencies) = postProject
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187} = {349EE8F9-7D25-4909-AAF5-FF3FADE72187}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xusb", "examples\_xusb_2008.vcproj", "{3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}"
- ProjectSection(ProjectDependencies) = postProject
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187} = {349EE8F9-7D25-4909-AAF5-FF3FADE72187}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "smuc", "examples\_smuc_2008.vcproj", "{4A6E2DEB-9E62-44CA-B5D8-6927F308223B}"
- ProjectSection(ProjectDependencies) = postProject
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187} = {349EE8F9-7D25-4909-AAF5-FF3FADE72187}
- EndProjectSection
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Debug|x64 = Debug|x64
- Release|Win32 = Release|Win32
- Release|x64 = Release|x64
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.Build.0 = Debug|Win32
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.Build.0 = Debug|x64
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.Build.0 = Release|Win32
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64
- {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.Build.0 = Release|x64
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32
- {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64
- {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|Win32.ActiveCfg = Debug|Win32
- {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|Win32.Build.0 = Debug|Win32
- {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|x64.ActiveCfg = Debug|x64
- {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|x64.Build.0 = Debug|x64
- {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|Win32.ActiveCfg = Release|Win32
- {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|Win32.Build.0 = Release|Win32
- {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|x64.ActiveCfg = Release|x64
- {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|x64.Build.0 = Release|x64
- {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|Win32.ActiveCfg = Debug|Win32
- {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|Win32.Build.0 = Debug|Win32
- {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|x64.ActiveCfg = Debug|x64
- {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|x64.Build.0 = Debug|x64
- {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|Win32.ActiveCfg = Release|Win32
- {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|Win32.Build.0 = Release|Win32
- {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|x64.ActiveCfg = Release|x64
- {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|x64.Build.0 = Release|x64
- {4A6E2DEB-9E62-44CA-B5D8-6927F308223B}.Debug|Win32.ActiveCfg = Debug|Win32
- {4A6E2DEB-9E62-44CA-B5D8-6927F308223B}.Debug|Win32.Build.0 = Debug|Win32
- {4A6E2DEB-9E62-44CA-B5D8-6927F308223B}.Debug|x64.ActiveCfg = Debug|x64
- {4A6E2DEB-9E62-44CA-B5D8-6927F308223B}.Debug|x64.Build.0 = Debug|x64
- {4A6E2DEB-9E62-44CA-B5D8-6927F308223B}.Release|Win32.ActiveCfg = Release|Win32
- {4A6E2DEB-9E62-44CA-B5D8-6927F308223B}.Release|Win32.Build.0 = Release|Win32
- {4A6E2DEB-9E62-44CA-B5D8-6927F308223B}.Release|x64.ActiveCfg = Release|x64
- {4A6E2DEB-9E62-44CA-B5D8-6927F308223B}.Release|x64.Build.0 = Release|x64
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
+Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (static)", "_libusb_static_2008.vcproj", "{349EE8F9-7D25-4909-AAF5-FF3FADE72187}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (dll)", "_libusb_dll_2008.vcproj", "{349EE8FA-7D25-4909-AAF5-FF3FADE72187}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lsusb", "examples\_lsusb_2008.vcproj", "{F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}" + ProjectSection(ProjectDependencies) = postProject + {349EE8F9-7D25-4909-AAF5-FF3FADE72187} = {349EE8F9-7D25-4909-AAF5-FF3FADE72187} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xusb", "examples\_xusb_2008.vcproj", "{3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}" + ProjectSection(ProjectDependencies) = postProject + {349EE8F9-7D25-4909-AAF5-FF3FADE72187} = {349EE8F9-7D25-4909-AAF5-FF3FADE72187} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32 + {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.Build.0 = Debug|Win32 + {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64 + {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.Build.0 = Debug|x64 + {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32 + {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.Build.0 = Release|Win32 + {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64 + {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.Build.0 = Release|x64 + {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32 + {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64 + {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32 + {349EE8FA-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64 + {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|Win32.ActiveCfg = Debug|Win32 + {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|Win32.Build.0 = Debug|Win32 + {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|x64.ActiveCfg = Debug|x64 + {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Debug|x64.Build.0 = Debug|x64 + {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|Win32.ActiveCfg = Release|Win32 + {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|Win32.Build.0 = Release|Win32 + {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|x64.ActiveCfg = Release|x64 + {F4938DB0-3DE7-4737-9C5A-EAD1BE819F87}.Release|x64.Build.0 = Release|x64 + {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|Win32.ActiveCfg = Debug|Win32 + {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|Win32.Build.0 = Debug|Win32 + {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|x64.ActiveCfg = Debug|x64 + {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Debug|x64.Build.0 = Debug|x64 + {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|Win32.ActiveCfg = Release|Win32 + {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|Win32.Build.0 = Release|Win32 + {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|x64.ActiveCfg = Release|x64 + {3F3138D0-7AB7-4268-9BF3-1A3EA5503A11}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/examples/_smuc_2008.vcproj b/examples/_smuc_2008.vcproj deleted file mode 100644 index 2298de5..0000000 --- a/examples/_smuc_2008.vcproj +++ /dev/null @@ -1,319 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="9.00"
- Name="smuc"
- ProjectGUID="{4A6E2DEB-9E62-44CA-B5D8-6927F308223B}"
- RootNamespace="examples"
- Keyword="Win32Proj"
- TargetFrameworkVersion="196613"
- >
- <Platforms>
- <Platform
- Name="Win32"
- />
- <Platform
- Name="x64"
- />
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)\examples\$(ProjectName)"
- ConfigurationType="1"
- CharacterSet="1"
- BuildLogFile="$(IntDir)\$(ProjectName).htm"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\msvc;..\libusb"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
- MinimalRebuild="true"
- RuntimeLibrary="1"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalLibraryDirectories=""
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Debug|x64"
- OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)\examples\$(ProjectName)"
- ConfigurationType="1"
- CharacterSet="1"
- BuildLogFile="$(IntDir)\$(ProjectName).htm"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- />
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="..\msvc;..\libusb"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
- MinimalRebuild="true"
- RuntimeLibrary="1"
- WarningLevel="3"
- DebugInformationFormat="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalLibraryDirectories=""
- GenerateDebugInformation="true"
- SubSystem="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)\examples\$(ProjectName)"
- ConfigurationType="1"
- CharacterSet="1"
- WholeProgramOptimization="1"
- BuildLogFile="$(IntDir)\$(ProjectName).htm"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="..\msvc;..\libusb"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
- RuntimeLibrary="0"
- WarningLevel="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalLibraryDirectories=""
- SubSystem="1"
- TargetMachine="1"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
- Name="Release|x64"
- OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)\examples"
- IntermediateDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)\examples\$(ProjectName)"
- ConfigurationType="1"
- CharacterSet="1"
- WholeProgramOptimization="1"
- BuildLogFile="$(IntDir)\$(ProjectName).htm"
- >
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- TargetEnvironment="3"
- />
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="..\msvc;..\libusb"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
- RuntimeLibrary="0"
- WarningLevel="3"
- />
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
- Name="VCLinkerTool"
- AdditionalLibraryDirectories=""
- SubSystem="1"
- TargetMachine="17"
- />
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
- <File
- RelativePath=".\smuc.c"
- >
- </File>
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/examples/smuc.c b/examples/smuc.c deleted file mode 100644 index 3543917..0000000 --- a/examples/smuc.c +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Super Mega USB Challenge: libusb hotplug and topology demo - * Copyright (c) 2011 Pete Batard <pbatard@gmail.com> - * - * This test program highlights the use of the new hotplug and - * topology calls from the point of view of game controller setup. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <config.h> -#include <stdio.h> -#include <stdint.h> -#include <stdlib.h> -#include <string.h> -#include <stdarg.h> - -#include "libusb.h" - -// Global variables -FILE *config_fd = NULL; -int nb_controllers = 0; -struct libusb_device* controller_list[16]; -uint8_t config_bus[16]; -uint8_t config_data[16][7]; -uint8_t config_len[16]; -uint8_t bus_number[16]; -uint8_t nb_bus_used = 0; - -void connected(struct libusb_device *dev, void *data) { - struct libusb_device_descriptor dev_desc; - struct libusb_device_topology topology; - uint8_t i; - - controller_list[nb_controllers++] = dev; - - if (libusb_get_device_descriptor(dev, &dev_desc) == LIBUSB_SUCCESS) { - printf("\nController #%d: VID:PID %04X:%04X [ignored, as assumed identical]\n", - nb_controllers, dev_desc.idVendor, dev_desc.idProduct); - } - if (libusb_get_device_topology(dev, &topology) == LIBUSB_SUCCESS) { - printf("bus: %d, port: %d, depth: %d\n", topology.bus, topology.port, topology.depth); - } - // To minimize data, each bus is handled separately - for (i=0; i<nb_bus_used; i++) { - if (bus_number[i] == topology.bus) { - return; - } - } - bus_number[nb_bus_used++] = topology.bus; -} - -void init_controllers(void) { - int i, j, r; - struct libusb_device *last_parent, *current_parent; - struct libusb_device_topology topology; - uint8_t b, current_depth; - uint8_t minimal_depth = 0; - - libusb_register_hotplug_listeners(NULL, connected, NULL, NULL); - - printf("Controller initialization: please plug each controller in the order\n"); - printf("you want them assigned to players (first plugged => player 1, etc.)\n"); - printf("When done, press Enter (would be \"a button on any controller\" for actual app)\n"); - - while(getchar() != 0x0A); - - // Ideally, to avoid separate bus number processing, we could treat the bus# as a port# for a depth 0 "hub" - for (b=0; b<nb_bus_used; b++) { - last_parent = NULL; - for (i=0; i<nb_controllers; i++) { - if (libusb_get_device_topology(controller_list[i], &topology) != LIBUSB_SUCCESS) { - fprintf(stderr, "failed to read topology 1\n"); - return; - } - - if (topology.bus != bus_number[b]) { - continue; - } - config_len[i] = 0; - - // First controller for this bus - if (last_parent == NULL) { - minimal_depth = topology.depth; - last_parent = topology.parent_dev; - } - - // At the very least, we need the leaf port (and bus number) - config_data[i][config_len[i]++] = topology.port; - config_bus[i] = topology.bus; - - // If our depth is higher, get to the same depth as current minimal - while (topology.depth > minimal_depth) { - if (libusb_get_device_topology(topology.parent_dev, &topology) != LIBUSB_SUCCESS) { - fprintf(stderr, "failed to read topology\n"); - return; - } - config_data[i][config_len[i]++] = topology.port; - }; - - // Keep a copy of our current depth, in case it is lower than last - current_depth = topology.depth; - current_parent = topology.parent_dev; - - // Lower everyone before us until we get to the common ancestor - while (current_parent != last_parent) { - minimal_depth--; - // All ancestors up to i-1 are the same as this stage, so just pick up the port from last common parent - if (libusb_get_device_topology(last_parent, &topology)) { - fprintf(stderr, "failed to read topology\n"); - return; - } - last_parent = topology.parent_dev; - for (j=0; j<i; j++) { - config_data[j][config_len[j]++] = topology.port; - } - if (current_depth <= topology.depth) { - // If the depths are different, we are just lowering existing data to our - // current depth => don't go further until we can compare parents on the same footing - continue; - } - if ((r = libusb_get_device_topology(current_parent, &topology)) != LIBUSB_SUCCESS) { - fprintf(stderr, "failed to read topology\n"); - return; - } - current_parent = topology.parent_dev; - } - } - printf("Minimum distance to root, to uniquely identify all controllers on bus %d: %d\n", bus_number[b], minimal_depth); - } - - // Display config data - printf("\nConfig data:\n"); - for (i=0; i<nb_controllers; i++) { - printf("Controller #%d: Len:%02X, Bus:%02X, Port(s):", i+1, ++config_len[i], config_bus[i]); - fwrite(&config_len[i], 1, 1, config_fd); - fwrite(&config_bus[i], 1, 1, config_fd); - for (j=0; j<config_len[i]-1; j++) { - printf(" %02X", config_data[i][j]); - fwrite(&config_data[i][j], 1, 1, config_fd); - } - printf("\n"); - } -} - -void check_controllers(void) { - printf("Confirming controller setup...\n\n"); - printf("(This is the part where we would scan all devices with our controllers VID:PID\n"); - printf("and check that they match the config, using the same code as in init_controllers)\n"); -} - - -int main(int argc, char** argv) -{ - int show_help = 0; - int debug_mode = 0; - int controller_setup = 0; - int j, r; - size_t len; - - // Default to HID, expecting VID:PID - if (argc >= 2) { - for (j = 1; j<argc; j++) { - len = strlen(argv[j]); - if ( ((argv[j][0] == '-') || (argv[j][0] == '/')) && (len >= 2) ) { - switch(argv[j][1]) { - case 'd': - debug_mode = -1; - break; - default: - show_help = -1; - break; - } - } else { - show_help = -1; - } - } - } - - if ((show_help) || (argc > 2)) { - printf("usage: %s [-d] [-h]\n", argv[0]); - printf(" -h: display usage\n"); - printf(" -d: enable debug output (if library was compiled with debug enabled)\n"); - return 0; - } - - printf("\nSuper Mega USB Challenge! (c) 2011 MomCo\n\n"); - - config_fd = fopen("smuc.cfg", "rb"); - if (config_fd == NULL) { - config_fd = fopen("smuc.cfg", "wb"); - if (config_fd == NULL) { - fprintf(stderr, "unable to create config file\n"); - exit(1); - } - controller_setup = -1; - len = 0; - } else { - fseek(config_fd, 0, SEEK_END); - len = (size_t)ftell(config_fd); - fseek(config_fd, 0, SEEK_SET); - if (len == 0) { - controller_setup = -1; - } - } - - r = libusb_init(NULL); - if (r < 0) { - fclose(config_fd); - return r; - } - - // Warnings = 2, Debug = 4 - libusb_set_debug(NULL, debug_mode?4:2); - - if (controller_setup) { - init_controllers(); - } else { - check_controllers(); - } - - fclose(config_fd); - libusb_exit(NULL); - - return 0; -} |