Ble Hid Keyboard > Physical Button > Send Keys

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
AnPa_4583841
Level 1
Level 1

The BLE HID Keyboard example is software simulated keypresses.  I want to add a physical button to a pin on a CY8CKIT - 042 - BLE A that when pressed sends a key such as, "a".  I want the device to advertise as an HID KB to windows via BLE rather in order to avoid needing a 3rd party key remapper.

The BLE HID Keyboard example included w/ PSoC 4.2 sets, "SW2" to input a capsLockPress.  I wondered if someone could help me change this to simply send an ASCII keyPress such as, "a" rather than caps lock.  Specifically w/ the code, and various areas where code needs changed as well.

Any guidance is appreciated, however it would be extra helpful for specifics, if not a simple walk-through.

Here is code from BLE HID Keyboard example in PSoC:

void SimulateKeyboard(void)

{

    static uint8 keyboard_data[KEYBOARD_DATA_SIZE]={0,0,0,0,0,0,0,0};

    CYBLE_API_RESULT_T apiResult;

    static uint32 keyboardTimer = KEYBOARD_TIMEOUT;

    static uint8 simKey;

    static uint8 capsLockPress = 0u;

    uint8 i;

   

    /* Scan SW2 key each connection interval */

    if(0u == SW2_Read())

    {

        if(capsLockPress < KEYBOARD_JITTER_SIZE)

        {

            capsLockPress++;

        }

        else if(capsLockPress == KEYBOARD_JITTER_SIZE)

        {

            keyboard_data[2u] = CAPS_LOCK;              /* Set up keyboard data */

            keyboardTimer = 1u;                         /* Clear Simulation timer to send data */

            capsLockPress++;

        }

        else    /* Ignore long key pressing */

        {

        }

    }

    else

    {

        capsLockPress = 0u;

    }

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
Yugandhar
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 5 likes given

Hello,

Please refer to the below attached project. In this project, When SW2 button is pressed it will send the ASCII values 'a' ,'b',...
And also, the device will be advertised as 'HID KB'.

Please let me know if this helps.

Thanks,
P Yugandhar.

View solution in original post

0 Likes
1 Reply
lock attach
Attachments are accessible only for community members.
Yugandhar
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 5 likes given

Hello,

Please refer to the below attached project. In this project, When SW2 button is pressed it will send the ASCII values 'a' ,'b',...
And also, the device will be advertised as 'HID KB'.

Please let me know if this helps.

Thanks,
P Yugandhar.

0 Likes