2014-03-28 02:50:40 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace DS4Library
|
|
|
|
|
{
|
|
|
|
|
public class DS4State
|
|
|
|
|
{
|
2014-03-29 06:29:08 +01:00
|
|
|
|
public DateTime ReportTimeStamp;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
public bool Square, Triangle, Circle, Cross;
|
|
|
|
|
public bool DpadUp, DpadDown, DpadLeft, DpadRight;
|
|
|
|
|
public bool L1, L3, R1, R3;
|
|
|
|
|
public bool Share, Options, PS, Touch1, Touch2, TouchButton;
|
2014-03-29 06:29:08 +01:00
|
|
|
|
public byte Touch1Identifier, Touch2Identifier;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
public byte LX, RX, LY, RY, L2, R2;
|
2014-03-29 06:29:08 +01:00
|
|
|
|
public byte FrameCounter; // 0, 1, 2...62, 63, 0....
|
|
|
|
|
public byte TouchPacketCounter; // we break these out automatically
|
|
|
|
|
public byte Battery; // 0 for charging, 10/20/30/40/50/60/70/80/90/100 for percentage of full
|
|
|
|
|
|
2014-03-28 02:50:40 +01:00
|
|
|
|
public DS4State()
|
|
|
|
|
{
|
|
|
|
|
Square = Triangle = Circle = Cross = false;
|
|
|
|
|
DpadUp = DpadDown = DpadLeft = DpadRight = false;
|
|
|
|
|
L1 = L3 = R1 = R3 = false;
|
|
|
|
|
Share = Options = PS = Touch1 = Touch2 = TouchButton = false;
|
|
|
|
|
LX = RX = LY = RY = 127;
|
|
|
|
|
L2 = R2 = 0;
|
2014-03-29 06:29:08 +01:00
|
|
|
|
FrameCounter = 255; // only actually has 6 bits, so this is a null indicator
|
|
|
|
|
TouchPacketCounter = 255; // 8 bits, no great junk value
|
2014-03-28 02:50:40 +01:00
|
|
|
|
Battery = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DS4State(DS4State state)
|
|
|
|
|
{
|
2014-03-29 06:29:08 +01:00
|
|
|
|
ReportTimeStamp = state.ReportTimeStamp;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
Square = state.Square;
|
|
|
|
|
Triangle = state.Triangle;
|
|
|
|
|
Circle = state.Circle;
|
|
|
|
|
Cross = state.Cross;
|
|
|
|
|
DpadUp = state.DpadUp;
|
|
|
|
|
DpadDown = state.DpadDown;
|
|
|
|
|
DpadLeft = state.DpadLeft;
|
|
|
|
|
DpadRight = state.DpadRight;
|
|
|
|
|
L1 = state.L1;
|
|
|
|
|
L2 = state.L2;
|
|
|
|
|
L3 = state.L3;
|
|
|
|
|
R1 = state.R1;
|
|
|
|
|
R2 = state.R2;
|
|
|
|
|
R3 = state.R3;
|
|
|
|
|
Share = state.Share;
|
|
|
|
|
Options = state.Options;
|
|
|
|
|
PS = state.PS;
|
|
|
|
|
Touch1 = state.Touch1;
|
2014-03-29 06:29:08 +01:00
|
|
|
|
Touch1Identifier = state.Touch1Identifier;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
Touch2 = state.Touch2;
|
2014-03-29 06:29:08 +01:00
|
|
|
|
Touch2Identifier = state.Touch2Identifier;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
TouchButton = state.TouchButton;
|
2014-03-29 06:29:08 +01:00
|
|
|
|
TouchPacketCounter = state.TouchPacketCounter;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
LX = state.LX;
|
|
|
|
|
RX = state.RX;
|
|
|
|
|
LY = state.LY;
|
|
|
|
|
RY = state.RY;
|
2014-03-29 06:29:08 +01:00
|
|
|
|
FrameCounter = state.FrameCounter;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
Battery = state.Battery;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DS4State Clone()
|
|
|
|
|
{
|
|
|
|
|
return new DS4State(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Copy(DS4State state)
|
|
|
|
|
{
|
2014-03-29 06:29:08 +01:00
|
|
|
|
state.ReportTimeStamp = ReportTimeStamp;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
state.Square = Square;
|
|
|
|
|
state.Triangle = Triangle;
|
|
|
|
|
state.Circle = Circle;
|
|
|
|
|
state.Cross = Cross;
|
|
|
|
|
state.DpadUp = DpadUp;
|
|
|
|
|
state.DpadDown = DpadDown;
|
|
|
|
|
state.DpadLeft = DpadLeft;
|
|
|
|
|
state.DpadRight = DpadRight;
|
|
|
|
|
state.L1 = L1;
|
|
|
|
|
state.L2 = L2;
|
|
|
|
|
state.L3 = L3;
|
|
|
|
|
state.R1 = R1;
|
|
|
|
|
state.R2 = R2;
|
|
|
|
|
state.R3 = R3;
|
|
|
|
|
state.Share = Share;
|
|
|
|
|
state.Options = Options;
|
|
|
|
|
state.PS = PS;
|
|
|
|
|
state.Touch1 = Touch1;
|
2014-03-29 06:29:08 +01:00
|
|
|
|
state.Touch1Identifier = Touch1Identifier;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
state.Touch2 = Touch2;
|
2014-03-29 06:29:08 +01:00
|
|
|
|
state.Touch2Identifier = Touch2Identifier;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
state.TouchButton = TouchButton;
|
2014-03-29 06:29:08 +01:00
|
|
|
|
state.TouchPacketCounter = TouchPacketCounter;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
state.LX = LX;
|
|
|
|
|
state.RX = RX;
|
|
|
|
|
state.LY = LY;
|
|
|
|
|
state.RY = RY;
|
2014-03-29 06:29:08 +01:00
|
|
|
|
state.FrameCounter = FrameCounter;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
state.Battery = Battery;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|