1 Reply Latest reply on May 26, 2020 11:08 PM by PY_21

    Ble Hid Keyboard > Physical Button > Send Keys

    AnPa_4583841

      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;

          }