HID connect, key and modifier sending and keyboard state

Hi,

I am using ble_sdk_app_hids_keyboard example:

https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.0.0%2Fble_sdk_app_hids_keyboard.html

I try to HID connect an iOS MPA, toggle the keyboard and send HID keys.

I encounter the following issues:

1) On HID connect, the state of the keyboard is unknown (User/System - meaning the keyboard is toggled up or down). On that case the toggle might create the opposite conditions required in the application. Is there a way to configure that on HID connection, the keyboard will be toggled down allways?

2) With regards to (1), is there a way to know the keyboard state on connection (i.e. through descriptors or other info).

3) I have been able to write characters to the screen (a, b, c..) using key - 0x04, 0x05 .. and modifiers 0x00. However, when trying to send other sequences (such as spotlight - modifier 0x08, key 0x2C), the HID send has no effect. I am using the upper example, so no sure what could go wrong.

I'll really appreciate any help,

Kobi

Parents
  • Hey Edvin,

    First, happy Easter!

    1) By state I meant if the keyboard is toggled on or off, meaning does the user able to enter chars - if the kb is toggled on, it is shown on the screen and prints are enabled. If the kb is toggled off, it is not shown and no prints from the user are allowed.

    2) Maybe the HID or the nrf allows a way to read the descriptor of the OS keyboard, to see if the keyboard is toggled on/off.

    3) Please see my comment below and the use of the hids_init function. As I said, this way of configuration enables the toggle, but somehow, interrupts with printing capital letters (using the 0x02 in the modifier field.)

    tnx alot!

    Kobi

  • Hello Kobi,

    I was not aware of such a toggle function. Are you sure it is not just to have your application not send HID updates when the device is toggled off (or even disconnect to save power)? Either way this seems like a sort of state that you would need to keep track of in your application, or is it something that the computer can send to the keyboard as well (commands to toggle on/off)?

    I guess this is sort of like capslock, right?

    At least I see from the ble_app_hids_keyboard example that the capslock is always started with m_caps_on = false. According to the example comments, the host will re-send the output report containing the caps lock state. If you say that this spotlight functionality is causing it to print in capital letters, it may be that the on_hid_rep_char_write() function is a bit aggressive, interpreting the output report messages to being caps lock reports?

    Does the log from the nRF say anything useful when you are testing this spotlight functionality?

    BR,

    Edvin

  • Hey Edvin,

    1) The spotlight is just a sequence of chars sent with the HID protocol (modifier: 0x08, key: 0x2C) that causes the iOS phone to leave currently running application and move to a window called spotlight.

    The toggle is also a report sent with the HID, that just brings up/down the keyboard on the iOS phone. To add this I changed the hids_init function as shown in the first replay above.  In short I added a report to the report_map_data array and changed the size of input_report_array array to 2. (please see the first replay I made)

    In the example supplied by nrf, pressing button 1 sends a char (modifier: 0x00, key: 0x0f), while if also holding button 2, the char is sent as capital letter. This is done by changing the data sent with the HID as follows: 

    data[modifier_index] |= 0x02.

    While modifier_index is 0, and 0x02 simulates a left shift press, which will cause the letter to be capital.

    The thing is, after I changed the hids_init function, the letters are always shown in the iOS as small letters. The data sent is similar, but the letters in the iOS are small. I imagen it has something to do with the way the report_map_data array is written. Just did not find the reason.

    2) When I connect to iOS phone, if the user was in the middle of typing ,the keyboard in the iOS phone is up and the user can keep on typing. I wished to find a way, so when the nrf connects the iOS phone, the keyboard will be disabled. 

    There is a way to disable the keyboard in the iOS phone and this is done by the toggle I added and described above. The thing is, this functionality is binary, and can only be toggled from 0->1 and vice versa. It can not be set to one of the states. So, if for example, the user in the iOS phone was not typing while the nrf connection, if I will send the toggle report, the keyboard will be toggled up and the user will be able to use it.

Reply
  • Hey Edvin,

    1) The spotlight is just a sequence of chars sent with the HID protocol (modifier: 0x08, key: 0x2C) that causes the iOS phone to leave currently running application and move to a window called spotlight.

    The toggle is also a report sent with the HID, that just brings up/down the keyboard on the iOS phone. To add this I changed the hids_init function as shown in the first replay above.  In short I added a report to the report_map_data array and changed the size of input_report_array array to 2. (please see the first replay I made)

    In the example supplied by nrf, pressing button 1 sends a char (modifier: 0x00, key: 0x0f), while if also holding button 2, the char is sent as capital letter. This is done by changing the data sent with the HID as follows: 

    data[modifier_index] |= 0x02.

    While modifier_index is 0, and 0x02 simulates a left shift press, which will cause the letter to be capital.

    The thing is, after I changed the hids_init function, the letters are always shown in the iOS as small letters. The data sent is similar, but the letters in the iOS are small. I imagen it has something to do with the way the report_map_data array is written. Just did not find the reason.

    2) When I connect to iOS phone, if the user was in the middle of typing ,the keyboard in the iOS phone is up and the user can keep on typing. I wished to find a way, so when the nrf connects the iOS phone, the keyboard will be disabled. 

    There is a way to disable the keyboard in the iOS phone and this is done by the toggle I added and described above. The thing is, this functionality is binary, and can only be toggled from 0->1 and vice versa. It can not be set to one of the states. So, if for example, the user in the iOS phone was not typing while the nrf connection, if I will send the toggle report, the keyboard will be toggled up and the user will be able to use it.

Children
No Data
Related