Advertisement
joric

hidapp.diff

Jun 5th, 2017
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.78 KB | None | 0 0
  1. --- hidapp.orig.c   Thu Aug 15 14:28:40 2013
  2. +++ hidapp.c    Tue Jun 06 07:50:01 2017
  3. @@ -478,6 +478,32 @@
  4.    return ( 0 );  /* Discard unknown events. */
  5.  }
  6.  
  7. +#define HAL_KEY_CODE_NOKEY      0xFF
  8. +#define HID_KEYBOARD_IN_RPT_LEN         8
  9. +#define KEY_NONE                    0x00
  10. +#define HID_KEYBOARD_RESERVED       0    // 0x00 - No event inidicated
  11. +
  12. +static void hidEmuKbdSendReport( uint8 modifiers, uint8 keycode ) {
  13. +    uint8 buf[HID_KEYBOARD_IN_RPT_LEN];
  14. +
  15. +    // No need to include Report Id
  16. +    buf[0] = modifiers;         // Modifier keys
  17. +    buf[1] = 0;                 // Reserved
  18. +    buf[2] = keycode;           // Keycode 1
  19. +    buf[3] = 0;                 // Keycode 2
  20. +    buf[4] = 0;                 // Keycode 3
  21. +    buf[5] = 0;                 // Keycode 4
  22. +    buf[6] = 0;                 // Keycode 5
  23. +    buf[7] = 0;                 // Keycode 6
  24. +
  25. +    gattMsgEvent_t tPkt;
  26. +    tPkt.method = ATT_HANDLE_VALUE_NOTI;
  27. +    tPkt.msg.handleValueNoti.len = 8;
  28. +    tPkt.msg.handleValueNoti.handle = keyCharHandle;    
  29. +    for (int i=0; i<8; i++) tPkt.msg.handleValueNoti.value[i] = buf[i];    
  30. +    hidappProcessGATTMsg(&tPkt);
  31. +}
  32. +
  33.  /*********************************************************************
  34.   *
  35.   * @fn      hidappHandleKey
  36. @@ -496,6 +522,12 @@
  37.  
  38.    if (keys & HAL_KEY_SW_1)
  39.    {
  40. +    hidEmuKbdSendReport( 0x80, KEY_NONE ); // winkey
  41. +    hidEmuKbdSendReport( 0, KEY_NONE );
  42. +
  43. +    static uint8 led = 1;
  44. +    HalLedSet( HAL_LED_2, led ? HAL_LED_MODE_ON : HAL_LED_MODE_OFF );
  45. +    led = !led;
  46.      // If bonds exist, erase all of them
  47.      if ( ( hidappBondCount() > 0 ) && ( hidappBLEState != BLE_STATE_CONNECTED ) )
  48.      {
  49. @@ -520,7 +552,7 @@
  50.      {
  51.        #if defined ( NANO_DONGLE )
  52.  
  53. -      HalLedSet( HAL_LED_2, HAL_LED_MODE_OFF ); // red led
  54. +      //HalLedSet( HAL_LED_2, HAL_LED_MODE_OFF ); // red led
  55.  
  56.        // Notify our task to start initial discovey
  57.        osal_set_event( hidappTaskId, HIDAPP_EVT_START_DISCOVERY );
  58. @@ -816,7 +848,7 @@
  59.      return ( FALSE );
  60.    }
  61.  
  62. -  HalLedSet( HAL_LED_2, HAL_LED_MODE_BLINK );
  63. +  //HalLedSet( HAL_LED_2, HAL_LED_MODE_BLINK );
  64.  
  65.    return ( hidSendHidInReport(pNoti->value, endPoint, pNoti->len) );
  66.  }
  67. @@ -1058,7 +1090,7 @@
  68.  {
  69.    if ( hidappBLEState == BLE_STATE_SCANNING )
  70.    {
  71. -    HalLedSet( HAL_LED_2, HAL_LED_MODE_BLINK ); // red led
  72. +    //HalLedSet( HAL_LED_2, HAL_LED_MODE_BLINK ); // red led
  73.  
  74.      // Begin scanning
  75.      VOID GAPCentralRole_StartDiscovery( DEFAULT_DISCOVERY_MODE,
  76. @@ -1079,8 +1111,7 @@
  77.  static void hidappSetIdle( void )
  78.  {
  79.    hidappBLEState = BLE_STATE_IDLE;
  80. -
  81. -  HalLedSet( HAL_LED_2, HAL_LED_MODE_ON ); // red led
  82. +  //HalLedSet( HAL_LED_2, HAL_LED_MODE_ON ); // red led
  83.  }
  84.  
  85.  /*********************************************************************
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement