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

How to implement Ctrl-C for HID keyboard

Hi Guys, I try to implements the ctrl-C/V for bluetooth HID keyboard. But from SDK, I can't figure out how to send two keys. Even I do not use buffer_enqueue/dequeue in order to keep 'Ctrl' pressed, not released, still can't work. Does anyone figure out how to work on it?

Parents
  • Hi,

    I just checked what are escape codes for "ctr+c" and "ctr+v". I did it by debugging function: cli_state_collect in nrf_cli module.

    Here are escape codes:

    • ctr+c = 0x03
    • ctr+v = 0x16

    To handle it I would need to update cli_state_collect function with two extra cases in below switch statement:

    switch (data)
    {
        case NRF_CLI_VT100_ASCII_ESC:       /* ESCAPE */
            NRF_CLI_RECIEVE_STATE_NEXT(p_cli, NRF_CLI_RECEIVE_ESC);
            break;
        case '\0':
            break;
        case '\t':                          /* TAB */
            cli_tab_handle(p_cli);
            break;
        case NRF_CLI_VT100_ASCII_BSPACE:    /* BACKSPACE */
            char_backspace(p_cli);
            break;
        case NRF_CLI_VT100_ASCII_DEL:       /* DELETE */
            char_delete(p_cli);
            break;
    
        case 0x03   // ctr+c
            break;
        case 0x16:  // ctr+v
            break;
    
        default:
            if (isprint((int)data))
            {
                char_insert(p_cli, data);
            }
            break;
    }
    
Reply
  • Hi,

    I just checked what are escape codes for "ctr+c" and "ctr+v". I did it by debugging function: cli_state_collect in nrf_cli module.

    Here are escape codes:

    • ctr+c = 0x03
    • ctr+v = 0x16

    To handle it I would need to update cli_state_collect function with two extra cases in below switch statement:

    switch (data)
    {
        case NRF_CLI_VT100_ASCII_ESC:       /* ESCAPE */
            NRF_CLI_RECIEVE_STATE_NEXT(p_cli, NRF_CLI_RECEIVE_ESC);
            break;
        case '\0':
            break;
        case '\t':                          /* TAB */
            cli_tab_handle(p_cli);
            break;
        case NRF_CLI_VT100_ASCII_BSPACE:    /* BACKSPACE */
            char_backspace(p_cli);
            break;
        case NRF_CLI_VT100_ASCII_DEL:       /* DELETE */
            char_delete(p_cli);
            break;
    
        case 0x03   // ctr+c
            break;
        case 0x16:  // ctr+v
            break;
    
        default:
            if (isprint((int)data))
            {
                char_insert(p_cli, data);
            }
            break;
    }
    
Children
No Data
Related