USB Host Shield 2.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
PS4USB.h
Go to the documentation of this file.
1 /* Copyright (C) 2014 Kristian Lauszus, TKJ Electronics. 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 Lauszus, TKJ Electronics
14  Web : http://www.tkjelectronics.com
15  e-mail : kristianl@tkjelectronics.com
16  */
17 
18 #ifndef _ps4usb_h_
19 #define _ps4usb_h_
20 
21 #include "hiduniversal.h"
22 #include "PS4Parser.h"
23 
24 #define PS4_VID 0x054C // Sony Corporation
25 #define PS4_PID 0x05C4 // PS4 Controller
26 
31 class PS4USB : public HIDUniversal, public PS4Parser {
32 public:
37  PS4USB(USB *p) :
38  HIDUniversal(p) {
40  };
41 
46  bool connected() {
48  };
49 
54  void attachOnInit(void (*funcOnInit)(void)) {
55  pFuncOnInit = funcOnInit;
56  };
57 
58 protected:
67  virtual void ParseHIDData(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) {
69  PS4Parser::Parse(len, buf);
70  };
71 
77  virtual uint8_t OnInitSuccessful() {
79  if (HIDUniversal::VID == PS4_VID && HIDUniversal::PID == PS4_PID && pFuncOnInit)
80  pFuncOnInit(); // Call the user function
81  return 0;
82  };
85 private:
86  void (*pFuncOnInit)(void); // Pointer to function called in onInit()
87 };
88 #endif
uint16_t PID
Definition: hiduniversal.h:54
void Reset()
Definition: PS4Parser.h:260
void attachOnInit(void(*funcOnInit)(void))
Definition: PS4USB.h:54
virtual bool isReady()
Definition: hiduniversal.h:82
virtual uint8_t OnInitSuccessful()
Definition: PS4USB.h:77
Definition: PS4USB.h:31
uint16_t VID
Definition: hiduniversal.h:54
void Parse(uint8_t len, uint8_t *buf)
Definition: PS4Parser.cpp:76
virtual void ParseHIDData(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf)
Definition: PS4USB.h:67
Definition: hid.h:143
bool connected()
Definition: PS4USB.h:46
#define PS4_VID
Definition: PS4USB.h:24
#define PS4_PID
Definition: PS4USB.h:25
PS4USB(USB *p)
Definition: PS4USB.h:37
Definition: UsbCore.h:176