NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
bta_hh_api.h
1/******************************************************************************
2 *
3 * NOTICE OF CHANGES
4 * 2025/03/11:
5 * - Restore old function signatures
6 *
7 * Compile with REVOLUTION defined to include these changes.
8 *
9 ******************************************************************************/
10
11
12
13/******************************************************************************
14 *
15 * Copyright (C) 2002-2012 Broadcom Corporation
16 *
17 * Licensed under the Apache License, Version 2.0 (the "License");
18 * you may not use this file except in compliance with the License.
19 * You may obtain a copy of the License at:
20 *
21 * http://www.apache.org/licenses/LICENSE-2.0
22 *
23 * Unless required by applicable law or agreed to in writing, software
24 * distributed under the License is distributed on an "AS IS" BASIS,
25 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26 * See the License for the specific language governing permissions and
27 * limitations under the License.
28 *
29 ******************************************************************************/
30#ifndef BTA_HH_API_H
31#define BTA_HH_API_H
32
33#include "bta_api.h"
34#include "hidh_api.h"
35
36/*****************************************************************************
37** Constants and Type Definitions
38*****************************************************************************/
39#ifndef BTA_HH_DEBUG
40#define BTA_HH_DEBUG FALSE
41#endif
42
43#ifndef BTA_HH_SSR_MAX_LATENCY_DEF
44#define BTA_HH_SSR_MAX_LATENCY_DEF 1600
45#endif
46
47#ifndef BTA_HH_SSR_MIN_TOUT_DEF
48#define BTA_HH_SSR_MIN_TOUT_DEF 2
49#endif
50
51/* BTA HID Host callback events */
52#define BTA_HH_ENABLE_EVT 0 /* HH enabled */
53#define BTA_HH_DISABLE_EVT 1 /* HH disabled */
54#define BTA_HH_OPEN_EVT 2 /* connection opened */
55#define BTA_HH_CLOSE_EVT 3 /* connection closed */
56#define BTA_HH_GET_RPT_EVT 4 /* BTA_HhGetReport callback */
57#define BTA_HH_SET_RPT_EVT 5 /* BTA_HhSetReport callback */
58#define BTA_HH_GET_PROTO_EVT 6 /* BTA_GetProtoMode callback */
59#define BTA_HH_SET_PROTO_EVT 7 /* BTA_HhSetProtoMode callback */
60#define BTA_HH_GET_IDLE_EVT 8 /* BTA_HhGetIdle comes callback */
61#define BTA_HH_SET_IDLE_EVT 9 /* BTA_HhSetIdle finish callback */
62#define BTA_HH_GET_DSCP_EVT 10 /* Get report descripotor */
63#define BTA_HH_ADD_DEV_EVT 11 /* Add Device callback */
64#define BTA_HH_RMV_DEV_EVT 12 /* remove device finished */
65#define BTA_HH_VC_UNPLUG_EVT 13 /* virtually unplugged */
66#define BTA_HH_UPDATE_UCD_EVT 14
67#define BTA_HH_API_ERR_EVT 15 /* API error is caught */
68
69typedef UINT16 tBTA_HH_EVT;
70
71/* defined the minimum offset */
72#define BTA_HH_MIN_OFFSET L2CAP_MIN_OFFSET+1
73
74#define BTA_HH_MAX_KNOWN HID_HOST_MAX_DEVICES
75/* invalid device handle */
76#define BTA_HH_INVALID_HANDLE 0xff
77
78/* type of protocol mode */
79#define BTA_HH_PROTO_RPT_MODE (0x00)
80#define BTA_HH_PROTO_BOOT_MODE (0x01)
81#define BTA_HH_PROTO_UNKNOWN (0xff)
82typedef UINT8 tBTA_HH_PROTO_MODE;
83
84enum
85{
86 BTA_HH_KEYBD_RPT_ID = 1,
87 BTA_HH_MOUSE_RPT_ID
88};
89typedef UINT8 tBTA_HH_BOOT_RPT_ID;
90
91/* type of devices, bit mask */
92#define BTA_HH_DEVT_UNKNOWN 0x00
93#define BTA_HH_DEVT_JOS 0x01 /* joy stick */
94#define BTA_HH_DEVT_GPD 0x02 /* game pad */
95#define BTA_HH_DEVT_RMC 0x03 /* remote control */
96#define BTA_HH_DEVT_SED 0x04 /* sensing device */
97#define BTA_HH_DEVT_DGT 0x05 /* Digitizer tablet */
98#define BTA_HH_DEVT_CDR 0x06 /* card reader */
99#define BTA_HH_DEVT_KBD 0x10 /* keyboard */
100#define BTA_HH_DEVT_MIC 0x20 /* pointing device */
101#define BTA_HH_DEVT_COM 0x30 /* Combo keyboard/pointing */
102#define BTA_HH_DEVT_OTHER 0x80
103typedef UINT8 tBTA_HH_DEVT;
104
105enum
106{
107 BTA_HH_OK,
108 BTA_HH_HS_HID_NOT_READY, /* handshake error : device not ready */
109 BTA_HH_HS_INVALID_RPT_ID, /* handshake error : invalid report ID */
110 BTA_HH_HS_TRANS_NOT_SPT, /* handshake error : transaction not spt */
111 BTA_HH_HS_INVALID_PARAM, /* handshake error : invalid paremter */
112 BTA_HH_HS_ERROR, /* handshake error : unspecified HS error */
113 BTA_HH_ERR, /* general BTA HH error */
114 BTA_HH_ERR_SDP, /* SDP error */
115 BTA_HH_ERR_PROTO, /* SET_Protocol error,
116 only used in BTA_HH_OPEN_EVT callback */
117 BTA_HH_ERR_DB_FULL, /* device database full error, used in
118 BTA_HH_OPEN_EVT/BTA_HH_ADD_DEV_EVT */
119 BTA_HH_ERR_TOD_UNSPT, /* type of device not supported */
120 BTA_HH_ERR_NO_RES, /* out of system resources */
121 BTA_HH_ERR_AUTH_FAILED, /* authentication fail */
122 BTA_HH_ERR_HDL
123};
124typedef UINT8 tBTA_HH_STATUS;
125
126
127#define BTA_HH_VIRTUAL_CABLE HID_VIRTUAL_CABLE
128#define BTA_HH_NORMALLY_CONNECTABLE HID_NORMALLY_CONNECTABLE
129#define BTA_HH_RECONN_INIT HID_RECONN_INIT
130#define BTA_HH_SDP_DISABLE HID_SDP_DISABLE
131#define BTA_HH_BATTERY_POWER HID_BATTERY_POWER
132#define BTA_HH_REMOTE_WAKE HID_REMOTE_WAKE
133#define BTA_HH_SUP_TOUT_AVLBL HID_SUP_TOUT_AVLBL
134#define BTA_HH_SEC_REQUIRED HID_SEC_REQUIRED
135typedef UINT16 tBTA_HH_ATTR_MASK;
136
137
138/* supported type of device and corresponding application ID */
139typedef struct
140{
141 tBTA_HH_DEVT tod; /* type of device */
142 UINT8 app_id; /* corresponding application ID */
144
145/* configuration struct */
146typedef struct
147{
148 UINT8 max_devt_spt; /* max number of types of devices spt */
149 tBTA_HH_SPT_TOD *p_devt_list; /* supported types of device list */
150 UINT16 sdp_db_size;
152
153enum
154{
155 BTA_HH_RPTT_RESRV, /* reserved */
156 BTA_HH_RPTT_INPUT, /* input report */
157 BTA_HH_RPTT_OUTPUT, /* output report */
158 BTA_HH_RPTT_FEATURE /* feature report */
159};
160typedef UINT8 tBTA_HH_RPT_TYPE;
161
162/* HID_CONTROL operation code used in BTA_HhSendCtrl()
163*/
164enum
165{
166 BTA_HH_CTRL_NOP = 0 + HID_PAR_CONTROL_NOP ,/* mapping from BTE */
167 BTA_HH_CTRL_HARD_RESET, /* hard reset */
168 BTA_HH_CTRL_SOFT_RESET, /* soft reset */
169 BTA_HH_CTRL_SUSPEND, /* enter suspend */
170 BTA_HH_CTRL_EXIT_SUSPEND, /* exit suspend */
171 BTA_HH_CTRL_VIRTUAL_CABLE_UNPLUG /* virtual unplug */
172};
173typedef UINT8 tBTA_HH_TRANS_CTRL_TYPE;
174
175typedef tHID_DEV_DSCP_INFO tBTA_HH_DEV_DESCR;
176
177/* id DI is not existing in remote device, vendor_id in tBTA_HH_DEV_DSCP_INFO will be set to 0xffff */
178#define BTA_HH_VENDOR_ID_INVALID 0xffff
179
180
181/* report descriptor information */
182typedef struct
183{
184 UINT16 vendor_id; /* vendor ID */
185 UINT16 product_id; /* product ID */
186 UINT16 version; /* version */
187 UINT16 ssr_max_latency; /* SSR max latency */
188 UINT16 ssr_min_tout; /* SSR min timeout */
189 UINT8 ctry_code; /*Country Code.*/
190 tBTA_HH_DEV_DESCR descriptor;
192
193/* callback event data for BTA_HH_OPEN_EVT */
194typedef struct
195{
196 BD_ADDR bda; /* HID device bd address */
197 tBTA_HH_STATUS status; /* operation status */
198 UINT8 handle; /* device handle */
200
201typedef tBTA_HH_CONN tBTA_HH_DEV_INFO;
202
203/* callback event data */
204typedef struct
205{
206 tBTA_HH_STATUS status; /* operation status */
207 UINT8 handle; /* device handle */
209
210enum
211{
212 BTA_HH_MOD_CTRL_KEY,
213 BTA_HH_MOD_SHFT_KEY,
214 BTA_HH_MOD_ALT_KEY,
215 BTA_HH_MOD_GUI_KEY,
216 BTA_HH_MOD_MAX_KEY
217};
218
219/* parsed boot mode keyboard report */
220typedef struct
221{
222 UINT8 this_char[6]; /* virtual key code */
223 BOOLEAN mod_key[BTA_HH_MOD_MAX_KEY];
224 /* ctrl, shift, Alt, GUI */
225 /* modifier key: is Shift key pressed */
226 /* modifier key: is Ctrl key pressed */
227 /* modifier key: is Alt key pressed */
228 /* modifier key: GUI up/down */
229 BOOLEAN caps_lock; /* is caps locked */
230 BOOLEAN num_lock; /* is Num key pressed */
232
233/* parsed boot mode mouse report */
234typedef struct
235{
236 UINT8 mouse_button; /* mouse button is clicked */
237 INT8 delta_x; /* displacement x */
238 INT8 delta_y; /* displacement y */
240
241/* parsed Boot report */
242typedef struct
243{
244 tBTA_HH_BOOT_RPT_ID dev_type; /* type of device report */
245 union
246 {
247 tBTA_HH_KEYBD_RPT keybd_rpt; /* keyboard report */
248 tBTA_HH_MICE_RPT mice_rpt; /* mouse report */
249 } data_rpt;
251
252/* handshake data */
253typedef struct
254{
255 tBTA_HH_STATUS status; /* handshake status */
256 UINT8 handle; /* device handle */
257 union
258 {
259 tBTA_HH_PROTO_MODE proto_mode; /* GET_PROTO_EVT :protocol mode */
260 BT_HDR *p_rpt_data; /* GET_RPT_EVT : report data */
261 UINT8 idle_rate; /* GET_IDLE_EVT : idle rate */
262 } rsp_data;
263
265
266/* union of data associated with HD callback */
267typedef union
268{
269 tBTA_HH_DEV_INFO dev_info; /* BTA_HH_ADD_DEV_EVT, BTA_HH_RMV_DEV_EVT */
270 tBTA_HH_CONN conn; /* BTA_HH_OPEN_EVT */
271 tBTA_HH_CBDATA dev_status; /* BTA_HH_CLOSE_EVT,
272 BTA_HH_SET_PROTO_EVT
273 BTA_HH_SET_RPT_EVT
274 BTA_HH_SET_IDLE_EVT */
275
276 tBTA_HH_STATUS status; /* BTA_HH_ENABLE_EVT */
277 tBTA_HH_DEV_DSCP_INFO dscp_info; /* BTA_HH_GET_DSCP_EVT */
278 tBTA_HH_HSDATA hs_data; /* GET_ transaction callback
279 BTA_HH_GET_RPT_EVT
280 BTA_HH_GET_PROTO_EVT
281 BTA_HH_GET_IDLE_EVT */
282} tBTA_HH;
283
284/* BTA HH callback function */
285typedef void (tBTA_HH_CBACK) (tBTA_HH_EVT event, tBTA_HH *p_data);
286
287
288/*****************************************************************************
289** External Function Declarations
290*****************************************************************************/
291#ifdef __cplusplus
292extern "C"
293{
294#endif
295
296/*******************************************************************************
297**
298** Function BTA_HhRegister
299**
300** Description This function enable HID host and registers HID-Host with
301** lower layers.
302**
303** Returns void
304**
305*******************************************************************************/
306#ifdef REVOLUTION
307BTA_API extern void BTA_HhEnable(tBTA_SEC sec_mask, tBTA_HH_CBACK *p_cback);
308#else
309BTA_API extern void BTA_HhEnable(tBTA_SEC sec_mask, BOOLEAN ucd_enabled, tBTA_HH_CBACK *p_cback);
310#endif
311
312/*******************************************************************************
313**
314** Function BTA_HhDeregister
315**
316** Description This function is called when the host is about power down.
317**
318** Returns void
319**
320*******************************************************************************/
321BTA_API extern void BTA_HhDisable(void);
322
323/*******************************************************************************
324**
325** Function BTA_HhOpen
326**
327** Description This function is called to start an inquiry and read SDP
328** record of responding devices; connect to a device if only
329** one active HID device is found.
330**
331** Returns void
332**
333*******************************************************************************/
334BTA_API extern void BTA_HhOpen (BD_ADDR dev_bda, tBTA_HH_PROTO_MODE mode,
335 tBTA_SEC sec_mask);
336
337/*******************************************************************************
338**
339** Function BTA_HhClose
340**
341** Description This function disconnects the device.
342**
343** Returns void
344**
345*******************************************************************************/
346BTA_API extern void BTA_HhClose(UINT8 dev_handle);
347
348/*******************************************************************************
349**
350** Function BTA_HhSetProtoMode
351**
352** Description This function set the protocol mode at specified HID handle
353**
354** Returns void
355**
356*******************************************************************************/
357BTA_API extern void BTA_HhSetProtoMode(UINT8 handle, tBTA_HH_PROTO_MODE t_type);
358
359/*******************************************************************************
360**
361** Function BTA_HhGetProtoMode
362**
363** Description This function get the protocol mode of a specified HID device.
364**
365** Returns void
366**
367*******************************************************************************/
368BTA_API extern void BTA_HhGetProtoMode(UINT8 dev_handle);
369/*******************************************************************************
370**
371** Function BTA_HhSetReport
372**
373** Description send SET_REPORT to device.
374**
375** Returns void
376**
377*******************************************************************************/
378BTA_API extern void BTA_HhSetReport(UINT8 dev_handle, tBTA_HH_RPT_TYPE r_type,
379 BT_HDR *p_data);
380
381/*******************************************************************************
382**
383** Function BTA_HhGetReport
384**
385** Description Send a GET_REPORT to HID device.
386**
387** Returns void
388**
389*******************************************************************************/
390BTA_API extern void BTA_HhGetReport(UINT8 dev_handle, tBTA_HH_RPT_TYPE r_type,
391 UINT8 rpt_id, UINT16 buf_size);
392/*******************************************************************************
393**
394** Function BTA_HhSendCtrl
395**
396** Description Send HID_CONTROL request to a HID device.
397**
398** Returns void
399**
400*******************************************************************************/
401BTA_API extern void BTA_HhSendCtrl(UINT8 dev_handle,
402 tBTA_HH_TRANS_CTRL_TYPE c_type);
403
404/*******************************************************************************
405**
406** Function BTA_HhSetIdle
407**
408** Description send SET_IDLE to device.
409**
410** Returns void
411**
412*******************************************************************************/
413BTA_API extern void BTA_HhSetIdle(UINT8 dev_handle, UINT16 idle_rate);
414
415
416/*******************************************************************************
417**
418** Function BTA_HhGetIdle
419**
420** Description Send a GET_IDLE from HID device.
421**
422** Returns void
423**
424*******************************************************************************/
425BTA_API extern void BTA_HhGetIdle(UINT8 dev_handle);
426
427/*******************************************************************************
428**
429** Function BTA_HhSendData
430**
431** Description Send DATA transaction to a HID device.
432**
433** Returns void
434**
435*******************************************************************************/
436#ifdef REVOLUTION
437BTA_API extern void BTA_HhSendData(UINT8 dev_handle, BT_HDR *p_buf);
438#else
439BTA_API extern void BTA_HhSendData(UINT8 dev_handle, BD_ADDR dev_bda, BT_HDR *p_buf);
440#endif
441
442/*******************************************************************************
443**
444** Function BTA_HhGetDscpInfo
445**
446** Description Get report descriptor of the device
447**
448** Returns void
449**
450*******************************************************************************/
451BTA_API extern void BTA_HhGetDscpInfo(UINT8 dev_handle);
452
453/*******************************************************************************
454**
455** Function BTA_HhAddDev
456**
457** Description Add a virtually cabled device into HID-Host device list
458** to manage and assign a device handle for future API call,
459** host applciation call this API at start-up to initialize its
460** virtually cabled devices.
461**
462** Returns void
463**
464*******************************************************************************/
465#ifdef REVOLUTION
466BTA_API extern void BTA_HhAddDev(BD_ADDR bda, tBTA_HH_ATTR_MASK attr_mask,
467 UINT8 sub_class, UINT8 app_id,
468 tBTA_HH_DEV_DESCR dscp_info);
469#else
470BTA_API extern void BTA_HhAddDev(BD_ADDR bda, tBTA_HH_ATTR_MASK attr_mask,
471 UINT8 sub_class, UINT8 app_id,
472 tBTA_HH_DEV_DSCP_INFO dscp_info);
473#endif
474/*******************************************************************************
475**
476** Function BTA_HhRemoveDev
477**
478** Description Remove a device from the HID host devices list.
479**
480** Returns void
481**
482*******************************************************************************/
483BTA_API extern void BTA_HhRemoveDev(UINT8 dev_handle );
484/*******************************************************************************
485**
486** Parsing Utility Functions
487**
488*******************************************************************************/
489/*******************************************************************************
490**
491** Function BTA_HhParseBootRpt
492**
493** Description This utility function parse a boot mode report.
494**
495** Returns void
496**
497*******************************************************************************/
498BTA_API extern void BTA_HhParseBootRpt(tBTA_HH_BOOT_RPT *p_data, UINT8 *p_report,
499 UINT16 report_len);
500
501#ifdef __cplusplus
502}
503#endif
504
505#endif /* BTA_HH_API_H */