-
Notifications
You must be signed in to change notification settings - Fork 40
/
libs.go
74 lines (67 loc) · 2.21 KB
/
libs.go
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
// usb - Self contained USB and HID library for Go
// Copyright 2019 The library Authors
//
// This library is free software: you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option) any
// later version.
//
// The library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
// A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License along
// with the library. If not, see <http://www.gnu.org/licenses/>.
// +build freebsd,cgo linux,cgo darwin,!ios,cgo windows,cgo
package usb
/*
#cgo CFLAGS: -I./hidapi/hidapi
#cgo CFLAGS: -I./libusb/libusb
#cgo CFLAGS: -DDEFAULT_VISIBILITY=""
#cgo CFLAGS: -DPOLL_NFDS_TYPE=int
#cgo linux CFLAGS: -DOS_LINUX -D_GNU_SOURCE -DHAVE_SYS_TIME_H
#cgo linux,!android LDFLAGS: -lrt
#cgo darwin CFLAGS: -DOS_DARWIN -DHAVE_SYS_TIME_H
#cgo darwin LDFLAGS: -framework CoreFoundation -framework IOKit -lobjc
#cgo windows CFLAGS: -DOS_WINDOWS
#cgo windows LDFLAGS: -lsetupapi
#cgo freebsd CFLAGS: -DOS_FREEBSD
#cgo freebsd LDFLAGS: -lusb
#cgo openbsd CFLAGS: -DOS_OPENBSD
#if defined(OS_LINUX) || defined(OS_DARWIN) || defined(DOS_FREEBSD) || defined(OS_OPENBSD)
#include <poll.h>
#include "os/threads_posix.c"
#include "os/poll_posix.c"
#elif defined(OS_WINDOWS)
#include "os/poll_windows.c"
#include "os/threads_windows.c"
#endif
#ifdef OS_LINUX
#include "os/linux_usbfs.c"
#include "os/linux_netlink.c"
#include "hidapi/libusb/hid.c"
#elif OS_DARWIN
#include "os/darwin_usb.c"
#include "hidapi/mac/hid.c"
#elif OS_WINDOWS
#include "os/windows_nt_common.c"
#include "os/windows_usbdk.c"
#include "os/windows_winusb.c"
#include "hidapi/windows/hid.c"
#elif OS_FREEBSD
#include <libusb.h>
#include "hidapi/libusb/hid.c"
#elif DOS_OPENBSD
#include "os/openbsd_usb.c"
#include "hidapi/libusb/hid.c"
#endif
#ifndef OS_FREEBSD
#include "core.c"
#include "descriptor.c"
#include "hotplug.c"
#include "io.c"
#include "strerror.c"
#include "sync.c"
#endif
*/
import "C"