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

Sending BLE HID command to open the context menu, descriptor configuration

Hello to all!
I am trying to implement a device that can send keys from the code table 0x07 and a context menu key to the device.
Here is my descriptor:

{
	0x05, 0x01,       // Usage Page (Generic Desktop)
	0x09, 0x06,       // Usage (Keyboard)
	0xA1, 0x01,       // Collection (Application)
		0x95, 0x05,       // Report Count (5)
		0x75, 0x01,       // Report Size (1)
		0x05, 0x08,       // Usage Page (Page# for LEDs)
		0x19, 0x01,       // Usage Minimum (1)
		0x29, 0x05,       // Usage Maximum (5)
		0x91, 0x02,       // Output (Data, Variable, Absolute), Led report
		0x95, 0x01,       // Report Count (1)
		0x75, 0x03,       // Report Size (3)
		0x91, 0x01,       // Output (Data, Variable, Absolute), Led report padding

		0x95, 0x06,       // Report Count (6)
		0x75, 0x08,       // Report Size (8)
		0x15, 0x00,       // Logical Minimum (0)
		0x25, 0xFF,       // Logical Maximum (255)
		0x05, 0x07,       // Usage Page (Key codes)
		0x19, 0x00,       // Usage Minimum (0)
		0x29, 0xFF,       // Usage Maximum (255)
		0x81, 0x00,       // Input (Data, Array) Key array(6 bytes)
	0xC0,              // End Collection (Application)

	0x05, 0x01,         // Usage Page (Desktop),
	0x09, 0x80,         // Usage (Sys Control),
	0xA1, 0x01,         // Collection (Application),
		0x85, 0x01,         // Report ID (1),
		0x19, 0x81,         // Usage Minimum (Sys Power Down),
		0x29, 0x88,         // Usage Maximum (System Menu Exit),
		0x15, 0x00,         // Logical Minimum (0),
		0x25, 0x01,         // Logical Maximum (1),
		0x95, 0x08,         // Report Count (8),
		0x75, 0x01,         // Report Size (1),
		0x81, 0x02,         // Input (Variable),
	0xC0,               // End Collection,
};

The first part of the descriptor consists of 7 bytes,
1st byte for the opposite answer for LEDs, the remaining 6 bytes is a set of keys from the code table 0x07

The second part is 1 byte for sending system commands, in general I need only 1 bit is the context menu. But I decided not to limit myself to this.

Now about sending:
I am using a function from nordic

err_code = ble_hids_inp_rep_send(p_hids,
                                 INPUT_REPORT_KEYS_INDEX,
                                 INPUT_REPORT_KEYS_MAX_LEN,
                                 data,
                                 m_conn_handle);

INPUT_REPORT_KEYS_MAX_LEN = 7
INPUT_REPORT_KEYS_INDEX = 0

I want to send only the context menu key, for this, I pass [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (1 << 3)] to the data, where (1 << 3) bits the context menu command.
But unfortunately, this does not work. Most likely the error in the descriptor, but I do not have enough experience to understand what the error is. Also, I don’t know how to debug this on the phone side except for Key event viewer

Thanks!

Parents
  • I found a BLE keyboard that has this key to enable the virtual keyboard. After testing the keyboard, I found out the following things: 1) On Windows, this button launches the context menu, keycode 0x65 2) On android, this button launches the context menu 3) On ios, hides and opens the virtual keyboard

    I tried to send this code (0x65) through my device. And as expected on windows and android opens a context menu. However, on ios it is not recognized. The keyboard does not appear, programs see the key as undefined.

    Does anyone know what the problem is? What code do I need to send to IOS to open the virtual keyboard? Can there be a problem in the HID descriptor?

    0x05, 0x01,       // Usage Page (Generic Desktop)
    0x09, 0x06,       // Usage (Keyboard)
    0xA1, 0x01,       // Collection (Application)
    	0x85, 0x01,		  // Report id(1)
    	0x15, 0x00, 	  // Logical Minimum (0)
    	0x25, 0x01, 	  // Logical Maximum (1)
    	0x95, 0x05,       // Report Count (5)
    	0x75, 0x01,       // Report Size (1)
    	0x05, 0x08,       // Usage Page (Page# for LEDs)
    	0x19, 0x01,       // Usage Minimum (1)
    	0x29, 0x05,       // Usage Maximum (5)
    	0x91, 0x02,       // Output (Data, Variable, Absolute), Led report
    	0x95, 0x01,       // Report Count (1)
    	0x75, 0x03,       // Report Size (3)
    	0x91, 0x01,       // Output (Data, Variable, Absolute), Led report padding
    
    	0x95, 0x04,       // Report Count (5)
    	0x75, 0x08,       // Report Size (8)
    	0x15, 0x00,       // Logical Minimum (0)
    	0x25, 0xFF,       // Logical Maximum (255)
    	0x05, 0x07,       // Usage Page (Key codes)
    	0x19, 0x00,       // Usage Minimum (0)
    	0x29, 0xFF,       // Usage Maximum (255)
    	0x81, 0x00,       // Input (Data, Array) Key array(6 bytes)
    0xC0,              // End Collection (Application)
    
    0x05, 0x01,         // Usage Page (Desktop),
    0x09, 0x80,         // Usage (Generic Desktop),
    0xA1, 0x01,         // Collection (Application),
    	0x85, 0x02,			// Report id(2)
    	0x75, 0x01, 		// Report Size (1)
    	0x95, 0x08, 		// Report Count (8)
    	0x15, 0x00, 		// Logical Minimum (0)
    	0x25, 0x01, 		// Logical Maximum (1)
    	0x09, 0x81, 		// Usage (System Power Down)
    	0x09, 0x82, 		// Usage (System Sleep)
    	0x09, 0x83, 		// Usage (System Wake Up)
    	0x09, 0x84, 		// Usage (System Context Menu)
    	0x09, 0x85, 		// Usage (System Main Menu)
    	0x09, 0x86, 		// Usage (System App Menu)
    	0x09, 0x87, 		// Usage (System Menu Help)
    	0x09, 0x88, 		// Usage (System Menu Exit)
    	0x81, 0x02, 		// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
    0xC0,               // End Collection,

  • Does anyone know what the problem is? What code do I need to send to IOS to open the virtual keyboard?

    See the suggestion in this post. Might be possible to do something with the HID media eject key as well. 

Reply Children
Related