]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
Removing windows specific code. Everything now compile and work the same for the...
authorizsh@fail0verflow.com <izsh@fail0verflow.com@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Sat, 20 Feb 2010 23:35:09 +0000 (23:35 +0000)
committerizsh@fail0verflow.com <izsh@fail0verflow.com@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Sat, 20 Feb 2010 23:35:09 +0000 (23:35 +0000)
16 files changed:
client/COMPILING [new file with mode: 0644]
client/Makefile
client/cli.c
client/cmdmain.c
client/flash.c
client/flasher.c
client/include/hidpi.h [deleted file]
client/include/hidsdi.h [deleted file]
client/include/hidusage.h [deleted file]
client/prox.c [deleted file]
client/proxmark3.c
client/proxmark3.h
client/proxusb.c
client/proxusb.h
client/snooper.c
client/ui.c

diff --git a/client/COMPILING b/client/COMPILING
new file mode 100644 (file)
index 0000000..1396c81
--- /dev/null
@@ -0,0 +1,39 @@
+The client compiles on Linux, Mac OS X and Windows (MinGW/MSYS).
+
+it requires:
+- gcc
+- libpthread
+- libreadline
+- libusb
+
+and optionally libQT
+
+
+To compile, just run "make".
+
+
+==========
+= MingGW =
+==========
+It is known to work using:
+- MingW 5.1.6
+- MSYS 1.0.11
+- libpthread 2.8.0 (from MinGW or directly from pthread-win32)
+- readline 5.0 from gnuwin32
+- libusb-win32-device-bin-0.1.12.2
+  Be careful here, it is *NOT* working with the filter version!
+  You have to use the device version and use the inf-wizard
+  to create a driver for your proxmark and install it.
+
+
+============
+= Mac OS X =
+============
+
+macport stuff should do ;)
+
+============
+=   Linux  =
+============
+
+
index d0978a9891d3a116d635cde1ca18a656ceacf21c..779687b953035183f8565ec7697183811f595e82 100644 (file)
@@ -7,7 +7,6 @@ LDLIBS = -L/opt/local/lib -L/usr/local/lib -lusb -lreadline -lpthread
 LDFLAGS = $(COMMON_FLAGS)
 CFLAGS = -std=gnu99 -I. -I../include -I../common -I/opt/local/include -Wall -Wno-unused-function $(COMMON_FLAGS) -g3
 
-WINLIBS = -lgdi32 -lsetupapi
 CXXFLAGS = $(shell pkg-config --cflags QtCore QtGui 2>/dev/null) -Wall
 QTLDLIBS = $(shell pkg-config --libs QtCore QtGui 2>/dev/null)
 
@@ -33,8 +32,6 @@ CMDSRCS = \
 
 CMDOBJS = $(CMDSRCS:.c=.o)
 
-ifeq ($(shell echo ""),)
-
 ifeq ($(shell uname),Darwin)
 CXXFLAGS = -I/Library/Frameworks/QtGui.framework/Versions/Current/Headers -I/Library/Frameworks/QtCore.framework/Versions/Current/Headers
 QTLDLIBS = -framework QtGui -framework QtCore
@@ -52,20 +49,12 @@ endif
 
 RM = rm -f
 BINS = proxmark3 snooper cli flasher
-CLEAN = cli flasher proxmark3 snooper *.o $(CMDOBJS) *.moc.cpp
-else
-RM = del
-BINS = prox.exe
-CLEAN = prox.exe
-endif
+CLEAN = cli cli.exe flasher flasher.exe proxmark3 proxmark3.exe snooper snooper.exe *.o $(CMDOBJS) *.moc.cpp
 
 all: $(BINS)
 
 all-static: LDLIBS:=-static $(LDLIBS)
 all-static: snooper cli flasher
-
-prox.exe: prox.o wingui.o $(CMDOBJS) flash.o
-       $(CC) $(CFLAGS) $(DEFINES) -o prox.exe prox.o wingui.o $(CMDOBJS) flash.c $(WINLIBS)
        
 proxmark3: LDLIBS+=$(QTLDLIBS)
 proxmark3: proxmark3.o $(CMDOBJS) proxusb.o $(QTGUI)
index 25567677eeaa79500d5858fcef99567c927e34f8..1fcdd0c3840366f14bb6eabc558bba34783b7151 100644 (file)
@@ -1,4 +1,5 @@
 #include <stdio.h>
+#include "sleep.h"
 #include "ui.h"
 #include "proxusb.h"
 #include "cmdmain.h"
