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

HID KEYBOARD CODE

Hello,

I have posted a question regarding the HID template code for the nrf8001. I would like to say that the progress from your help has helped immensely.

Currently, the roadblock that I am having is assigning different 'keys' to different switches. Heres the snippet of the code:

  Method for sending HID Reports
  */
  if (lib_aci_is_pipe_available(&aci_state, PIPE_HID_SERVICE_HID_REPORT_TX) 
      && (aci_state.data_credit_available == 2))
  {    
    if (digitalRead(0)==LOW)
    {   
    keypressA[2] = 0x04; 
    lib_aci_send_data(PIPE_HID_SERVICE_HID_REPORT_TX, &keypressA[0], 8);
    aci_state.data_credit_available--;
    }
    else if (digitalRead(1)==LOW)
    {
    keypressA[2] = 0x05; 
    lib_aci_send_data(PIPE_HID_SERVICE_HID_REPORT_TX, &keypressA[0], 8);
    aci_state.data_credit_available--;
  }

for some reason I cant seem to assign the letter 'a' or 'b' to these two switches. Also, may i ask for some clarification on the release key '0x00'? I would like to know how I would use it so that it would stop spamming the letter that I am interested.

I am sorry if my question is dumb. I am lost and need some guidance.

Don.

Parents
  • Hi,

    HID uses "release-keys" to indicate that the button has been pushed and released. For instance, when you hold in back-space, you will only transmit the "backspace" cmd once, then the PC will know that it should delete multiple char's instead of one.

    To stop spamming the key, just send release-keys afterwards: uint8_t release[] = {0,0,0,0, 0,0,0,0}; send_key(my_key_buffer, 8); send_key(release, 8);

    Best regards Håkon

Reply
  • Hi,

    HID uses "release-keys" to indicate that the button has been pushed and released. For instance, when you hold in back-space, you will only transmit the "backspace" cmd once, then the PC will know that it should delete multiple char's instead of one.

    To stop spamming the key, just send release-keys afterwards: uint8_t release[] = {0,0,0,0, 0,0,0,0}; send_key(my_key_buffer, 8); send_key(release, 8);

    Best regards Håkon

Children
  • This is unrelated to what I asked originally, but for the HID keyboard template code i am using (it is called BLE_HID_KEYBOARD_TEMPLATE), do you know how I would be able to change the broadcasting name? at the moment, it is being seen as Nordic Keyboard.

  • If you open file "hid_keyboard.xml", you can edit the field <name></name> under "gap settings", and then run the batch file that is located in the same directory.

    You can also open the .xml file in nRFgo Studio and change the setting there.

    Best regards Håkon