How to customize HID raw report descriptor using RN42 module with Arduino

Greetings,
I am currently developing a custom gamepad for mobile devices which consists of :

  • 9 Buttons,
  • x2 Analog Joysticks,
  • Bluetooth HC05 (Flashed with RN42 firmware),
  • Leonardo Pro Micro Arduino ATMEGA32U4 5V 16MHz.

After accessing the Command mode via serial monitor, I managed to set the Bluetooth device as an HID gamepad type device and the rest of configurations.
I found out that RN42 has a preset of its own set of report scans and as far as I understand are not modifiable? Could someone correct me if I am wrong?

The problem is that the scans that I send via Serial1.write have a limitation for 16 buttons and 2 joysticks, the second joystick is being limited to Z and X axis. D-PAD (POV) is missing as well. What I need is a full range of available buttons like in popular Playstation or Xbox controllers.


Gamepad properties on Windows 10

After unsuccessful attempts using available libraries such as BPLib, I managed to send the scans like this:

void JoystickInput(byte ST_BTN, byte ND_BTN, byte L_X, byte L_Y, byte R_X, byte R_Y) {

  Serial1.write((byte)0xFD);   // HID raw report descriptor
  Serial1.write((byte)0x6);    // Length
  Serial1.write((byte)R_X);   // Right X Axis
  Serial1.write((byte)R_Y);   // Right Y Axis
  Serial1.write((byte)L_X);   // Left X Axis
  Serial1.write((byte)L_Y);   // Left Y Axis
  Serial1.write((byte)ST_BTN & 0xFF); // first 8 buttons
  Serial1.write((byte)ND_BTN & 0xFF); //  second 8 buttons
}

Importantly, I need access to D-PAD and Y rotation. Is there any way to send scans to the host while still being identified as a gamepad on different devices? If it is possible to do it by modifying the descriptor, could someone point me in the right direction how to do it? Thank you in advance.

Bump!

Hey dude, did you achieve something?

I am interested in this too, but there is nothing on the internet

So, I was curious and I opened the files of the firmware dump with a simple text editor and all I saw was code like this

@000000 0000
@000001 0000
@000002 0000
@000003 55e0
@000004 df01

I suppose that the first column is something like a "coordenate" where the next hex number goes, and this last number is part of the programming.

Then, I search a example of the HID report descriptor of a gamepad on the net and I begin to search a structure like this in the dump files:

0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
0x09, 0x05,                    // USAGE (Game Pad)
0xa1, 0x01,                    // COLLECTION (Application)
0xa1, 0x00,                    //   COLLECTION (Physical)
0x05, 0x01,                    //     USAGE_PAGE (Generic Desktop)
0x09, 0x30,                    //     USAGE (X)
0x09, 0x31,                    //     USAGE (Y)
0x09, 0x32,                    //     USAGE (Z) rx
0x09, 0x35,                    //     USAGE (Rx) ry
0x35, 0x00,                    //     PHYSICAL_MINIMUM (0)
0x46, 0xff, 0x00,              //     PHYSICAL_MAXIMUM (255)
0x15, 0x00,                    //     LOGICAL_MINIMUM (-127)
0x26, 0xff, 0x00,                    //     LOGICAL_MAXIMUM (127)
0x75, 0x08,                    //     REPORT_SIZE (8)
0x95, 0x04,                    //     REPORT_COUNT (4)
0x81, 0x02,                    //     INPUT (Data,Var,Abs)
0xc0,                          //   END_COLLECTION
0xc0                           // END_COLLECTION

(I´m not sure if the last code is good or not)

Then in the file with extension .xpv I found a structure very similar:

@06ef75 0005
@06ef76 0001
@06ef77 0009
@06ef78 0005
@06ef79 00a1
@06ef7a 0001
@06ef7b 0009
@06ef7c 0001
@06ef7d 00a1
@06ef7e 0000
@06ef7f 0009
@06ef80 0030
@06ef81 0009
@06ef82 0031
@06ef83 0009
@06ef84 0032
@06ef85 0009
@06ef86 0033
@06ef87 0015
@06ef88 0081
@06ef89 0025
@06ef8a 007f
@06ef8b 0075
@06ef8c 0008
@06ef8d 0095
@06ef8e 0004
@06ef8f 0081
@06ef90 0002
@06ef91 0005
@06ef92 0009
@06ef93 0019
@06ef94 0001
@06ef95 0029
@06ef96 0010
@06ef97 0015
@06ef98 0000
@06ef99 0025
@06ef9a 0001
@06ef9b 0095
@06ef9c 0010
@06ef9d 0075
@06ef9e 0001
@06ef9f 0081
@06efa0 0002
@06efa1 00c0
@06efa2 00c0

My questions now are:

Only editing this part with a simple text editor is viable?
What happens if is needed to move the whole code down or up?

I´m beginner in coding, I was making some patterns of light with leds, next I saw Evan Kale´s video, I make my own PS2 Bluetooht gamepad but I noticed that the buttons wasn´t cordinated with that the device was saying. So I made my own code (It took me more than a week make something functional ), but I´m not satisfied with the result, and I´m here now

In this point I need help

Sorry if my english is bad.