1 /****************************************************************************** 2 * 3 * Copyright (C) 2009-2012 Broadcom Corporation 4 * 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: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 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. 16 * 17 ******************************************************************************/ 18 19 #ifndef BTIF_HH_H 20 #define BTIF_HH_H 21 22 #include <hardware/bluetooth.h> 23 #include <hardware/bt_hh.h> 24 #include <stdint.h> 25 #include "bta_hh_api.h" 26 27 /******************************************************************************* 28 ** Constants & Macros 29 ********************************************************************************/ 30 31 #define BTIF_HH_MAX_HID 8 32 #define BTIF_HH_MAX_ADDED_DEV 32 33 34 #define BTIF_HH_MAX_KEYSTATES 3 35 #define BTIF_HH_KEYSTATE_MASK_NUMLOCK 0x01 36 #define BTIF_HH_KEYSTATE_MASK_CAPSLOCK 0x02 37 #define BTIF_HH_KEYSTATE_MASK_SCROLLLOCK 0x04 38 39 40 /******************************************************************************* 41 ** Type definitions and return values 42 ********************************************************************************/ 43 44 typedef enum 45 { 46 BTIF_HH_DISABLED = 0, 47 BTIF_HH_ENABLED, 48 BTIF_HH_DISABLING, 49 BTIF_HH_DEV_UNKNOWN, 50 BTIF_HH_DEV_CONNECTING, 51 BTIF_HH_DEV_CONNECTED, 52 BTIF_HH_DEV_DISCONNECTED 53 } BTIF_HH_STATUS; 54 55 typedef struct 56 { 57 bthh_connection_state_t dev_status; 58 UINT8 dev_handle; 59 bt_bdaddr_t bd_addr; 60 tBTA_HH_ATTR_MASK attr_mask; 61 UINT8 sub_class; 62 UINT8 app_id; 63 int fd; 64 BT_HDR *p_buf; 65 } btif_hh_device_t; 66 67 /* Control block to maintain properties of devices */ 68 typedef struct 69 { 70 UINT8 dev_handle; 71 bt_bdaddr_t bd_addr; 72 tBTA_HH_ATTR_MASK attr_mask; 73 } btif_hh_added_device_t; 74 75 /** 76 * BTIF-HH control block to maintain added devices and currently 77 * connected hid devices 78 */ 79 typedef struct 80 { 81 BTIF_HH_STATUS status; 82 btif_hh_device_t devices[BTIF_HH_MAX_HID]; 83 UINT32 device_num; 84 btif_hh_added_device_t added_devices[BTIF_HH_MAX_ADDED_DEV]; 85 btif_hh_device_t *p_curr_dev; 86 } btif_hh_cb_t; 87 88 89 /******************************************************************************* 90 ** Functions 91 ********************************************************************************/ 92 93 extern btif_hh_cb_t btif_hh_cb; 94 95 extern btif_hh_device_t *btif_hh_find_connected_dev_by_handle(UINT8 handle); 96 extern void btif_hh_remove_device(bt_bdaddr_t bd_addr); 97 extern bt_status_t btif_hh_virtual_unplug(bt_bdaddr_t *bd_addr); 98 extern void btif_hh_disconnect(bt_bdaddr_t *bd_addr); 99 100 BOOLEAN btif_hh_add_added_dev(bt_bdaddr_t bd_addr, tBTA_HH_ATTR_MASK attr_mask); 101 102 #endif 103