mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-24 19:05:31 +00:00
Added X11Mouse driver.
This commit is contained in:
parent
c8fa8a7b93
commit
9bd06cf09e
|
@ -1065,4 +1065,35 @@ XF86VidModeGetGammaRampSize(
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public enum MouseMask
|
||||||
|
{
|
||||||
|
Button1MotionMask = (1 << 8),
|
||||||
|
Button2MotionMask = (1 << 9),
|
||||||
|
Button3MotionMask = (1 << 10),
|
||||||
|
Button4MotionMask = (1 << 11),
|
||||||
|
Button5MotionMask = (1 << 12),
|
||||||
|
Button1Mask = (1 << 8),
|
||||||
|
Button2Mask = (1 << 9),
|
||||||
|
Button3Mask = (1 << 10),
|
||||||
|
Button4Mask = (1 << 11),
|
||||||
|
Button5Mask = (1 << 12),
|
||||||
|
ShiftMask = (1 << 0),
|
||||||
|
LockMask = (1 << 1),
|
||||||
|
ControlMask = (1 << 2),
|
||||||
|
Mod1Mask = (1 << 3),
|
||||||
|
Mod2Mask = (1 << 4),
|
||||||
|
Mod3Mask = (1 << 5),
|
||||||
|
Mod4Mask = (1 << 6),
|
||||||
|
Mod5Mask = (1 << 7),
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum MouseButton
|
||||||
|
{
|
||||||
|
Button1 = 1,
|
||||||
|
Button2 = 2,
|
||||||
|
Button3 = 3,
|
||||||
|
Button4 = 4,
|
||||||
|
Button5 = 5,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,6 +135,14 @@ namespace OpenTK.Platform.X11
|
||||||
{
|
{
|
||||||
keyboardDriver.ProcessKeyboardEvent(e.KeyEvent);
|
keyboardDriver.ProcessKeyboardEvent(e.KeyEvent);
|
||||||
}
|
}
|
||||||
|
while (API.CheckMaskEvent(window.Display, EventMask.ButtonPressMask | EventMask.ButtonPressMask, ref e))
|
||||||
|
{
|
||||||
|
mouseDriver.ProcessButton(e.ButtonEvent);
|
||||||
|
}
|
||||||
|
while (API.CheckMaskEvent(window.Display, EventMask.PointerMotionMask | EventMask.PointerMotionHintMask, ref e))
|
||||||
|
{
|
||||||
|
mouseDriver.ProcessMotion(e.MotionEvent);
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
if (API.Pending(window.Display) > 0)
|
if (API.Pending(window.Display) > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,6 +25,15 @@ namespace OpenTK.Platform.X11
|
||||||
public X11Mouse(WindowInfo window)
|
public X11Mouse(WindowInfo window)
|
||||||
{
|
{
|
||||||
this.window = window;
|
this.window = window;
|
||||||
|
|
||||||
|
// Just create one mouse now.
|
||||||
|
// TODO: support for multiple devices through evdev.
|
||||||
|
Mouse m = new Mouse();
|
||||||
|
m.Description = "Default X11 mouse";
|
||||||
|
m.DeviceID = IntPtr.Zero;
|
||||||
|
m.NumberOfButtons = 5;
|
||||||
|
m.NumberOfWheels = 1;
|
||||||
|
mice.Add(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -33,14 +42,39 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
public IList<Mouse> Mouse
|
public IList<Mouse> Mouse
|
||||||
{
|
{
|
||||||
get { }
|
get { return mice; }
|
||||||
}
|
|
||||||
|
|
||||||
public int RegisterDevices()
|
|
||||||
{
|
|
||||||
throw new Exception("The method or operation is not implemented.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Processes XButtonEvents.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e">The X11.XButtonEvent to process.</param>
|
||||||
|
/// <returns>True if the event was processed, false otherwise.</returns>
|
||||||
|
internal bool ProcessButton(X11.XButtonEvent e)
|
||||||
|
{
|
||||||
|
Mouse m = mice[0];
|
||||||
|
bool pressed = e.type == XEventName.ButtonPress;
|
||||||
|
if ((e.state & (int)X11.MouseMask.Button1Mask) != 0) m[OpenTK.Input.MouseButton.Button1] = pressed;
|
||||||
|
if ((e.state & (int)X11.MouseMask.Button2Mask) != 0) m[OpenTK.Input.MouseButton.Button2] = pressed;
|
||||||
|
if ((e.state & (int)X11.MouseMask.Button3Mask) != 0) m[OpenTK.Input.MouseButton.Button3] = pressed;
|
||||||
|
if ((e.state & (int)X11.MouseMask.Button4Mask) != 0) m[OpenTK.Input.MouseButton.Button4] = pressed;
|
||||||
|
if ((e.state & (int)X11.MouseMask.Button5Mask) != 0) m[OpenTK.Input.MouseButton.Button5] = pressed;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Processes XMotionEvents.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e">The X11.XMotionEvent to process.</param>
|
||||||
|
/// <returns>True if the event was processed, false otherwise.</returns>
|
||||||
|
internal bool ProcessMotion(X11.XMotionEvent e)
|
||||||
|
{
|
||||||
|
Mouse m = mice[0];
|
||||||
|
m.X = e.x;
|
||||||
|
m.Y = e.y;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue