Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Bluetooth LE device info on Windows #309

Merged
merged 1 commit into from
Sep 6, 2021

Conversation

DJm00n
Copy link
Contributor

@DJm00n DJm00n commented Jul 22, 2021

This PR fixes issue with empty manufacturer_string/product_string/serial_number in hid_device_info struct with Bluetooth LE devices on Windows systems.

Fixes: #282

@DJm00n
Copy link
Contributor Author

DJm00n commented Jul 22, 2021

BLE Controllers example: Amazon Luna and Xbox One Model Model 1914.

Before:

Device Found
  type: 0171 0419
  path: \\?\hid#{00001812-0000-1000-8000-00805f9b34fb}_dev_vid&010171_pid&0419_rev&0100_0cee99d33b5b&col01#9&261ae24b&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      100
  Interface:    -1
  Usage (page): 0x5 (0x1)

Device Found
  type: 0171 0419
  path: \\?\hid#{00001812-0000-1000-8000-00805f9b34fb}_dev_vid&010171_pid&0419_rev&0100_0cee99d33b5b&col02#9&261ae24b&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      100
  Interface:    -1
  Usage (page): 0x20 (0xff00)
  
Device Found
  type: 045e 0b13
  path: \\?\hid#{00001812-0000-1000-8000-00805f9b34fb}&dev&vid_5e&pid_0b13&rev_0505&987a14b7e3a7&ig_00#9&10a6f04f&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      505
  Interface:    -1
  Usage (page): 0x5 (0x1)

After:

Device Found
  type: 0171 0419
  path: \\?\hid#{00001812-0000-1000-8000-00805f9b34fb}_dev_vid&010171_pid&0419_rev&0100_0cee99d33b5b&col01#9&261ae24b&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 0cee99d33b5b
  Manufacturer: Amazon
  Product:      Luna Gamepad
  Release:      100
  Interface:    -1
  Usage (page): 0x5 (0x1)

Device Found
  type: 0171 0419
  path: \\?\hid#{00001812-0000-1000-8000-00805f9b34fb}_dev_vid&010171_pid&0419_rev&0100_0cee99d33b5b&col02#9&261ae24b&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 0cee99d33b5b
  Manufacturer: Amazon
  Product:      Luna Gamepad
  Release:      100
  Interface:    -1
  Usage (page): 0x20 (0xff00)
  
Device Found
  type: 045e 0b13
  path: \\?\hid#{00001812-0000-1000-8000-00805f9b34fb}&dev&vid_5e&pid_0b13&rev_0505&987a14b7e3a7&ig_00#9&10a6f04f&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 987a14b7e3a7
  Manufacturer: Microsoft
  Product:      Xbox Wireless Controller 987A14B7E3A7
  Release:      505
  Interface:    -1
  Usage (page): 0x5 (0x1)

@mcuee
Copy link
Member

mcuee commented Jul 25, 2021

This seems to work.

Before (mainline git)

Device Found
  type: 16c0 05df
  path: \\?\hid#{00001812-0000-1000-8000-00805f9b34fb}_dev_vid&0216c0_pid&05df_rev&0100_30aea44c4efa#9&38bb9e5a&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      100
  Interface:    -1
  Usage (page): 0x100 (0xff00)

Device Found
  type: 16c0 05df
  path: \\?\hid#{00001812-0000-1000-8000-00805f9b34fb}_dev_vid&0216c0_pid&05df_rev&0100_30aea44c4efa#9&f97cf65&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      100
  Interface:    -1
  Usage (page): 0x1 (0xc)

#309 output

Device Found
  type: 16c0 05df
  path: \\?\hid#{00001812-0000-1000-8000-00805f9b34fb}_dev_vid&0216c0_pid&05df_rev&0100_30aea44c4efa#9&38bb9e5a&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 30aea44c4efa
  Manufacturer: Espressif
  Product:      ESP BLE HID2
  Release:      100
  Interface:    -1
  Usage (page): 0x100 (0xff00)
  Bus type: 2

Device Found
  type: 16c0 05df
  path: \\?\hid#{00001812-0000-1000-8000-00805f9b34fb}_dev_vid&0216c0_pid&05df_rev&0100_30aea44c4efa#9&f97cf65&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 30aea44c4efa
  Manufacturer: Espressif
  Product:      ESP BLE HID2
  Release:      100
  Interface:    -1
  Usage (page): 0x1 (0xc)
  Bus type: 2

@mcuee
Copy link
Member

mcuee commented Jul 27, 2021

Yes the latest git is good.


C:\work\hid\hidapi_ble\windows\x64\Release [ble_device_info ≡]> .\hidtest.exe
hidapi test/example tool. Compiled with hidapi version 0.11.0, runtime version 0.11.0.
Compile-time version matches runtime version of hidapi.

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col01#7&383a3a17&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x2 (0x1)
  Bus type: 1

Device Found
  type: 16c0 05df
  path: \\?\hid#{00001812-0000-1000-8000-00805f9b34fb}_dev_vid&0216c0_pid&05df_rev&0100_30aea44c4efa#9&38bb9e5a&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 30aea44c4efa
  Manufacturer: Espressif
  Product:      ESP BLE HID2
  Release:      100
  Interface:    -1
  Usage (page): 0x100 (0xff00)
  Bus type: 2

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col02#7&383a3a17&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x1 (0xc)
  Bus type: 1

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col03#7&383a3a17&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x80 (0x1)
  Bus type: 1

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col04#7&383a3a17&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x1 (0xff00)
  Bus type: 1

Device Found
  type: 0488 121f
  path: \\?\hid#dell091a&col01#5&99b72d3&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 9999
  Manufacturer: Microsoft
  Product:      HIDI2C Device
  Release:      40d
  Interface:    -1
  Usage (page): 0x2 (0x1)
  Bus type: 3

Device Found
  type: 8087 0a1e
  path: \\?\hid#intc816&col01#3&36a7043c&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      200
  Interface:    -1
  Usage (page): 0xc (0x1)
  Bus type: 255

Device Found
  type: 044e 1212
  path: \\?\hid#vid_044e&pid_1212&col01&col02#7&290aacae&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}\kbd
  serial_number:
  Manufacturer:
  Product:
  Release:      0
  Interface:    -1
  Usage (page): 0x6 (0x1)
  Bus type: 255

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_01&col05#7&383a3a17&0&0004#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    1
  Usage (page): 0x2 (0xff00)
  Bus type: 1

Device Found
  type: 8087 0a1e
  path: \\?\hid#intc816&col02#3&36a7043c&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      200
  Interface:    -1
  Usage (page): 0xd (0x1)
  Bus type: 255

Device Found
  type: 044e 1212
  path: \\?\hid#vid_044e&pid_1212&col01&col01#7&290aacae&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      0
  Interface:    -1
  Usage (page): 0x2 (0x1)
  Bus type: 255

Device Found
  type: 0488 121f
  path: \\?\hid#dell091a&col02#5&99b72d3&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 9999
  Manufacturer: Microsoft
  Product:      HIDI2C Device
  Release:      40d
  Interface:    -1
  Usage (page): 0x5 (0xd)
  Bus type: 3

Device Found
  type: 047f c056
  path: \\?\hid#vid_047f&pid_c056&mi_03&col01#f&39e6f119&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: D1CEC32927974D5F9BD6B2AEBF2EA8E3
  Manufacturer: Plantronics
  Product:      Plantronics Blackwire 3220 Series
  Release:      210
  Interface:    3
  Usage (page): 0x1 (0xc)
  Bus type: 1

Device Found
  type: 045e 0000
  path: \\?\hid#converteddevice&col02#5&379854aa&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      0
  Interface:    -1
  Usage (page): 0x1 (0xc)
  Bus type: 255

Device Found
  type: 047f c056
  path: \\?\hid#vid_047f&pid_c056&mi_03&col02#f&39e6f119&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: D1CEC32927974D5F9BD6B2AEBF2EA8E3
  Manufacturer: Plantronics
  Product:      Plantronics Blackwire 3220 Series
  Release:      210
  Interface:    3
  Usage (page): 0x5 (0xb)
  Bus type: 1

Device Found
  type: 045e 0000
  path: \\?\hid#converteddevice&col03#5&379854aa&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number:
  Manufacturer:
  Product:
  Release:      0
  Interface:    -1
  Usage (page): 0x80 (0x1)
  Bus type: 255

