diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/lsusb.dsp | 4 | ||||
-rw-r--r-- | examples/lsusb_2008.vcproj | 4 | ||||
-rw-r--r-- | examples/xusb.c | 128 | ||||
-rw-r--r-- | examples/xusb.dsp | 4 | ||||
-rw-r--r-- | examples/xusb_2008.vcproj | 4 |
5 files changed, 85 insertions, 59 deletions
diff --git a/examples/lsusb.dsp b/examples/lsusb.dsp index d7b223f..bf16c4e 100644 --- a/examples/lsusb.dsp +++ b/examples/lsusb.dsp @@ -50,7 +50,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "D:/Program Files/Microsoft SDK/Lib/setupapi.lib" /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib setupapi.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "lsusb - Win32 Debug" @@ -74,7 +74,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo /n "../Win32/Debug/dll/core.sbr" "../Win32/Debug/dll/descriptor.sbr" "../Win32/Debug/dll/io.sbr" "../Win32/Debug/dll/sync.sbr" "../Win32/Debug/dll/poll_windows.sbr" "../Win32/Debug/dll/windows_usb.sbr" LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "D:/Program Files/Microsoft SDK/Lib/setupapi.lib" /nologo /subsystem:console /debug /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib setupapi.lib /nologo /subsystem:console /debug /machine:I386 # SUBTRACT LINK32 /pdb:none !ENDIF diff --git a/examples/lsusb_2008.vcproj b/examples/lsusb_2008.vcproj index a550240..560f296 100644 --- a/examples/lsusb_2008.vcproj +++ b/examples/lsusb_2008.vcproj @@ -53,7 +53,6 @@ UsePrecompiledHeader="0" WarningLevel="3" DebugInformationFormat="4" - CallingConvention="2" /> <Tool Name="VCManagedResourceCompilerTool" @@ -131,7 +130,6 @@ UsePrecompiledHeader="0" WarningLevel="3" DebugInformationFormat="3" - CallingConvention="2" /> <Tool Name="VCManagedResourceCompilerTool" @@ -209,7 +207,6 @@ UsePrecompiledHeader="0" WarningLevel="3" DebugInformationFormat="3" - CallingConvention="2" /> <Tool Name="VCManagedResourceCompilerTool" @@ -290,7 +287,6 @@ UsePrecompiledHeader="0" WarningLevel="3" DebugInformationFormat="3" - CallingConvention="2" /> <Tool Name="VCManagedResourceCompilerTool" diff --git a/examples/xusb.c b/examples/xusb.c index 6bc3b4f..5664ce6 100644 --- a/examples/xusb.c +++ b/examples/xusb.c @@ -154,7 +154,7 @@ void display_buffer_hex(unsigned char *buffer, unsigned size) } -// The XBOX Controller is really a HID device that got its HID Report Descriptors +// The XBOX Controller is really a HID device that got its HID Report Descriptors // removed by Microsoft. // Input/Output reports described at http://euc.jp/periphs/xbox-controller.ja.html int display_xbox_status(libusb_device_handle *handle) @@ -691,7 +691,10 @@ __cdecl #endif main(int argc, char** argv) { + int show_help = 0; + int got_vidpid = 0; int r; + size_t i, arglen1, arglen2; unsigned tmp_vid, tmp_pid; uint16_t endian_test = 0xBE00; @@ -707,63 +710,94 @@ main(int argc, char** argv) } if (argc >= 2) { - if ((argv[1][0] != '-') || (argv[1][1] == 'h')) { - printf("usage: %s [-h] [-i] [-j] [-k] [-l] [-s] [-x] [vid:pid]\n", argv[0]); - printf(" -h: display usage\n"); - printf(" -i: test HID device\n"); - printf(" -j: test OLIMEX ARM-USB-TINY JTAG, 2 channel composite device\n"); - printf(" -k: test Mass Storage USB device\n"); - printf(" -l: test Plantronics Headset (HID)\n"); - printf(" -s: test Microsoft Sidewinder Precision Pro (HID)\n"); - printf(" -x: test Microsoft XBox Controller Type S (default)\n"); - - return 0; + arglen1 = strlen(argv[1]); + if ( ((argv[1][0] == '-') || (argv[1][0] == '/')) + && (arglen1 >= 2) ) { + switch(argv[1][1]) { + case 'i': + // IBM HID Optical mouse - 1 interface + VID = 0x04B3; + PID = 0x3108; + test_mode = USE_HID; + break; + case 'j': + // OLIMEX ARM-USB-TINY JTAG, 2 channel composite device - 2 interfaces + VID = 0x15BA; + PID = 0x0004; + test_mode = USE_JTAG; + break; + case 'k': + // Generic 2 GB USB Key (SCSI Transparent/Bulk Only) - 1 interface + VID = 0x0204; + PID = 0x6025; + test_mode = USE_KEY; + break; + case 'l': + // Plantronics DSP 400, 2 channel HID composite device - 1 HID interface + VID = 0x047F; + PID = 0x0CA1; + test_mode = USE_HID; + break; + case 's': + // Microsoft Sidewinder Precision Pro Joystick - 1 HID interface + VID = 0x045E; + PID = 0x0008; + test_mode = USE_HID; + break; + default: + show_help = -1; + break; + } + } else { + for (i=0; i<arglen1; i++) { + if (argv[1][i] == ':') + break; + } + if (i != arglen1) { + if (sscanf_s(argv[1], "%x:%x" , &tmp_vid, &tmp_pid) != 2) { + printf(" Please specify VID & PID as \"vid:pid\" in hexadecimal format\n"); + return 1; + } + VID = (uint16_t)tmp_vid; + PID = (uint16_t)tmp_pid; + test_mode = USE_KEY; + got_vidpid = -1; + } else { + show_help = -1; + } } - switch(argv[1][1]) { - case 'i': - // IBM HID Optical mouse - 1 interface - VID = 0x04B3; - PID = 0x3108; - test_mode = USE_HID; - break; - case 'j': - // OLIMEX ARM-USB-TINY JTAG, 2 channel composite device - 2 interfaces - VID = 0x15BA; - PID = 0x0004; - test_mode = USE_JTAG; - break; - case 'k': - // Generic 2 GB USB Key (SCSI Transparent/Bulk Only) - 1 interface - VID = 0x0204; - PID = 0x6025; - test_mode = USE_KEY; - break; - case 'l': - // Plantronics DSP 400, 2 channel HID composite device - 1 HID interface - VID = 0x047F; - PID = 0x0CA1; - test_mode = USE_HID; - break; - case 's': - // Microsoft Sidewinder Precision Pro Joystick - 1 HID interface - VID = 0x045E; - PID = 0x0008; - test_mode = USE_HID; - break; - default: - break; + } + + if ((argc == 3) && (!got_vidpid)) { + arglen2 = strlen(argv[2]); + for (i=0; i<arglen2; i++) { + if (argv[2][i] == ':') + break; } - if (argc == 3) { + if (i != arglen2) { if (sscanf_s(argv[2], "%x:%x" , &tmp_vid, &tmp_pid) != 2) { printf(" Please specify VID & PID as \"vid:pid\" in hexadecimal format\n"); return 1; } VID = (uint16_t)tmp_vid; PID = (uint16_t)tmp_pid; - printf("%04X:%04X\n", VID, PID); + } else { + show_help = -1; } } + if ((show_help) || (argc == 1) || (argc >= 4)) { + printf("usage: %s [-h] [-i] [-j] [-k] [-l] [-s] [-x] [vid:pid]\n", argv[0]); + printf(" -h: display usage\n"); + printf(" -i: test HID device\n"); + printf(" -j: test OLIMEX ARM-USB-TINY JTAG, 2 channel composite device\n"); + printf(" -k: test Mass Storage USB device\n"); + printf(" -l: test Plantronics Headset (HID)\n"); + printf(" -s: test Microsoft Sidewinder Precision Pro (HID)\n"); + printf(" -x: test Microsoft XBox Controller Type S (default)\n"); + return 0; + } + r = libusb_init(NULL); if (r < 0) return r; diff --git a/examples/xusb.dsp b/examples/xusb.dsp index 981ac47..9bd5e38 100644 --- a/examples/xusb.dsp +++ b/examples/xusb.dsp @@ -50,7 +50,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "D:/Program Files/Microsoft SDK/Lib/setupapi.lib" /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib setupapi.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "xusb - Win32 Debug" @@ -74,7 +74,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo /n "../Win32/Debug/dll/core.sbr" "../Win32/Debug/dll/descriptor.sbr" "../Win32/Debug/dll/io.sbr" "../Win32/Debug/dll/sync.sbr" "../Win32/Debug/dll/poll_windows.sbr" "../Win32/Debug/dll/windows_usb.sbr" LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "D:/Program Files/Microsoft SDK/Lib/setupapi.lib" /nologo /subsystem:console /debug /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib setupapi.lib /nologo /subsystem:console /debug /machine:I386 !ENDIF diff --git a/examples/xusb_2008.vcproj b/examples/xusb_2008.vcproj index f604ecc..224249a 100644 --- a/examples/xusb_2008.vcproj +++ b/examples/xusb_2008.vcproj @@ -53,7 +53,6 @@ UsePrecompiledHeader="0" WarningLevel="3" DebugInformationFormat="4" - CallingConvention="2" /> <Tool Name="VCManagedResourceCompilerTool" @@ -131,7 +130,6 @@ UsePrecompiledHeader="0" WarningLevel="3" DebugInformationFormat="3" - CallingConvention="2" /> <Tool Name="VCManagedResourceCompilerTool" @@ -209,7 +207,6 @@ UsePrecompiledHeader="0" WarningLevel="3" DebugInformationFormat="3" - CallingConvention="2" /> <Tool Name="VCManagedResourceCompilerTool" @@ -290,7 +287,6 @@ UsePrecompiledHeader="0" WarningLevel="3" DebugInformationFormat="3" - CallingConvention="2" /> <Tool Name="VCManagedResourceCompilerTool" |