Updates to delta handling. Now uses x - last_x instead of storing a delta directly.
This commit is contained in:
parent
46cb5ca3f8
commit
be89cff72c
1 changed files with 37 additions and 23 deletions
|
@ -19,7 +19,8 @@ namespace OpenTK.Input
|
||||||
private int numButtons, numWheels;
|
private int numButtons, numWheels;
|
||||||
private IntPtr id;
|
private IntPtr id;
|
||||||
private bool[] button = new bool[(int)MouseButton.LastButton];
|
private bool[] button = new bool[(int)MouseButton.LastButton];
|
||||||
private int wheel, x, y, wheel_delta, delta_x, delta_y;
|
private int wheel, x, y; //, wheel_delta , delta_x, delta_y;
|
||||||
|
internal int last_x, last_y, last_wheel;
|
||||||
|
|
||||||
#region --- IInputDevice Members ---
|
#region --- IInputDevice Members ---
|
||||||
|
|
||||||
|
@ -42,7 +43,7 @@ namespace OpenTK.Input
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region --- IMouse Members ---
|
#region --- Public Methods ---
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets an integer representing the number of buttons on this MouseDevice.
|
/// Gets an integer representing the number of buttons on this MouseDevice.
|
||||||
|
@ -79,6 +80,7 @@ namespace OpenTK.Input
|
||||||
get { return wheel; }
|
get { return wheel; }
|
||||||
internal set
|
internal set
|
||||||
{
|
{
|
||||||
|
last_wheel = wheel;
|
||||||
wheel = value;
|
wheel = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,14 +92,9 @@ namespace OpenTK.Input
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
int delta = wheel_delta;
|
return wheel - last_wheel;
|
||||||
//wheel_delta = 0;
|
|
||||||
return delta;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
wheel_delta = value;
|
|
||||||
}
|
}
|
||||||
|
//internal set { wheel_delta = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -106,7 +103,11 @@ namespace OpenTK.Input
|
||||||
public int X
|
public int X
|
||||||
{
|
{
|
||||||
get { return x; }
|
get { return x; }
|
||||||
internal set { x = value; }
|
internal set
|
||||||
|
{
|
||||||
|
last_x = x;
|
||||||
|
x = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -115,7 +116,11 @@ namespace OpenTK.Input
|
||||||
public int Y
|
public int Y
|
||||||
{
|
{
|
||||||
get { return y; }
|
get { return y; }
|
||||||
internal set { y = value; }
|
internal set
|
||||||
|
{
|
||||||
|
last_y = y;
|
||||||
|
y = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -123,8 +128,12 @@ namespace OpenTK.Input
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int XDelta
|
public int XDelta
|
||||||
{
|
{
|
||||||
get { return delta_x; }
|
get
|
||||||
internal set { delta_x = value; }
|
{
|
||||||
|
//return delta_x;
|
||||||
|
return x - last_x;
|
||||||
|
}
|
||||||
|
//internal set { delta_x = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -132,8 +141,12 @@ namespace OpenTK.Input
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int YDelta
|
public int YDelta
|
||||||
{
|
{
|
||||||
get { return delta_y; }
|
get
|
||||||
internal set { delta_y = value; }
|
{
|
||||||
|
//return delta_y;
|
||||||
|
return y - last_y;
|
||||||
|
}
|
||||||
|
//internal set { delta_y = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
//public event MouseMoveEvent Move;
|
//public event MouseMoveEvent Move;
|
||||||
|
@ -148,12 +161,19 @@ namespace OpenTK.Input
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event MouseButtonUpEvent ButtonUp;
|
public event MouseButtonUpEvent ButtonUp;
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region public bool this[MouseButton b]
|
#region public bool this[MouseButton b]
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating the status of the specified MouseButton.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">The MouseButton to check.</param>
|
||||||
|
/// <returns>True if the MouseButton is pressed, false otherwise.</returns>
|
||||||
public bool this[MouseButton b]
|
public bool this[MouseButton b]
|
||||||
{
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return button[(int)b];
|
||||||
|
}
|
||||||
internal set
|
internal set
|
||||||
{
|
{
|
||||||
if (ButtonDown != null && value && !button[(int)b])
|
if (ButtonDown != null && value && !button[(int)b])
|
||||||
|
@ -167,16 +187,10 @@ namespace OpenTK.Input
|
||||||
button[(int)b] = value;
|
button[(int)b] = value;
|
||||||
//System.Diagnostics.Debug.Print("Mouse button {0} {1}", b, value ? "down" : "up");
|
//System.Diagnostics.Debug.Print("Mouse button {0} {1}", b, value ? "down" : "up");
|
||||||
}
|
}
|
||||||
get
|
|
||||||
{
|
|
||||||
return button[(int)b];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region --- Public Methods ---
|
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
//return base.GetHashCode();
|
//return base.GetHashCode();
|
||||||
|
|
Loading…
Reference in a new issue