1 /******************************************************************************
3 * Copyright (C) 2009-2012 Broadcom Corporation
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 ******************************************************************************/
22 #include <hardware/bluetooth.h>
23 #include <hardware/bt_hh.h>
26 #include "bta_hh_api.h"
30 /*******************************************************************************
32 ********************************************************************************/
34 #define BTIF_HH_MAX_HID 8
35 #define BTIF_HH_MAX_ADDED_DEV 32
37 #define BTIF_HH_MAX_KEYSTATES 3
38 #define BTIF_HH_KEYSTATE_MASK_NUMLOCK 0x01
39 #define BTIF_HH_KEYSTATE_MASK_CAPSLOCK 0x02
40 #define BTIF_HH_KEYSTATE_MASK_SCROLLLOCK 0x04
43 /*******************************************************************************
44 ** Type definitions and return values
45 ********************************************************************************/
53 BTIF_HH_DEV_CONNECTING,
54 BTIF_HH_DEV_CONNECTED,
55 BTIF_HH_DEV_DISCONNECTED
60 bthh_connection_state_t dev_status;
63 tBTA_HH_ATTR_MASK attr_mask;
67 BOOLEAN ready_for_data;
68 pthread_t hh_poll_thread_id;
69 UINT8 hh_keep_polling;
71 BOOLEAN local_vup; // Indicated locally initiated VUP
74 /* Control block to maintain properties of devices */
79 tBTA_HH_ATTR_MASK attr_mask;
80 } btif_hh_added_device_t;
83 * BTIF-HH control block to maintain added devices and currently
84 * connected hid devices
88 BTIF_HH_STATUS status;
89 btif_hh_device_t devices[BTIF_HH_MAX_HID];
91 btif_hh_added_device_t added_devices[BTIF_HH_MAX_ADDED_DEV];
92 btif_hh_device_t *p_curr_dev;
96 /*******************************************************************************
98 ********************************************************************************/
100 extern btif_hh_cb_t btif_hh_cb;
102 extern btif_hh_device_t *btif_hh_find_connected_dev_by_handle(UINT8 handle);
103 extern void btif_hh_remove_device(bt_bdaddr_t bd_addr);
104 BOOLEAN btif_hh_add_added_dev(bt_bdaddr_t bda, tBTA_HH_ATTR_MASK attr_mask);
105 extern bt_status_t btif_hh_virtual_unplug(bt_bdaddr_t *bd_addr);
106 extern void btif_hh_disconnect(bt_bdaddr_t *bd_addr);
107 extern void btif_hh_setreport(btif_hh_device_t *p_dev, bthh_report_type_t r_type,
108 UINT16 size, UINT8* report);
110 BOOLEAN btif_hh_add_added_dev(bt_bdaddr_t bd_addr, tBTA_HH_ATTR_MASK attr_mask);