USB Host Shield 2.0
XBOXONESBT.h
Go to the documentation of this file.
1 /* Copyright (C) 2020 Kristian Sloth Lauszus. All rights reserved.
2 
3  This software may be distributed and modified under the terms of the GNU
4  General Public License version 2 (GPL2) as published by the Free Software
5  Foundation and appearing in the file GPL2.TXT included in the packaging of
6  this file. Please note that GPL2 Section 2[b] requires that all works based
7  on this software must also be made publicly available under the terms of
8  the GPL2 ("Copyleft").
9 
10  Contact information
11  -------------------
12 
13  Kristian Sloth Lauszus
14  Web : https://lauszus.com
15  e-mail : lauszus@gmail.com
16  */
17 
18 #ifndef _xboxonesbt_h_
19 #define _xboxonesbt_h_
20 
21 #include "BTHID.h"
22 #include "XBOXONESParser.h"
23 
28 class XBOXONESBT : public BTHID, public XBOXONESParser {
29 public:
35  XBOXONESBT(BTD *p, bool pair = false) :
36  BTHID(p, pair) {
38  pBtd->useSimplePairing = true; // The Xbox One S controller only works via simple pairing
39  };
40 
45  bool connected() {
46  return BTHID::connected;
47  };
48 
49 protected:
56  virtual void ParseBTHIDData(uint8_t len, uint8_t *buf) {
57  XBOXONESParser::Parse(len, buf);
58  };
59 
65  virtual void OnInitBTHID() {
67  if (pFuncOnInit)
68  pFuncOnInit(); // Call the user function
69  };
70 
72  virtual void ResetBTHID() {
74  };
77 #if 0
78 
79  virtual void sendOutputReport(uint8_t *data, uint8_t nbytes) {
80  // See: https://lore.kernel.org/patchwork/patch/973394/
81  uint8_t buf[nbytes + 2];
82 
83  buf[0] = 0x52; // HID BT Set_report (0x50) | Report Type (Output 0x02)
84  buf[1] = 0x03; // Report ID
85 
86  memcpy(buf + 2, data, nbytes);
87 
88  Notify(PSTR("\r\n"), 0x80);
89  for (uint8_t i = 0; i < sizeof(buf); i++) {
90  D_PrintHex<uint8_t > (buf[i], 0x80);
91  Notify(PSTR(" "), 0x80);
92  }
93  Notify(PSTR("\r\n"), 0x80);
94 
95  //pBtd->L2CAP_Command(hci_handle, data, nbytes, interrupt_scid[0], interrupt_scid[1]);
96  pBtd->L2CAP_Command(hci_handle, buf, sizeof(buf), control_scid[0], control_scid[1]);
97  };
99 #endif
100 };
101 #endif
bool useSimplePairing
Definition: BTD.h:531
Definition: BTD.h:221
virtual void ParseBTHIDData(uint8_t len, uint8_t *buf)
Definition: XBOXONESBT.h:56
bool connected
Definition: BTHID.h:88
virtual void ResetBTHID()
Definition: XBOXONESBT.h:72
uint8_t control_scid[2]
Definition: BTHID.h:139
#define Notify(...)
Definition: message.h:51
void Parse(uint8_t len, uint8_t *buf)
XBOXONESBT(BTD *p, bool pair=false)
Definition: XBOXONESBT.h:35
void(* pFuncOnInit)(void)
Definition: BTD.h:643
#define PSTR(str)
BTD * pBtd
Definition: BTD.h:646
bool connected()
Definition: XBOXONESBT.h:45
uint16_t hci_handle
Definition: BTD.h:649
void L2CAP_Command(uint16_t handle, uint8_t *data, uint8_t nbytes, uint8_t channelLow=0x01, uint8_t channelHigh=0x00)
Definition: BTD.cpp:1447
Definition: BTHID.h:29
void pair(void)
Definition: BTHID.h:91
virtual void OnInitBTHID()
Definition: XBOXONESBT.h:65