Removed more boxing

This commit is contained in:
Travis Nickles 2019-02-24 17:11:52 -06:00
parent 2497ced5d5
commit 68f8232441
4 changed files with 28 additions and 22 deletions

View File

@ -4,12 +4,12 @@ namespace DS4Windows
{ {
interface ITouchpadBehaviour interface ITouchpadBehaviour
{ {
void touchesBegan(object sender, TouchpadEventArgs arg); void touchesBegan(DS4Touchpad sender, TouchpadEventArgs arg);
void touchesMoved(object sender, TouchpadEventArgs arg); void touchesMoved(DS4Touchpad sender, TouchpadEventArgs arg);
void touchButtonUp(object sender, TouchpadEventArgs arg); void touchButtonUp(DS4Touchpad sender, TouchpadEventArgs arg);
void touchButtonDown(object sender, TouchpadEventArgs arg); void touchButtonDown(DS4Touchpad sender, TouchpadEventArgs arg);
void touchesEnded(object sender, TouchpadEventArgs arg); void touchesEnded(DS4Touchpad sender, TouchpadEventArgs arg);
void sixaxisMoved(object sender, SixAxisEventArgs unused); void sixaxisMoved(DS4SixAxis sender, SixAxisEventArgs unused);
void touchUnchanged(object sender, EventArgs unused); void touchUnchanged(DS4Touchpad sender, EventArgs unused);
} }
} }

View File

