mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-25 17:41:10 +00:00
Added support for fractional mouse wheel values. Fixes issue [#1279]: "Mouse wheel does not seem to work".
This commit is contained in:
parent
f509286611
commit
6471772777
|
@ -188,7 +188,7 @@ namespace Examples.Tests
|
||||||
ControlLogMouseWheel ControlLogMouseWheelChanges =
|
ControlLogMouseWheel ControlLogMouseWheelChanges =
|
||||||
delegate(GameWindow input_window, InputLogger control, object sender, MouseWheelEventArgs e)
|
delegate(GameWindow input_window, InputLogger control, object sender, MouseWheelEventArgs e)
|
||||||
{
|
{
|
||||||
control.MouseWheelText.Text = e.Value.ToString();
|
control.MouseWheelText.Text = e.ValuePrecise.ToString("F2");
|
||||||
};
|
};
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace OpenTK.Input
|
||||||
IntPtr id;
|
IntPtr id;
|
||||||
int numButtons, numWheels;
|
int numButtons, numWheels;
|
||||||
readonly bool[] button_state = new bool[Enum.GetValues(typeof(MouseButton)).Length];
|
readonly bool[] button_state = new bool[Enum.GetValues(typeof(MouseButton)).Length];
|
||||||
int wheel, last_wheel;
|
float wheel, last_wheel;
|
||||||
Point pos = new Point(), last_pos = new Point();
|
Point pos = new Point(), last_pos = new Point();
|
||||||
MouseMoveEventArgs move_args = new MouseMoveEventArgs();
|
MouseMoveEventArgs move_args = new MouseMoveEventArgs();
|
||||||
MouseButtonEventArgs button_args = new MouseButtonEventArgs();
|
MouseButtonEventArgs button_args = new MouseButtonEventArgs();
|
||||||
|
@ -131,9 +131,19 @@ namespace OpenTK.Input
|
||||||
#region public int Wheel
|
#region public int Wheel
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets an integer representing the absolute wheel position.
|
/// Gets the absolute wheel position in integer units.
|
||||||
|
/// To support high-precision mice, it is recommended to use <see cref="WheelPrecise"/> instead.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Wheel
|
public int Wheel
|
||||||
|
{
|
||||||
|
get { return (int)(wheel + 0.5f); }
|
||||||
|
internal set { WheelPrecise = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the absolute wheel position in floating-point units.
|
||||||
|
/// </summary>
|
||||||
|
public float WheelPrecise
|
||||||
{
|
{
|
||||||
get { return wheel; }
|
get { return wheel; }
|
||||||
internal set
|
internal set
|
||||||
|
@ -142,10 +152,10 @@ namespace OpenTK.Input
|
||||||
|
|
||||||
wheel_args.X = pos.X;
|
wheel_args.X = pos.X;
|
||||||
wheel_args.Y = pos.Y;
|
wheel_args.Y = pos.Y;
|
||||||
wheel_args.Value = wheel;
|
wheel_args.ValuePrecise = wheel;
|
||||||
wheel_args.Delta = wheel - last_wheel;
|
wheel_args.DeltaPrecise = wheel - last_wheel;
|
||||||
|
|
||||||
WheelChanged(this, wheel_args );
|
WheelChanged(this, wheel_args);
|
||||||
|
|
||||||
last_wheel = wheel;
|
last_wheel = wheel;
|
||||||
}
|
}
|
||||||
|
@ -296,8 +306,8 @@ namespace OpenTK.Input
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
int result = wheel - wheel_last_accessed;
|
int result = (int)(wheel - wheel_last_accessed + 0.5f);
|
||||||
wheel_last_accessed = wheel;
|
wheel_last_accessed = (int)wheel;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -561,8 +571,8 @@ namespace OpenTK.Input
|
||||||
{
|
{
|
||||||
#region Fields
|
#region Fields
|
||||||
|
|
||||||
int value;
|
float value;
|
||||||
int delta;
|
float delta;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -601,14 +611,26 @@ namespace OpenTK.Input
|
||||||
#region Public Members
|
#region Public Members
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the value of the wheel.
|
/// Gets the value of the wheel in integer units.
|
||||||
|
/// To support high-precision mice, it is recommended to use <see cref="ValuePrecise"/> instead.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Value { get { return this.value; } internal set { this.value = value; } }
|
public int Value { get { return (int)(value + 0.5f); } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the change in value of the wheel for this event.
|
/// Gets the change in value of the wheel for this event in integer units.
|
||||||
|
/// To support high-precision mice, it is recommended to use <see cref="DeltaPrecise"/> instead.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Delta { get { return delta; } internal set { delta = value; } }
|
public int Delta { get { return (int)(delta + 0.5f); } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the precise value of the wheel in floating-point units.
|
||||||
|
/// </summary>
|
||||||
|
public float ValuePrecise { get { return value; } internal set { this.value = value; } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the precise change in value of the wheel for this event in floating-point units.
|
||||||
|
/// </summary>
|
||||||
|
public float DeltaPrecise { get { return delta; } internal set { delta = value; } }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
@ -316,7 +316,7 @@ namespace OpenTK.Platform.Windows
|
||||||
case WindowMessage.MOUSEWHEEL:
|
case WindowMessage.MOUSEWHEEL:
|
||||||
// This is due to inconsistent behavior of the WParam value on 64bit arch, whese
|
// This is due to inconsistent behavior of the WParam value on 64bit arch, whese
|
||||||
// wparam = 0xffffffffff880000 or wparam = 0x00000000ff100000
|
// wparam = 0xffffffffff880000 or wparam = 0x00000000ff100000
|
||||||
mouse.Wheel += (int)((long)wParam << 32 >> 48) / 120;
|
mouse.WheelPrecise += ((long)wParam << 32 >> 48) / 120.0f;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WindowMessage.LBUTTONDOWN:
|
case WindowMessage.LBUTTONDOWN:
|
||||||
|
|
Loading…
Reference in a new issue