| 1 | /* |
| 2 | Copyright (c) 2004 Ross Bencina <[email protected]> |
| 3 | Copyright (c) 2004 Jason McMullan <[email protected]> |
| 4 | |
| 5 | USB/HID I/O routines |
| 6 | */ |
| 7 | /* |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU Lesser General Public License as published by |
| 10 | * the Free Software Foundation; either version 2.1 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU Lesser General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 | */ |
| 22 | #ifndef USB_HID_H |
| 23 | #define USB_HID_H |
| 24 | |
| 25 | #ifdef __cplusplus |
| 26 | extern "C" { |
| 27 | #endif |
| 28 | |
| 29 | typedef struct USBHID_struct *USBHID; |
| 30 | |
| 31 | #define INVALID_USBHID_VALUE (0) |
| 32 | |
| 33 | |
| 34 | #define SELECT_VENDOR_ID_FLAG (0x01) |
| 35 | #define SELECT_PRODUCT_ID_FLAG (0x02) |
| 36 | #define SELECT_VERSION_NUMBER_FLAG (0x04) |
| 37 | |
| 38 | |
| 39 | /* |
| 40 | Open the indexth USBHID device which match the delection criteria. The |
| 41 | selection criteria may be any combination of vendor id, product id and |
| 42 | version number as specified by the flags parameter. |
| 43 | |
| 44 | Returns an open handle on success, or INVALID_USBHIDHANDLE if an error |
| 45 | occurred. |
| 46 | */ |
| 47 | USBHID OpenUSBHID( int index, int vendorId, int productId, int versionNumber, int flags ); |
| 48 | |
| 49 | |
| 50 | /* |
| 51 | Close a USB HID handle previously opened with OpenUSBHID() |
| 52 | */ |
| 53 | void CloseUSBHID( USBHID handle ); |
| 54 | |
| 55 | |
| 56 | /* |
| 57 | Read count bytes from the USB HID into dest. Returns the number of bytes |
| 58 | read. This routine reads from the Kernel HID ring buffer, if it is no called |
| 59 | frequently enough the data returned may lag behind the latest HID reports |
| 60 | from the device. |
| 61 | |
| 62 | HidD_GetInputReport will read the most recent report, but is only |
| 63 | implemented on Windows XP. |
| 64 | */ |
| 65 | int ReadUSBHID( USBHID handle, void *dest, int count ); |
| 66 | |
| 67 | |
| 68 | int SetUSBHIDFeature( USBHID handle, char *report, int count ); |
| 69 | |
| 70 | int GetUSBHIDFeature( USBHID handle, char *report, int count ); |
| 71 | |
| 72 | |
| 73 | #ifdef __cplusplus |
| 74 | } |
| 75 | #endif |
| 76 | |
| 77 | #endif /* USB_HID_H */ |