Bluetooth hid proxy mode

The crux of finding a HID proxy-capable USB bluetooth adapter

So, for some not very profound reasons (watching demos and putting my spare Ivy Bridge CPU to a use), I ended up having a living room PC again. And as it’s the living room, input devices must be wireless. Since I’m not a fan of running proprietary wireless technologies that jam my Wifi’s 2.4 GHz band and because of increased usability with other devices such as tablets, I wanted a keyboard and a mouse based on Bluetooth technology. Because of design, functionality and good experiences I bought Microsoft’s Wedge mobile keyboard and Sculpt Touch mouse:

Microsoft Wedge Mobile Keyboard (with German layout) Microsoft Sculpt Touch Mouse

All nice and sleek and working within an installed OS but it is only when you’re trying to reinstall your operating system or need to enter your BIOS that bluetooth-based input devices still have a large drawback: they do not work without a Bluetooth driver stack. And during both OS installation and BIOS configuration you do not have one yet. Even the modern UEFI world doesn’t change that.

At least in the PC world — Apple has been using Bluetooth-based input devices for over a decade now and admittedly often went a step forward for the sake of user experience. When the Apple Wireless keyboard was introduced in September 2003, a software update was published that allowed for the wireless keyboard to take control of the boot process.

However, this was strictly speaking not Apple’s merit alone: the software update worked with Cambridge Silicon Radio (CSR)-based adapters only because that very company introduced a technique called HID proxy for its adapters in August 2003 (see their press release “CSR saves stranded mice”).

The idea behind HID proxy is that the bluetooth adapter has additional intelligence that allows it to a.) take over responsibility from the host it’s connected to run and run certain software layers itself and b.) run in this special mode until the OS’s bluetooth stack is loaded and tells it to return to “normal” operation. In HID proxy mode, the adapter communicates on its own with previously paired Bluetooth input devices and emulates to its host a USB keyboard and USB mouse through a HID interface instead of exposing the ordinary HCI interface. As the PC industry has at least succeeded in getting broad USB support into BIOS and OS installation software, this means that the Bluetooth keyboard and mouse will magically work in spite of a missing Bluetooth stack.

You see, Apple did not magically invent an Apple-only, HID proxy-capable bluetooth adapter. In fact, in 2003 the internal Bluetooth modules in their Notebooks were software-compatible with certain revisions of the D-Link USB bluetooth adapter DBT-120. They also didn’t ground-breakingly integrate Bluetooth functionality into their EFI firmware. They just made their Bluetooth hardware default to HID proxy mode until Mac OS X tells it to switch to HCI mode, that’s the whole secret.

Читайте также:  Bluetooth отключается через минуту

D-Link DBT-120 USB bluetooth adapter

However, this means that if you use such a Bluetooth adapter in HID proxy mode, the OS must be aware of it and tell it to switch to HCI mode or you will have no Bluetooth functionality once it’s loaded. And to my knowledge no Windows Bluetooth stack does, not even Microsoft’s own stack in the latest Windows 8.1.

For this very reason, Apple, on its Bluetooth Firmware Update 1.2 Download page, warned that applying that update “[…] to a D-Link USB to Bluetooth adapter will make it incompatible with non-Macintosh systems”. Which, back then, yet seems to have been overseen by a number of users, considering this FAQ page by German computer magazine c’t. Yet, this does not mean a DBT-120 flashed with the Apple update is bricked, as Edd Dumbill pointed out among others.

The other problem is: the DBT-120 is an old Bluetooth 1.1 device that’s not produced anymore and by 2014 it is next to impossible to find a HID proxy-capable USB bluetooth adapter on the market. This tonymacx86.com forum post lists four, one of them being the Apple built-in BT module (which apparantly can be modded to be hooked up to an USB port) and one being the mentioned DBT-120 from 2003. The Belkin F8T016NG mentioned seems to be still available at Amazon UK and Amazon Germany despite being listed as being “made anymore”, whereas the fourth adapter, the Belkin F8T016CW, does not seem to be available in Germany at all.

From a hardware perspective, there is no reason for this situation. As this leaked CSR presentation on their BlueCore firmware points out, having HID proxy support is merely a question of enabling it in firmware builds. It doesn’t seem to be a question of firmware size either if only integrating RFCOMM support (which nobody seems to need) requires an 8 MBit flash chip and even the DBT-120 back then could be flashed to support both HID proxy and HCI.

The real reason is the lack of software support instead: as mentioned above, even with CSR-specific drivers Windows bluetooth stacks treat the adapter as an USB HID device and do not know that it can be told to reveal its real nature in form of the HCI interface.