index 1e49e6cbcee9eb66b72843c63879dfdcb6d07c77..5334384fa31827eecee6b8800153028d8d1ec00f 100644 (file)
@@ -46,16 +46,6 @@ int CmdQuit(const char *Cmd)
 void WaitForResponse(uint32_t response_type)
 {
   while (received_command != response_type) {
-#ifdef WIN32
-    // FIXME: Do we really need this under windows or is it
-    // just some historical code?
-    // pthread seems to be availabe for win32 nowadays
-    // so we should be able to port the code and get rid
-    // of this part.
-    UsbCommand c;
-    if (ReceiveCommandPoll(&c))
-      UsbCommandReceived(&c);
-#endif
     msleep(10); // XXX ugh
   }
   received_command = CMD_UNKNOWN;
index b4e4c8918b21e82df6ad8638ff005ae4f685f21d..68d3b097000fb503b24e1377e13bdf12abfe8386 100644 (file)
@@ -1,14 +1,8 @@
-#ifdef WIN32
-#include <windows.h>
-#include <setupapi.h>
-#define bzero(b,len) (memset((b), '\0', (len)), (void) 0)
-BOOL UsbConnect(void);
-#endif
-#include <proxusb.h>
-
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include "sleep.h"
+#include "proxusb.h"
 #include "flash.h"
 #include "elf.h"
 
@@ -194,7 +188,7 @@ unsigned int EnterFlashState(void)
   if (state & DEVICE_INFO_FLAG_CURRENT_MODE_OS) {
     fprintf(stderr,"Entering flash-mode...\n");
     UsbCommand c;
-    bzero(&c, sizeof(c));
+    memset(&c, 0, sizeof (c));
 
     if ((state & DEVICE_INFO_FLAG_BOOTROM_PRESENT) && (state & DEVICE_INFO_FLAG_OSIMAGE_PRESENT)) {
       /* New style handover: Send CMD_START_FLASH, which will reset the board and
@@ -212,15 +206,10 @@ unsigned int EnterFlashState(void)
       fprintf(stderr,"Waiting for Proxmark to reappear on USB... ");
     }
 
-#ifdef WIN32
-    Sleep(1000);
-    while (!UsbConnect()) { Sleep(1000); }
-#else
     CloseProxmark();
     sleep(1);
 
     while (!OpenProxmark(0)) { sleep(1); }
-#endif
     fprintf(stderr,"Found.\n");
 
     return GetProxmarkState();
index d6a51f3e9bcc694790163b2f58ce5a6c4ea7cc1f..418718dd0cf44767d400b8f2f24fbb60347c5676 100644 (file)
@@ -1,5 +1,6 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include "sleep.h"
 #include "proxusb.h"
 #include "flash.h"
 
diff --git a/client/include/hidpi.h b/client/include/hidpi.h
deleted file mode 100644 (file)
index e0d9c9d..0000000
+++ /dev/null
@@ -1,1787 +0,0 @@
-/*++\r
-\r
-Copyright (c) 1996-1998      Microsoft Corporation\r
-\r
-Module Name:\r
-\r
-        HIDPI.H\r
-\r
-Abstract:\r
-\r
-   Public Interface to the HID parsing library.\r
-\r
-Environment:\r
-\r
-    Kernel & user mode\r
-\r
---*/\r
-\r
-#ifndef   __HIDPI_H__\r
-#define   __HIDPI_H__\r
-\r
-#include <pshpack4.h>\r
-typedef LONG NTSTATUS;\r
-// Please include "hidsdi.h" to use the user space (dll / parser)\r
-// Please include "hidpddi.h" to use the kernel space parser\r
-\r
-//\r
-// Special Link collection values for using the query functions\r
-//\r
-// Root collection references the collection at the base of the link\r
-// collection tree.\r
-// Unspecifies, references all collections in the link collection tree.\r
-//\r
-#define HIDP_LINK_COLLECTION_ROOT ((USHORT) -1)\r
-#define HIDP_LINK_COLLECTION_UNSPECIFIED ((USHORT) 0)\r
-\r
-\r
-typedef enum _HIDP_REPORT_TYPE\r
-{\r
-    HidP_Input,\r
-    HidP_Output,\r
-    HidP_Feature\r
-} HIDP_REPORT_TYPE;\r
-\r
-typedef struct _USAGE_AND_PAGE\r
-{\r
-    USAGE Usage;\r
-    USAGE UsagePage;\r
-} USAGE_AND_PAGE, *PUSAGE_AND_PAGE;\r
-\r
-#define HidP_IsSameUsageAndPage(u1, u2) ((* (PULONG) &u1) == (* (PULONG) &u2))\r
-\r
-typedef struct _HIDP_BUTTON_CAPS\r
-{\r
-    USAGE    UsagePage;\r
-    UCHAR    ReportID;\r
-    BOOLEAN  IsAlias;\r
-\r
-    USHORT   BitField;\r
-    USHORT   LinkCollection;   // A unique internal index pointer\r
-\r
-    USAGE    LinkUsage;\r
-    USAGE    LinkUsagePage;\r
-\r
-    BOOLEAN  IsRange;\r
-    BOOLEAN  IsStringRange;\r
-    BOOLEAN  IsDesignatorRange;\r
-    BOOLEAN  IsAbsolute;\r
-\r
-    ULONG    Reserved[10];\r
-    union {\r
-        struct {\r
-            USAGE    UsageMin,         UsageMax;\r
-            USHORT   StringMin,        StringMax;\r
-            USHORT   DesignatorMin,    DesignatorMax;\r
-            USHORT   DataIndexMin,     DataIndexMax;\r
-        } Range;\r
-        struct  {\r
-            USAGE    Usage,            Reserved1;\r
-            USHORT   StringIndex,      Reserved2;\r
-            USHORT   DesignatorIndex,  Reserved3;\r
-            USHORT   DataIndex,        Reserved4;\r
-        } NotRange;\r
-    };\r
-\r
-} HIDP_BUTTON_CAPS, *PHIDP_BUTTON_CAPS;\r
-\r
-\r
-typedef struct _HIDP_VALUE_CAPS\r
-{\r
-    USAGE    UsagePage;\r
-    UCHAR    ReportID;\r
-    BOOLEAN  IsAlias;\r
-\r
-    USHORT   BitField;\r
-    USHORT   LinkCollection;   // A unique internal index pointer\r
-\r
-    USAGE    LinkUsage;\r
-    USAGE    LinkUsagePage;\r
-\r
-    BOOLEAN  IsRange;\r
-    BOOLEAN  IsStringRange;\r
-    BOOLEAN  IsDesignatorRange;\r
-    BOOLEAN  IsAbsolute;\r
-\r
-    BOOLEAN  HasNull;        // Does this channel have a null report   union\r
-    UCHAR    Reserved;\r
-    USHORT   BitSize;        // How many bits are devoted to this value?\r
-\r
-    USHORT   ReportCount;    // See Note below.  Usually set to 1.\r
-    USHORT   Reserved2[5];\r
-\r
-    ULONG    UnitsExp;\r
-    ULONG    Units;\r
-\r
-    LONG     LogicalMin,       LogicalMax;\r
-    LONG     PhysicalMin,      PhysicalMax;\r
-\r
-    union {\r
-        struct {\r
-            USAGE    UsageMin,         UsageMax;\r
-            USHORT   StringMin,        StringMax;\r
-            USHORT   DesignatorMin,    DesignatorMax;\r
-            USHORT   DataIndexMin,     DataIndexMax;\r
-        } Range;\r
-\r
-        struct {\r
-            USAGE    Usage,            Reserved1;\r
-            USHORT   StringIndex,      Reserved2;\r
-            USHORT   DesignatorIndex,  Reserved3;\r
-            USHORT   DataIndex,        Reserved4;\r
-        } NotRange;\r
-    };\r
-} HIDP_VALUE_CAPS, *PHIDP_VALUE_CAPS;\r
-\r
-//\r
-// Notes:\r
-//\r
-// ReportCount:  When a report descriptor declares an Input, Output, or\r
-// Feature main item with fewer usage declarations than the report count, then\r
-// the last usage applies to all remaining unspecified count in that main item.\r
-// (As an example you might have data that required many fields to describe,\r
-// possibly buffered bytes.)  In this case, only one value cap structure is\r
-// allocated for these associtated fields, all with the same usage, and Report\r
-// Count reflects the number of fields involved.  Normally ReportCount is 1.\r
-// To access all of the fields in such a value structure would require using\r
-// HidP_GetUsageValueArray and HidP_SetUsageValueArray.   HidP_GetUsageValue/\r
-// HidP_SetScaledUsageValue will also work, however, these functions will only\r
-// work with the first field of the structure.\r
-//\r
-\r
-//\r
-// The link collection tree consists of an array of LINK_COLLECTION_NODES\r
-// where the index into this array is the same as the collection number.\r
-//\r
-// Given a collection A which contains a subcollection B, A is defined to be\r
-// the parent B, and B is defined to be the child.\r
-//\r
-// Given collections A, B, and C where B and C are children of A, and B was\r
-// encountered before C in the report descriptor, B is defined as a sibling of\r
-// C.  (This implies, of course, that if B is a sibling of C, then C is NOT a\r
-// sibling of B).\r
-//\r
-// B is defined as the NextSibling of C if and only if there exists NO\r
-// child collection of A, call it D, such that B is a sibling of D and D\r
-// is a sibling of C.\r
-//\r
-// E is defined to be the FirstChild of A if and only if for all children of A,\r
-// F, that are not equivalent to E, F is a sibling of E.\r
-// (This implies, of course, that the does not exist a child of A, call it G,\r
-// where E is a sibling of G).  In other words the first sibling is the last\r
-// link collection found in the list.\r
-//\r
-// In other words, if a collection B is defined within the definition of another\r
-// collection A, B becomes a child of A.  All collections with the same parent\r
-// are considered siblings.  The FirstChild of the parent collection, A, will be\r
-// last collection defined that has A as a parent.  The order of sibling pointers\r
-// is similarly determined.  When a collection B is defined, it becomes the\r
-// FirstChild of it's parent collection.  The previously defined FirstChild of the\r
-// parent collection becomes the NextSibling of the new collection.  As new\r
-// collections with the same parent are discovered, the chain of sibling is built.\r
-//\r
-// With that in mind, the following describes conclusively a data structure\r
-// that provides direct traversal up, down, and accross the link collection\r
-// tree.\r
-//\r
-//\r
-typedef struct _HIDP_LINK_COLLECTION_NODE\r
-{\r
-    USAGE    LinkUsage;\r
-    USAGE    LinkUsagePage;\r
-    USHORT   Parent;\r
-    USHORT   NumberOfChildren;\r
-    USHORT   NextSibling;\r
-    USHORT   FirstChild;\r
-    ULONG    CollectionType: 8;  // As defined in 6.2.2.6 of HID spec\r
-    ULONG    IsAlias : 1; // This link node is an allias of the next link node.\r
-    ULONG    Reserved: 23;\r
-    PVOID    UserContext; // The user can hang his coat here.\r
-} HIDP_LINK_COLLECTION_NODE, *PHIDP_LINK_COLLECTION_NODE;\r
-\r
-//\r
-// When a link collection is described by a delimiter, alias link collection\r
-// nodes are created.  (One for each usage within the delimiter).\r
-// The parser assigns each capability description listed above only one\r
-// link collection.\r
-//\r
-// If a control is defined within a collection defined by\r
-// delimited usages, then that control is said to be within multiple link\r
-// collections, one for each usage within the open and close delimiter tokens.\r
-// Such multiple link collecions are said to be aliases.  The first N-1 such\r
-// collections, listed in the link collection node array, have their IsAlias\r
-// bit set.  The last such link collection is the link collection index used\r
-// in the capabilities described above.\r
-// Clients wishing to set a control in an aliased collection, should walk the\r
-// collection array once for each time they see the IsAlias flag set, and use\r
-// the last link collection as the index for the below accessor functions.\r
-//\r
-// NB: if IsAlias is set, then NextSibling should be one more than the current\r
-// link collection node index.\r
-//\r
-\r
-typedef PUCHAR  PHIDP_REPORT_DESCRIPTOR;\r
-typedef struct _HIDP_PREPARSED_DATA * PHIDP_PREPARSED_DATA;\r
-\r
-typedef struct _HIDP_CAPS\r
-{\r
-    USAGE    Usage;\r
-    USAGE    UsagePage;\r
-    USHORT   InputReportByteLength;\r
-    USHORT   OutputReportByteLength;\r
-    USHORT   FeatureReportByteLength;\r
-    USHORT   Reserved[17];\r
-\r
-    USHORT   NumberLinkCollectionNodes;\r
-\r
-    USHORT   NumberInputButtonCaps;\r
-    USHORT   NumberInputValueCaps;\r
-    USHORT   NumberInputDataIndices;\r
-\r
-    USHORT   NumberOutputButtonCaps;\r
-    USHORT   NumberOutputValueCaps;\r
-    USHORT   NumberOutputDataIndices;\r
-\r
-    USHORT   NumberFeatureButtonCaps;\r
-    USHORT   NumberFeatureValueCaps;\r
-    USHORT   NumberFeatureDataIndices;\r
-} HIDP_CAPS, *PHIDP_CAPS;\r
-\r
-typedef struct _HIDP_DATA\r
-{\r
-    USHORT  DataIndex;\r
-    USHORT  Reserved;\r
-    union {\r
-        ULONG   RawValue; // for values\r
-        BOOLEAN On; // for buttons MUST BE TRUE for buttons.\r
-    };\r
-} HIDP_DATA, *PHIDP_DATA;\r
-//\r
-// The HIDP_DATA structure is used with HidP_GetData and HidP_SetData\r
-// functions.\r
-//\r
-// The parser contiguously assigns every control (button or value) in a hid\r
-// device a unique data index from zero to NumberXXXDataIndices -1 , inclusive.\r
-// This value is found in the HIDP_BUTTON_CAPS and HIDP_VALUE_CAPS structures.\r
-//\r
-// Most clients will find the Get/Set Buttons / Value accessor functions\r
-// sufficient to their needs, as they will allow the clients to access the\r
-// data known to them while ignoring the other controls.\r
-//\r
-// More complex clients, which actually read the Button / Value Caps, and which\r
-// do a value add service to these routines (EG Direct Input), will need to\r
-// access all the data in the device without interest in the individual usage\r
-// or link collection location.  These are the clients that will find\r
-// HidP_Data useful.\r
-//\r
-\r
-typedef struct _HIDP_UNKNOWN_TOKEN\r
-{\r
-    UCHAR  Token;\r
-    UCHAR  Reserved[3];\r
-    ULONG  BitField;\r
-} HIDP_UNKNOWN_TOKEN, *PHIDP_UNKNOWN_TOKEN;\r
-\r
-typedef struct _HIDP_EXTENDED_ATTRIBUTES\r
-{\r
-    UCHAR   NumGlobalUnknowns;\r
-    UCHAR   Reserved [3];\r
-    PHIDP_UNKNOWN_TOKEN  GlobalUnknowns;\r
-    // ... Additional attributes\r
-    ULONG   Data [1]; // variableLength  DO NOT ACCESS THIS FIELD\r
-} HIDP_EXTENDED_ATTRIBUTES, *PHIDP_EXTENDED_ATTRIBUTES;\r
-\r
-NTSTATUS __stdcall\r
-HidP_GetCaps (\r
-   IN      PHIDP_PREPARSED_DATA      PreparsedData,\r
-   OUT     PHIDP_CAPS                Capabilities\r
-   );\r
-/*++\r
-Routine Description:\r
-   Returns a list of capabilities of a given hid device as described by its\r
-   preparsed data.\r
-\r
-Arguments:\r
-   PreparsedData    The preparsed data returned from HIDCLASS.\r
-   Capabilities     a HIDP_CAPS structure\r
-\r
-Return Value:\r
-·  HIDP_STATUS_SUCCESS\r
-·  HIDP_STATUS_INVALID_PREPARSED_DATA\r
---*/\r
-\r
-NTSTATUS __stdcall\r
-HidP_GetLinkCollectionNodes (\r
-   OUT      PHIDP_LINK_COLLECTION_NODE LinkCollectionNodes,\r
-   IN OUT   PULONG                     LinkCollectionNodesLength,\r
-   IN       PHIDP_PREPARSED_DATA       PreparsedData\r
-   );\r
-/*++\r
-Routine Description:\r
-   Return a list of PHIDP_LINK_COLLECTION_NODEs used to describe the link\r
-   collection tree of this hid device.  See the above description of\r
-   struct _HIDP_LINK_COLLECTION_NODE.\r
-\r
-Arguments:\r
-   LinkCollectionNodes - a caller allocated array into which\r
-                 HidP_GetLinkCollectionNodes will store the information\r
-\r
-   LinKCollectionNodesLength - the caller sets this value to the length of the\r
-                 the array in terms of number of elements.\r
-                 HidP_GetLinkCollectionNodes sets this value to the actual\r
-                 number of elements set. The total number of nodes required to\r
-                 describe this HID device can be found in the\r
-                 NumberLinkCollectionNodes field in the HIDP_CAPS structure.\r
-\r
---*/\r
-\r
-NTSTATUS __stdcall\r
-HidP_GetButtonCaps (\r
-   IN       HIDP_REPORT_TYPE     ReportType,\r
-   OUT      PHIDP_BUTTON_CAPS    ButtonCaps,\r
-   IN OUT   PUSHORT              ButtonCapsLength,\r
-   IN       PHIDP_PREPARSED_DATA PreparsedData\r
-);\r
-#define HidP_GetButtonCaps(_Type_, _Caps_, _Len_, _Data_) \\r
-        HidP_GetSpecificButtonCaps (_Type_, 0, 0, 0, _Caps_, _Len_, _Data_)\r
-NTSTATUS __stdcall\r
-HidP_GetSpecificButtonCaps (\r
-   IN       HIDP_REPORT_TYPE     ReportType,\r
-   IN       USAGE                UsagePage,      // Optional (0 => ignore)\r
-   IN       USHORT               LinkCollection, // Optional (0 => ignore)\r
-   IN       USAGE                Usage,          // Optional (0 => ignore)\r
-   OUT      PHIDP_BUTTON_CAPS    ButtonCaps,\r
-   IN OUT   PUSHORT              ButtonCapsLength,\r
-   IN       PHIDP_PREPARSED_DATA PreparsedData\r
-   );\r
-/*++\r
-Description:\r
-   HidP_GetButtonCaps returns all the buttons (binary values) that are a part\r
-   of the given report type for the Hid device represented by the given\r
-   preparsed data.\r
-\r
-Parameters:\r
-   ReportType  One of HidP_Input, HidP_Output, or HidP_Feature.\r
-\r
-   UsagePage   A usage page value used to limit the button caps returned to\r
-                those on a given usage page.  If set to 0, this parameter is\r
-                ignored.  Can be used with LinkCollection and Usage parameters\r
-                to further limit the number of button caps structures returned.\r
-\r
-   LinkCollection HIDP_LINK_COLLECTION node array index used to limit the\r
-                  button caps returned to those buttons in a given link\r
-                  collection.  If set to 0, this parameter is\r
-                  ignored.  Can be used with UsagePage and Usage parameters\r
-                  to further limit the number of button caps structures\r
-                  returned.\r
-\r
-   Usage      A usage value used to limit the button caps returned to those\r
-               with the specified usage value.  If set to 0, this parameter\r
-               is ignored.  Can be used with LinkCollection and UsagePage\r
-               parameters to further limit the number of button caps\r
-               structures returned.\r
-\r
-   ButtonCaps A _HIDP_BUTTON_CAPS array containing information about all the\r
-               binary values in the given report.  This buffer is provided by\r
-               the caller.\r
-\r
-   ButtonLength   As input, this parameter specifies the length of the\r
-                  ButtonCaps parameter (array) in number of array elements.\r
-                  As output, this value is set to indicate how many of those\r
-                  array elements were filled in by the function.  The maximum number of\r
-                  button caps that can be returned is found in the HIDP_CAPS\r
-                  structure.  If HIDP_STATUS_BUFFER_TOO_SMALL is returned,\r
-                  this value contains the number of array elements needed to\r
-                  successfully complete the request.\r
-\r
-   PreparsedData  The preparsed data returned from HIDCLASS.\r
-\r
-\r
-Return Value\r
-HidP_GetSpecificButtonCaps returns the following error codes:\r
-· HIDP_STATUS_SUCCESS.\r
-· HIDP_STATUS_INVALID_REPORT_TYPE\r
-· HIDP_STATUS_INVALID_PREPARSED_DATA\r
-· HIDP_STATUS_BUFFER_TOO_SMALL (all given entries however have been filled in)\r
-· HIDP_STATUS_USAGE_NOT_FOUND\r
---*/\r
-\r
-NTSTATUS __stdcall\r
-HidP_GetValueCaps (\r
-   IN       HIDP_REPORT_TYPE     ReportType,\r
-   OUT      PHIDP_VALUE_CAPS     ValueCaps,\r
-   IN OUT   PUSHORT              ValueCapsLength,\r
-   IN       PHIDP_PREPARSED_DATA PreparsedData\r
-);\r
-#define HidP_GetValueCaps(_Type_, _Caps_, _Len_, _Data_) \\r
-        HidP_GetSpecificValueCaps (_Type_, 0, 0, 0, _Caps_, _Len_, _Data_)\r
-NTSTATUS __stdcall\r
-HidP_GetSpecificValueCaps (\r
-   IN       HIDP_REPORT_TYPE     ReportType,\r
-   IN       USAGE                UsagePage,      // Optional (0 => ignore)\r
-   IN       USHORT               LinkCollection, // Optional (0 => ignore)\r
-   IN       USAGE                Usage,          // Optional (0 => ignore)\r
-   OUT      PHIDP_VALUE_CAPS     ValueCaps,\r
-   IN OUT   PUSHORT              ValueCapsLength,\r
-   IN       PHIDP_PREPARSED_DATA PreparsedData\r
-   );\r
-/*++\r
-Description:\r
-   HidP_GetValueCaps returns all the values (non-binary) that are a part\r
-   of the given report type for the Hid device represented by the given\r
-   preparsed data.\r
-\r
-Parameters:\r
-   ReportType  One of HidP_Input, HidP_Output, or HidP_Feature.\r
-\r
-   UsagePage   A usage page value used to limit the value caps returned to\r
-                those on a given usage page.  If set to 0, this parameter is\r
-                ignored.  Can be used with LinkCollection and Usage parameters\r
-                to further limit the number of value caps structures returned.\r
-\r
-   LinkCollection HIDP_LINK_COLLECTION node array index used to limit the\r
-                  value caps returned to those buttons in a given link\r
-                  collection.  If set to 0, this parameter is\r
-                  ignored.  Can be used with UsagePage and Usage parameters\r
-                  to further limit the number of value caps structures\r
-                  returned.\r
-\r
-   Usage      A usage value used to limit the value caps returned to those\r
-               with the specified usage value.  If set to 0, this parameter\r
-               is ignored.  Can be used with LinkCollection and UsagePage\r
-               parameters to further limit the number of value caps\r
-               structures returned.\r
-\r
-   ValueCaps  A _HIDP_VALUE_CAPS array containing information about all the\r
-               non-binary values in the given report.  This buffer is provided\r
-               by the caller.\r
-\r
-   ValueLength   As input, this parameter specifies the length of the ValueCaps\r
-                  parameter (array) in number of array elements.  As output,\r
-                  this value is set to indicate how many of those array elements\r
-                  were filled in by the function.  The maximum number of\r
-                  value caps that can be returned is found in the HIDP_CAPS\r
-                  structure.  If HIDP_STATUS_BUFFER_TOO_SMALL is returned,\r
-                  this value contains the number of array elements needed to\r
-                  successfully complete the request.\r
-\r
-   PreparsedData  The preparsed data returned from HIDCLASS.\r
-\r
-\r
-Return Value\r
-HidP_GetValueCaps returns the following error codes:\r
-· HIDP_STATUS_SUCCESS.\r
-· HIDP_STATUS_INVALID_REPORT_TYPE\r
-· HIDP_STATUS_INVALID_PREPARSED_DATA\r
-· HIDP_STATUS_BUFFER_TOO_SMALL (all given entries however have been filled in)\r
-· HIDP_STATUS_USAGE_NOT_FOUND\r
-\r
---*/\r
-\r
-NTSTATUS __stdcall\r
-HidP_GetExtendedAttributes (\r
-    IN      HIDP_REPORT_TYPE            ReportType,\r
-    IN      USHORT                      DataIndex,\r
-    IN      PHIDP_PREPARSED_DATA        PreparsedData,\r
-    OUT     PHIDP_EXTENDED_ATTRIBUTES   Attributes,\r
-    IN OUT  PULONG                      LengthAttributes\r
-    );\r
-/*++\r
-Description:\r
-    Given a data index from the value or button capabilities of a given control\r
-    return any extended attributes for the control if any exist.\r
-\r
-Parameters:\r
-    ReportType  One of HidP_Input, HidP_Output, or HidP_Feature.\r
-\r
-    DataIndex   The data index for the given control, found in the capabilities\r
-                structure for that control\r
-\r
-    PreparsedData   The preparsed data returned from HIDCLASS.\r
-\r
-    Attributes  Pointer to a buffer into which the extended attribute data will\r
-                be copied.\r
-\r
-    LengthAttributes    Length of the given buffer in bytes.\r
-\r
-Return Value\r
-    HIDP_STATUS_SUCCESS\r
-    HIDP_STATUS_DATA_INDEX_NOT_FOUND\r
---*/\r
-\r
-NTSTATUS __stdcall\r
-HidP_InitializeReportForID (\r
-   IN       HIDP_REPORT_TYPE      ReportType,\r
-   IN       UCHAR                 ReportID,\r
-   IN       PHIDP_PREPARSED_DATA  PreparsedData,\r
-   IN OUT   PCHAR                 Report,\r
-   IN       ULONG                 ReportLength\r
-   );\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    Initialize a report based on the given report ID.\r
-\r
-Parameters:\r
-\r
-    ReportType  One of HidP_Input, HidP_Output, or HidP_Feature.\r
-\r
-    PreparasedData  Preparsed data structure returned by HIDCLASS\r
-\r
-    Report      Buffer which to set the data into.\r
-\r
-    ReportLength Length of Report...Report should be at least as long as the\r
-                value indicated in the HIDP_CAPS structure for the device and\r
-                the corresponding ReportType\r
-\r
-Return Value\r
-\r
-· HIDP_STATUS_INVALID_REPORT_TYPE    -- if ReportType is not valid.\r
-· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid\r
-· HIDP_STATUS_INVALID_REPORT_LENGTH  -- the length of the report packet is not equal\r
-                                        to the length specified in HIDP_CAPS\r
-                                        structure for the given ReportType\r
-· HIDP_STATUS_REPORT_DOES_NOT_EXIST  -- if there are no reports on this device\r
-                                        for the given ReportType\r
-\r
---*/\r
-\r
-NTSTATUS __stdcall\r
-HidP_SetData (\r
-   IN       HIDP_REPORT_TYPE      ReportType,\r
-   IN       PHIDP_DATA            DataList,\r
-   IN OUT   PULONG                DataLength,\r
-   IN       PHIDP_PREPARSED_DATA  PreparsedData,\r
-   IN OUT   PCHAR                 Report,\r
-   IN       ULONG                 ReportLength\r
-   );\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    Please Note: Since usage value arrays deal with multiple fields for\r
-                 for one usage value, they cannot be used with HidP_SetData\r
-                 and HidP_GetData.  In this case,\r
-                 HIDP_STATUS_IS_USAGE_VALUE_ARRAY will be returned.\r
-\r
-Parameters:\r
-\r
-    ReportType  One of HidP_Input, HidP_Output, or HidP_Feature.\r
-\r
-    DataList    Array of HIDP_DATA structures that contains the data values\r
-                that are to be set into the given report\r
-\r
-    DataLength  As input, length in array elements of DataList.  As output,\r
-                contains the number of data elements set on successful\r
-                completion or an index into the DataList array to identify\r
-                the faulting HIDP_DATA value if an error code is returned.\r
-\r
-    PreparasedData  Preparsed data structure returned by HIDCLASS\r
-\r
-    Report      Buffer which to set the data into.\r
-\r
-    ReportLength Length of Report...Report should be at least as long as the\r
-                value indicated in the HIDP_CAPS structure for the device and\r
-                the corresponding ReportType\r
-\r
-Return Value\r
-    HidP_SetData returns the following error codes.  The report packet will\r
-        have all the data set up until the HIDP_DATA structure that caused the\r
-        error.  DataLength, in the error case, will return this problem index.\r
-\r
-· HIDP_STATUS_SUCCESS                -- upon successful insertion of all data\r
-                                        into the report packet.\r
-· HIDP_STATUS_INVALID_REPORT_TYPE    -- if ReportType is not valid.\r
-· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid\r
-· HIDP_STATUS_DATA_INDEX_NOT_FOUND   -- if a HIDP_DATA structure referenced a\r
-                                        data index that does not exist for this\r
-                                        device's ReportType\r
-· HIDP_STATUS_INVALID_REPORT_LENGTH  -- the length of the report packet is not equal\r
-                                        to the length specified in HIDP_CAPS\r
-                                        structure for the given ReportType\r
-· HIDP_STATUS_REPORT_DOES_NOT_EXIST  -- if there are no reports on this device\r
-                                        for the given ReportType\r
-· HIDP_STATUS_IS_USAGE_VALUE_ARRAY   -- if one of the HIDP_DATA structures\r
-                                        references a usage value array.\r
-                                        DataLength will contain the index into\r
-                                        the array that was invalid\r
-· HIDP_STATUS_BUTTON_NOT_PRESSED     -- if a HIDP_DATA structure attempted\r
-                                        to unset a button that was not already\r
-                                        set in the Report\r
-· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- a HIDP_DATA structure was found with\r
-                                        a valid index value but is contained\r
-                                        in a different report than the one\r
-                                        currently being processed\r
-· HIDP_STATUS_BUFFER_TOO_SMALL       -- if there are not enough entries in\r
-                                        a given Main Array Item to report all\r
-                                        buttons that have been requested to be\r
-                                        set\r
---*/\r
-\r
-NTSTATUS __stdcall\r
-HidP_GetData (\r
-   IN       HIDP_REPORT_TYPE      ReportType,\r
-   OUT      PHIDP_DATA            DataList,\r
-   IN OUT   PULONG                DataLength,\r
-   IN       PHIDP_PREPARSED_DATA  PreparsedData,\r
-   IN       PCHAR                 Report,\r
-   IN       ULONG                 ReportLength\r
-   );\r
-/*++\r
-\r
-Routine Description:\r
-\r
-    Please Note: For obvious reasons HidP_SetData and HidP_GetData will not\r
-    access UsageValueArrays.\r
-\r
-Parameters:\r
-    ReportType  One of HidP_Input, HidP_Output, or HidP_Feature.\r
-\r
-    DataList    Array of HIDP_DATA structures that will receive the data\r
-                values that are set in the given report\r
-\r
-    DataLength  As input, length in array elements of DataList.  As output,\r
-                contains the number of data elements that were successfully\r
-                set by HidP_GetData.  The maximum size necessary for DataList\r
-                can be determined by calling HidP_MaxDataListLength\r
-\r
-    PreparasedData  Preparsed data structure returned by HIDCLASS\r
-\r
-    Report      Buffer which to set the data into.\r
-\r
-    ReportLength Length of Report...Report should be at least as long as the\r
-                value indicated in the HIDP_CAPS structure for the device and\r
-                the corresponding ReportType\r
-\r
-Return Value\r
-    HidP_GetData returns the following error codes.\r
-\r
-· HIDP_STATUS_SUCCESS                -- upon successful retrieval of all data\r
-                                        from the report packet.\r
-· HIDP_STATUS_INVALID_REPORT_TYPE    -- if ReportType is not valid.\r
-· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid\r
-· HIDP_STATUS_INVALID_REPORT_LENGTH  -- the length of the report packet is not equal\r
-                                        to the length specified in HIDP_CAPS\r
-                                        structure for the given ReportType\r
-· HIDP_STATUS_REPORT_DOES_NOT_EXIST  -- if there are no reports on this device\r
-                                        for the given ReportType\r
-· HIDP_STATUS_BUFFER_TOO_SMALL       -- if there are not enough array entries in\r
-                                        DataList to store all the indice values\r
-                                        in the given report.  DataLength will\r
-                                        contain the number of array entries\r
-                                        required to hold all data\r
---*/\r
-\r
-ULONG __stdcall\r
-HidP_MaxDataListLength (\r
-   IN HIDP_REPORT_TYPE      ReportType,\r
-   IN PHIDP_PREPARSED_DATA  PreparsedData\r
-   );\r
-/*++\r
-Routine Description:\r
-\r
-    This function returns the maximum length of HIDP_DATA elements that\r
-    HidP_GetData could return for the given report type.\r
-\r
-Parameters:\r
-\r
-    ReportType  One of HidP_Input, HidP_Output or HidP_Feature.\r
-\r
-    PreparsedData    Preparsed data structure returned by HIDCLASS\r
-\r
-Return Value:\r
-\r
-    The length of the data list array required for the HidP_GetData function\r
-    call.  If an error occurs (either HIDP_STATUS_INVALID_REPORT_TYPE or\r
-    HIDP_STATUS_INVALID_PREPARSED_DATA), this function returns 0.\r
-\r
---*/\r
-\r
-#define HidP_SetButtons(Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle) \\r
-        HidP_SetUsages(Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle)\r
-\r
-NTSTATUS __stdcall\r
-HidP_SetUsages (\r
-   IN       HIDP_REPORT_TYPE      ReportType,\r
-   IN       USAGE                 UsagePage,\r
-   IN       USHORT                LinkCollection, // Optional\r
-   IN       PUSAGE                UsageList,\r
-   IN OUT   PULONG                UsageLength,\r
-   IN       PHIDP_PREPARSED_DATA  PreparsedData,\r
-   IN OUT   PCHAR                 Report,\r
-   IN       ULONG                 ReportLength\r
-   );\r
-/*++\r
-\r
-Routine Description:\r
-    This function sets binary values (buttons) in a report.  Given an\r
-    initialized packet of correct length, it modifies the report packet so that\r
-    each element in the given list of usages has been set in the report packet.\r
-    For example, in an output report with 5 LED\92s, each with a given usage,\r
-    an application could turn on any subset of these lights by placing their\r
-    usages in any order into the usage array (UsageList).  HidP_SetUsages would,\r
-    in turn, set the appropriate bit or add the corresponding byte into the\r
-    HID Main Array Item.\r
-\r
-    A properly initialized Report packet is one of the correct byte length,\r
-    and all zeros.\r
-\r
-    NOTE: A packet that has already been set with a call to a HidP_Set routine\r
-          can also be passed in.  This routine then sets processes the UsageList\r
-          in the same fashion but verifies that the ReportID already set in\r
-          Report matches the report ID for the given usages.\r
-\r
-Parameters:\r
-    ReportType  One of HidP_Input, HidP_Output or HidP_Feature.\r
-\r
-    UsagePage   All of the usages in the usage array, which HidP_SetUsages will\r
-                set in the report, refer to this same usage page.\r
-                If a client wishes to set usages in a report for multiple\r
-                usage pages then that client needs to make multiple calls to\r
-                HidP_SetUsages for each of the usage pages.\r
-\r
-    UsageList   A usage array containing the usages that HidP_SetUsages will set in\r
-                the report packet.\r
-\r
-    UsageLength The length of the given usage array in array elements.\r
-                The parser will set this value to the position in the usage\r
-                array where it stopped processing.  If successful, UsageLength\r
-                will be unchanged.  In any error condition, this parameter\r
-                reflects how many of the usages in the usage list have\r
-                actually been set by the parser.  This is useful for finding\r
-                the usage in the list which caused the error.\r
-\r
-    PreparsedData The preparsed data recevied from HIDCLASS\r
-\r
-    Report      The report packet.\r
-\r
-    ReportLength   Length of the given report packet...Must be equal to the\r
-                   value reported in the HIDP_CAPS structure for the device\r
-                   and corresponding report type.\r
-\r
-Return Value\r
-    HidP_SetUsages returns the following error codes.  On error, the report packet\r
-    will be correct up until the usage element that caused the error.\r
-\r
-· HIDP_STATUS_SUCCESS                -- upon successful insertion of all usages\r
-                                        into the report packet.\r
-· HIDP_STATUS_INVALID_REPORT_TYPE    -- if ReportType is not valid.\r
-· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid\r
-· HIDP_STATUS_INVALID_REPORT_LENGTH  -- the length of the report packet is not\r
-                                        equal to the length specified in\r
-                                        the HIDP_CAPS structure for the given\r
-                                        ReportType\r
-· HIDP_STATUS_REPORT_DOES_NOT_EXIST  -- if there are no reports on this device\r
-                                        for the given ReportType\r
-· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- if a usage was found that exists in a\r
-                                        different report.  If the report is\r
-                                        zero-initialized on entry the first\r
-                                        usage in the list will determine which\r
-                                        report ID is used.  Otherwise, the\r
-                                        parser will verify that usage matches\r
-                                        the passed in report's ID\r
-· HIDP_STATUS_USAGE_NOT_FOUND        -- if the usage does not exist for any\r
-                                        report (no matter what the report ID)\r
-                                        for the given report type.\r
-· HIDP_STATUS_BUFFER_TOO_SMALL       -- if there are not enough entries in a\r
-                                        given Main Array Item to list all of\r
-                                        the given usages.  The caller needs\r
-                                        to split his request into more than\r
-                                        one call\r
---*/\r
-\r
-#define HidP_UnsetButtons(Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle) \\r
-        HidP_UnsetUsages(Rty, Up, Lco, ULi, ULe, Ppd, Rep, Rle)\r
-\r
-NTSTATUS __stdcall\r
-HidP_UnsetUsages (\r
-   IN       HIDP_REPORT_TYPE      ReportType,\r
-   IN       USAGE                 UsagePage,\r
-   IN       USHORT                LinkCollection, // Optional\r
-   IN       PUSAGE                UsageList,\r
-   IN OUT   PULONG                UsageLength,\r
-   IN       PHIDP_PREPARSED_DATA  PreparsedData,\r
-   IN OUT   PCHAR                 Report,\r
-   IN       ULONG                 ReportLength\r
-   );\r
-/*++\r
-\r
-Routine Description:\r
-    This function unsets (turns off) binary values (buttons) in the report.  Given\r
-    an initialized packet of correct length, it modifies the report packet so\r
-    that each element in the given list of usages has been unset in the\r
-    report packet.\r
-\r
-    This function is the "undo" operation for SetUsages.  If the given usage\r
-    is not already set in the Report, it will return an error code of\r
-    HIDP_STATUS_BUTTON_NOT_PRESSED.  If the button is pressed, HidP_UnsetUsages\r
-    will unset the appropriate bit or remove the corresponding index value from\r
-    the HID Main Array Item.\r
-\r
-    A properly initialized Report packet is one of the correct byte length,\r
-    and all zeros..\r
-\r
-    NOTE: A packet that has already been set with a call to a HidP_Set routine\r
-          can also be passed in.  This routine then processes the UsageList\r
-          in the same fashion but verifies that the ReportID already set in\r
-          Report matches the report ID for the given usages.\r
-\r
-Parameters:\r
-    ReportType  One of HidP_Input, HidP_Output or HidP_Feature.\r
-\r
-    UsagePage   All of the usages in the usage array, which HidP_UnsetUsages will\r
-                unset in the report, refer to this same usage page.\r
-                If a client wishes to unset usages in a report for multiple\r
-                usage pages then that client needs to make multiple calls to\r
-                HidP_UnsetUsages for each of the usage pages.\r
-\r
-    UsageList   A usage array containing the usages that HidP_UnsetUsages will\r
-                unset in the report packet.\r
-\r
-    UsageLength The length of the given usage array in array elements.\r
-                The parser will set this value to the position in the usage\r
-                array where it stopped processing.  If successful, UsageLength\r
-                will be unchanged.  In any error condition, this parameter\r
-                reflects how many of the usages in the usage list have\r
-                actually been unset by the parser.  This is useful for finding\r
-                the usage in the list which caused the error.\r
-\r
-    PreparsedData The preparsed data recevied from HIDCLASS\r
-\r
-    Report      The report packet.\r
-\r
-    ReportLength   Length of the given report packet...Must be equal to the\r
-                   value reported in the HIDP_CAPS structure for the device\r
-                   and corresponding report type.\r
-\r
-Return Value\r
-    HidP_UnsetUsages returns the following error codes.  On error, the report\r
-    packet will be correct up until the usage element that caused the error.\r
-\r
-· HIDP_STATUS_SUCCESS                -- upon successful "unsetting" of all usages\r
-                                        in the report packet.\r
-· HIDP_STATUS_INVALID_REPORT_TYPE    -- if ReportType is not valid.\r
-· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid\r
-· HIDP_STATUS_INVALID_REPORT_LENGTH  -- the length of the report packet is not\r
-                                        equal to the length specified in\r
-                                        the HIDP_CAPS structure for the given\r
-                                        ReportType\r
-· HIDP_STATUS_REPORT_DOES_NOT_EXIST  -- if there are no reports on this device\r
-                                        for the given ReportType\r
-· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- if a usage was found that exists in a\r
-                                        different report.  If the report is\r
-                                        zero-initialized on entry the first\r
-                                        usage in the list will determine which\r
-                                        report ID is used.  Otherwise, the\r
-                                        parser will verify that usage matches\r
-                                        the passed in report's ID\r
-· HIDP_STATUS_USAGE_NOT_FOUND        -- if the usage does not exist for any\r
-                                        report (no matter what the report ID)\r
-                                        for the given report type.\r
-· HIDP_STATUS_BUTTON_NOT_PRESSED     -- if a usage corresponds to a button that\r
-                                        is not already set in the given report\r
---*/\r
-\r
-#define HidP_GetButtons(Rty, UPa, LCo, ULi, ULe, Ppd, Rep, RLe) \\r
-        HidP_GetUsages(Rty, UPa, LCo, ULi, ULe, Ppd, Rep, RLe)\r
-\r
-NTSTATUS __stdcall\r
-HidP_GetUsages (\r
-   IN       HIDP_REPORT_TYPE     ReportType,\r
-   IN       USAGE                UsagePage,\r
-   IN       USHORT               LinkCollection, // Optional\r
-   OUT      USAGE *              UsageList,\r
-   IN OUT   ULONG *              UsageLength,\r
-   IN       PHIDP_PREPARSED_DATA PreparsedData,\r
-   IN       PCHAR                Report,\r
-   IN       ULONG                ReportLength\r
-   );\r
-/*++\r
-\r
-Routine Description:\r
-    This function returns the binary values (buttons) that are set in a HID\r
-    report.  Given a report packet of correct length, it searches the report\r
-    packet for each usage for the given usage page and returns them in the\r
-    usage list.\r
-\r
-Parameters:\r
-    ReportType One of HidP_Input, HidP_Output or HidP_Feature.\r
-\r
-    UsagePage  All of the usages in the usage list, which HidP_GetUsages will\r
-               retrieve in the report, refer to this same usage page.\r
-               If the client wishes to get usages in a packet for multiple\r
-               usage pages then that client needs to make multiple calls\r
-               to HidP_GetUsages.\r
-\r
-    LinkCollection  An optional value which can limit which usages are returned\r
-                    in the UsageList to those usages that exist in a specific\r
-                    LinkCollection.  A non-zero value indicates the index into\r
-                    the HIDP_LINK_COLLECITON_NODE list returned by\r
-                    HidP_GetLinkCollectionNodes of the link collection the\r
-                    usage should belong to.  A value of 0 indicates this\r
-                    should value be ignored.\r
-\r
-    UsageList  The usage array that will contain all the usages found in\r
-               the report packet.\r
-\r
-    UsageLength The length of the given usage array in array elements.\r
-                On input, this value describes the length of the usage list.\r
-                On output, HidP_GetUsages sets this value to the number of\r
-                usages that was found.  Use HidP_MaxUsageListLength to\r
-                determine the maximum length needed to return all the usages\r
-                that a given report packet may contain.\r
-\r
-    PreparsedData Preparsed data structure returned by HIDCLASS\r
-\r
-    Report       The report packet.\r
-\r
-    ReportLength  Length (in bytes) of the given report packet\r
-\r
-\r
-Return Value\r
-    HidP_GetUsages returns the following error codes:\r
-\r
-· HIDP_STATUS_SUCCESS                -- upon successfully retrieving all the\r
-                                        usages from the report packet\r
-· HIDP_STATUS_INVALID_REPORT_TYPE    -- if ReportType is not valid.\r
-· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid\r
-· HIDP_STATUS_INVALID_REPORT_LENGTH  -- the length of the report packet is not\r
-                                        equal to the length specified in\r
-                                        the HIDP_CAPS structure for the given\r
-                                        ReportType\r
-· HIDP_STATUS_REPORT_DOES_NOT_EXIST  -- if there are no reports on this device\r
-                                        for the given ReportType\r
-· HIDP_STATUS_BUFFER_TOO_SMALL       -- if the UsageList is not big enough to\r
-                                        hold all the usages found in the report\r
-                                        packet.  If this is returned, the buffer\r
-                                        will contain UsageLength number of\r
-                                        usages.  Use HidP_MaxUsageListLength to\r
-                                        find the maximum length needed\r
-· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- if no usages were found but usages\r
-                                        that match the UsagePage and\r
-                                        LinkCollection specified could be found\r
-                                        in a report with a different report ID\r
-· HIDP_STATUS_USAGE_NOT_FOUND        -- if there are no usages in a reports for\r
-                                        the device and ReportType that match the\r
-                                        UsagePage and LinkCollection that were\r
-                                        specified\r
---*/\r
-\r
-#define HidP_GetButtonsEx(Rty, LCo, BLi, ULe, Ppd, Rep, RLe)  \\r
-        HidP_GetUsagesEx(Rty, LCo, BLi, ULe, Ppd, Rep, RLe)\r
-\r
-NTSTATUS __stdcall\r
-HidP_GetUsagesEx (\r
-   IN       HIDP_REPORT_TYPE     ReportType,\r
-   IN       USHORT               LinkCollection, // Optional\r
-   OUT      PUSAGE_AND_PAGE      ButtonList,\r
-   IN OUT   ULONG *              UsageLength,\r
-   IN       PHIDP_PREPARSED_DATA PreparsedData,\r
-   IN       PCHAR                Report,\r
-   IN       ULONG                ReportLength\r
-   );\r
-\r
-/*++\r
-\r
-Routine Description:\r
-    This function returns the binary values (buttons) in a HID report.\r
-    Given a report packet of correct length, it searches the report packet\r
-    for all buttons and returns the UsagePage and Usage for each of the buttons\r
-    it finds.\r
-\r
-Parameters:\r
-    ReportType  One of HidP_Input, HidP_Output or HidP_Feature.\r
-\r
-    LinkCollection  An optional value which can limit which usages are returned\r
-                    in the ButtonList to those usages that exist in a specific\r
-                    LinkCollection.  A non-zero value indicates the index into\r
-                    the HIDP_LINK_COLLECITON_NODE list returned by\r
-                    HidP_GetLinkCollectionNodes of the link collection the\r
-                    usage should belong to.  A value of 0 indicates this\r
-                    should value be ignored.\r
-\r
-    ButtonList  An array of USAGE_AND_PAGE structures describing all the\r
-                buttons currently ``down'' in the device.\r
-\r
-    UsageLength The length of the given array in terms of elements.\r
-                On input, this value describes the length of the list.  On\r
-                output, HidP_GetUsagesEx sets this value to the number of\r
-                usages that were found.  Use HidP_MaxUsageListLength to\r
-                determine the maximum length needed to return all the usages\r
-                that a given report packet may contain.\r
-\r
-    PreparsedData Preparsed data returned by HIDCLASS\r
-\r
-    Report       The report packet.\r
-\r
-    ReportLength Length (in bytes) of the given report packet.\r
-\r
-\r
-Return Value\r
-    HidP_GetUsagesEx returns the following error codes:\r
-\r
-· HIDP_STATUS_SUCCESS                -- upon successfully retrieving all the\r
-                                        usages from the report packet\r
-· HIDP_STATUS_INVALID_REPORT_TYPE    -- if ReportType is not valid.\r
-· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid\r
-· HIDP_STATUS_INVALID_REPORT_LENGTH  -- the length of the report packet is not\r
-                                        equal to the length specified in\r
-                                        the HIDP_CAPS structure for the given\r
-                                        ReportType\r
-· HIDP_STATUS_REPORT_DOES_NOT_EXIST  -- if there are no reports on this device\r
-                                        for the given ReportType\r
-· HIDP_STATUS_BUFFER_TOO_SMALL       -- if ButtonList is not big enough to\r
-                                        hold all the usages found in the report\r
-                                        packet.  If this is returned, the buffer\r
-                                        will contain UsageLength number of\r
-                                        usages.  Use HidP_MaxUsageListLength to\r
-                                        find the maximum length needed\r
-· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- if no usages were found but usages\r
-                                        that match the specified LinkCollection\r
-                                        exist in report with a different report\r
-                                        ID.\r
-· HIDP_STATUS_USAGE_NOT_FOUND        -- if there are no usages in any reports that\r
-                                        match the LinkCollection parameter\r
---*/\r
-\r
-#define HidP_GetButtonListLength(RTy, UPa, Ppd) \\r
-        HidP_GetUsageListLength(Rty, UPa, Ppd)\r
-\r
-ULONG __stdcall\r
-HidP_MaxUsageListLength (\r
-   IN HIDP_REPORT_TYPE      ReportType,\r
-   IN USAGE                 UsagePage, // Optional\r
-   IN PHIDP_PREPARSED_DATA  PreparsedData\r
-   );\r
-/*++\r
-Routine Description:\r
-    This function returns the maximum number of usages that a call to\r
-    HidP_GetUsages or HidP_GetUsagesEx could return for a given HID report.\r
-    If calling for number of usages returned by HidP_GetUsagesEx, use 0 as\r
-    the UsagePage value.\r
-\r
-Parameters:\r
-    ReportType  One of HidP_Input, HidP_Output or HidP_Feature.\r
-\r
-    UsagePage   Specifies the optional UsagePage to query for.  If 0, will\r
-                return all the maximum number of usage values that could be\r
-                returned for a given ReportType.   If non-zero, will return\r
-                the maximum number of usages that would be returned for the\r
-                ReportType with the given UsagePage.\r
-\r
-    PreparsedData Preparsed data returned from HIDCLASS\r
-\r
-Return Value:\r
-    The length of the usage list array required for the HidP_GetUsages or\r
-    HidP_GetUsagesEx function call.  If an error occurs (such as\r
-    HIDP_STATUS_INVALID_REPORT_TYPE or HIDP_INVALID_PREPARSED_DATA, this\r
-    returns 0.\r
---*/\r
-\r
-NTSTATUS __stdcall\r
-HidP_SetUsageValue (\r
-   IN       HIDP_REPORT_TYPE     ReportType,\r
-   IN       USAGE                UsagePage,\r
-   IN       USHORT               LinkCollection, // Optional\r
-   IN       USAGE                Usage,\r
-   IN       ULONG                UsageValue,\r
-   IN       PHIDP_PREPARSED_DATA PreparsedData,\r
-   IN OUT   PCHAR                Report,\r
-   IN       ULONG                ReportLength\r
-   );\r
-/*++\r
-Description:\r
-    HidP_SetUsageValue inserts a value into the HID Report Packet in the field\r
-    corresponding to the given usage page and usage.  HidP_SetUsageValue\r
-    casts this value to the appropriate bit length.  If a report packet\r
-    contains two different fields with the same Usage and UsagePage,\r
-    they can be distinguished with the optional LinkCollection field value.\r
-    Using this function sets the raw value into the report packet with\r
-    no checking done as to whether it actually falls within the logical\r
-    minimum/logical maximum range.  Use HidP_SetScaledUsageValue for this...\r
-\r
-    NOTE: Although the UsageValue parameter is a ULONG, any casting that is\r
-          done will preserve or sign-extend the value.  The value being set\r
-          should be considered a LONG value and will be treated as such by\r
-          this function.\r
-\r
-Parameters:\r
-\r
-    ReportType  One of HidP_Output or HidP_Feature.\r
-\r
-    UsagePage   The usage page to which the given usage refers.\r
-\r
-    LinkCollection  (Optional)  This value can be used to differentiate\r
-                                between two fields that may have the same\r
-                                UsagePage and Usage but exist in different\r
-                                collections.  If the link collection value\r
-                                is zero, this function will set the first field\r
-                                it finds that matches the usage page and\r
-                                usage.\r
-\r
-    Usage       The usage whose value HidP_SetUsageValue will set.\r
-\r
-    UsageValue  The raw value to set in the report buffer.  This value must be within\r
-                the logical range or if a NULL value this value should be the\r
-                most negative value that can be represented by the number of bits\r
-                for this field.\r
-\r
-    PreparsedData The preparsed data returned for HIDCLASS\r
-\r
-    Report      The report packet.\r
-\r
-    ReportLength Length (in bytes) of the given report packet.\r
-\r
-\r
-Return Value:\r
-    HidP_SetUsageValue returns the following error codes:\r
-\r
-· HIDP_STATUS_SUCCESS                -- upon successfully setting the value\r
-                                        in the report packet\r
-· HIDP_STATUS_INVALID_REPORT_TYPE    -- if ReportType is not valid.\r
-· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid\r
-· HIDP_STATUS_INVALID_REPORT_LENGTH  -- the length of the report packet is not\r
-                                        equal to the length specified in\r
-                                        the HIDP_CAPS structure for the given\r
-                                        ReportType\r
-· HIDP_STATUS_REPORT_DOES_NOT_EXIST  -- if there are no reports on this device\r
-                                        for the given ReportType\r
-· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- the specified usage page, usage and\r
-                                        link collection exist but exists in\r
-                                        a report with a different report ID\r
-                                        than the report being passed in.  To\r
-                                        set this value, call HidP_SetUsageValue\r
-                                        again with a zero-initizialed report\r
-                                        packet\r
-· HIDP_STATUS_USAGE_NOT_FOUND        -- if the usage page, usage, and link\r
-                                        collection combination does not exist\r
-                                        in any reports for this ReportType\r
---*/\r
-\r
-NTSTATUS __stdcall\r
-HidP_SetScaledUsageValue (\r
-   IN       HIDP_REPORT_TYPE     ReportType,\r
-   IN       USAGE                UsagePage,\r
-   IN       USHORT               LinkCollection, // Optional\r
-   IN       USAGE                Usage,\r
-   IN       LONG                 UsageValue,\r
-   IN       PHIDP_PREPARSED_DATA PreparsedData,\r
-   IN OUT   PCHAR                Report,\r
-   IN       ULONG                ReportLength\r
-   );\r
-\r
-/*++\r
-Description:\r
-    HidP_SetScaledUsageValue inserts the UsageValue into the HID report packet\r
-    in the field corresponding to the given usage page and usage.  If a report\r
-    packet contains two different fields with the same Usage and UsagePage,\r
-    they can be distinguished with the optional LinkCollection field value.\r
-\r
-    If the specified field has a defined physical range, this function converts\r
-    the physical value specified to the corresponding logical value for the\r
-    report.  If a physical value does not exist, the function will verify that\r
-    the value specified falls within the logical range and set according.\r
-\r
-    If the range checking fails but the field has NULL values, the function will\r
-    set the field to the defined NULL value (most negative number possible) and\r
-    return HIDP_STATUS_NULL.  In other words, use this function to set NULL\r
-    values for a given field by passing in a value that falls outside the\r
-    physical range if it is defined or the logical range otherwise.\r
-\r
-    If the field does not support NULL values, an out of range error will be\r
-    returned instead.\r
-\r
-Parameters:\r
-\r
-    ReportType  One of HidP_Output or HidP_Feature.\r
-\r
-    UsagePage   The usage page to which the given usage refers.\r
-\r
-    LinkCollection  (Optional)  This value can be used to differentiate\r
-                                between two fields that may have the same\r
-                                UsagePage and Usage but exist in different\r
-                                collections.  If the link collection value\r
-                                is zero, this function will set the first field\r
-                                it finds that matches the usage page and\r
-                                usage.\r
-\r
-    Usage       The usage whose value HidP_SetScaledUsageValue will set.\r
-\r
-    UsageValue  The value to set in the report buffer.  See the routine\r
-                description above for the different interpretations of this\r
-                value\r
-\r
-    PreparsedData The preparsed data returned from HIDCLASS\r
-\r
-    Report      The report packet.\r
-\r
-    ReportLength Length (in bytes) of the given report packet.\r
-\r
-\r
-Return Value:\r
-   HidP_SetScaledUsageValue returns the following error codes:\r
-\r
-· HIDP_STATUS_SUCCESS                -- upon successfully setting the value\r
-                                        in the report packet\r
-· HIDP_STATUS_NULL                   -- upon successfully setting the value\r
-                                        in the report packet as a NULL value\r
-· HIDP_STATUS_INVALID_REPORT_TYPE    -- if ReportType is not valid.\r
-· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid\r
-· HIDP_STATUS_INVALID_REPORT_LENGTH  -- the length of the report packet is not\r
-                                        equal to the length specified in\r
-                                        the HIDP_CAPS structure for the given\r
-                                        ReportType\r
-· HIDP_STATUS_VALUE_OUT_OF_RANGE     -- if the value specified failed to fall\r
-                                        within the physical range if it exists\r
-                                        or within the logical range otherwise\r
-                                        and the field specified by the usage\r
-                                        does not allow NULL values\r
-· HIDP_STATUS_BAD_LOG_PHY_VALUES     -- if the field has a physical range but\r
-                                        either the logical range is invalid\r
-                                        (max <= min) or the physical range is\r
-                                        invalid\r
-· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- the specified usage page, usage and\r
-                                        link collection exist but exists in\r
-                                        a report with a different report ID\r
-                                        than the report being passed in.  To\r
-                                        set this value, call\r
-                                        HidP_SetScaledUsageValue again with\r
-                                        a zero-initialized report packet\r
-· HIDP_STATUS_USAGE_NOT_FOUND        -- if the usage page, usage, and link\r
-                                        collection combination does not exist\r
-                                        in any reports for this ReportType\r
---*/\r
-\r
-NTSTATUS __stdcall\r
-HidP_SetUsageValueArray (\r
-    IN    HIDP_REPORT_TYPE     ReportType,\r
-    IN    USAGE                UsagePage,\r
-    IN    USHORT               LinkCollection, // Optional\r
-    IN    USAGE                Usage,\r
-    IN    PCHAR                UsageValue,\r
-    IN    USHORT               UsageValueByteLength,\r
-    IN    PHIDP_PREPARSED_DATA PreparsedData,\r
-    OUT   PCHAR                Report,\r
-    IN    ULONG                ReportLength\r
-    );\r
-\r
-/*++\r
-Routine Descripton:\r
-    A usage value array occurs when the last usage in the list of usages\r
-    describing a main item must be repeated because there are less usages defined\r
-    than there are report counts declared for the given main item.  In this case\r
-    a single value cap is allocated for that usage and the report count of that\r
-    value cap is set to reflect the number of fields to which that usage refers.\r
-\r
-    HidP_SetUsageValueArray sets the raw bits for that usage which spans\r
-    more than one field in a report.\r
-\r
-    NOTE: This function currently does not support value arrays where the\r
-          ReportSize for each of the fields in the array is not a multiple\r
-          of 8 bits.\r
-\r
-          The UsageValue buffer should have the values set as they would appear\r
-          in the report buffer.  If this function supported non 8-bit multiples\r
-          for the ReportSize then caller should format the input buffer so that\r
-          each new value begins at the bit immediately following the last bit\r
-          of the previous value\r
-\r
-Parameters:\r
-\r
-    ReportType  One of HidP_Output or HidP_Feature.\r
-\r
-    UsagePage   The usage page to which the given usage refers.\r
-\r
-    LinkCollection  (Optional)  This value can be used to differentiate\r
-                                between two fields that may have the same\r
-                                UsagePage and Usage but exist in different\r
-                                collections.  If the link collection value\r
-                                is zero, this function will set the first field\r
-                                it finds that matches the usage page and\r
-                                usage.\r
-\r
-    Usage       The usage whose value array HidP_SetUsageValueArray will set.\r
-\r
-    UsageValue  The buffer with the values to set into the value array.\r
-                The number of BITS required is found by multiplying the\r
-                BitSize and ReportCount fields of the Value Cap for this\r
-                control.  The least significant bit of this control found in the\r
-                given report will be placed in the least significan bit location\r
-                of the array given (little-endian format), regardless of whether\r
-                or not the field is byte alligned or if the BitSize is a multiple\r
-                of sizeof (CHAR).\r
-\r
-                See the above note for current implementation limitations.\r
-\r
-    UsageValueByteLength  Length of the UsageValue buffer (in bytes)\r
-\r
-    PreparsedData The preparsed data returned from HIDCLASS\r
-\r
-    Report      The report packet.\r
-\r
-    ReportLength Length (in bytes) of the given report packet.\r
-\r
-\r
-Return Value:\r
-· HIDP_STATUS_SUCCESS                -- upon successfully setting the value\r
-                                        array in the report packet\r
-· HIDP_STATUS_INVALID_REPORT_TYPE    -- if ReportType is not valid.\r
-· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid\r
-· HIDP_STATUS_INVALID_REPORT_LENGTH  -- the length of the report packet is not\r
-                                        equal to the length specified in\r
-                                        the HIDP_CAPS structure for the given\r
-                                        ReportType\r
-· HIDP_STATUS_REPORT_DOES_NOT_EXIST  -- if there are no reports on this device\r
-                                        for the given ReportType\r
-· HIDP_STATUS_NOT_VALUE_ARRAY        -- if the control specified is not a\r
-                                        value array -- a value array will have\r
-                                        a ReportCount field in the\r
-                                        HIDP_VALUE_CAPS structure that is > 1\r
-                                        Use HidP_SetUsageValue instead\r
-· HIDP_STATUS_BUFFER_TOO_SMALL       -- if the size of the passed in buffer with\r
-                                        the values to set is too small (ie. has\r
-                                        fewer values than the number of fields in\r
-                                        the array\r
-· HIDP_STATUS_NOT_IMPLEMENTED        -- if the usage value array has field sizes\r
-                                        that are not multiples of 8 bits, this\r
-                                        error code is returned since the function\r
-                                        currently does not handle setting into\r
-                                        such arrays.\r
-· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- the specified usage page, usage and\r
-                                        link collection exist but exists in\r
-                                        a report with a different report ID\r
-                                        than the report being passed in.  To\r
-                                        set this value, call\r
-                                        HidP_SetUsageValueArray again with\r
-                                        a zero-initialized report packet\r
-· HIDP_STATUS_USAGE_NOT_FOUND        -- if the usage page, usage, and link\r
-                                        collection combination does not exist\r
-                                        in any reports for this ReportType\r
---*/\r
-\r
-\r
-NTSTATUS __stdcall\r
-HidP_GetUsageValue (\r
-   IN    HIDP_REPORT_TYPE     ReportType,\r
-   IN    USAGE                UsagePage,\r
-   IN    USHORT               LinkCollection, // Optional\r
-   IN    USAGE                Usage,\r
-   OUT   PULONG               UsageValue,\r
-   IN    PHIDP_PREPARSED_DATA PreparsedData,\r
-   IN    PCHAR                Report,\r
-   IN    ULONG                ReportLength\r
-   );\r
-\r
-/*\r
-Description\r
-    HidP_GetUsageValue retrieves the value from the HID Report for the usage\r
-    specified by the combination of usage page, usage and link collection.\r
-    If a report packet contains two different fields with the same\r
-    Usage and UsagePage, they can be distinguished with the optional\r
-    LinkCollection field value.\r
-\r
-Parameters:\r
-\r
-    ReportType  One of HidP_Input or HidP_Feature.\r
-\r
-    UsagePage   The usage page to which the given usage refers.\r
-\r
-    LinkCollection  (Optional)  This value can be used to differentiate\r
-                                between two fields that may have the same\r
-                                UsagePage and Usage but exist in different\r
-                                collections.  If the link collection value\r
-                                is zero, this function will set the first field\r
-                                it finds that matches the usage page and\r
-                                usage.\r
-\r
-    Usage       The usage whose value HidP_GetUsageValue will retrieve\r
-\r
-    UsageValue  The raw value that is set for the specified field in the report\r
-                buffer. This value will either fall within the logical range\r
-                or if NULL values are allowed, a number outside the range to\r
-                indicate a NULL\r
-\r
-    PreparsedData The preparsed data returned for HIDCLASS\r
-\r
-    Report      The report packet.\r
-\r
-    ReportLength Length (in bytes) of the given report packet.\r
-\r
-\r
-Return Value:\r
-    HidP_GetUsageValue returns the following error codes:\r
-\r
-· HIDP_STATUS_SUCCESS                -- upon successfully retrieving the value\r
-                                        from the report packet\r
-· HIDP_STATUS_INVALID_REPORT_TYPE    -- if ReportType is not valid.\r
-· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid\r
-· HIDP_STATUS_INVALID_REPORT_LENGTH  -- the length of the report packet is not\r
-                                        equal to the length specified in\r
-                                        the HIDP_CAPS structure for the given\r
-                                        ReportType\r
-· HIDP_STATUS_REPORT_DOES_NOT_EXIST  -- if there are no reports on this device\r
-                                        for the given ReportType\r
-· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- the specified usage page, usage and\r
-                                        link collection exist but exists in\r
-                                        a report with a different report ID\r
-                                        than the report being passed in.  To\r
-                                        set this value, call HidP_GetUsageValue\r
-                                        again with a different report packet\r
-· HIDP_STATUS_USAGE_NOT_FOUND        -- if the usage page, usage, and link\r
-                                        collection combination does not exist\r
-                                        in any reports for this ReportType\r
---*/\r
-\r
-\r
-NTSTATUS __stdcall\r
-HidP_GetScaledUsageValue (\r
-   IN    HIDP_REPORT_TYPE     ReportType,\r
-   IN    USAGE                UsagePage,\r
-   IN    USHORT               LinkCollection, // Optional\r
-   IN    USAGE                Usage,\r
-   OUT   PLONG                UsageValue,\r
-   IN    PHIDP_PREPARSED_DATA PreparsedData,\r
-   IN    PCHAR                Report,\r
-   IN    ULONG                ReportLength\r
-   );\r
-\r
-/*++\r
-Description\r
-    HidP_GetScaledUsageValue retrieves a UsageValue from the HID report packet\r
-    in the field corresponding to the given usage page and usage.  If a report\r
-    packet contains two different fields with the same Usage and UsagePage,\r
-    they can be distinguished with the optional LinkCollection field value.\r
-\r
-    If the specified field has a defined physical range, this function converts\r
-    the logical value that exists in the report packet to the corresponding\r
-    physical value.  If a physical range does not exist, the function will\r
-    return the logical value.  This function will check to verify that the\r
-    logical value in the report falls within the declared logical range.\r
-\r
-    When doing the conversion between logical and physical values, this\r
-    function assumes a linear extrapolation between the physical max/min and\r
-    the logical max/min. (Where logical is the values reported by the device\r
-    and physical is the value returned by this function).  If the data field\r
-    size is less than 32 bits, then HidP_GetScaledUsageValue will sign extend\r
-    the value to 32 bits.\r
-\r
-    If the range checking fails but the field has NULL values, the function\r
-    will set UsageValue to 0 and return HIDP_STATUS_NULL.  Otherwise, it\r
-    returns a HIDP_STATUS_OUT_OF_RANGE error.\r
-\r
-Parameters:\r
-\r
-    ReportType  One of HidP_Output or HidP_Feature.\r
-\r
-    UsagePage   The usage page to which the given usage refers.\r
-\r
-    LinkCollection  (Optional)  This value can be used to differentiate\r
-                                between two fields that may have the same\r
-                                UsagePage and Usage but exist in different\r
-                                collections.  If the link collection value\r
-                                is zero, this function will retrieve the first\r
-                                field it finds that matches the usage page\r
-                                and usage.\r
-\r
-    Usage       The usage whose value HidP_GetScaledUsageValue will retrieve\r
-\r
-    UsageValue  The value retrieved from the report buffer.  See the routine\r
-                description above for the different interpretations of this\r
-                value\r
-\r
-    PreparsedData The preparsed data returned from HIDCLASS\r
-\r
-    Report      The report packet.\r
-\r
-    ReportLength Length (in bytes) of the given report packet.\r
-\r
-\r
-Return Value:\r
-   HidP_GetScaledUsageValue returns the following error codes:\r
-\r
-· HIDP_STATUS_SUCCESS                -- upon successfully retrieving the value\r
-                                        from the report packet\r
-· HIDP_STATUS_NULL                   -- if the report packet had a NULL value\r
-                                        set\r
-· HIDP_STATUS_INVALID_REPORT_TYPE    -- if ReportType is not valid.\r
-· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid\r
-· HIDP_STATUS_INVALID_REPORT_LENGTH  -- the length of the report packet is not\r
-                                        equal to the length specified in\r
-                                        the HIDP_CAPS structure for the given\r
-                                        ReportType\r
-· HIDP_STATUS_VALUE_OUT_OF_RANGE     -- if the value retrieved from the packet\r
-                                        falls outside the logical range and\r
-                                        the field does not support NULL values\r
-· HIDP_STATUS_BAD_LOG_PHY_VALUES     -- if the field has a physical range but\r
-                                        either the logical range is invalid\r
-                                        (max <= min) or the physical range is\r
-                                        invalid\r
-· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- the specified usage page, usage and\r
-                                        link collection exist but exists in\r
-                                        a report with a different report ID\r
-                                        than the report being passed in.  To\r
-                                        set this value, call\r
-                                        HidP_GetScaledUsageValue with a\r
-                                        different report packet\r
-· HIDP_STATUS_USAGE_NOT_FOUND        -- if the usage page, usage, and link\r
-                                        collection combination does not exist\r
-                                        in any reports for this ReportType\r
---*/\r
-\r
-NTSTATUS __stdcall\r
-HidP_GetUsageValueArray (\r
-    IN    HIDP_REPORT_TYPE     ReportType,\r
-    IN    USAGE                UsagePage,\r
-    IN    USHORT               LinkCollection, // Optional\r
-    IN    USAGE                Usage,\r
-    OUT   PCHAR                UsageValue,\r
-    IN    USHORT               UsageValueByteLength,\r
-    IN    PHIDP_PREPARSED_DATA PreparsedData,\r
-    IN    PCHAR                Report,\r
-    IN    ULONG                ReportLength\r
-    );\r
-\r
-/*++\r
-Routine Descripton:\r
-    A usage value array occurs when the last usage in the list of usages\r
-    describing a main item must be repeated because there are less usages defined\r
-    than there are report counts declared for the given main item.  In this case\r
-    a single value cap is allocated for that usage and the report count of that\r
-    value cap is set to reflect the number of fields to which that usage refers.\r
-\r
-    HidP_GetUsageValueArray returns the raw bits for that usage which spans\r
-    more than one field in a report.\r
-\r
-    NOTE: This function currently does not support value arrays where the\r
-          ReportSize for each of the fields in the array is not a multiple\r
-          of 8 bits.\r
-\r
-          The UsageValue buffer will have the raw values as they are set\r
-          in the report packet.\r
-\r
-Parameters:\r
-\r
-    ReportType  One of HidP_Input, HidP_Output or HidP_Feature.\r
-\r
-    UsagePage   The usage page to which the given usage refers.\r
-\r
-    LinkCollection  (Optional)  This value can be used to differentiate\r
-                                between two fields that may have the same\r
-                                UsagePage and Usage but exist in different\r
-                                collections.  If the link collection value\r
-                                is zero, this function will set the first field\r
-                                it finds that matches the usage page and\r
-                                usage.\r
-\r
-   Usage       The usage whose value HidP_GetUsageValueArray will retreive.\r
-\r
-   UsageValue  A pointer to an array of characters where the value will be\r
-               placed.  The number of BITS required is found by multiplying the\r
-               BitSize and ReportCount fields of the Value Cap for this\r
-               control.  The least significant bit of this control found in the\r
-               given report will be placed in the least significant bit location\r
-               of the buffer (little-endian format), regardless of whether\r
-               or not the field is byte aligned or if the BitSize is a multiple\r
-               of sizeof (CHAR).\r
-\r
-               See note above about current implementation limitations\r
-\r
-   UsageValueByteLength\r
-               the length of the given UsageValue buffer.\r
-\r
-   PreparsedData The preparsed data returned by the HIDCLASS\r
-\r
-   Report      The report packet.\r
-\r
-   ReportLength   Length of the given report packet.\r
-\r
-Return Value:\r
-\r
-· HIDP_STATUS_SUCCESS                -- upon successfully retrieving the value\r
-                                        from the report packet\r
-· HIDP_STATUS_INVALID_REPORT_TYPE    -- if ReportType is not valid.\r
-· HIDP_STATUS_INVALID_PREPARSED_DATA -- if PreparsedData is not valid\r
-· HIDP_STATUS_INVALID_REPORT_LENGTH  -- the length of the report packet is not\r
-                                        equal to the length specified in\r
-                                        the HIDP_CAPS structure for the given\r
-                                        ReportType\r
-· HIDP_STATUS_NOT_VALUE_ARRAY        -- if the control specified is not a\r
-                                        value array -- a value array will have\r
-                                        a ReportCount field in the\r
-                                        HIDP_VALUE_CAPS structure that is > 1\r
-                                        Use HidP_GetUsageValue instead\r
-· HIDP_STATUS_BUFFER_TOO_SMALL       -- if the size of the passed in buffer in\r
-                                        which to return the array is too small\r
-                                        (ie. has fewer values than the number of\r
-                                        fields in the array\r
-· HIDP_STATUS_NOT_IMPLEMENTED        -- if the usage value array has field sizes\r
-                                        that are not multiples of 8 bits, this\r
-                                        error code is returned since the function\r
-                                        currently does not handle getting values\r
-                                        from such arrays.\r
-· HIDP_STATUS_INCOMPATIBLE_REPORT_ID -- the specified usage page, usage and\r
-                                        link collection exist but exists in\r
-                                        a report with a different report ID\r
-                                        than the report being passed in.  To\r
-                                        set this value, call\r
-                                        HidP_GetUsageValueArray with a\r
-                                        different report packet\r
-· HIDP_STATUS_USAGE_NOT_FOUND        -- if the usage page, usage, and link\r
-                                        collection combination does not exist\r
-                                        in any reports for this ReportType\r
---*/\r
-\r
-NTSTATUS __stdcall\r
-HidP_UsageListDifference (\r
-    IN    PUSAGE   PreviousUsageList,\r
-    IN    PUSAGE   CurrentUsageList,\r
-    OUT   PUSAGE   BreakUsageList,\r
-    OUT   PUSAGE   MakeUsageList,\r
-    IN    ULONG    UsageListLength\r
-    );\r
-/*++\r
-Routine Description:\r
-    This function will return the difference between a two lists of usages\r
-    (as might be returned from HidP_GetUsages),  In other words, it will return\r
-    return a list of usages that are in the current list but not the previous\r
-    list as well as a list of usages that are in the previous list but not\r
-    the current list.\r
-\r
-Parameters:\r
-\r
-    PreviousUsageList   The list of usages before.\r
-    CurrentUsageList    The list of usages now.\r
-    BreakUsageList      Previous - Current.\r
-    MakeUsageList       Current - Previous.\r
-    UsageListLength     Represents the length of the usage lists in array\r
-                        elements.  If comparing two lists with a differing\r
-                        number of array elements, this value should be\r
-                        the size of the larger of the two lists.  Any\r
-                        zero found with a list indicates an early termination\r
-                        of the list and any usages found after the first zero\r
-                        will be ignored.\r
---*/\r
-\r
-NTSTATUS __stdcall\r
-HidP_UsageAndPageListDifference (\r
-   IN    PUSAGE_AND_PAGE PreviousUsageList,\r
-   IN    PUSAGE_AND_PAGE CurrentUsageList,\r
-   OUT   PUSAGE_AND_PAGE BreakUsageList,\r
-   OUT   PUSAGE_AND_PAGE MakeUsageList,\r
-   IN    ULONG           UsageListLength\r
-   );\r
-\r
-//\r
-// Produce Make or Break Codes\r
-//\r
-typedef enum _HIDP_KEYBOARD_DIRECTION {\r
-    HidP_Keyboard_Break,\r
-    HidP_Keyboard_Make\r
-} HIDP_KEYBOARD_DIRECTION;\r
-\r
-//\r
-// A bitmap of the current shift state of the keyboard when using the\r
-// below keyboard usages to i8042 translation function.\r
-//\r
-typedef struct _HIDP_KEYBOARD_MODIFIER_STATE {\r
-   union {\r
-      struct {\r
-         ULONG LeftControl: 1;\r
-         ULONG LeftShift: 1;\r
-         ULONG LeftAlt: 1;\r
-         ULONG LeftGUI: 1;\r
-         ULONG RightControl: 1;\r
-         ULONG RightShift: 1;\r
-         ULONG RightAlt: 1;\r
-         ULONG RigthGUI: 1;\r
-         ULONG CapsLock: 1;\r
-         ULONG ScollLock: 1;\r
-         ULONG NumLock: 1;\r
-         ULONG Reserved: 21;\r
-      };\r
-      ULONG ul;\r
-   };\r
-\r
-} HIDP_KEYBOARD_MODIFIER_STATE, * PHIDP_KEYBOARD_MODIFIER_STATE;\r
-\r
-//\r
-// A call back function to give the i8042 scan codes to the caller of\r
-// the below translation function.\r
-//\r
-typedef BOOLEAN (* PHIDP_INSERT_SCANCODES) (\r
-                  IN PVOID Context,  // Some caller supplied context.\r
-                  IN PCHAR NewScanCodes, // A list of i8042 scan codes.\r
-                  IN ULONG Length // the length of the scan codes.\r
-                  );\r
-\r
-NTSTATUS __stdcall\r
-HidP_TranslateUsageAndPagesToI8042ScanCodes (\r
-    IN     PUSAGE_AND_PAGE               ChangedUsageList,\r
-    IN     ULONG                         UsageListLength,\r
-    IN     HIDP_KEYBOARD_DIRECTION       KeyAction,\r
-    IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,\r
-    IN     PHIDP_INSERT_SCANCODES        InsertCodesProcedure,\r
-    IN     PVOID                         InsertCodesContext\r
-    );\r
-/*++\r
-Routine Description:\r
-Parameters:\r
---*/\r
-\r
-NTSTATUS __stdcall\r
-HidP_TranslateUsagesToI8042ScanCodes (\r
-    IN     PUSAGE                        ChangedUsageList,\r
-    IN     ULONG                         UsageListLength,\r
-    IN     HIDP_KEYBOARD_DIRECTION       KeyAction,\r
-    IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,\r
-    IN     PHIDP_INSERT_SCANCODES        InsertCodesProcedure,\r
-    IN     PVOID                         InsertCodesContext\r
-    );\r
-/*++\r
-Routine Description:\r
-Parameters:\r
---*/\r
-\r
-\r
-\r
-//\r
-// Define NT Status codes with Facility Code of FACILITY_HID_ERROR_CODE\r
-//\r
-\r
-// FACILITY_HID_ERROR_CODE defined in ntstatus.h\r
-#ifndef FACILITY_HID_ERROR_CODE\r
-#define FACILITY_HID_ERROR_CODE 0x11\r
-#endif\r
-\r
-#define HIDP_ERROR_CODES(SEV, CODE) \\r
-        ((NTSTATUS) (((SEV) << 28) | (FACILITY_HID_ERROR_CODE << 16) | (CODE)))\r
-\r
-#define HIDP_STATUS_SUCCESS                  (HIDP_ERROR_CODES(0x0,0))\r
-#define HIDP_STATUS_NULL                     (HIDP_ERROR_CODES(0x8,1))\r
-#define HIDP_STATUS_INVALID_PREPARSED_DATA   (HIDP_ERROR_CODES(0xC,1))\r
-#define HIDP_STATUS_INVALID_REPORT_TYPE      (HIDP_ERROR_CODES(0xC,2))\r
-#define HIDP_STATUS_INVALID_REPORT_LENGTH    (HIDP_ERROR_CODES(0xC,3))\r
-#define HIDP_STATUS_USAGE_NOT_FOUND          (HIDP_ERROR_CODES(0xC,4))\r
-#define HIDP_STATUS_VALUE_OUT_OF_RANGE       (HIDP_ERROR_CODES(0xC,5))\r
-#define HIDP_STATUS_BAD_LOG_PHY_VALUES       (HIDP_ERROR_CODES(0xC,6))\r
-#define HIDP_STATUS_BUFFER_TOO_SMALL         (HIDP_ERROR_CODES(0xC,7))\r
-#define HIDP_STATUS_INTERNAL_ERROR           (HIDP_ERROR_CODES(0xC,8))\r
-#define HIDP_STATUS_I8042_TRANS_UNKNOWN      (HIDP_ERROR_CODES(0xC,9))\r
-#define HIDP_STATUS_INCOMPATIBLE_REPORT_ID   (HIDP_ERROR_CODES(0xC,0xA))\r
-#define HIDP_STATUS_NOT_VALUE_ARRAY          (HIDP_ERROR_CODES(0xC,0xB))\r
-#define HIDP_STATUS_IS_VALUE_ARRAY           (HIDP_ERROR_CODES(0xC,0xC))\r
-#define HIDP_STATUS_DATA_INDEX_NOT_FOUND     (HIDP_ERROR_CODES(0xC,0xD))\r
-#define HIDP_STATUS_DATA_INDEX_OUT_OF_RANGE  (HIDP_ERROR_CODES(0xC,0xE))\r
-#define HIDP_STATUS_BUTTON_NOT_PRESSED       (HIDP_ERROR_CODES(0xC,0xF))\r
-#define HIDP_STATUS_REPORT_DOES_NOT_EXIST    (HIDP_ERROR_CODES(0xC,0x10))\r
-#define HIDP_STATUS_NOT_IMPLEMENTED          (HIDP_ERROR_CODES(0xC,0x20))\r
-\r
-//\r
-// We blundered this status code.\r
-//\r
-#define HIDP_STATUS_I8242_TRANS_UNKNOWN HIDP_STATUS_I8042_TRANS_UNKNOWN\r
-\r
-#include <poppack.h>\r
-\r
-#endif\r
diff --git a/client/include/hidsdi.h b/client/include/hidsdi.h
deleted file mode 100644 (file)
index 08a19e8..0000000
+++ /dev/null
@@ -1,412 +0,0 @@
-/*++\r
-\r
-Copyright (c) 1996    Microsoft Corporation\r
-\r
-Module Name:\r
-\r
-    HIDSDI.H\r
-\r
-Abstract:\r
-\r
-    This module contains the PUBLIC definitions for the\r
-    code that implements the HID dll.\r
-\r
-Environment:\r
-\r
-    Kernel & user mode\r
-\r
---*/\r
-\r
-\r
-#ifndef _HIDSDI_H\r
-#define _HIDSDI_H\r
-\r
-#include <pshpack4.h>\r
-\r
-//#include "wtypes.h"\r
-\r
-//#include <windef.h>\r
-//#include <win32.h>\r
-//#include <basetyps.h>\r
-\r
-//typedef LONG NTSTATUS;\r
-#include "hidusage.h"\r
-#include "hidpi.h"\r
-\r
-typedef struct _HIDD_CONFIGURATION {\r
-    PVOID    cookie;\r
-    ULONG    size;\r
-    ULONG    RingBufferSize;\r
-} HIDD_CONFIGURATION, *PHIDD_CONFIGURATION;\r
-\r
-typedef struct _HIDD_ATTRIBUTES {\r
-    ULONG   Size; // = sizeof (struct _HIDD_ATTRIBUTES)\r
-\r
-    //\r
-    // Vendor ids of this hid device\r
-    //\r
-    USHORT  VendorID;\r
-    USHORT  ProductID;\r
-    USHORT  VersionNumber;\r
-\r
-    //\r
-    // Additional fields will be added to the end of this structure.\r
-    //\r
-} HIDD_ATTRIBUTES, *PHIDD_ATTRIBUTES;\r
-\r
-\r
-BOOLEAN __stdcall\r
-HidD_GetAttributes (\r
-    IN  HANDLE              HidDeviceObject,\r
-    OUT PHIDD_ATTRIBUTES    Attributes\r
-    );\r
-/*++\r
-Routine Description:\r
-    Fill in the given HIDD_ATTRIBUTES structure with the attributes of the\r
-    given hid device.\r
-\r
---*/\r
-\r
-\r
-void __stdcall\r
-HidD_GetHidGuid (\r
-   OUT   LPGUID   HidGuid\r
-   );\r
-\r
-BOOLEAN __stdcall\r
-HidD_GetPreparsedData (\r
-   IN    HANDLE                  HidDeviceObject,\r
-   OUT   PHIDP_PREPARSED_DATA  * PreparsedData\r
-   );\r
-/*++\r
-Routine Description:\r
-    Given a handle to a valid Hid Class Device Object, retrieve the preparsed\r
-    data for the device.  This routine will allocate the appropriately \r
-    sized buffer to hold this preparsed data.  It is up to client to call\r
-    HidP_FreePreparsedData to free the memory allocated to this structure when\r
-    it is no longer needed.\r
-\r
-Arguments:\r
-   HidDeviceObject A handle to a Hid Device that the client obtains using \r
-                   a call to CreateFile on a valid Hid device string name.\r
-                   The string name can be obtained using standard PnP calls.\r
-\r
-   PreparsedData   An opaque data structure used by other functions in this \r
-                   library to retrieve information about a given device.\r
-\r
-Return Value:\r
-   TRUE if successful.\r
-   FALSE otherwise  -- Use GetLastError() to get extended error information\r
---*/\r
-\r
-BOOLEAN __stdcall\r
-HidD_FreePreparsedData (\r
-   IN    PHIDP_PREPARSED_DATA PreparsedData\r
-   );\r
-\r
-BOOLEAN __stdcall\r
-HidD_FlushQueue (\r
-   IN    HANDLE                HidDeviceObject\r
-   );\r
-/*++\r
-Routine Description:\r
-    Flush the input queue for the given HID device.\r
-\r
-Arguments:\r
-   HidDeviceObject A handle to a Hid Device that the client obtains using \r
-                   a call to CreateFile on a valid Hid device string name.\r
-                   The string name can be obtained using standard PnP calls.\r
-\r
-Return Value:\r
-   TRUE if successful\r
-   FALSE otherwise  -- Use GetLastError() to get extended error information\r
---*/\r
-\r
-BOOLEAN __stdcall\r
-HidD_GetConfiguration (\r
-   IN   HANDLE               HidDeviceObject,\r
-   OUT  PHIDD_CONFIGURATION  Configuration,\r
-   IN   ULONG                ConfigurationLength\r
-   );\r
-/*++\r
-Routine Description:\r
-    Get the configuration information for this Hid device\r
-\r
-Arguments:\r
-   HidDeviceObject      A handle to a Hid Device Object.\r
-\r
-   Configuration        A configuration structure.  HidD_GetConfiguration MUST\r
-                        be called before the configuration can be modified and\r
-                        set using HidD_SetConfiguration\r
-\r
-   ConfigurationLength  That is ``sizeof (HIDD_CONFIGURATION)''. Using this\r
-                        parameter, we can later increase the length of the \r
-                        configuration array and not break older apps.\r
-\r
-Return Value:\r
-   TRUE if successful\r
-   FALSE otherwise  -- Use GetLastError() to get extended error information\r
---*/\r
-\r
-BOOLEAN __stdcall\r
-HidD_SetConfiguration (\r
-   IN   HANDLE               HidDeviceObject,\r
-   IN   PHIDD_CONFIGURATION  Configuration,\r
-   IN   ULONG                ConfigurationLength\r
-   );\r
-/*++\r
-Routine Description:\r
-   Set the configuration information for this Hid device...\r
-   \r
-   NOTE: HidD_GetConfiguration must be called to retrieve the current \r
-         configuration information before this information can be modified \r
-         and set.\r
-\r
-Arguments:\r
-    HidDeviceObject      A handle to a Hid Device Object.\r
\r
-    Configuration        A configuration structure.  HidD_GetConfiguration MUST\r
-                         be called before the configuration can be modified and\r
-                         set using HidD_SetConfiguration\r
\r
-    ConfigurationLength  That is ``sizeof (HIDD_CONFIGURATION)''. Using this\r
-                         parameter, we can later increase the length of the \r
-                         configuration array and not break older apps.\r
-\r
-Return Value:\r
-    TRUE if successful\r
-    FALSE otherwise  -- Use GetLastError() to get extended error information\r
---*/\r
-\r
-BOOLEAN __stdcall\r
-HidD_GetFeature (\r
-   IN    HANDLE   HidDeviceObject,\r
-   OUT   PVOID    ReportBuffer,\r
-   IN    ULONG    ReportBufferLength\r
-   );\r
-/*++\r
-Routine Description:\r
-    Retrieve a feature report from a HID device.\r
-\r
-Arguments:\r
-    HidDeviceObject      A handle to a Hid Device Object.\r
\r
-    ReportBuffer         The buffer that the feature report should be placed \r
-                         into.  The first byte of the buffer should be set to\r
-                         the report ID of the desired report\r
\r
-    ReportBufferLength   The size (in bytes) of ReportBuffer.  This value \r
-                         should be greater than or equal to the \r
-                         FeatureReportByteLength field as specified in the \r
-                         HIDP_CAPS structure for the device\r
-Return Value:\r
-    TRUE if successful\r
-    FALSE otherwise  -- Use GetLastError() to get extended error information\r
---*/\r
-\r
-BOOLEAN __stdcall\r
-HidD_SetFeature (\r
-   IN    HANDLE   HidDeviceObject,\r
-   IN    PVOID    ReportBuffer,\r
-   IN    ULONG    ReportBufferLength\r
-   );\r
-/*++\r
-Routine Description:\r
-    Send a feature report to a HID device.\r
-\r
-Arguments:\r
-    HidDeviceObject      A handle to a Hid Device Object.\r
\r
-    ReportBuffer         The buffer of the feature report to send to the device\r
\r
-    ReportBufferLength   The size (in bytes) of ReportBuffer.  This value \r
-                         should be greater than or equal to the \r
-                         FeatureReportByteLength field as specified in the \r
-                         HIDP_CAPS structure for the device\r
-Return Value:\r
-    TRUE if successful\r
-    FALSE otherwise  -- Use GetLastError() to get extended error information\r
---*/\r
-\r
-BOOLEAN __stdcall\r
-HidD_GetNumInputBuffers (\r
-    IN  HANDLE  HidDeviceObject,\r
-    OUT PULONG  NumberBuffers\r
-    );\r
-/*++\r
-Routine Description:\r
-    This function returns the number of input buffers used by the specified\r
-    file handle to the Hid device.  Each file object has a number of buffers\r
-    associated with it to queue reports read from the device but which have\r
-    not yet been read by the user-mode app with a handle to that device.\r
-\r
-Arguments:\r
-    HidDeviceObject      A handle to a Hid Device Object.\r
\r
-    NumberBuffers        Number of buffers currently being used for this file\r
-                         handle to the Hid device\r
-\r
-Return Value:\r
-    TRUE if successful\r
-    FALSE otherwise  -- Use GetLastError() to get extended error information\r
---*/\r
-\r
-BOOLEAN __stdcall\r
-HidD_SetNumInputBuffers (\r
-    IN  HANDLE HidDeviceObject,\r
-    OUT ULONG  NumberBuffers\r
-    );\r
-/*++\r
-\r
-Routine Description:\r
-    This function sets the number of input buffers used by the specified\r
-    file handle to the Hid device.  Each file object has a number of buffers\r
-    associated with it to queue reports read from the device but which have\r
-    not yet been read by the user-mode app with a handle to that device.\r
-\r
-Arguments:\r
-    HidDeviceObject      A handle to a Hid Device Object.\r
\r
-    NumberBuffers        New number of buffers to use for this file handle to\r
-                         the Hid device\r
-\r
-Return Value:\r
-    TRUE if successful\r
-    FALSE otherwise  -- Use GetLastError() to get extended error information\r
---*/\r
-\r
-BOOLEAN __stdcall\r
-HidD_GetPhysicalDescriptor (\r
-   IN    HANDLE   HidDeviceObject,\r
-   OUT   PVOID    Buffer,\r
-   IN    ULONG    BufferLength\r
-   );\r
-/*++\r
-Routine Description:\r
-    This function retrieves the raw physical descriptor for the specified\r
-    Hid device.  \r
-\r
-Arguments:\r
-    HidDeviceObject      A handle to a Hid Device Object.\r
\r
-    Buffer               Buffer which on return will contain the physical\r
-                         descriptor if one exists for the specified device\r
-                         handle\r
-\r
-    BufferLength         Length of buffer (in bytes)\r
-\r
-\r
-Return Value:\r
-    TRUE if successful\r
-    FALSE otherwise  -- Use GetLastError() to get extended error information\r
---*/\r
-\r
-BOOLEAN __stdcall\r
-HidD_GetManufacturerString (\r
-   IN    HANDLE   HidDeviceObject,\r
-   OUT   PVOID    Buffer,\r
-   IN    ULONG    BufferLength\r
-   );\r
-/*++\r
-Routine Description:\r
-    This function retrieves the manufacturer string from the specified \r
-    Hid device.  \r
-\r
-Arguments:\r
-    HidDeviceObject      A handle to a Hid Device Object.\r
\r
-    Buffer               Buffer which on return will contain the manufacturer\r
-                         string returned from the device.  This string is a \r
-                         wide-character string\r
-\r
-    BufferLength         Length of Buffer (in bytes)\r
-\r
-\r
-Return Value:\r
-    TRUE if successful\r
-    FALSE otherwise  -- Use GetLastError() to get extended error information\r
---*/\r
-\r
-BOOLEAN __stdcall\r
-HidD_GetProductString (\r
-   IN    HANDLE   HidDeviceObject,\r
-   OUT   PVOID    Buffer,\r
-   IN    ULONG    BufferLength\r
-   );\r
-/*++\r
-Routine Description:\r
-    This function retrieves the product string from the specified \r
-    Hid device.  \r
-\r
-Arguments:\r
-    HidDeviceObject      A handle to a Hid Device Object.\r
\r
-    Buffer               Buffer which on return will contain the product\r
-                         string returned from the device.  This string is a \r
-                         wide-character string\r
-\r
-    BufferLength         Length of Buffer (in bytes)\r
-\r
-\r
-Return Value:\r
-    TRUE if successful\r
-    FALSE otherwise  -- Use GetLastError() to get extended error information\r
---*/\r
-\r
-BOOLEAN __stdcall\r
-HidD_GetIndexedString (\r
-   IN    HANDLE   HidDeviceObject,\r
-   IN    ULONG    StringIndex,\r
-   OUT   PVOID    Buffer,\r
-   IN    ULONG    BufferLength\r
-   );\r
-/*++\r
-Routine Description:\r
-    This function retrieves a string from the specified Hid device that is\r
-    specified with a certain string index.\r
-\r
-Arguments:\r
-    HidDeviceObject      A handle to a Hid Device Object.\r
\r
-    StringIndex          Index of the string to retrieve\r
-\r
-    Buffer               Buffer which on return will contain the product\r
-                         string returned from the device.  This string is a \r
-                         wide-character string\r
-\r
-    BufferLength         Length of Buffer (in bytes)\r
-\r
-Return Value:\r
-    TRUE if successful\r
-    FALSE otherwise  -- Use GetLastError() to get extended error information\r
---*/\r
-\r
-BOOLEAN __stdcall\r
-HidD_GetSerialNumberString (\r
-   IN    HANDLE   HidDeviceObject,\r
-   OUT   PVOID    Buffer,\r
-   IN    ULONG    BufferLength\r
-   );\r
-/*++\r
-Routine Description:\r
-    This function retrieves the serial number string from the specified \r
-    Hid device.  \r
-\r
-Arguments:\r
-    HidDeviceObject      A handle to a Hid Device Object.\r
\r
-    Buffer               Buffer which on return will contain the serial number\r
-                         string returned from the device.  This string is a \r
-                         wide-character string\r
-\r
-    BufferLength         Length of Buffer (in bytes)\r
-\r
-Return Value:\r
-    TRUE if successful\r
-    FALSE otherwise  -- Use GetLastError() to get extended error information\r
---*/\r
-\r
-\r
-#include <poppack.h>\r
-\r
-#endif\r
diff --git a/client/include/hidusage.h b/client/include/hidusage.h
deleted file mode 100644 (file)
index 4ea9dd1..0000000
+++ /dev/null
@@ -1,263 +0,0 @@
-/*++\r
-\r
-Copyright (c) 1996, 1997      Microsoft Corporation\r
-\r
-Module Name:\r
-\r
-        HIDUSAGE.H\r
-\r
-Abstract:\r
-\r
-   Public Definitions of HID USAGES.\r
-\r
-Environment:\r
-\r
-    Kernel & user mode\r
-\r
---*/\r
-\r
-#ifndef   __HIDUSAGE_H__\r
-#define   __HIDUSAGE_H__\r
-\r
-//\r
-// Usage Pages\r
-//\r
-\r
-typedef USHORT USAGE, *PUSAGE;\r
-\r
-#define HID_USAGE_PAGE_GENERIC        ((USAGE) 0x01)\r
-#define HID_USAGE_PAGE_SIMULATION     ((USAGE) 0x02)\r
-#define HID_USAGE_PAGE_VR             ((USAGE) 0x03)\r
-#define HID_USAGE_PAGE_SPORT          ((USAGE) 0x04)\r
-#define HID_USAGE_PAGE_GAME           ((USAGE) 0x05)\r
-#define HID_USAGE_PAGE_KEYBOARD       ((USAGE) 0x07)\r
-#define HID_USAGE_PAGE_LED            ((USAGE) 0x08)\r
-#define HID_USAGE_PAGE_BUTTON         ((USAGE) 0x09)\r
-#define HID_USAGE_PAGE_ORDINAL        ((USAGE) 0x0A)\r
-#define HID_USAGE_PAGE_TELEPHONY      ((USAGE) 0x0B)\r
-#define HID_USAGE_PAGE_CONSUMER       ((USAGE) 0x0C)\r
-#define HID_USAGE_PAGE_DIGITIZER      ((USAGE) 0x0D)\r
-#define HID_USAGE_PAGE_UNICODE        ((USAGE) 0x10)\r
-#define HID_USAGE_PAGE_ALPHANUMERIC   ((USAGE) 0x14)\r
-\r
-\r
-//\r
-// Usages from Generic Desktop Page (0x01)\r
-//\r
-\r
-#define HID_USAGE_GENERIC_POINTER      ((USAGE) 0x01)\r
-#define HID_USAGE_GENERIC_MOUSE        ((USAGE) 0x02)\r
-#define HID_USAGE_GENERIC_JOYSTICK     ((USAGE) 0x04)\r
-#define HID_USAGE_GENERIC_GAMEPAD      ((USAGE) 0x05)\r
-#define HID_USAGE_GENERIC_KEYBOARD     ((USAGE) 0x06)\r
-#define HID_USAGE_GENERIC_KEYPAD       ((USAGE) 0x07)\r
-#define HID_USAGE_GENERIC_SYSTEM_CTL   ((USAGE) 0x80)\r
-\r
-#define HID_USAGE_GENERIC_X                        ((USAGE) 0x30)\r
-#define HID_USAGE_GENERIC_Y                        ((USAGE) 0x31)\r
-#define HID_USAGE_GENERIC_Z                        ((USAGE) 0x32)\r
-#define HID_USAGE_GENERIC_RX                       ((USAGE) 0x33)\r
-#define HID_USAGE_GENERIC_RY                       ((USAGE) 0x34)\r
-#define HID_USAGE_GENERIC_RZ                       ((USAGE) 0x35)\r
-#define HID_USAGE_GENERIC_SLIDER                   ((USAGE) 0x36)\r
-#define HID_USAGE_GENERIC_DIAL                     ((USAGE) 0x37)\r
-#define HID_USAGE_GENERIC_WHEEL                    ((USAGE) 0x38)\r
-#define HID_USAGE_GENERIC_HATSWITCH                ((USAGE) 0x39)\r
-#define HID_USAGE_GENERIC_COUNTED_BUFFER           ((USAGE) 0x3A)\r
-#define HID_USAGE_GENERIC_BYTE_COUNT               ((USAGE) 0x3B)\r
-#define HID_USAGE_GENERIC_MOTION_WAKEUP            ((USAGE) 0x3C)\r
-#define HID_USAGE_GENERIC_VX                       ((USAGE) 0x40)\r
-#define HID_USAGE_GENERIC_VY                       ((USAGE) 0x41)\r
-#define HID_USAGE_GENERIC_VZ                       ((USAGE) 0x42)\r
-#define HID_USAGE_GENERIC_VBRX                     ((USAGE) 0x43)\r
-#define HID_USAGE_GENERIC_VBRY                     ((USAGE) 0x44)\r
-#define HID_USAGE_GENERIC_VBRZ                     ((USAGE) 0x45)\r
-#define HID_USAGE_GENERIC_VNO                      ((USAGE) 0x46)\r
-#define HID_USAGE_GENERIC_SYSCTL_POWER             ((USAGE) 0x81)\r
-#define HID_USAGE_GENERIC_SYSCTL_SLEEP             ((USAGE) 0x82)\r
-#define HID_USAGE_GENERIC_SYSCTL_WAKE              ((USAGE) 0x83)\r
-#define HID_USAGE_GENERIC_SYSCTL_CONTEXT_MENU      ((USAGE) 0x84)\r
-#define HID_USAGE_GENERIC_SYSCTL_MAIN_MENU         ((USAGE) 0x85)\r
-#define HID_USAGE_GENERIC_SYSCTL_APP_MENU          ((USAGE) 0x86)\r
-#define HID_USAGE_GENERIC_SYSCTL_HELP_MENU         ((USAGE) 0x87)\r
-#define HID_USAGE_GENERIC_SYSCTL_MENU_EXIT         ((USAGE) 0x88)\r
-#define HID_USAGE_GENERIC_SYSCTL_MENU_SELECT       ((USAGE) 0x89)\r
-#define HID_USAGE_GENERIC_SYSCTL_MENU_RIGHT        ((USAGE) 0x8A)\r
-#define HID_USAGE_GENERIC_SYSCTL_MENU_LEFT         ((USAGE) 0x8B)\r
-#define HID_USAGE_GENERIC_SYSCTL_MENU_UP           ((USAGE) 0x8C)\r
-#define HID_USAGE_GENERIC_SYSCTL_MENU_DOWN         ((USAGE) 0x8D)\r
-\r
-//\r
-// Usages from Simulation Controls Page (0x02)\r
-//\r
-\r
-#define HID_USAGE_SIMULATION_RUDDER                ((USAGE) 0xBA)\r
-#define HID_USAGE_SIMULATION_THROTTLE              ((USAGE) 0xBB)\r
-\r
-//\r
-// Virtual Reality Controls Page (0x03)\r
-//\r
-\r
-\r
-//\r
-// Sport Controls Page (0x04)\r
-//\r
-\r
-\r
-//\r
-// Game Controls Page (0x05)\r
-//\r
-\r
-\r
-//\r
-// Keyboard/Keypad Page (0x07)\r
-//\r
-\r
-        // Error "keys"\r
-#define HID_USAGE_KEYBOARD_NOEVENT     ((USAGE) 0x00)\r
-#define HID_USAGE_KEYBOARD_ROLLOVER    ((USAGE) 0x01)\r
-#define HID_USAGE_KEYBOARD_POSTFAIL    ((USAGE) 0x02)\r
-#define HID_USAGE_KEYBOARD_UNDEFINED   ((USAGE) 0x03)\r
-\r
-        // Letters\r
-#define HID_USAGE_KEYBOARD_aA          ((USAGE) 0x04)\r
-#define HID_USAGE_KEYBOARD_zZ          ((USAGE) 0x1D)\r
-        // Numbers\r
-#define HID_USAGE_KEYBOARD_ONE         ((USAGE) 0x1E)\r
-#define HID_USAGE_KEYBOARD_ZERO        ((USAGE) 0x27)\r
-        // Modifier Keys\r
-#define HID_USAGE_KEYBOARD_LCTRL       ((USAGE) 0xE0)\r
-#define HID_USAGE_KEYBOARD_LSHFT       ((USAGE) 0xE1)\r
-#define HID_USAGE_KEYBOARD_LALT        ((USAGE) 0xE2)\r
-#define HID_USAGE_KEYBOARD_LGUI        ((USAGE) 0xE3)\r
-#define HID_USAGE_KEYBOARD_RCTRL       ((USAGE) 0xE4)\r
-#define HID_USAGE_KEYBOARD_RSHFT       ((USAGE) 0xE5)\r
-#define HID_USAGE_KEYBOARD_RALT        ((USAGE) 0xE6)\r
-#define HID_USAGE_KEYBOARD_RGUI        ((USAGE) 0xE7)\r
-#define HID_USAGE_KEYBOARD_SCROLL_LOCK ((USAGE) 0x47)\r
-#define HID_USAGE_KEYBOARD_NUM_LOCK    ((USAGE) 0x53)\r
-#define HID_USAGE_KEYBOARD_CAPS_LOCK   ((USAGE) 0x39)\r
-        // Funtion keys\r
-#define HID_USAGE_KEYBOARD_F1          ((USAGE) 0x3A)\r
-#define HID_USAGE_KEYBOARD_F12         ((USAGE) 0x45)\r
-\r
-#define HID_USAGE_KEYBOARD_RETURN      ((USAGE) 0x28)\r
-#define HID_USAGE_KEYBOARD_ESCAPE      ((USAGE) 0x29)\r
-#define HID_USAGE_KEYBOARD_DELETE      ((USAGE) 0x2A)\r
-\r
-#define HID_USAGE_KEYBOARD_PRINT_SCREEN ((USAGE) 0x46)\r
-\r
-// and hundreds more...\r
-\r
-//\r
-// LED Page (0x08)\r
-//\r
-\r
-#define HID_USAGE_LED_NUM_LOCK               ((USAGE) 0x01)\r
-#define HID_USAGE_LED_CAPS_LOCK              ((USAGE) 0x02)\r
-#define HID_USAGE_LED_SCROLL_LOCK            ((USAGE) 0x03)\r
-#define HID_USAGE_LED_COMPOSE                ((USAGE) 0x04)\r
-#define HID_USAGE_LED_KANA                   ((USAGE) 0x05)\r
-#define HID_USAGE_LED_POWER                  ((USAGE) 0x06)\r
-#define HID_USAGE_LED_SHIFT                  ((USAGE) 0x07)\r
-#define HID_USAGE_LED_DO_NOT_DISTURB         ((USAGE) 0x08)\r
-#define HID_USAGE_LED_MUTE                   ((USAGE) 0x09)\r
-#define HID_USAGE_LED_TONE_ENABLE            ((USAGE) 0x0A)\r
-#define HID_USAGE_LED_HIGH_CUT_FILTER        ((USAGE) 0x0B)\r
-#define HID_USAGE_LED_LOW_CUT_FILTER         ((USAGE) 0x0C)\r
-#define HID_USAGE_LED_EQUALIZER_ENABLE       ((USAGE) 0x0D)\r
-#define HID_USAGE_LED_SOUND_FIELD_ON         ((USAGE) 0x0E)\r
-#define HID_USAGE_LED_SURROUND_FIELD_ON      ((USAGE) 0x0F)\r
-#define HID_USAGE_LED_REPEAT                 ((USAGE) 0x10)\r
-#define HID_USAGE_LED_STEREO                 ((USAGE) 0x11)\r
-#define HID_USAGE_LED_SAMPLING_RATE_DETECT   ((USAGE) 0x12)\r
-#define HID_USAGE_LED_SPINNING               ((USAGE) 0x13)\r
-#define HID_USAGE_LED_CAV                    ((USAGE) 0x14)\r
-#define HID_USAGE_LED_CLV                    ((USAGE) 0x15)\r
-#define HID_USAGE_LED_RECORDING_FORMAT_DET   ((USAGE) 0x16)\r
-#define HID_USAGE_LED_OFF_HOOK               ((USAGE) 0x17)\r
-#define HID_USAGE_LED_RING                   ((USAGE) 0x18)\r
-#define HID_USAGE_LED_MESSAGE_WAITING        ((USAGE) 0x19)\r
-#define HID_USAGE_LED_DATA_MODE              ((USAGE) 0x1A)\r
-#define HID_USAGE_LED_BATTERY_OPERATION      ((USAGE) 0x1B)\r
-#define HID_USAGE_LED_BATTERY_OK             ((USAGE) 0x1C)\r
-#define HID_USAGE_LED_BATTERY_LOW            ((USAGE) 0x1D)\r
-#define HID_USAGE_LED_SPEAKER                ((USAGE) 0x1E)\r
-#define HID_USAGE_LED_HEAD_SET               ((USAGE) 0x1F)\r
-#define HID_USAGE_LED_HOLD                   ((USAGE) 0x20)\r
-#define HID_USAGE_LED_MICROPHONE             ((USAGE) 0x21)\r
-#define HID_USAGE_LED_COVERAGE               ((USAGE) 0x22)\r
-#define HID_USAGE_LED_NIGHT_MODE             ((USAGE) 0x23)\r
-#define HID_USAGE_LED_SEND_CALLS             ((USAGE) 0x24)\r
-#define HID_USAGE_LED_CALL_PICKUP            ((USAGE) 0x25)\r
-#define HID_USAGE_LED_CONFERENCE             ((USAGE) 0x26)\r
-#define HID_USAGE_LED_STAND_BY               ((USAGE) 0x27)\r
-#define HID_USAGE_LED_CAMERA_ON              ((USAGE) 0x28)\r
-#define HID_USAGE_LED_CAMERA_OFF             ((USAGE) 0x29)\r
-#define HID_USAGE_LED_ON_LINE                ((USAGE) 0x2A)\r
-#define HID_USAGE_LED_OFF_LINE               ((USAGE) 0x2B)\r
-#define HID_USAGE_LED_BUSY                   ((USAGE) 0x2C)\r
-#define HID_USAGE_LED_READY                  ((USAGE) 0x2D)\r
-#define HID_USAGE_LED_PAPER_OUT              ((USAGE) 0x2E)\r
-#define HID_USAGE_LED_PAPER_JAM              ((USAGE) 0x2F)\r
-#define HID_USAGE_LED_REMOTE                 ((USAGE) 0x30)\r
-#define HID_USAGE_LED_FORWARD                ((USAGE) 0x31)\r
-#define HID_USAGE_LED_REVERSE                ((USAGE) 0x32)\r
-#define HID_USAGE_LED_STOP                   ((USAGE) 0x33)\r
-#define HID_USAGE_LED_REWIND                 ((USAGE) 0x34)\r
-#define HID_USAGE_LED_FAST_FORWARD           ((USAGE) 0x35)\r
-#define HID_USAGE_LED_PLAY                   ((USAGE) 0x36)\r
-#define HID_USAGE_LED_PAUSE                  ((USAGE) 0x37)\r
-#define HID_USAGE_LED_RECORD                 ((USAGE) 0x38)\r
-#define HID_USAGE_LED_ERROR                  ((USAGE) 0x39)\r
-#define HID_USAGE_LED_SELECTED_INDICATOR     ((USAGE) 0x3A)\r
-#define HID_USAGE_LED_IN_USE_INDICATOR       ((USAGE) 0x3B)\r
-#define HID_USAGE_LED_MULTI_MODE_INDICATOR   ((USAGE) 0x3C)\r
-#define HID_USAGE_LED_INDICATOR_ON           ((USAGE) 0x3D)\r
-#define HID_USAGE_LED_INDICATOR_FLASH        ((USAGE) 0x3E)\r
-#define HID_USAGE_LED_INDICATOR_SLOW_BLINK   ((USAGE) 0x3F)\r
-#define HID_USAGE_LED_INDICATOR_FAST_BLINK   ((USAGE) 0x40)\r
-#define HID_USAGE_LED_INDICATOR_OFF          ((USAGE) 0x41)\r
-#define HID_USAGE_LED_FLASH_ON_TIME          ((USAGE) 0x42)\r
-#define HID_USAGE_LED_SLOW_BLINK_ON_TIME     ((USAGE) 0x43)\r
-#define HID_USAGE_LED_SLOW_BLINK_OFF_TIME    ((USAGE) 0x44)\r
-#define HID_USAGE_LED_FAST_BLINK_ON_TIME     ((USAGE) 0x45)\r
-#define HID_USAGE_LED_FAST_BLINK_OFF_TIME    ((USAGE) 0x46)\r
-#define HID_USAGE_LED_INDICATOR_COLOR        ((USAGE) 0x47)\r
-#define HID_USAGE_LED_RED                    ((USAGE) 0x48)\r
-#define HID_USAGE_LED_GREEN                  ((USAGE) 0x49)\r
-#define HID_USAGE_LED_AMBER                  ((USAGE) 0x4A)\r
-#define HID_USAGE_LED_GENERIC_INDICATOR      ((USAGE) 0x3B)\r
-\r
-//\r
-//  Button Page (0x09)\r
-//\r
-//  There is no need to label these usages.\r
-//\r
-\r
-\r
-//\r
-//  Ordinal Page (0x0A)\r
-//\r
-//  There is no need to label these usages.\r
-//\r
-\r
-\r
-//\r
-//  Telephony Device Page (0x0B)\r
-//\r
-\r
-#define HID_USAGE_TELEPHONY_PHONE                  ((USAGE) 0x01)\r
-#define HID_USAGE_TELEPHONY_ANSWERING_MACHINE      ((USAGE) 0x02)\r
-#define HID_USAGE_TELEPHONY_MESSAGE_CONTROLS       ((USAGE) 0x03)\r
-#define HID_USAGE_TELEPHONY_HANDSET                ((USAGE) 0x04)\r
-#define HID_USAGE_TELEPHONY_HEADSET                ((USAGE) 0x05)\r
-#define HID_USAGE_TELEPHONY_KEYPAD                 ((USAGE) 0x06)\r
-#define HID_USAGE_TELEPHONY_PROGRAMMABLE_BUTTON    ((USAGE) 0x07)\r
-\r
-//\r
-// and others...\r
-//\r
-\r
-\r
-#endif\r
diff --git a/client/prox.c b/client/prox.c
deleted file mode 100644 (file)
index d619c82..0000000
+++ /dev/null
@@ -1,282 +0,0 @@
-#include <windows.h>\r
-#include <setupapi.h>\r
-#include <stdio.h>\r
-#include <ctype.h>\r
-#include <stdlib.h>\r
-//extern "C" {\r
-#include "include/hidusage.h"\r
-#include "include/hidpi.h"\r
-#include "include/hidsdi.h"\r
-//}\r
-\r
-#include "flash.h"\r
-#include "usb_cmd.h"\r
-#include "ui.h"\r
-\r
-#define OUR_VID 0x9ac4\r
-#define OUR_PID 0x4b8f\r
-#define bzero(b,len) (memset((b), '\0', (len)), (void) 0)\r
-\r
-int offline = 0;\r
-HANDLE UsbHandle;\r
-extern unsigned int current_command;\r
-extern struct partition partitions[];\r
-\r
-static void ShowError(void)\r
-{\r
-       char buf[1024];\r
-       FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0,\r
-               buf, sizeof(buf), NULL);\r
-       printf("ERROR: %s", buf);\r
-}\r
-\r
-BOOL UsbConnect(void)\r
-{\r
-       typedef void (__stdcall *GetGuidProc)(GUID *);\r
-       typedef BOOLEAN (__stdcall *GetAttrProc)(HANDLE, HIDD_ATTRIBUTES *);\r
-       typedef BOOLEAN (__stdcall *GetPreparsedProc)(HANDLE,\r
-                                                                               PHIDP_PREPARSED_DATA *);\r
-       typedef NTSTATUS (__stdcall *GetCapsProc)(PHIDP_PREPARSED_DATA, PHIDP_CAPS);\r
-       GetGuidProc                     getGuid;\r
-       GetAttrProc                     getAttr;\r
-       GetPreparsedProc        getPreparsed;\r
-       GetCapsProc                     getCaps;\r
-\r
-       HMODULE h               = LoadLibrary("hid.dll");\r
-       getGuid                 = (GetGuidProc)GetProcAddress(h, "HidD_GetHidGuid");\r
-       getAttr                 = (GetAttrProc)GetProcAddress(h, "HidD_GetAttributes");\r
-       getPreparsed    = (GetPreparsedProc)GetProcAddress(h, "HidD_GetPreparsedData");\r
-       getCaps                 = (GetCapsProc)GetProcAddress(h, "HidP_GetCaps");\r
-\r
-       GUID hidGuid;\r
-       getGuid(&hidGuid);\r
-\r
-       HDEVINFO devInfo;\r
-       devInfo = SetupDiGetClassDevs(&hidGuid, NULL, NULL,\r
-               DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);\r
-\r
-       SP_DEVICE_INTERFACE_DATA devInfoData;\r
-       devInfoData.cbSize = sizeof(devInfoData);\r
-\r
-       int i;\r
-       for(i = 0;; i++) {\r
-               if(!SetupDiEnumDeviceInterfaces(devInfo, 0, &hidGuid, i, &devInfoData))\r
-               {\r
-                       if(GetLastError() != ERROR_NO_MORE_ITEMS) {\r
-//                             printf("SetupDiEnumDeviceInterfaces failed\n");\r
-                       }\r
-//                     printf("done list\n");\r
-                       SetupDiDestroyDeviceInfoList(devInfo);\r
-                       return FALSE;\r
-               }\r
-\r
-//             printf("item %d:\n", i);\r
-\r
-               DWORD sizeReqd = 0;\r
-               if(!SetupDiGetDeviceInterfaceDetail(devInfo, &devInfoData,\r
-                       NULL, 0, &sizeReqd, NULL))\r
-               {\r
-                       if(GetLastError() != ERROR_INSUFFICIENT_BUFFER) {\r
-//                             printf("SetupDiGetDeviceInterfaceDetail (0) failed\n");\r
-                               continue;\r
-                       }\r
-               }\r
-\r
-               SP_DEVICE_INTERFACE_DETAIL_DATA *devInfoDetailData =\r
-                       (SP_DEVICE_INTERFACE_DETAIL_DATA *)malloc(sizeReqd);\r
-               devInfoDetailData->cbSize = sizeof(*devInfoDetailData);\r
-\r
-               if(!SetupDiGetDeviceInterfaceDetail(devInfo, &devInfoData,\r
-                       devInfoDetailData, 87, NULL, NULL))\r
-               {\r
-//                     printf("SetupDiGetDeviceInterfaceDetail (1) failed\n");\r
-                       continue;\r
-               }\r
-\r
-               char *path = devInfoDetailData->DevicePath;\r
-\r
-               UsbHandle = CreateFile(path, /*GENERIC_READ |*/ GENERIC_WRITE,\r
-                       FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,\r
-                       FILE_FLAG_OVERLAPPED, NULL);\r
-\r
-               if(UsbHandle == INVALID_HANDLE_VALUE) {\r
-                       ShowError();\r
-//                     printf("CreateFile failed: for '%s'\n", path);\r
-                       continue;\r
-               }\r
-\r
-               HIDD_ATTRIBUTES attr;\r
-               attr.Size = sizeof(attr);\r
-               if(!getAttr(UsbHandle, &attr)) {\r
-                       ShowError();\r
-//                     printf("HidD_GetAttributes failed\n");\r
-                       continue;\r
-               }\r
-\r
-//             printf("VID: %04x PID %04x\n", attr.VendorID, attr.ProductID);\r
-\r
-               if(attr.VendorID != OUR_VID || attr.ProductID != OUR_PID) {\r
-                       CloseHandle(UsbHandle);\r
-//                     printf("        nope, not us\n");\r
-                       continue;\r
-               }\r
-\r
-//             printf ("got it!\n");\r
-               CloseHandle(UsbHandle);\r
-\r
-               UsbHandle = CreateFile(path, GENERIC_READ | GENERIC_WRITE,\r
-                       FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,\r
-                       FILE_FLAG_OVERLAPPED, NULL);\r
-\r
-               if(UsbHandle == INVALID_HANDLE_VALUE) {\r
-                       ShowError();\r
-//                     printf("Error, couldn't open our own handle as desired.\n");\r
-                       return FALSE;\r
-               }\r
-\r
-               PHIDP_PREPARSED_DATA pp;\r
-               getPreparsed(UsbHandle, &pp);\r
-               HIDP_CAPS caps;\r
-\r
-               if(getCaps(pp, &caps) != HIDP_STATUS_SUCCESS) {\r
-//                     printf("getcaps failed\n");\r
-                       return FALSE;\r
-               }\r
-\r
-//             printf("input/out report %d/%d\n", caps.InputReportByteLength,\r
-//                     caps.OutputReportByteLength);\r
-\r
-\r
-               return TRUE;\r
-       }\r
-       return FALSE;\r
-}\r
-\r
-bool ReceiveCommandPoll(UsbCommand *c)\r
-{\r
-       static BOOL ReadInProgress = FALSE;\r
-       static OVERLAPPED Ov;\r
-       static BYTE Buf[65];\r
-       static DWORD HaveRead;\r
-\r
-       if(!ReadInProgress) {\r
-               memset(&Ov, 0, sizeof(Ov));\r
-               ReadFile(UsbHandle, Buf, 65, &HaveRead, &Ov);\r
-               if(GetLastError() != ERROR_IO_PENDING) {\r
-                       ShowError();\r
-                       exit(-1);\r
-               }\r
-               ReadInProgress = TRUE;\r
-       }\r
-\r
-       if(HasOverlappedIoCompleted(&Ov)) {\r
-               ReadInProgress = FALSE;\r
-\r
-               if(!GetOverlappedResult(UsbHandle, &Ov, &HaveRead, FALSE)) {\r
-                       ShowError();\r
-                       exit(-1);\r
-               }\r
-\r
-               memcpy(c, Buf+1, 64);\r
-\r
-               return TRUE;\r
-       } else {\r
-               return FALSE;\r
-       }\r
-}\r
-\r
-void ReceiveCommand(UsbCommand *c)\r
-{\r
-       while(!ReceiveCommandPoll(c)) {\r
-               Sleep(0);\r
-       }\r
-}\r
-\r
-void SendCommand(UsbCommand *c)\r
-{\r
-       BYTE buf[65];\r
-       buf[0] = 0;\r
-       memcpy(buf+1, c, 64);\r
-\r
-       DWORD written;\r
-       OVERLAPPED ov;\r
-\r
-       memset(&ov, 0, sizeof(ov));\r
-       WriteFile(UsbHandle, buf, 65, &written, &ov);\r
-       if(GetLastError() != ERROR_IO_PENDING) {\r
-               ShowError();\r
-               exit(-1);\r
-       }\r
-\r
-       while(!HasOverlappedIoCompleted(&ov)) {\r
-               Sleep(0);\r
-       }\r
-\r
-       if(!GetOverlappedResult(UsbHandle, &ov, &written, FALSE)) {\r
-               ShowError();\r
-               exit(-1);\r
-       }\r
-       current_command = c->cmd;\r
-}\r
-\r
-static void usage(char **argv)\r
-{\r
-       int i;\r
-               printf("Usage: %s gui\n", argv[0]);\r
-               printf("       %s offline\n", argv[0]);\r
-               printf("       %s areas file.elf\n", argv[0]);\r
-               printf("               Known areas are:");\r
-               for(i=0; partitions[i].name != NULL; i++) {\r
-                       fprintf(stderr, " %s", partitions[i].name);\r
-               }\r
-\r
-               printf("\n");\r
-}\r
-\r
-int main(int argc, char **argv)\r
-{\r
-       int i = 0;\r
-\r
-       if(argc < 2) {\r
-               usage(argv);\r
-               exit(-1);\r
-       }\r
-\r
-       // Only do this if NOT in offline mode\r
-       if (strcmp(argv[1], "offline"))\r
-       {\r
-               for(;;) {\r
-                       if(UsbConnect()) {\r
-                               break;\r
-                       }\r
-                       if(i == 0) {\r
-                               printf("...no device connected, polling for it now\n");\r
-                       }\r
-                       if(i > 50000) {\r
-                               printf("Could not connect to USB device; exiting.\n");\r
-                               return -1;\r
-                       }\r
-                       i++;\r
-                       Sleep(5);\r
-               }\r
-       }\r
-\r
-       if(strcmp(argv[1], "gui")==0) {\r
-               ShowGui();\r
-       } else if(strcmp(argv[1], "offline")==0) {\r
-               offline = 1;\r
-               ShowGui();\r
-       }\r
-\r
-       /* Count area arguments */\r
-       int areas = 0, offset=-1, length=0;\r
-       while(find_next_area(argv[1], &offset, &length)) areas++;\r
-\r
-       if(areas != argc - 2) {\r
-               usage(argv);\r
-               exit(-1);\r
-       }\r
-\r
-       do_flash(argv);\r
-       return 0;\r
-}\r
index 77c37715893b94a928f12bc0965b65a4c9eb0223..9873f26a9b246f099f0b3df7eea1ce65ec2c9477 100644 (file)
@@ -35,6 +35,7 @@ static void *usb_receiver(void *targ)
   }
 
   pthread_exit(NULL);
+  return NULL;
 }
 
 static void *main_loop(void *targ)
