RetroArch
bte.h
Go to the documentation of this file.
1 #ifndef __BTE_H__
2 #define __BTE_H__
3 
4 #include <gccore.h>
5 #include "bd_addr.h"
6 
7 #define ERR_OK 0
8 #define ERR_MEM -1
9 #define ERR_BUF -2
10 #define ERR_ABRT -3
11 #define ERR_RST -4
12 #define ERR_CLSD -5
13 #define ERR_CONN -6
14 #define ERR_VAL -7
15 #define ERR_ARG -8
16 #define ERR_RTE -9
17 #define ERR_USE -10
18 #define ERR_IF -11
19 #define ERR_PKTSIZE -17
20 
21 #define HIDP_STATE_READY 0x00
22 #define HIDP_STATE_LISTEN 0x01
23 #define HIDP_STATE_CONNECTING 0x02
24 #define HIDP_STATE_CONNECTED 0x04
25 
26 #define HIDP_CONTROL_CHANNEL 0x11
27 #define HIDP_DATA_CHANNEL 0x13
28 
29 #define HIDP_HDR_TRANS_MASK 0xf0
30 #define HIDP_HDR_PARAM_MASK 0x0f
31 
32 #define HIDP_TRANS_HANDSHAKE 0x00
33 #define HIDP_TRANS_HIDCONTROL 0x10
34 #define HIDP_TRANS_GETREPORT 0x40
35 #define HIDP_TRANS_SETREPORT 0x50
36 #define HIDP_TRANS_GETPROTOCOL 0x60
37 #define HIDP_TRANS_SETPROTOCOL 0x70
38 #define HIDP_TRANS_GETIDLE 0x80
39 #define HIDP_TRANS_SETIDLE 0x90
40 #define HIDP_TRANS_DATA 0xa0
41 #define HIDP_TRANS_DATAC 0xb0
42 
43 #define HIDP_HSHK_SUCCESSFULL 0x00
44 #define HIDP_HSHK_NOTREADY 0x01
45 #define HIDP_HSHK_INV_REPORTID 0x02
46 #define HIDP_HSHK_NOTSUPPORTED 0x03
47 #define HIDP_HSHK_IVALIDPARAM 0x04
48 #define HIDP_HSHK_UNKNOWNERROR 0x0e
49 #define HIDP_HSHK_FATALERROR 0x0f
50 
51 #define HIDP_CTRL_NOP 0x00
52 #define HIDP_CTRL_HARDRESET 0x01
53 #define HIDP_CTRL_SOFTRESET 0x02
54 #define HIDP_CTRL_SUSPEND 0x03
55 #define HIDP_CTRL_RESUME 0x04
56 #define HIDP_CTRL_VC_UNPLUG 0x05
57 
58 /* HIDP data transaction headers */
59 #define HIDP_DATA_RTYPE_MASK 0x03
60 #define HIDP_DATA_RSRVD_MASK 0x0c
61 #define HIDP_DATA_RTYPE_OTHER 0x00
62 #define HIDP_DATA_RTYPE_INPUT 0x01
63 #define HIDP_DATA_RTYPE_OUPUT 0x02
64 #define HIDP_DATA_RTYPE_FEATURE 0x03
65 
66 #define HIDP_PROTO_BOOT 0x00
67 #define HIDP_PROTO_REPORT 0x01
68 
69 #ifdef __cplusplus
70  extern "C" {
71 #endif /* __cplusplus */
72 
73 struct l2cap_pcb;
74 struct ctrl_req_t;
75 
77 {
78  struct bd_addr bdaddr;
79  u8 cod[3];
80 };
81 
83 {
84  struct bd_addr bdaddr;
85  u8 cod[3];
89 };
90 
92 {
93  struct bd_addr bdaddr;
94  u8 key[16];
95 };
96 
97 struct bte_pcb
98 {
101  void *cbarg;
102 
105 
107 
108  struct bd_addr bdaddr;
109 
112 
113 
114  s32 (*recv)(void *arg,void *buffer,u16 len);
115  s32 (*conn_cfm)(void *arg,struct bte_pcb *pcb,u8 err);
116  s32 (*disconn_cfm)(void *arg,struct bte_pcb *pcb,u8 err);
117 };
118 
119 typedef s32 (*btecallback)(s32 result,void *userdata);
120 
121 void BTE_Init();
122 void BTE_Shutdown();
126 s32 BTE_ReadStoredLinkKey(struct linkkey_info *keys,u8 max_cnt,btecallback cb);
128 void (*BTE_SetDisconnectCallback(void (*callback)(struct bd_addr *bdaddr,u8 reason)))(struct bd_addr *bdaddr,u8 reason);
129 
130 struct bte_pcb* bte_new();
131 void bte_arg(struct bte_pcb *pcb,void *arg);
132 void bte_received(struct bte_pcb *pcb, s32 (*recv)(void *arg,void *buffer,u16 len));
133 void bte_disconnected(struct bte_pcb *pcb,s32 (disconn_cfm)(void *arg,struct bte_pcb *pcb,u8 err));
134 
135 s32 bte_registerdeviceasync(struct bte_pcb *pcb,struct bd_addr *bdaddr,s32 (*conn_cfm)(void *arg,struct bte_pcb *pcb,u8 err));
136 
137 s32 bte_disconnect(struct bte_pcb *pcb);
138 
139 //s32 bte_listen(struct bte_pcb *pcb,struct bd_addr *bdaddr,u8 psm);
140 //s32 bte_accept(struct bte_pcb *pcb,s32 (*recv)(void *arg,void *buffer,u16 len));
141 s32 bte_inquiry(struct inquiry_info *info,u8 max_cnt,u8 flush);
142 s32 bte_inquiry_ex(struct inquiry_info_ex *info,u8 max_cnt,u8 flush);
143 //s32 bte_connect(struct bte_pcb *pcb,struct bd_addr *bdaddr,u8 psm,s32 (*recv)(void *arg,void *buffer,u16 len));
144 //s32 bte_connect_ex(struct bte_pcb *pcb,struct inquiry_info_ex *info,u8 psm,s32 (*recv)(void *arg,void *buffer,u16 len));
145 s32 bte_senddata(struct bte_pcb *pcb,void *message,u16 len);
146 s32 bte_sendmessage(struct bte_pcb *pcb,void *message,u16 len);
147 s32 bte_sendmessageasync(struct bte_pcb *pcb,void *message,u16 len,s32 (*sent)(void *arg,struct bte_pcb *pcb,u8 err));
148 
149 #ifdef __cplusplus
150  }
151 #endif /* __cplusplus */
152 
153 #endif
154 
s32 bte_disconnect(struct bte_pcb *pcb)
Definition: bte.c:627
s32 bte_registerdeviceasync(struct bte_pcb *pcb, struct bd_addr *bdaddr, s32(*conn_cfm)(void *arg, struct bte_pcb *pcb, u8 err))
Definition: bte.c:520
int32_t s32
32bit signed integer
Definition: gctypes.h:24
GLuint buffer
Definition: glext.h:6555
u8 key[16]
Definition: bte.h:94
Definition: libretro.h:2275
GLenum GLsizei len
Definition: glext.h:7389
void bte_received(struct bte_pcb *pcb, s32(*recv)(void *arg, void *buffer, u16 len))
Definition: bte.c:818
struct bd_addr bdaddr
Definition: bte.h:93
s32(* recv)(void *arg, void *buffer, u16 len)
Definition: bte.h:114
struct bd_addr bdaddr
Definition: bte.h:108
void * cbarg
Definition: bte.h:101
Definition: l2cap.h:161
typedef void(__stdcall *PFN_DESTRUCTION_CALLBACK)(void *pData)
Definition: bte.h:97
s32(* btecallback)(s32 result, void *userdata)
Definition: bte.h:119
struct ctrl_req_t * ctrl_req_tail
Definition: bte.h:104
s32 BTE_ReadStoredLinkKey(struct linkkey_info *keys, u8 max_cnt, btecallback cb)
Definition: bte.c:468
Definition: bte.h:76
u32 lwpq_t
typedef for the thread queue's context handle
Definition: lwp.h:68
Core header which includes all subsequent subsystem headers.
Definition: bte.c:59
s32 bte_inquiry_ex(struct inquiry_info_ex *info, u8 max_cnt, u8 flush)
Definition: bte.c:595
void BTE_Shutdown()
Definition: bte.c:397
ssize_t recv(int sockfd, void *buf, size_t len, int flags)
void callback(s32 result, dvdcmdblk *block)
Definition: dvd.c:2293
void BTE_Init()
Definition: bte.c:366
u32 state
Definition: bte.h:100
Definition: bte.h:91
u8 err
Definition: bte.h:99
Definition: bd_addr.h:42
uint16_t u16
16bit unsigned integer
Definition: gctypes.h:18
struct ctrl_req_t * ctrl_req_head
Definition: bte.h:103
void(*)(struct bd_addr *bdaddr, u8 reason) BTE_SetDisconnectCallback(void(*callback)(struct bd_addr *bdaddr, u8 reason))
Definition: bte.h:128
struct bte_pcb * bte_new()
Definition: bte.c:506
void bte_disconnected(struct bte_pcb *pcb, s32(disconn_cfm)(void *arg, struct bte_pcb *pcb, u8 err))
Definition: bte.c:826
void bte_arg(struct bte_pcb *pcb, void *arg)
Definition: bte.c:810
s32 BTE_InitSub(btecallback cb)
Definition: bte.c:452
GLenum GLuint GLenum GLsizei const GLchar * message
Definition: glext.h:6233
s32 bte_inquiry(struct inquiry_info *info, u8 max_cnt, u8 flush)
Definition: bte.c:566
s32 bte_senddata(struct bte_pcb *pcb, void *message, u16 len)
Definition: bte.c:723
u8 psm
Definition: bte.h:87
GLuint64EXT * result
Definition: glext.h:12211
struct bd_addr bdaddr
Definition: bte.h:78
u8 cod[3]
Definition: bte.h:79
s32 BTE_InitCore(btecallback cb)
Definition: bte.c:419
s32(* disconn_cfm)(void *arg, struct bte_pcb *pcb, u8 err)
Definition: bte.h:116
struct bd_addr bdaddr
Definition: bte.h:84
s32 bte_sendmessage(struct bte_pcb *pcb, void *message, u16 len)
Definition: bte.c:775
s32 BTE_ApplyPatch(btecallback cb)
Definition: bte.c:435
s32 BTE_ReadBdAddr(struct bd_addr *bdaddr, btecallback cb)
Definition: bte.c:485
u8 cod[3]
Definition: bte.h:85
struct l2cap_pcb * ctl_pcb
Definition: bte.h:110
s32 bte_sendmessageasync(struct bte_pcb *pcb, void *message, u16 len, s32(*sent)(void *arg, struct bte_pcb *pcb, u8 err))
Definition: bte.c:745
Definition: video4linux2.c:51
s32(* conn_cfm)(void *arg, struct bte_pcb *pcb, u8 err)
Definition: bte.h:115
uint8_t u8
8bit unsigned integer
Definition: gctypes.h:17
uint32_t u32
32bit unsigned integer
Definition: gctypes.h:19
u16 co
Definition: bte.h:88
struct l2cap_pcb * data_pcb
Definition: bte.h:111
lwpq_t cmdq
Definition: bte.h:106
u8 psrm
Definition: bte.h:86
Definition: bte.h:82