-
Notifications
You must be signed in to change notification settings - Fork 1
/
hidapi_mod.h
91 lines (65 loc) · 2.3 KB
/
hidapi_mod.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*Originally based on hidapi, only thing that remains are a few comments and function names*/
/*******************************************************
HIDAPI - Multi-Platform library for
communication with HID devices.
Alan Ott
Signal 11 Software
8/22/2009
Copyright 2009, All Rights Reserved.
At the discretion of the user of this library,
this software may be licensed under the terms of the
GNU Public License v3, a BSD-Style license, or the
original HIDAPI license as outlined in the LICENSE.txt,
LICENSE-gpl3.txt, LICENSE-bsd.txt, and LICENSE-orig.txt
files located at the root of the source distribution.
These files may also be found in the public source
code repository located at:
http://github.com/signal11/hidapi .
********************************************************/
#pragma once
#ifndef HIDAPI_H__
#define HIDAPI_H__
#include <libusb-1.0/libusb.h>
#include "iconv.h"
#include <string>
struct GKeyboardDevice
{
//the LIBUSB device handle
//HANDLE device;
/* Handle to the actual device. */
libusb_device_handle *device_handle;
//physical device
libusb_device *usb_dev;
//interface of the usb device
int interface;
//store the VID/PID, to determine which commands to use for each device type
//G510 or G110
unsigned short product_id;
unsigned short vendor_id;
struct GKeyboardDevice* next;
};
/** @brief Enumerate the HID Devices.
This function returns a linked list of all the HID devices
attached to the system which match vendor_id and product_id.
@ingroup API
@param vendor_id The Vendor ID (VID) of the types of device
to open.
@param product_id The Product ID (PID) of the types of
device to open.
@returns
This function returns a pointer to a linked list of type
struct #hid_device, containing information about the HID devices
attached to the system, or NULL in the case of failure. Free
this linked list by calling hid_free_enumeration().
*/
GKeyboardDevice* hid_enumerate(unsigned short vendor_id, unsigned short product_id);
/** @brief Free an enumeration Linked List
This function frees a linked list created by hid_enumerate().
@ingroup API
@param devs Pointer to a list of struct_device returned from
hid_enumerate().
*/
void hid_free_enumeration(GKeyboardDevice *devs);
// check for valid pointer
bool NotValidHandle(void* h);
#endif