RSeries astromech firmware
PSController.h
Go to the documentation of this file.
1 #ifndef PSController_h
2 #define PSController_h
3 
4 #if !defined(ESP32)
5 #error Only supports ESP32
6 #endif
7 
8 #include <inttypes.h>
9 #include "JoystickController.h"
10 #include "Arduino.h"
11 
12 
14 {
15 public:
16  enum Type
17  {
21  };
22 
23  PSController(const char* mac, Type type = kPS3Nav);
24  PSController() : PSController(nullptr) {}
25 
26  static bool startListening(const char* mac = nullptr);
27  static bool startListening(String& mac) { return startListening(mac.c_str()); }
28  static bool stopListening();
29 
30  static String getDeviceAddress();
31 
32  void setPlayer(int player);
33  void setLED(uint8_t r, uint8_t g, uint8_t b);
34  void setRumble(float leftIntensity, int leftDuration, float rightIntensity, int rightDuration);
35  void setRumble(float intensity, int duration = -1)
36  {
37  setRumble(intensity, duration, intensity, duration);
38  }
39  virtual void disconnect() override;
40 
41  void setType(Type type);
42  void setMacAddress(const char* mac);
43 
44  class priv;
45 private:
46  friend class L2CAP;
47  void parsePacket(uint8_t* packet);
48 
49  Type fType;
50  int fPlayer;
51  uint16_t fHIDC;
52  uint16_t fHIDI;
53  uint8_t fBDAddr[6];
54  State fState;
55 };
56 
57 #endif
PSController::getDeviceAddress
static String getDeviceAddress()
PSController::Type
Type
Definition: PSController.h:16
PSController::kPS3Nav
@ kPS3Nav
Definition: PSController.h:19
PSController::PSController
PSController()
Definition: PSController.h:24
JoystickController::State
Definition: JoystickController.h:128
PSController::L2CAP
friend class L2CAP
Definition: PSController.h:44
PSController
Definition: PSController.h:13
PSController::setType
void setType(Type type)
PSController::setRumble
void setRumble(float intensity, int duration=-1)
Definition: PSController.h:35
PSController::startListening
static bool startListening(String &mac)
Definition: PSController.h:27
PSController::kPS4
@ kPS4
Definition: PSController.h:20
PSController::setLED
void setLED(uint8_t r, uint8_t g, uint8_t b)
PSController::startListening
static bool startListening(const char *mac=nullptr)
PSController::stopListening
static bool stopListening()
JoystickController.h
PSController::setPlayer
void setPlayer(int player)
PSController::kPS3
@ kPS3
Definition: PSController.h:18
PSController::setMacAddress
void setMacAddress(const char *mac)
JoystickController
Definition: JoystickController.h:4
PSController::setRumble
void setRumble(float leftIntensity, int leftDuration, float rightIntensity, int rightDuration)
PSController::disconnect
virtual void disconnect() override