@@ -70,6 +71,7 @@ static void *main_loop(void *targ)
 
   ExitGraphics();
   pthread_exit(NULL);
+  return NULL;
 }
 
 int main(int argc, char **argv)
index 5d55fc820db096b2003957d4e02a439235924a65..323480ea7e16c9bb4064ef83fc4a6c340c6bd123 100644 (file)
@@ -3,4 +3,4 @@
 
 #define PROXPROMPT "proxmark3> "
 
-#endif
\ No newline at end of file
+#endif
index be37fc69cca16719186e21be93c980d81abae62a..b71cffc1ed2745509ede3e42eabd43aaaf5490b2 100644 (file)
@@ -6,10 +6,16 @@
 #include <strings.h>
 #include <errno.h>
 
+#include "sleep.h"
 #include "proxusb.h"
 #include "proxmark3.h"
 #include "usb_cmd.h"
 
+// It seems to be missing for mingw
+#ifndef ETIMEDOUT
+#define ETIMEDOUT 116
+#endif
+
 usb_dev_handle *devh = NULL;
 static unsigned int claimed_iface = 0;
 unsigned char return_on_error = 0;
@@ -37,7 +43,7 @@ void SendCommand(UsbCommand *c)
       usb_close(devh);
       devh = NULL;
     }
