mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Put DPADEnum into the source file, so it does not conflict with the one in the SRWS1 driver
This commit is contained in:
parent
f05f791841
commit
267f330ed7
2 changed files with 38 additions and 35 deletions
|
@ -17,6 +17,18 @@
|
||||||
|
|
||||||
#include "PS4Parser.h"
|
#include "PS4Parser.h"
|
||||||
|
|
||||||
|
enum DPADEnum {
|
||||||
|
DPAD_UP = 0x0,
|
||||||
|
DPAD_UP_RIGHT = 0x1,
|
||||||
|
DPAD_RIGHT = 0x2,
|
||||||
|
DPAD_RIGHT_DOWN = 0x3,
|
||||||
|
DPAD_DOWN = 0x4,
|
||||||
|
DPAD_DOWN_LEFT = 0x5,
|
||||||
|
DPAD_LEFT = 0x6,
|
||||||
|
DPAD_LEFT_UP = 0x7,
|
||||||
|
DPAD_OFF = 0x8,
|
||||||
|
};
|
||||||
|
|
||||||
// To enable serial debugging see "settings.h"
|
// To enable serial debugging see "settings.h"
|
||||||
//#define PRINTREPORT // Uncomment to print the report send by the PS4 Controller
|
//#define PRINTREPORT // Uncomment to print the report send by the PS4 Controller
|
||||||
|
|
||||||
|
@ -114,3 +126,28 @@ void PS4Parser::Parse(uint8_t len, uint8_t *buf) {
|
||||||
if (ps4Output.reportChanged)
|
if (ps4Output.reportChanged)
|
||||||
sendOutputReport(&ps4Output); // Send output report
|
sendOutputReport(&ps4Output); // Send output report
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PS4Parser::Reset() {
|
||||||
|
uint8_t i;
|
||||||
|
for (i = 0; i < sizeof(ps4Data.hatValue); i++)
|
||||||
|
ps4Data.hatValue[i] = 127; // Center value
|
||||||
|
ps4Data.btn.val = 0;
|
||||||
|
oldButtonState.val = 0;
|
||||||
|
for (i = 0; i < sizeof(ps4Data.trigger); i++)
|
||||||
|
ps4Data.trigger[i] = 0;
|
||||||
|
for (i = 0; i < sizeof(ps4Data.xy)/sizeof(ps4Data.xy[0]); i++) {
|
||||||
|
for (uint8_t j = 0; j < sizeof(ps4Data.xy[0].finger)/sizeof(ps4Data.xy[0].finger[0]); j++)
|
||||||
|
ps4Data.xy[i].finger[j].touching = 1; // The bit is cleared if the finger is touching the touchpad
|
||||||
|
}
|
||||||
|
|
||||||
|
ps4Data.btn.dpad = DPAD_OFF;
|
||||||
|
oldButtonState.dpad = DPAD_OFF;
|
||||||
|
buttonClickState.dpad = 0;
|
||||||
|
oldDpad = 0;
|
||||||
|
|
||||||
|
ps4Output.bigRumble = ps4Output.smallRumble = 0;
|
||||||
|
ps4Output.r = ps4Output.g = ps4Output.b = 0;
|
||||||
|
ps4Output.flashOn = ps4Output.flashOff = 0;
|
||||||
|
ps4Output.reportChanged = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
36
PS4Parser.h
36
PS4Parser.h
|
@ -120,18 +120,6 @@ struct PS4Output {
|
||||||
bool reportChanged; // The data is send when data is received from the controller
|
bool reportChanged; // The data is send when data is received from the controller
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
enum DPADEnum {
|
|
||||||
DPAD_UP = 0x0,
|
|
||||||
DPAD_UP_RIGHT = 0x1,
|
|
||||||
DPAD_RIGHT = 0x2,
|
|
||||||
DPAD_RIGHT_DOWN = 0x3,
|
|
||||||
DPAD_DOWN = 0x4,
|
|
||||||
DPAD_DOWN_LEFT = 0x5,
|
|
||||||
DPAD_LEFT = 0x6,
|
|
||||||
DPAD_LEFT_UP = 0x7,
|
|
||||||
DPAD_OFF = 0x8,
|
|
||||||
};
|
|
||||||
|
|
||||||
/** This class parses all the data sent by the PS4 controller */
|
/** This class parses all the data sent by the PS4 controller */
|
||||||
class PS4Parser {
|
class PS4Parser {
|
||||||
public:
|
public:
|
||||||
|
@ -366,29 +354,7 @@ protected:
|
||||||
void Parse(uint8_t len, uint8_t *buf);
|
void Parse(uint8_t len, uint8_t *buf);
|
||||||
|
|
||||||
/** Used to reset the different buffers to their default values */
|
/** Used to reset the different buffers to their default values */
|
||||||
void Reset() {
|
void Reset();
|
||||||
uint8_t i;
|
|
||||||
for (i = 0; i < sizeof(ps4Data.hatValue); i++)
|
|
||||||
ps4Data.hatValue[i] = 127; // Center value
|
|
||||||
ps4Data.btn.val = 0;
|
|
||||||
oldButtonState.val = 0;
|
|
||||||
for (i = 0; i < sizeof(ps4Data.trigger); i++)
|
|
||||||
ps4Data.trigger[i] = 0;
|
|
||||||
for (i = 0; i < sizeof(ps4Data.xy)/sizeof(ps4Data.xy[0]); i++) {
|
|
||||||
for (uint8_t j = 0; j < sizeof(ps4Data.xy[0].finger)/sizeof(ps4Data.xy[0].finger[0]); j++)
|
|
||||||
ps4Data.xy[i].finger[j].touching = 1; // The bit is cleared if the finger is touching the touchpad
|
|
||||||
}
|
|
||||||
|
|
||||||
ps4Data.btn.dpad = DPAD_OFF;
|
|
||||||
oldButtonState.dpad = DPAD_OFF;
|
|
||||||
buttonClickState.dpad = 0;
|
|
||||||
oldDpad = 0;
|
|
||||||
|
|
||||||
ps4Output.bigRumble = ps4Output.smallRumble = 0;
|
|
||||||
ps4Output.r = ps4Output.g = ps4Output.b = 0;
|
|
||||||
ps4Output.flashOn = ps4Output.flashOff = 0;
|
|
||||||
ps4Output.reportChanged = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send the output to the PS4 controller. This is implemented in PS4BT.h and PS4USB.h.
|
* Send the output to the PS4 controller. This is implemented in PS4BT.h and PS4USB.h.
|
||||||
|
|
Loading…
Reference in a new issue