0

I am planning to create a macro keyboard that is compatible with Windows, Mac, and Linux. To achieve this, I need to detect the type of operating system and perform different key codes accordingly. I am using CircuitPython in Pi Pico and I am wondering how I can detect the OS in this setup.

1 Answers1

1

I do not think that is going to be possible unless you write custom drivers for each platform, as I do not think there are any keyboards that can do this -- instead they have some sort of manual control so the user can set it (eg., via an extra function key that combines with some set of letters, the alternate function of which is to select "Android", "iOS", "Windows", or an extra switch on the side etc). I did a quick search to find some confirmation of that, and ran across this reddit thread which links to a US patent held by MediaTek (a Taiwanese semiconductor corp), summarized:

A USB device enumeration process implemented in a USB device is described. The USB device first detects a type of the operating system (OS) of the USB host connected to the device, and performs device enumeration using a process selected from multiple stored processes based on the detected host OS type. To detect the host OS type, the USB device first presents itself to the host as a USB MSD or HID, performs device enumeration to collect OS behavior factors from the host, and determines the OS type from the OS behavior factors.

There's obviously more detail in the patent although I did not skim far enough to tell how explicit this gets about what the "behavior factors" are.

Unless you are planning to use this publicly, you are probably fine copying it. Otherwise you'd best beware you are not treading on it.

But IMO you should do what most keyboards do, include a simple method for the user to select an OS -- which has the further advantage of being pretty bulletproof error proneness wise including vs. those "behaviour factors" changing with a new version of whatever OS.

goldilocks
  • 60,325
  • 17
  • 117
  • 234