summaryrefslogtreecommitdiff
path: root/spectro/hidio.h
blob: 90a741b9fecef8b2b45b1d718a811c763060798d (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
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
92
93

#ifndef HIDIO_H

 /* General USB HID I/O support */

/* 
 * Argyll Color Correction System
 *
 * Author: Graeme W. Gill
 * Date:   2007/10/10
 *
 * Copyright 2006 - 2013 Graeme W. Gill
 * All rights reserved.
 *
 * This material is licenced under the GNU GENERAL PUBLIC LICENSE Version 2 or later :-
 * see the License2.txt file for licencing details.
 */

/* These routines supliement the class code in ntio.c and unixio.c */

#ifdef __APPLE__
#include <sys/param.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/IOCFPlugIn.h>
#include <IOKit/hid/IOHIDLib.h>
#include <IOKit/hid/IOHIDKeys.h>
#include <CoreFoundation/CoreFoundation.h>
#endif /* __APPLE__ */

#ifdef __cplusplus
	extern "C" {
#endif

/* Add or modify paths to USB HID connected instruments, to the existing */
/* icompath paths in the icoms structure, if HID access is supported. */
/* return icom error */
int hid_get_paths(struct _icompaths *p);

void hid_close_port(icoms *p);

/* Set the HID specific icoms methods */
void hid_set_hid_methods(icoms *p);

/* Copy hid_idevice contents */
/* return icom error */
int hid_copy_hid_idevice(icoms *d, icompath *s);

/* Cleanup and then free a hid_del_hid_idevice */
void hid_del_hid_idevice(struct hid_idevice *dev);

/* Cleanup any HID specific icoms info */
void hid_del_hid(icoms *p);

/* Opaque structure to hid OS dependent HID details */
struct hid_idevice {
#if defined(NT)
	char *dpath;				/* Device path */
	/* Stuff setup when device is open: */
	HANDLE fh;					/* File handle for write/read */
	OVERLAPPED ols;				/* Overlapped structure for write/read */
#endif
#if defined(__APPLE__)
# if defined(USE_NEW_OSX_CODE) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
	int lid;							/* Location ID */
	IOHIDDeviceRef ioob;				/* Object to open */
	/* Stuff setup when device is open: */
	CFRunLoopRef rlr;
#else
	int lid;							/* Location ID */
	io_object_t ioob;					/* Object to open */
	/* Stuff setup when device is open: */
	IOHIDDeviceInterface122 **device;	/* OS X HID device we've opened */
	mach_port_t port;					/* Other stuff present when opened */
	CFRunLoopSourceRef evsrc;
	CFRunLoopRef rlr;
	IOReturn result;
#   define HID_RBUF_SIZE 1024
	unsigned char rbuf[HID_RBUF_SIZE];	/* Buffer for read callback */
    int bread;            				/* Bytes read by callback */
#endif	/* __MAC_OS_X_VERSION_MAX_ALLOWED < 1060 */
#endif
};

/* Cleanup and then free an hidd entry */
void hid_del_hid_idevice(struct hid_idevice *hidd);

#ifdef __cplusplus
	}
#endif

#define HIDIO_H
#endif /* HIDIO_H */