-    while(!(devh=OpenProxmark(0))) { sleep(1); }
+    while(!OpenProxmark(0)) { sleep(1); }
     printf(PROXPROMPT);
     fflush(NULL);
 
@@ -49,7 +55,7 @@ bool ReceiveCommandPoll(UsbCommand *c)
 {
   int ret;
 
-  bzero(c, sizeof(UsbCommand));
+  memset(c, 0, sizeof (UsbCommand));
   ret = usb_bulk_read(devh, 0x82, (char*)c, sizeof(UsbCommand), 500);
   if (ret<0) {
     if (ret != -ETIMEDOUT) {
@@ -64,7 +70,7 @@ bool ReceiveCommandPoll(UsbCommand *c)
         usb_close(devh);
         devh = NULL;
       }
-      while(!(devh=OpenProxmark(0))) { sleep(1); }
+      while(!OpenProxmark(0)) { sleep(1); }
       printf(PROXPROMPT);
       fflush(NULL);
 
@@ -130,7 +136,7 @@ usb_dev_handle* OpenProxmark(int verbose)
   usb_dev_handle *handle = NULL;
   unsigned int iface;
 
-#ifndef __APPLE__
+#ifdef __linux__
   handle = findProxmark(verbose, &iface);
   if (!handle)
     return NULL;
@@ -143,20 +149,28 @@ usb_dev_handle* OpenProxmark(int verbose)
   if (!handle)
     return NULL;
 
-#ifndef __APPLE__
+#ifdef __linux__
   /* detach kernel driver first */
   ret = usb_detach_kernel_driver_np(handle, iface);
   /* don't complain if no driver attached */
   if (ret<0 && ret != -61 && verbose)
     fprintf(stderr, "detach kernel driver failed: (%d) %s!\n", ret, usb_strerror());
 #endif
+
+  // Needed for Windows. Optional for Mac OS and Linux
+  ret = usb_set_configuration(handle, 1);
+  if (ret < 0) {
+    if (verbose)
+      fprintf(stderr, "configuration set failed: %s!\n", usb_strerror());
+    return NULL;
+  }
+
   ret = usb_claim_interface(handle, iface);
   if (ret < 0) {
     if (verbose)
       fprintf(stderr, "claim failed: %s!\n", usb_strerror());
     return NULL;
   }
-
   claimed_iface = iface;
   devh = handle;
   return handle;
@@ -166,4 +180,5 @@ void CloseProxmark(void)
 {
   usb_release_interface(devh, claimed_iface);
   usb_close(devh);
+  devh = NULL;
 }
index 32a334c68edec7690796388d288c8e57d10d6b2d..3842d39f041eff3ce0fecf931f850a87bd16a878 100644 (file)
@@ -3,9 +3,7 @@
 
 #include <stdint.h>
 #include <stdbool.h>
-#ifndef WIN32
 #include <usb.h>
-#endif
 #include "usb_cmd.h"
 
 extern unsigned char return_on_error;
index 014497485d1efea7e44d11bcfe25709524c2500a..7723a470d8ae088aa9e2036504075ad97297f4e5 100644 (file)
@@ -1,3 +1,4 @@
+#include "sleep.h"
 #include "ui.h"
 #include "proxusb.h"
 #include "cmdmain.h"
index 99c9f17007240191a7da4f14fd6b6464385a096c..f0fa8e733ab94ef08e7e3c2d15876fff7e8bbdbe 100644 (file)
@@ -10,11 +10,6 @@ int offline;
 
 static char *logfilename = "proxmark3.log";
 
-// FIXME: ifndef not really nice...
-// We should eventually get rid of it once
-// we fully factorize the code between *nix and windows
-// (using pthread and alikes...)
-#ifndef WIN32
 void PrintAndLog(char *fmt, ...)
 {
   va_list argptr, argptr2;
@@ -41,7 +36,6 @@ void PrintAndLog(char *fmt, ...)
   }
   va_end(argptr2);
 }
-#endif
 
 void SetLogFilename(char *fn)
 {
Impressum, Datenschutz