How does my keyboard recognize which PC it connect(windows or MAC)

Dear Nordic Engineers

 How can  keyboard recognize which PC it connect(windows or MAC)?

If the PC is a window, left bottom key are "alt" or "win" and other

If the PC is a MAC ,left bottom key are "cmd" or "option" and other

Best regards

Ted

Parents Reply Children
  • Hi Ted

    Is it HID over Bluetooth or over USB?

    Assuming you are connecting over Bluetooth I am not sure there is a 100% reliable way of detecting whether or not you are connected to a PC or a Mac, since the HID standard doesn't include mechanisms for the HID device to get information about the host. 

    One trick that works on mobile platforms (Android vs iOS) is to set up a GATT client on the peripheral (keyboard) side and do a discovery of the services available in the central. If the central device uses the device information service you can read out information about the manufacturer here, and if it uses any Apple specific services (such as the Apple Notification Center Service) then this is also a good sign that you are connected to an Apple device. I am not sure if Mac's use this service though, as it is designed for mobile devices and not PC's. 

    Are you sure that you can not just send the same keycode from the keyboard, and it will be interpreted as either Windows button, cmd etc based on the host OS?

    Best regards
    Torbjørn

  • Hi Torbjørn

    Thank you for your reply!

    The keyboard can select  Bluetooth 、USB and ESB。

    If use USB or ESB.Is there any way to get PC information?

    I'm not sure if the host OS recognizes buttonby keycode, most keyboards use switches to switch between Window mode and Mac mode

    Best regards

    Ted

  • Hi Ted

    I don't think there is any way to get information about the host over USB, unless you add some driver or program on the PC side that writes a custom packet over USB with information about the host. Then you would need to implement a driver for Windows and a different one for Mac to set up the keyboard accordingly. 

    As an example Logitech provides a small software utility with their keyboard/mouse products in order to provide more configuration options. 

    When using ESB I assume you have a USB receiver dongle connected to the PC/Mac? 
    Then the limitation is the same as with USB. With ESB you can always send some custom data back to the keyboard if you want to, the question is how to get this information over the USB interface to the dongle. 

    According to this article it should be possible to use Windows keyboards on a Mac, but it does seem like you have to do a bit of configuration work on the Mac side for the best experience. 

    I would like to discuss this topic a bit more with some of my colleagues, and I will try to get back to you with more information later in the week. 

    Best regards
    Torbjørn

  • Hi Torbjørn

    Thank you again for your reply!

    I learned a lot from your answer

    Best regards

    Ted

  • Hi Ted

    Glad to hear I could help out Slight smile

    As I said I discussed this a bit more with one of the developers, and he didn't know about a good way to do this either unfortunately. 

    As he pointed out many existing keyboards include a switch that allows you to select between PC and Mac, rather than relying on being able to automatically detect it. 

    Best regards
    Torbjørn

Related