mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-24 17:05:37 +00:00
Modified GetState() to return the combined state for all mouse/keyboard devices.
This commit is contained in:
parent
a7427707ef
commit
0044e4442d
|
@ -208,6 +208,19 @@ namespace OpenTK.Input
|
|||
}
|
||||
}
|
||||
|
||||
internal void MergeBits(KeyboardState other)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
int* k2 = other.Keys;
|
||||
fixed (int* k1 = Keys)
|
||||
{
|
||||
for (int i = 0; i < NumInts; i++)
|
||||
*(k1 + i) |= *(k2 + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Members
|
||||
|
|
|
@ -300,6 +300,23 @@ namespace OpenTK.Input
|
|||
}
|
||||
}
|
||||
|
||||
internal void MergeBits(MouseState other)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
int* b2 = other.Buttons;
|
||||
fixed (int* b1 = Buttons)
|
||||
{
|
||||
for (int i = 0; i < NumInts; i++)
|
||||
*(b1 + i) |= *(b2 + i);
|
||||
}
|
||||
|
||||
WheelPrecise += other.WheelPrecise;
|
||||
X += other.X;
|
||||
Y += other.Y;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Members
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
#endregion
|
||||
|
||||
#region internal static void UpdateKeyboardList()
|
||||
#region UpdateKeyboardList
|
||||
|
||||
internal void UpdateKeyboardList()
|
||||
{
|
||||
|
@ -264,10 +264,12 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
public KeyboardState GetState()
|
||||
{
|
||||
if (keyboards.Count > 0)
|
||||
return keyboards[0];
|
||||
else
|
||||
return new KeyboardState();
|
||||
KeyboardState master = new KeyboardState();
|
||||
foreach (KeyboardState ks in keyboards)
|
||||
{
|
||||
master.MergeBits(ks);
|
||||
}
|
||||
return master;
|
||||
}
|
||||
|
||||
public KeyboardState GetState(int index)
|
||||
|
|
|
@ -65,10 +65,12 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
public MouseState GetState()
|
||||
{
|
||||
if (mice.Count > 0)
|
||||
return mice[0];
|
||||
else
|
||||
return new MouseState();
|
||||
MouseState master = new MouseState();
|
||||
foreach (MouseState ms in mice)
|
||||
{
|
||||
master.MergeBits(ms);
|
||||
}
|
||||
return master;
|
||||
}
|
||||
|
||||
public MouseState GetState(int index)
|
||||
|
|
|
@ -104,10 +104,12 @@ namespace OpenTK.Platform.X11
|
|||
public MouseState GetState()
|
||||
{
|
||||
ProcessEvents();
|
||||
if (mice.Count > 0)
|
||||
return mice[0];
|
||||
else
|
||||
return new MouseState();
|
||||
MouseState master = new MouseState();
|
||||
foreach (MouseState ms in mice)
|
||||
{
|
||||
master.MergeBits(ms);
|
||||
}
|
||||
return master;
|
||||
}
|
||||
|
||||
public MouseState GetState(int index)
|
||||
|
|
Loading…
Reference in a new issue