adafruit / Adafruit_nRF52_Arduino

Adafruit code for the Nordic nRF52 BLE SoC on Arduino
Other
615 stars 496 forks source link

Adafruit nRF52840 Feather: Please give a tutorial on hold combinations and whitespace characters #785

Closed qbalsdon closed 1 year ago

qbalsdon commented 1 year ago

Is your feature request related to a problem? Please describe. I um using the BLE HID Example and looking at the code

I am trying to do an example where the code holds tab and presses and releases the 'x' key.

Describe the solution you'd like I would like to be able to release all keys or only specific keys, and / or have a method that presses and holds a key, and a separate method to press and release a key hold(key) releaseAll() - this exists as keyRelease release(key) pressAndRelease(key)

Describe alternatives you've considered I don't know what the key codes are, currently I have tried sending 0xB1 and 0x1B for Escape and it's not working. Shift, Ctrl, Alt, Tab are all a mystery.

I have found the TinyUSB codes that do seem to work, and I am trying to modify the gist here to do the following:

  uint8_t keycodes[6] = {  HID_KEY_X , HID_KEY_NONE , HID_KEY_NONE , HID_KEY_NONE , HID_KEY_NONE , HID_KEY_NONE };
  blehid.keyboardReport( HID_KEY_TAB , keycodes );
// also tried TAB as just a code
  uint8_t keycodes[6] = {  HID_KEY_TAB, HID_KEY_X , HID_KEY_NONE , HID_KEY_NONE , HID_KEY_NONE , HID_KEY_NONE };
  blehid.keyboardReport( 0 , keycodes );  

Additional context I am trying to use this device to turn on my iPhone's screen read, VoiceOver. The shortcut is (HOLD) TAB and (PRESS AND RELEASE) X and (RELEASE) TAB. If the TAB key is not pressed when X is released, the event will not fire. There are many similar shortcut codes that are fairly frustrating in their specificity.

qbalsdon commented 1 year ago

Never mind - I managed to resolve it with:

  uint8_t keycodes_no_x[6] = {  HID_KEY_TAB,  HID_KEY_NONE , HID_KEY_NONE , HID_KEY_NONE , HID_KEY_NONE , HID_KEY_NONE };
  uint8_t keycodes_in_x[6] = {  HID_KEY_TAB,  HID_KEY_X    , HID_KEY_NONE , HID_KEY_NONE , HID_KEY_NONE , HID_KEY_NONE };  

  blehid.keyboardReport( 0 , keycodes_no_x );  
  delay(5);
  blehid.keyboardReport( 0 , keycodes_in_x );  
  delay(5);
  blehid.keyboardReport( 0 , keycodes_no_x );  
  delay(250);
  blehid.keyRelease();