mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-11 22:42:31 +02:00
Updated hidapi to 0.14.0 release
Upstream: https://github.com/libusb/hidapi/releases/tag/hidapi-0.14.0
This commit is contained in:
17
src/hidapi/mac/.gitignore
vendored
Normal file
17
src/hidapi/mac/.gitignore
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
Debug
|
||||
Release
|
||||
*.exp
|
||||
*.ilk
|
||||
*.lib
|
||||
*.suo
|
||||
*.vcproj.*
|
||||
*.ncb
|
||||
*.suo
|
||||
*.dll
|
||||
*.pdb
|
||||
*.o
|
||||
hidapi-hidtest
|
||||
.deps
|
||||
.libs
|
||||
*.la
|
||||
*.lo
|
||||
48
src/hidapi/mac/CMakeLists.txt
Normal file
48
src/hidapi/mac/CMakeLists.txt
Normal file
@@ -0,0 +1,48 @@
|
||||
cmake_minimum_required(VERSION 3.4.3 FATAL_ERROR)
|
||||
|
||||
list(APPEND HIDAPI_PUBLIC_HEADERS "hidapi_darwin.h")
|
||||
|
||||
add_library(hidapi_darwin
|
||||
${HIDAPI_PUBLIC_HEADERS}
|
||||
hid.c
|
||||
)
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
target_link_libraries(hidapi_darwin
|
||||
PUBLIC hidapi_include
|
||||
PRIVATE Threads::Threads
|
||||
PRIVATE "-framework IOKit" "-framework CoreFoundation" "-framework AppKit"
|
||||
)
|
||||
|
||||
set_target_properties(hidapi_darwin
|
||||
PROPERTIES
|
||||
EXPORT_NAME "darwin"
|
||||
OUTPUT_NAME "hidapi"
|
||||
VERSION ${PROJECT_VERSION}
|
||||
SOVERSION ${PROJECT_VERSION_MAJOR}
|
||||
MACHO_COMPATIBILITY_VERSION ${PROJECT_VERSION_MAJOR}
|
||||
FRAMEWORK_VERSION ${PROJECT_VERSION_MAJOR}
|
||||
PUBLIC_HEADER "${HIDAPI_PUBLIC_HEADERS}"
|
||||
)
|
||||
|
||||
# compatibility with find_package()
|
||||
add_library(hidapi::darwin ALIAS hidapi_darwin)
|
||||
# compatibility with raw library link
|
||||
add_library(hidapi ALIAS hidapi_darwin)
|
||||
|
||||
set(PUBLIC_HEADER_DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
if(NOT CMAKE_FRAMEWORK)
|
||||
set(PUBLIC_HEADER_DESTINATION "${PUBLIC_HEADER_DESTINATION}/hidapi")
|
||||
endif()
|
||||
|
||||
if(HIDAPI_INSTALL_TARGETS)
|
||||
install(TARGETS hidapi_darwin EXPORT hidapi
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
FRAMEWORK DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
PUBLIC_HEADER DESTINATION "${PUBLIC_HEADER_DESTINATION}"
|
||||
)
|
||||
endif()
|
||||
|
||||
hidapi_configure_pc("${PROJECT_ROOT}/pc/hidapi.pc.in")
|
||||
@@ -9,24 +9,19 @@
|
||||
all: hidtest
|
||||
|
||||
CC=gcc
|
||||
CXX=g++
|
||||
COBJS=hid.o
|
||||
CPPOBJS=../hidtest/hidtest.o
|
||||
OBJS=$(COBJS) $(CPPOBJS)
|
||||
CFLAGS+=-I../hidapi -Wall -g -c
|
||||
LIBS=-framework IOKit -framework CoreFoundation
|
||||
COBJS=hid.o ../hidtest/test.o
|
||||
OBJS=$(COBJS)
|
||||
CFLAGS+=-I../hidapi -I. -Wall -g -c
|
||||
LIBS=-framework IOKit -framework CoreFoundation -framework AppKit
|
||||
|
||||
|
||||
hidtest: $(OBJS)
|
||||
g++ -Wall -g $^ $(LIBS) -o hidtest
|
||||
$(CC) -Wall -g $^ $(LIBS) -o hidtest
|
||||
|
||||
$(COBJS): %.o: %.c
|
||||
$(CC) $(CFLAGS) $< -o $@
|
||||
|
||||
$(CPPOBJS): %.o: %.cpp
|
||||
$(CXX) $(CFLAGS) $< -o $@
|
||||
|
||||
clean:
|
||||
rm -f *.o hidtest $(CPPOBJS)
|
||||
rm -f *.o hidtest
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
1655
src/hidapi/mac/hid.c
1655
src/hidapi/mac/hid.c
File diff suppressed because it is too large
Load Diff
98
src/hidapi/mac/hidapi_darwin.h
Normal file
98
src/hidapi/mac/hidapi_darwin.h
Normal file
@@ -0,0 +1,98 @@
|
||||
/*******************************************************
|
||||
HIDAPI - Multi-Platform library for
|
||||
communication with HID devices.
|
||||
|
||||
libusb/hidapi Team
|
||||
|
||||
Copyright 2022, All Rights Reserved.
|
||||
|
||||
At the discretion of the user of this library,
|
||||
this software may be licensed under the terms of the
|
||||
GNU General 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:
|
||||
https://github.com/libusb/hidapi .
|
||||
********************************************************/
|
||||
|
||||
/** @file
|
||||
* @defgroup API hidapi API
|
||||
|
||||
* Since version 0.12.0, @ref HID_API_VERSION >= HID_API_MAKE_VERSION(0, 12, 0)
|
||||
*/
|
||||
|
||||
#ifndef HIDAPI_DARWIN_H__
|
||||
#define HIDAPI_DARWIN_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "hidapi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @brief Get the location ID for a HID device.
|
||||
|
||||
Since version 0.12.0, @ref HID_API_VERSION >= HID_API_MAKE_VERSION(0, 12, 0)
|
||||
|
||||
@ingroup API
|
||||
@param dev A device handle returned from hid_open().
|
||||
@param location_id The device's location ID on return.
|
||||
|
||||
@returns
|
||||
This function returns 0 on success and -1 on error.
|
||||
*/
|
||||
int HID_API_EXPORT_CALL hid_darwin_get_location_id(hid_device *dev, uint32_t *location_id);
|
||||
|
||||
|
||||
/** @brief Changes the behavior of all further calls to @ref hid_open or @ref hid_open_path.
|
||||
|
||||
By default on Darwin platform all devices opened by HIDAPI with @ref hid_open or @ref hid_open_path
|
||||
are opened in exclusive mode (see kIOHIDOptionsTypeSeizeDevice).
|
||||
|
||||
Since version 0.12.0, @ref HID_API_VERSION >= HID_API_MAKE_VERSION(0, 12, 0)
|
||||
|
||||
@ingroup API
|
||||
@param open_exclusive When set to 0 - all further devices will be opened
|
||||
in non-exclusive mode. Otherwise - all further devices will be opened
|
||||
in exclusive mode.
|
||||
|
||||
@note During the initialisation by @ref hid_init - this property is set to 1 (TRUE).
|
||||
This is done to preserve full backward compatibility with previous behavior.
|
||||
|
||||
@note Calling this function before @ref hid_init or after @ref hid_exit has no effect.
|
||||
*/
|
||||
void HID_API_EXPORT_CALL hid_darwin_set_open_exclusive(int open_exclusive);
|
||||
|
||||
/** @brief Getter for option set by @ref hid_darwin_set_open_exclusive.
|
||||
|
||||
Since version 0.12.0, @ref HID_API_VERSION >= HID_API_MAKE_VERSION(0, 12, 0)
|
||||
|
||||
@ingroup API
|
||||
@return 1 if all further devices will be opened in exclusive mode.
|
||||
|
||||
@note Value returned by this function before calling to @ref hid_init or after @ref hid_exit
|
||||
is not reliable.
|
||||
*/
|
||||
int HID_API_EXPORT_CALL hid_darwin_get_open_exclusive(void);
|
||||
|
||||
/** @brief Check how the device was opened.
|
||||
|
||||
Since version 0.12.0, @ref HID_API_VERSION >= HID_API_MAKE_VERSION(0, 12, 0)
|
||||
|
||||
@ingroup API
|
||||
@param dev A device to get property from.
|
||||
|
||||
@return 1 if the device is opened in exclusive mode, 0 - opened in non-exclusive,
|
||||
-1 - if dev is invalid.
|
||||
*/
|
||||
int HID_API_EXPORT_CALL hid_darwin_is_device_open_exclusive(hid_device *dev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user