CSR saw that problem and provided a sample Windows command-line application, hid2hci.exe, that does exactly the job (do not confuse it with the Linux executable hid2hci from the BlueZ project). It is a small executable of 44KB size and without any external dependencies. You can optionally tell it the USB vendor ID and product ID of the bluetooth adapter to be addressed, defaulting to a vendor ID of 0x0a12, which is CSR’s ID, and a product ID of 0x1000, which is the product ID a CSR USB bluetooth adapter uses when in HID proxy mode. After running this executable, the adapter will reappear on the USB bus with a different product ID and a HID interface, causing the normal Bluetooth driver stack to take over control. This change is not permanent, so the executable needs to be run after each OS boot and after each plugging out and in the USB bus, but, as a followup post will show, that can be nicely automated.

Читайте также:  Jvc kd r717 bluetooth

So to summarize, what it takes to get your Bluetooth input devices working in the BIOS as well is:

  1. a USB bluetooth adapter defaulting to HID proxy mode
  2. the hid2hci.exe tool
  3. some automation magic

As for the first problem, no matter what CSR-based bluetooth adapter you own, you’d need a HID proxy-enabled firmware. The way it looks like Apple’s update is the only one freely available on the Internet, but it’s for the old D-Link DBT-120 only. Maybe you can find one on eBay. As chance would have it, I still had one flying around and tried the update without having a Mac. This followup post has more on this topic.

As for the second problem, I do not know if and in what context CSR distributes hid2hci.exe if at all. This blog post by Stephan Joseph used to have an archive btinstall.zip with it that was even referenced inside a book called “Take control of Windows running on a Mac” but you’ll have to look for yourself. Do not ask me to provide you with a copy.

As for the third problem, look out for a second followup post — I’ve done some cool PowerShell scripting 😉

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Bluetooth HID proxy is implemented using Arduino. Make a Bluetooth keyboard or mouse (WIP) work in BIOS or device without BT stack (e.g. TMK USB to USB Converter)

houkanshan/arduino-bt-hid-proxy

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Читайте также:  Настройка bluetooth gps android

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

Readme.md

Arduino Bluetooth HID Proxy

Bridge Bluetooth keyboard to wired USB. (i.e. Bluetooth HID Proxy Mode). Works like a Logitech Unifying Receiver but for bluetooth devices.

(Image idea from pihidproxy)

NOTE: If you are looking for a project that turns a wired keyboard into a wireless keyboard. This is not the right project. This project does the reverse.

It can be useful in two scenarios:

  1. You have a bluetooth keyboard, but it doesn’t work in BIOS, Bootloader or TV.
  2. You have a bluetooth keyboard and you want turn it into a programmable keyboard (with TMK USB to USB Converter)

Previously, I used MikerR’s pihidproxy but it’s not transparency enough and I don’t like the start-up time of RPi. So I made this one with Arduino.

  • SparkFun Micro Pro 3.3V (Other ATmega32U4 based board should also work)
  • USB Host Shield for Arduino Pro Mini (Out of stock due to COVID, I’m using this cheaper clone)
  • USB Bluetooth dongle (should supported by USB Host Library 2.0, I’ve tested this and this)
  • a Micro-USB to USB Cable, Soldering Iron Kit, Electronic Wire, Male Header Pin

Follow this guide to connect Micro Pro and USB Host Shield. Or tl;dr:

  1. Cut the line between VBUS and 2k2 to get 5.0V
  2. Two Jump wires on VCC and RST, VBUS and RAW
  3. Put Micro Pro on USB Host shield, align, and connect: (Top) INT, GND, (Bottom) SS, MOSI, MISO, SCK, VCC, GND, RAW
  1. Open in Arduino IDE
  2. In Tools -> Manage Libraries , search and install USB Host Shield Library 2.0 , HID-Project
  3. Let’s test if USB Host shield is working: File -> Examples -> USB Host Shield Library 2.0 -> board_qc
    1. Upload
    2. Tools -> Serial Monitor
    3. There’ll be a GPIO error, ignore it and send any key in the serial monitor.
    4. Wait until All tests passed.
    5. This article could be helpful if you meet any issue.

    Uploading for the first pairing

    1. Upload the project, open Tools -> Serial Monitor
    2. Turn on your bluetooth device and start pairing
    3. Wait for bluetooth scanning
    4. Follow the guide in the Serial Monitor and finish the pairing
    5. Now the paired address is remembered by arduino.

    The current code will try to re-pair every time after power on. Let’s stop it.

    1. In BTHID.ino , comment BTHID bthid(&Btd, PAIR, «0000»); and uncomment BTHID bthid(&Btd);
    2. Upload
    3. Press any button on the device, then it should be connected.
    1. In Documents/Arduino/libraries/USB_Host_Shield_2.0/settings.h , change #define ENABLE_UHS_DEBUGGING 0 to 1 . It will display detailed log in serial monitor
    2. For more detailed log, uncomment #define EXTRADEBUG in *.cpp file you want to inspect.

    About

    Bluetooth HID proxy is implemented using Arduino. Make a Bluetooth keyboard or mouse (WIP) work in BIOS or device without BT stack (e.g. TMK USB to USB Converter)

    Источник

Оцените статью
Adblock
detector