This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Is it possible to configure Nordic controller as an HID joystick/controller for gaming application?

Hi,

In nRF SDK15, Bluetooth peripheral examples for HID devices were limited to keyboard and mouse. By any means, can we configure Nordic device as a game controller?

Parents Reply Children
  •  Hi Håkon Alset,

    I do understand that there is a need to modify the device descriptor array "rep_map_data" corresponding to HID GAMEPAD settings. Unfortunately "hids_init()" contains a lot of other variable and stricture definitions and functions. What or how are we really supposed to configure those if we are planning to implement a gamepad.

  • BLE acts as the transport layer in this case, so your usb descriptor will be parsed as normal. You need to adjust your descriptor, and continue to send via the API call "ble_hids_inp_rep_send", just like the mouse and keyboard example in the SDK does.

    Best regards,

    Håkon

  • Hi,

    Like in the topic mentioned, I have used device descriptor as mentioned below.

    exports.report = new Uint8Array([
      0x05,   0x01,                    // USAGE_PAGE (Generic Desktop)
      0x09,   0x05,                    // USAGE (Game Pad) - Hut1_12v2.pdf p28 of 128
      0xA1,   0x01,                    // COLLECTION (Application)

      0xA1,   0x00,                    //   COLLECTION (Physical)
      0x05,   0x09,                    //     USAGE_PAGE (Button)
      0x19,   0x01,                    //     USAGE_MINIMUM (Button 1)
      0x29,   0x10,                    //     USAGE_MAXIMUM (Button 16)

      0x15,   0x00,                    //     LOGICAL_MINIMUM (0)
      0x25,   0x01,                    //     LOGICAL_MAXIMUM (1)
      0x95,   0x10,                    //     REPORT_COUNT (16)
      0x75,   0x01,                    //     REPORT_SIZE (1)

      0x81,   0x02,                    //     INPUT (Data,Var,Abs)

      0x05,   0x01,                    //     USAGE_PAGE (Generic Desktop)
      0x09,   0x30,                    //     USAGE (X)
      0x09,   0x31,                    //     USAGE (Y)
      0x09,   0x32,                    //     USAGE (Z) - Hut1_12v2.pdf p26 = represents R X-axis
      0x09,   0x33,                    //     USAGE (Rx) - Hut1_12v2.pdf p26 = represents R Y-axis

      0x15,   0x81,                    //     LOGICAL_MINIMUM (-127)
      0x25,   0x7F,                    //     LOGICAL_MAXIMUM (127)
      0x75,   0x08,                    //     REPORT_SIZE (8)
      0x95,   0x04,                    //     REPORT_COUNT (4)

      0x81,   0x06,                    //     INPUT (Data,Var,Abs) - absolute for joysticks ( != rel for mouse )
      0xC0,                            //   END_COLLECTION

      0xc0 ]                           // END_COLLECTION
    );

    I used a 6 byte input buffer with first 2 bytes used for 16 buttons and remaining 4 bytes used for left and right joystick.

    INPUT_REP_ID -> 0

    INPUT_REP_INDEX -> 0

    INPUT_REP_LEN -> 6

    But while testing the device functionality, out of 16, only 11 buttons were recognized (A, B, X, Y, L1, L2, L3, R1, R3, R3 & START) by my android device and the joystick movements were not registered. I wonder is there is something wrong with the descriptor or with my way doing stuffs.

    Smiley

  • Hi,

     

    I cannot see anything that stands out with your descriptor, but I do not have much experience with game pads / joysticks unfortunately. If 5 buttons are non-working, it might be that the host operating system does not implement or register these. Have you tried this with ios/windows etc to see if the behavior differs?

    Best regards,

    Håkon

Related