@ -71,7 +71,7 @@ namespace DS4Windows
set { toggleGyroMouse = value; ResetToggleGyroM(); } } set { toggleGyroMouse = value; ResetToggleGyroM(); } }
bool currentToggleGyroM = false; bool currentToggleGyroM = false;
public virtual void sixaxisMoved(object sender, SixAxisEventArgs arg) public virtual void sixaxisMoved(DS4SixAxis sender, SixAxisEventArgs arg)
{ {
if (Global.isUsingSAforMouse(deviceNum) && Global.getGyroSensitivity(deviceNum) > 0) if (Global.isUsingSAforMouse(deviceNum) && Global.getGyroSensitivity(deviceNum) > 0)
{ {
@ -156,7 +156,7 @@ namespace DS4Windows
} }
private bool tempBool = false; private bool tempBool = false;
public virtual void touchesMoved(object sender, TouchpadEventArgs arg) public virtual void touchesMoved(DS4Touchpad sender, TouchpadEventArgs arg)
{ {
s = dev.getCurrentStateRef(); s = dev.getCurrentStateRef();
@ -210,7 +210,7 @@ namespace DS4Windows
synthesizeMouseButtons(); synthesizeMouseButtons();
} }
public virtual void touchesBegan(object sender, TouchpadEventArgs arg) public virtual void touchesBegan(DS4Touchpad sender, TouchpadEventArgs arg)
{ {
if (!Global.UseTPforControls[deviceNum]) if (!Global.UseTPforControls[deviceNum])
{ {
@ -243,7 +243,7 @@ namespace DS4Windows
synthesizeMouseButtons(); synthesizeMouseButtons();
} }
public virtual void touchesEnded(object sender, TouchpadEventArgs arg) public virtual void touchesEnded(DS4Touchpad sender, TouchpadEventArgs arg)
{ {
s = dev.getCurrentStateRef(); s = dev.getCurrentStateRef();
slideright = slideleft = false; slideright = slideleft = false;
@ -375,7 +375,7 @@ namespace DS4Windows
return t.hwX >= 1920 * 2 / 5; return t.hwX >= 1920 * 2 / 5;
} }
public virtual void touchUnchanged(object sender, EventArgs unused) public virtual void touchUnchanged(DS4Touchpad sender, EventArgs unused)
{ {
s = dev.getCurrentStateRef(); s = dev.getCurrentStateRef();
@ -491,7 +491,7 @@ namespace DS4Windows
} }
} }
public virtual void touchButtonUp(object sender, TouchpadEventArgs arg) public virtual void touchButtonUp(DS4Touchpad sender, TouchpadEventArgs arg)
{ {
pushed = DS4Controls.None; pushed = DS4Controls.None;
upperDown = leftDown = rightDown = multiDown = false; upperDown = leftDown = rightDown = multiDown = false;
@ -501,7 +501,7 @@ namespace DS4Windows
synthesizeMouseButtons(); synthesizeMouseButtons();
} }
public virtual void touchButtonDown(object sender, TouchpadEventArgs arg) public virtual void touchButtonDown(DS4Touchpad sender, TouchpadEventArgs arg)
{ {
if (arg.touches == null) if (arg.touches == null)
upperDown = true; upperDown = true;

View File

@ -2,6 +2,8 @@
namespace DS4Windows namespace DS4Windows
{ {
public delegate void SixAxisHandler<TEventArgs>(DS4SixAxis sender, TEventArgs args);
public class SixAxisEventArgs : EventArgs public class SixAxisEventArgs : EventArgs
{ {
public readonly SixAxis sixAxis; public readonly SixAxis sixAxis;
@ -110,7 +112,8 @@ namespace DS4Windows
public class DS4SixAxis public class DS4SixAxis
{ {
public event EventHandler<SixAxisEventArgs> SixAccelMoved = null; //public event EventHandler<SixAxisEventArgs> SixAccelMoved = null;
public event SixAxisHandler<SixAxisEventArgs> SixAccelMoved = null;
private SixAxis sPrev = null, now = null; private SixAxis sPrev = null, now = null;
private CalibData[] calibrationData = new CalibData[6] { new CalibData(), new CalibData(), private CalibData[] calibrationData = new CalibData[6] { new CalibData(), new CalibData(),
new CalibData(), new CalibData(), new CalibData(), new CalibData() new CalibData(), new CalibData(), new CalibData(), new CalibData()

View File

@ -52,13 +52,16 @@ namespace DS4Windows
public class DS4Touchpad public class DS4Touchpad
{ {
public event EventHandler<TouchpadEventArgs> TouchesBegan = null; // finger one or two landed (or both, or one then two, or two then one; any touches[] count increase) public delegate void TouchHandler<TEventArgs>(DS4Touchpad sender, TEventArgs args);
public event EventHandler<TouchpadEventArgs> TouchesMoved = null; // deltaX/deltaY are set because one or both fingers were already down on a prior sensor reading
public event EventHandler<TouchpadEventArgs> TouchesEnded = null; // all fingers lifted public event TouchHandler<TouchpadEventArgs> TouchesBegan = null; // finger one or two landed (or both, or one then two, or two then one; any touches[] count increase)
public event EventHandler<TouchpadEventArgs> TouchButtonDown = null; // touchpad pushed down until the button clicks public event TouchHandler<TouchpadEventArgs> TouchesMoved = null; // deltaX/deltaY are set because one or both fingers were already down on a prior sensor reading
public event EventHandler<TouchpadEventArgs> TouchButtonUp = null; // touchpad button released public event TouchHandler<TouchpadEventArgs> TouchesEnded = null; // all fingers lifted
public event EventHandler<EventArgs> TouchUnchanged = null; // no status change for the touchpad itself... but other sensors may have changed, or you may just want to do some processing public event TouchHandler<TouchpadEventArgs> TouchButtonDown = null; // touchpad pushed down until the button clicks
public event EventHandler<EventArgs> PreTouchProcess = null; // used to publish that a touch packet is about to be processed public event TouchHandler<TouchpadEventArgs> TouchButtonUp = null; // touchpad button released
public event TouchHandler<EventArgs> TouchUnchanged = null; // no status change for the touchpad itself... but other sensors may have changed, or you may just want to do some processing
public event TouchHandler<EventArgs> PreTouchProcess = null; // used to publish that a touch packet is about to be processed
//public event EventHandler<EventArgs> PreTouchProcess = null; // used to publish that a touch packet is about to be processed
public readonly static int TOUCHPAD_DATA_OFFSET = 35; public readonly static int TOUCHPAD_DATA_OFFSET = 35;
internal int lastTouchPadX1, lastTouchPadY1, internal int lastTouchPadX1, lastTouchPadY1,