Valve contributed code is under the Zlib license
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 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419
diff --git a/src/hidapi/android/hid.cpp b/src/hidapi/android/hid.cpp
index e5af5ad..9e3f7e1 100644
--- a/src/hidapi/android/hid.cpp
+++ b/src/hidapi/android/hid.cpp
@@ -1,10 +1,26 @@
-//=================== Copyright Valve Corporation, All rights reserved. =======
-//
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 2021 Valve Corporation
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
// Purpose: A wrapper implementing "HID" API for Android
//
// This layer glues the hidapi API to Android's USB and BLE stack.
-//
-//=============================================================================
#include <jni.h>
#include <android/log.h>
diff --git a/src/hidapi/ios/hid.m b/src/hidapi/ios/hid.m
index 504a994..4c74767 100644
--- a/src/hidapi/ios/hid.m
+++ b/src/hidapi/ios/hid.m
@@ -1,8 +1,23 @@
-//======== Copyright (c) 2017 Valve Corporation, All rights reserved. =========
-//
-// Purpose: HID device abstraction temporary stub
-//
-//=============================================================================
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 2021 Valve Corporation
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
#include "../../SDL_internal.h"
#ifdef SDL_JOYSTICK_HIDAPI
diff --git a/src/hidapi/linux/hid.cpp b/src/hidapi/linux/hid.cpp
deleted file mode 100644
index 841f34f..0000000
--- a/src/hidapi/linux/hid.cpp
+++ /dev/null
@@ -1,333 +0,0 @@
-//=================== Copyright Valve Corporation, All rights reserved. =======
-//
-// Purpose: A wrapper around both the libusb and hidraw versions of HIDAPI
-//
-// The libusb version doesn't support Bluetooth, but not all Linux
-// distributions allow access to /dev/hidraw*
-//
-// This merges the two, at a small performance cost, until distributions
-// have granted access to /dev/hidraw*
-//
-//=============================================================================
-
-#define NAMESPACE HIDRAW
-#include "../hidapi/hidapi.h"
-#undef NAMESPACE
-#undef HIDAPI_H__
-
-#define NAMESPACE HIDUSB
-#include "../hidapi/hidapi.h"
-#undef NAMESPACE
-#undef HIDAPI_H__
-
-#include "../hidapi/hidapi.h"
-
-#include "../../../public/tier1/utlvector.h"
-#include "../../../public/tier1/utlhashmap.h"
-
-
-template <class T>
-void CopyHIDDeviceInfo( T *pSrc, struct hid_device_info *pDst )
-{
- pDst->path = pSrc->path ? strdup( pSrc->path ) : NULL;
- pDst->vendor_id = pSrc->vendor_id;
- pDst->product_id = pSrc->product_id;
- pDst->serial_number = pSrc->serial_number ? wcsdup( pSrc->serial_number ) : NULL;
- pDst->release_number = pSrc->release_number;
- pDst->manufacturer_string = pSrc->manufacturer_string ? wcsdup( pSrc->manufacturer_string ) : NULL;
- pDst->product_string = pSrc->product_string ? wcsdup( pSrc->product_string ) : NULL;
- pDst->usage_page = pSrc->usage_page;
- pDst->usage = pSrc->usage;
- pDst->interface_number = pSrc->interface_number;
- pDst->next = NULL;
-}
-
-extern "C"
-{
-
-enum EHIDAPIType
-{
- k_EHIDAPIUnknown,
- k_EHIDAPIRAW,
- k_EHIDAPIUSB
-};
-
-static CUtlHashMap<uintptr_t, EHIDAPIType> s_hashDeviceToAPI;
-
-static EHIDAPIType GetAPIForDevice( hid_device *pDevice )
-{
- int iIndex = s_hashDeviceToAPI.Find( (uintptr_t)pDevice );
- if ( iIndex != -1 )
- {
- return s_hashDeviceToAPI[ iIndex ];
- }
- return k_EHIDAPIUnknown;
-}
-
-struct hid_device_info HID_API_EXPORT * HID_API_CALL hid_enumerate(unsigned short vendor_id, unsigned short product_id)
-{
- struct HIDUSB::hid_device_info *usb_devs = HIDUSB::hid_enumerate( vendor_id, product_id );
- struct HIDUSB::hid_device_info *usb_dev;
- struct HIDRAW::hid_device_info *raw_devs = HIDRAW::hid_enumerate( vendor_id, product_id );
- struct HIDRAW::hid_device_info *raw_dev;
- struct hid_device_info *devs = NULL, *last = NULL, *new_dev;
-
- for ( usb_dev = usb_devs; usb_dev; usb_dev = usb_dev->next )
- {
- bool bFound = false;
- for ( raw_dev = raw_devs; raw_dev; raw_dev = raw_dev->next )
- {
- if ( usb_dev->vendor_id == raw_dev->vendor_id && usb_dev->product_id == raw_dev->product_id )
- {
- bFound = true;
- break;
- }
- }
-
-//printf("%s USB device VID/PID 0x%.4x/0x%.4x, %ls %ls\n", bFound ? "Found matching" : "Added new", usb_dev->vendor_id, usb_dev->product_id, usb_dev->manufacturer_string, usb_dev->product_string );
-
- if ( !bFound )
- {
- new_dev = new struct hid_device_info;
- CopyHIDDeviceInfo( usb_dev, new_dev );
-
- if ( last )
- {
- last->next = new_dev;
- }
- else
- {
- devs = new_dev;
- }
- last = new_dev;
- }
- }
- HIDUSB::hid_free_enumeration( usb_devs );
-
- for ( raw_dev = raw_devs; raw_dev; raw_dev = raw_dev->next )
- {
- new_dev = new struct hid_device_info;
- CopyHIDDeviceInfo( raw_dev, new_dev );
- new_dev->next = NULL;
-
- if ( last )
- {
- last->next = new_dev;
- }
- else
- {
- devs = new_dev;
- }
- last = new_dev;
- }
- HIDRAW::hid_free_enumeration( raw_devs );
-
- return devs;
-}
-
-void HID_API_EXPORT HID_API_CALL hid_free_enumeration(struct hid_device_info *devs)
-{
- while ( devs )
- {
- struct hid_device_info *next = devs->next;
- free( devs->path );
- free( devs->serial_number );
- free( devs->manufacturer_string );
- free( devs->product_string );
- delete devs;
- devs = next;
- }
-}
-
-HID_API_EXPORT hid_device * HID_API_CALL hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number)
-{
- hid_device *pDevice = NULL;
- if ( ( pDevice = (hid_device *)HIDRAW::hid_open( vendor_id, product_id, serial_number ) ) != NULL )
- {
- s_hashDeviceToAPI.Insert( (uintptr_t)pDevice, k_EHIDAPIRAW );
- return pDevice;
- }
- if ( ( pDevice = (hid_device *)HIDUSB::hid_open( vendor_id, product_id, serial_number ) ) != NULL )
- {
- s_hashDeviceToAPI.Insert( (uintptr_t)pDevice, k_EHIDAPIUSB );
- return pDevice;
- }
- return NULL;
-}
-
-HID_API_EXPORT hid_device * HID_API_CALL hid_open_path(const char *path, int bExclusive)
-{
- hid_device *pDevice = NULL;
- if ( ( pDevice = (hid_device *)HIDRAW::hid_open_path( path, bExclusive ) ) != NULL )
- {
- s_hashDeviceToAPI.Insert( (uintptr_t)pDevice, k_EHIDAPIRAW );
- return pDevice;
- }
- if ( ( pDevice = (hid_device *)HIDUSB::hid_open_path( path, bExclusive ) ) != NULL )
- {
- s_hashDeviceToAPI.Insert( (uintptr_t)pDevice, k_EHIDAPIUSB );
- return pDevice;
- }
- return NULL;
-}
-
-int HID_API_EXPORT HID_API_CALL hid_write(hid_device *device, const unsigned char *data, size_t length)
-{
- switch ( GetAPIForDevice( device ) )
- {
- case k_EHIDAPIRAW:
- return HIDRAW::hid_write( (HIDRAW::hid_device*)device, data, length );
- case k_EHIDAPIUSB:
- return HIDUSB::hid_write( (HIDUSB::hid_device*)device, data, length );
- default:
- return -1;
- }
-}
-
-int HID_API_EXPORT HID_API_CALL hid_read_timeout(hid_device *device, unsigned char *data, size_t length, int milliseconds)
-{
- switch ( GetAPIForDevice( device ) )
- {
- case k_EHIDAPIRAW:
- return HIDRAW::hid_read_timeout( (HIDRAW::hid_device*)device, data, length, milliseconds );
- case k_EHIDAPIUSB:
- return HIDUSB::hid_read_timeout( (HIDUSB::hid_device*)device, data, length, milliseconds );
- default:
- return -1;
- }
-}
-
-int HID_API_EXPORT HID_API_CALL hid_read(hid_device *device, unsigned char *data, size_t length)
-{
- switch ( GetAPIForDevice( device ) )
- {
- case k_EHIDAPIRAW:
- return HIDRAW::hid_read( (HIDRAW::hid_device*)device, data, length );
- case k_EHIDAPIUSB:
- return HIDUSB::hid_read( (HIDUSB::hid_device*)device, data, length );
- default:
- return -1;
- }
-}
-
-int HID_API_EXPORT HID_API_CALL hid_set_nonblocking(hid_device *device, int nonblock)
-{
- switch ( GetAPIForDevice( device ) )
- {
- case k_EHIDAPIRAW:
- return HIDRAW::hid_set_nonblocking( (HIDRAW::hid_device*)device, nonblock );
- case k_EHIDAPIUSB:
- return HIDUSB::hid_set_nonblocking( (HIDUSB::hid_device*)device, nonblock );
- default:
- return -1;
- }
-}
-
-int HID_API_EXPORT HID_API_CALL hid_send_feature_report(hid_device *device, const unsigned char *data, size_t length)
-{
- switch ( GetAPIForDevice( device ) )
- {
- case k_EHIDAPIRAW:
- return HIDRAW::hid_send_feature_report( (HIDRAW::hid_device*)device, data, length );
- case k_EHIDAPIUSB:
- return HIDUSB::hid_send_feature_report( (HIDUSB::hid_device*)device, data, length );
- default:
- return -1;
- }
-}
-
-int HID_API_EXPORT HID_API_CALL hid_get_feature_report(hid_device *device, unsigned char *data, size_t length)
-{
- switch ( GetAPIForDevice( device ) )
- {
- case k_EHIDAPIRAW:
- return HIDRAW::hid_get_feature_report( (HIDRAW::hid_device*)device, data, length );
- case k_EHIDAPIUSB:
- return HIDUSB::hid_get_feature_report( (HIDUSB::hid_device*)device, data, length );
- default:
- return -1;
- }
-}
-
-void HID_API_EXPORT HID_API_CALL hid_close(hid_device *device)
-{
- switch ( GetAPIForDevice( device ) )
- {
- case k_EHIDAPIRAW:
- HIDRAW::hid_close( (HIDRAW::hid_device*)device );
- break;
- case k_EHIDAPIUSB:
- HIDUSB::hid_close( (HIDUSB::hid_device*)device );
- break;
- default:
- break;
- }
- s_hashDeviceToAPI.Remove( (uintptr_t)device );
-}
-
-int HID_API_EXPORT_CALL hid_get_manufacturer_string(hid_device *device, wchar_t *string, size_t maxlen)
-{
- switch ( GetAPIForDevice( device ) )
- {
- case k_EHIDAPIRAW:
- return HIDRAW::hid_get_manufacturer_string( (HIDRAW::hid_device*)device, string, maxlen );
- case k_EHIDAPIUSB:
- return HIDUSB::hid_get_manufacturer_string( (HIDUSB::hid_device*)device, string, maxlen );
- default:
- return -1;
- }
-}
-
-int HID_API_EXPORT_CALL hid_get_product_string(hid_device *device, wchar_t *string, size_t maxlen)
-{
- switch ( GetAPIForDevice( device ) )
- {
- case k_EHIDAPIRAW:
- return HIDRAW::hid_get_product_string( (HIDRAW::hid_device*)device, string, maxlen );
- case k_EHIDAPIUSB:
- return HIDUSB::hid_get_product_string( (HIDUSB::hid_device*)device, string, maxlen );
- default:
- return -1;
- }
-}
-
-int HID_API_EXPORT_CALL hid_get_serial_number_string(hid_device *device, wchar_t *string, size_t maxlen)
-{
- switch ( GetAPIForDevice( device ) )
- {
- case k_EHIDAPIRAW:
- return HIDRAW::hid_get_serial_number_string( (HIDRAW::hid_device*)device, string, maxlen );
- case k_EHIDAPIUSB:
- return HIDUSB::hid_get_serial_number_string( (HIDUSB::hid_device*)device, string, maxlen );
- default:
- return -1;
- }
-}
-
-int HID_API_EXPORT_CALL hid_get_indexed_string(hid_device *device, int string_index, wchar_t *string, size_t maxlen)
-{
- switch ( GetAPIForDevice( device ) )
- {
- case k_EHIDAPIRAW:
- return HIDRAW::hid_get_indexed_string( (HIDRAW::hid_device*)device, string_index, string, maxlen );
- case k_EHIDAPIUSB:
- return HIDUSB::hid_get_indexed_string( (HIDUSB::hid_device*)device, string_index, string, maxlen );
- default:
- return -1;
- }
-}
-
-HID_API_EXPORT const wchar_t* HID_API_CALL hid_error(hid_device *device)
-{
- switch ( GetAPIForDevice( device ) )
- {
- case k_EHIDAPIRAW:
- return HIDRAW::hid_error( (HIDRAW::hid_device*)device );
- case k_EHIDAPIUSB:
- return HIDUSB::hid_error( (HIDUSB::hid_device*)device );
- default:
- return NULL;
- }
-}
-
-}
diff --git a/src/joystick/hidapi/steam/controller_constants.h b/src/joystick/hidapi/steam/controller_constants.h
index d57315b..d0d5688 100644
--- a/src/joystick/hidapi/steam/controller_constants.h
+++ b/src/joystick/hidapi/steam/controller_constants.h
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
- Copyright (C) 2020 Valve Corporation
+ Copyright (C) 2021 Valve Corporation
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages