Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1902e1b1 authored by Chris Manton's avatar Chris Manton Committed by Automerger Merge Worker
Browse files

Remove unused funcs bta/hh::bta_hh_parse_ am: 3a8c5c1e

Original change: https://android-review.googlesource.com/c/platform/system/bt/+/1700645

Change-Id: Ia3b7aa19f992f461ee8460f71e354c80fd661fd0
parents 374f3fed 3a8c5c1e
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -309,10 +309,6 @@ extern void bta_hh_open_failure(tBTA_HH_DEV_CB* p_cb,
/* utility functions */
extern uint8_t bta_hh_find_cb(const RawAddress& bda);
extern tBTA_HH_DEV_CB* bta_hh_get_cb(const RawAddress& bda);
extern void bta_hh_parse_keybd_rpt(tBTA_HH_BOOT_RPT* p_kb_data,
                                   uint8_t* p_report, uint16_t report_len);
extern void bta_hh_parse_mice_rpt(tBTA_HH_BOOT_RPT* p_kb_data,
                                  uint8_t* p_report, uint16_t report_len);
extern bool bta_hh_tod_spt(tBTA_HH_DEV_CB* p_cb, uint8_t sub_class);
extern void bta_hh_clean_up_kdev(tBTA_HH_DEV_CB* p_cb);

+0 −138
Original line number Diff line number Diff line
@@ -46,10 +46,6 @@

#define BTA_HH_MAX_RPT_CHARS 8

static const uint8_t bta_hh_mod_key_mask[BTA_HH_MOD_MAX_KEY] = {
    BTA_HH_KB_CTRL_MASK, BTA_HH_KB_SHIFT_MASK, BTA_HH_KB_ALT_MASK,
    BTA_HH_KB_GUI_MASK};

/*******************************************************************************
 *
 * Function         bta_hh_find_cb
@@ -232,140 +228,6 @@ bool bta_hh_tod_spt(tBTA_HH_DEV_CB* p_cb, uint8_t sub_class) {
  return false;
}

/*******************************************************************************
 *
 * Function         bta_hh_parse_keybd_rpt
 *
 * Description      This utility function parse a boot mode keyboard report.
 *
 * Returns          void
 *
 ******************************************************************************/
void bta_hh_parse_keybd_rpt(tBTA_HH_BOOT_RPT* p_kb_data, uint8_t* p_report,
                            uint16_t report_len) {
  tBTA_HH_KB_CB* p_kb = &bta_hh_cb.kb_cb;
  tBTA_HH_KEYBD_RPT* p_data = &p_kb_data->data_rpt.keybd_rpt;

  uint8_t this_char, ctl_shift;
  uint16_t xx, yy, key_idx = 0;
  uint8_t this_report[BTA_HH_MAX_RPT_CHARS];

#if (BTA_HH_DEBUG == TRUE)
  APPL_TRACE_DEBUG("bta_hh_parse_keybd_rpt:  (report=%p, report_len=%d) called",
                   p_report, report_len);
#endif

  if (report_len < 2) return;

  ctl_shift = *p_report++;
  report_len--;

  if (report_len > BTA_HH_MAX_RPT_CHARS) report_len = BTA_HH_MAX_RPT_CHARS;

  memset(this_report, 0, BTA_HH_MAX_RPT_CHARS);
  memset(p_data, 0, sizeof(tBTA_HH_KEYBD_RPT));
  memcpy(this_report, p_report, report_len);

  /* Take care of shift, control, GUI and alt, modifier keys  */
  for (xx = 0; xx < BTA_HH_MOD_MAX_KEY; xx++) {
    if (ctl_shift & bta_hh_mod_key_mask[xx]) {
      APPL_TRACE_DEBUG("Mod Key[%02x] pressed", bta_hh_mod_key_mask[xx]);
      p_kb->mod_key[xx] = true;
    } else if (p_kb->mod_key[xx]) {
      p_kb->mod_key[xx] = false;
    }
    /* control key flag is set */
    p_data->mod_key[xx] = p_kb->mod_key[xx];
  }

  /***************************************************************************/
  /*  First step is to remove all characters we saw in the last report       */
  /***************************************************************************/
  for (xx = 0; xx < report_len; xx++) {
    for (yy = 0; yy < BTA_HH_MAX_RPT_CHARS; yy++) {
      if (this_report[xx] == p_kb->last_report[yy]) {
        this_report[xx] = 0;
      }
    }
  }
  /***************************************************************************/
  /*  Now, process all the characters in the report, up to 6 keycodes        */
  /***************************************************************************/
  for (xx = 0; xx < report_len; xx++) {
#if (BTA_HH_DEBUG == TRUE)
    APPL_TRACE_DEBUG("this_char = %02x", this_report[xx]);
#endif
    this_char = this_report[xx];
    if (this_char == 0) continue;
    /* take the key code as the report data */
    if (this_report[xx] == BTA_HH_KB_CAPS_LOCK)
      p_kb->caps_lock = p_kb->caps_lock ? false : true;
    else if (this_report[xx] == BTA_HH_KB_NUM_LOCK)
      p_kb->num_lock = p_kb->num_lock ? false : true;
    else
      p_data->this_char[key_idx++] = this_char;

#if (BTA_HH_DEBUG == TRUE)
    APPL_TRACE_DEBUG("found keycode %02x ", this_report[xx]);
#endif
    p_data->caps_lock = p_kb->caps_lock;
    p_data->num_lock = p_kb->num_lock;
  }

  memset(p_kb->last_report, 0, BTA_HH_MAX_RPT_CHARS);
  memcpy(p_kb->last_report, p_report, report_len);

  return;
}

/*******************************************************************************
 *
 * Function         bta_hh_parse_mice_rpt
 *
 * Description      This utility function parse a boot mode mouse report.
 *
 * Returns          void
 *
 ******************************************************************************/
void bta_hh_parse_mice_rpt(tBTA_HH_BOOT_RPT* p_mice_data, uint8_t* p_report,
                           uint16_t report_len) {
  tBTA_HH_MICE_RPT* p_data = &p_mice_data->data_rpt.mice_rpt;
#if (BTA_HH_DEBUG == TRUE)
  uint8_t xx;

  APPL_TRACE_DEBUG(
      "bta_hh_parse_mice_rpt:  bta_keybd_rpt_rcvd(report=%p, \
                report_len=%d) called",
      p_report, report_len);
#endif

  if (report_len < 3) return;

  if (report_len > BTA_HH_MAX_RPT_CHARS) report_len = BTA_HH_MAX_RPT_CHARS;

#if (BTA_HH_DEBUG == TRUE)
  for (xx = 0; xx < report_len; xx++) {
    APPL_TRACE_DEBUG("this_char = %02x", p_report[xx]);
  }
#endif

  /* only first bytes lower 3 bits valid */
  p_data->mouse_button = (p_report[0] & 0x07);

  /* x displacement */
  p_data->delta_x = p_report[1];

  /* y displacement */
  p_data->delta_y = p_report[2];

#if (BTA_HH_DEBUG == TRUE)
  APPL_TRACE_DEBUG("mice button: 0x%2x", p_data->mouse_button);
  APPL_TRACE_DEBUG("mice move: x = %d y = %d", p_data->delta_x,
                   p_data->delta_y);
#endif

  return;
}

/*******************************************************************************
 *