Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Reading HID Bluetooth devices' buffer on Win32

Reading HID Bluetooth devices' buffer on Win32

Scheduled Pinned Locked Moved C / C++ / MFC
mobiledatabasejsonquestionlounge
1 Posts 1 Posters 37 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    GIANISM_JUSTICE
    wrote on last edited by
    #1

    I'm exploring Win32's HID API to read/write from/to various devices. So far, I've been able to read responsive input for two wired devices -- an XBOX 360 Compliant controller and a steering wheel. This is good, but buffers filled by reading Bluetooth HID devices with ReadFile are not updating with user input. I've been able to test two devices: an Xbox One Wireless Controller(VID=045E,PID=02E0), and an Xbox One S Controller [Bluetooth](VID=045E,PID=02FD). What could be causing this? Are there any specific things that must be done before/while reading a Bluetooth HID device? Some notes: • RawInput does not seem to be usable without a window(i.e., in a pure console program), since it requires WM_INPUT messages to function. • XInput seems to exclusively support Xbox controllers. May use it for Xbox controllers specifically(especially for trigger separation). • Have not explored DirectInput for controllers yet. Unsure if it's useable for modern controllers(including bluetooth-based ones). Here's the current code setup. Code notes: • The end goal is to read/write inputs for real-time programs(e.g., games). • Tangentially, I'm not very experienced with Win32 and its file handling, so there's probably some issues with the general usage. Code of interest

    if(isXOneX){
    HANDLE deviceHandle = CreateFile(devicePath,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_FLAG_OVERLAPPED,NULL);
    PHIDP_PREPARSED_DATA preparsedData;
    HidD_GetPreparsedData(deviceHandle,&preparsedData);
    HIDP_CAPS caps;
    HidP_GetCaps(preparsedData,&caps);
    HIDP_BUTTON_CAPS hidpButtonCaps[caps.NumberInputButtonCaps];
    HidP_GetButtonCaps(HIDP_REPORT_TYPE::HidP_Input,&hidpButtonCaps[0],&caps.NumberInputButtonCaps,preparsedData);
    DWORD reportId = hidpButtonCaps[0].ReportID;
    auto inputReportBufferLength = caps.InputReportByteLength+1;//+1 for report ID
    BYTE inputReportBuffer[inputReportBufferLength];
    while(true){
    OVERLAPPED overlapped;
    memset(&overlapped, 0, sizeof(overlapped));
    if(ReadFileEx(deviceHandle, &inputReportBuffer[0], inputReportBufferLength, &overlapped, NULL)){
    DWORD bytesTransferred;
    if(GetOverlappedResult(deviceHandle, &overlapped, &bytesTransferred, FALSE)){
    for(auto i=0;i

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups