2014-03-28 02:50:40 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
2015-02-08 22:51:52 +01:00
|
|
|
|
namespace DS4Windows
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
|
|
|
|
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;
|
2014-04-27 21:32:09 +02:00
|
|
|
|
public bool Share, Options, PS, Touch1, Touch2, TouchButton, TouchRight, TouchLeft;
|
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;
|
2014-04-27 21:32:09 +02:00
|
|
|
|
Share = Options = PS = Touch1 = Touch2 = TouchButton = TouchRight = TouchLeft = false;
|
2014-03-28 02:50:40 +01:00
|
|
|
|
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-04-27 21:32:09 +02:00
|
|
|
|
TouchRight = state.TouchRight;
|
|
|
|
|
TouchLeft = state.TouchLeft;
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-27 21:32:09 +02:00
|
|
|
|
public void CopyTo(DS4State state)
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
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-04-27 21:32:09 +02:00
|
|
|
|
state.TouchLeft = TouchLeft;
|
|
|
|
|
state.TouchRight = TouchRight;
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|