summaryrefslogtreecommitdiff
path: root/ScanHID.c
blob: 4d48d87aa47013d9b7447a36e9f0d95f6a97a2b2 (plain)
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
// ScanHID.cpp : Defines the entry point for the console application.
//

#define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
#define _CRT_SECURE_NO_DEPRECATE

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>

#include "hidapi.h"

int main(int argc, char* argv[])
{
	char product[256];
	char sernum[256] = "NULL";

	struct hid_device_info *devs, *cur_dev;
	const char *path_to_open = NULL;
	hid_device *handle = NULL;

	// Look for Device

	devs = hid_enumerate(0,0); // so we list devices(USHORT)VID, (USHORT)PID);
	cur_dev = devs;
	while (cur_dev)
	{
		wcstombs(product, cur_dev->product_string, 255);
		if (cur_dev->serial_number)
			wcstombs(sernum, cur_dev->serial_number, 255);

		if (product)
			printf("HID Device %s VID %X PID %X Ser %s\r\n Path %s\r\n\r\n", product, cur_dev->vendor_id, cur_dev->product_id, sernum, cur_dev->path);
		else
			printf("HID Device %s VID %X PID %X Ser %s\r\n Path %s\r\n\r\n", "Missing Product", cur_dev->vendor_id, cur_dev->product_id, sernum, cur_dev->path);


		cur_dev = cur_dev->next;
	}


	hid_free_enumeration(devs);
	printf("Press any key to Exit");
	_getch();


}