Device Found
  type: 047f c056
  path: \\?\hid#vid_047f&pid_c056&mi_03&col03#f&39e6f119&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: D1CEC32927974D5F9BD6B2AEBF2EA8E3
  Manufacturer: Plantronics
  Product:      Plantronics Blackwire 3220 Series
  Release:      210
  Interface:    3
  Usage (page): 0x3 (0xffa0)
  Bus type: 1

Device Found
  type: 0488 121f
  path: \\?\hid#dell091a&col03#5&99b72d3&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 9999
  Manufacturer: Microsoft
  Product:      HIDI2C Device
  Release:      40d
  Interface:    -1
  Usage (page): 0x1 (0xff01)
  Bus type: 3

Device Found
  type: 046d c534
  path: \\?\hid#vid_046d&pid_c534&mi_00#7&1c54b96&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\kbd
  serial_number:
  Manufacturer: Logitech
  Product:      USB Receiver
  Release:      2901
  Interface:    0
  Usage (page): 0x6 (0x1)
  Bus type: 1

Device Found
  type: 0488 121f
  path: \\?\hid#dell091a&col04#5&99b72d3&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 9999
  Manufacturer: Microsoft
  Product:      HIDI2C Device
  Release:      40d
  Interface:    -1
  Usage (page): 0x1 (0xff02)
  Bus type: 3

Device Found
  type: 16c0 05df
  path: \\?\hid#{00001812-0000-1000-8000-00805f9b34fb}_dev_vid&0216c0_pid&05df_rev&0100_30aea44c4efa#9&f97cf65&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 30aea44c4efa
  Manufacturer: Espressif
  Product:      ESP BLE HID2
  Release:      100
  Interface:    -1
  Usage (page): 0x1 (0xc)
  Bus type: 2

Device Found
  type: 0488 121f
  path: \\?\hid#dell091a&col05#5&99b72d3&0&0004#{4d1e55b2-f16f-11cf-88cb-001111000030}
  serial_number: 9999
  Manufacturer: Microsoft
  Product:      HIDI2C Device
  Release:      40d
  Interface:    -1
  Usage (page): 0xe (0xd)
  Bus type: 3

Device Found
  type: 045e 0000
  path: \\?\hid#converteddevice&col01#5&379854aa&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\kbd
  serial_number:
  Manufacturer:
  Product:
  Release:      0
  Interface:    -1
  Usage (page): 0x6 (0x1)
  Bus type: 255

unable to open device

@Youw
Copy link
Member

Youw commented Jul 28, 2021

@DJm00n could you make a BLE fix only?
With that part only I'd like to finally release a 0.11.0 version.

BUS_TYPE isn't finished for all platforms, and even when it is done - let's have it in master for some time, before releaseing it.

@DJm00n
Copy link
Contributor Author

DJm00n commented Aug 3, 2021

@Youw I rebased this PR without #308 changes.

@mcuee
Copy link
Member

mcuee commented Aug 6, 2021

@DJm00n You may want to disable the following warning for VS.

1>C:\work\hid\hidapi_ble\windows\hid.c(421,6): warning C4996: 'mbstowcs': This function or variable may be unsafe. Consider using mbstowcs_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>C:\work\hid\hidapi_ble\windows\hid.c(1126,2): warning C4996: 'wcsncpy': This function or variable may be unsafe. Consider using wcsncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>C:\work\hid\hidapi_ble\windows\hid.c(1136,2): warning C4996: 'wcsncpy': This function or variable may be unsafe. Consider using wcsncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>C:\work\hid\hidapi_ble\windows\hid.c(1146,2): warning C4996: 'wcsncpy': This function or variable may be unsafe. Consider using wcsncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

Copy link
Member

@Youw Youw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe the warning is valid after all

windows/hid.c Show resolved Hide resolved
@DJm00n DJm00n requested a review from Youw August 12, 2021 12:00
@Youw Youw self-assigned this Aug 12, 2021
Copy link
Member

@Youw Youw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a BLE device, so I can't really try this myself, but I've reviewed the implementation and it looks good, with regards to my last comments.
As soon as those are referred, I'll merge this.

windows/hid.c Outdated Show resolved Hide resolved
windows/hid.c Show resolved Hide resolved
windows/hid.c Outdated Show resolved Hide resolved
windows/hid.c Outdated Show resolved Hide resolved
Copy link
Member

@Youw Youw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awsome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Windows Related to Windows backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Need new backend for BLE under Windows
3 participants