mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-07-08 04:10:39 +00:00
Added support for higher mouse buttons under X11.
Use XCheckWindowEvent instead of XNextEvent.
This commit is contained in:
parent
ac68af8730
commit
26f1ac30d0
|
@ -32,7 +32,7 @@ namespace OpenTK.Build
|
||||||
|
|
||||||
static string PrebuildXml = Path.Combine(ToolPath, "Prebuild.xml");
|
static string PrebuildXml = Path.Combine(ToolPath, "Prebuild.xml");
|
||||||
|
|
||||||
static Regex DataFiles = new Regex(@"(\.jpg|\.txt|\.glsl)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
static Regex DataFiles = new Regex(@"^.*\.(jpg|txt|glsl)$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
enum BuildMode
|
enum BuildMode
|
||||||
{
|
{
|
||||||
|
|
|
@ -109,13 +109,19 @@ namespace Examples.Tests
|
||||||
delegate(GameWindow input_window, S04_Input_Logger control, MouseDevice sender, MouseButton button)
|
delegate(GameWindow input_window, S04_Input_Logger control, MouseDevice sender, MouseButton button)
|
||||||
{
|
{
|
||||||
if (sender.DeviceID == input_window.Mouse.DeviceID)
|
if (sender.DeviceID == input_window.Mouse.DeviceID)
|
||||||
|
{
|
||||||
control.MouseButtonsBox.Items.Add(button);
|
control.MouseButtonsBox.Items.Add(button);
|
||||||
|
System.Diagnostics.Debug.Print("Button down: {0}", button);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
ControlLogMouseKey ControlLogMouseKeyUp =
|
ControlLogMouseKey ControlLogMouseKeyUp =
|
||||||
delegate(GameWindow input_window, S04_Input_Logger control, MouseDevice sender, MouseButton button)
|
delegate(GameWindow input_window, S04_Input_Logger control, MouseDevice sender, MouseButton button)
|
||||||
{
|
{
|
||||||
if (sender.DeviceID == input_window.Mouse.DeviceID)
|
if (sender.DeviceID == input_window.Mouse.DeviceID)
|
||||||
|
{
|
||||||
control.MouseButtonsBox.Items.Remove(button);
|
control.MouseButtonsBox.Items.Remove(button);
|
||||||
|
System.Diagnostics.Debug.Print("Button up: {0}", button);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
delegate void ControlLogMousePosition(GameWindow input_window, S04_Input_Logger control);
|
delegate void ControlLogMousePosition(GameWindow input_window, S04_Input_Logger control);
|
||||||
|
|
|
@ -100,7 +100,7 @@ namespace OpenTK.Input
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets an integer representing the absolute x position of the pointer, in screen pixel coordinates.
|
/// Gets an integer representing the absolute x position of the pointer, in window pixel coordinates.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int X
|
public int X
|
||||||
{
|
{
|
||||||
|
@ -113,7 +113,7 @@ namespace OpenTK.Input
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets an integer representing the absolute y position of the pointer, in screen pixel coordinates.
|
/// Gets an integer representing the absolute y position of the pointer, in window pixel coordinates.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Y
|
public int Y
|
||||||
{
|
{
|
||||||
|
@ -154,7 +154,7 @@ namespace OpenTK.Input
|
||||||
#region public Point Position
|
#region public Point Position
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a System.Drawing.Point representing the absolute position of the pointer, in screen pixel coordinates.
|
/// Gets a System.Drawing.Point representing the absolute position of the pointer, in window pixel coordinates.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Point Position
|
public Point Position
|
||||||
{
|
{
|
||||||
|
@ -191,14 +191,11 @@ namespace OpenTK.Input
|
||||||
internal set
|
internal set
|
||||||
{
|
{
|
||||||
if (ButtonDown != null && value && !button[(int)b])
|
if (ButtonDown != null && value && !button[(int)b])
|
||||||
{
|
|
||||||
ButtonDown(this, b);
|
ButtonDown(this, b);
|
||||||
}
|
|
||||||
else if (ButtonUp != null && !value && button[(int)b])
|
else if (ButtonUp != null && !value && button[(int)b])
|
||||||
{
|
|
||||||
ButtonUp(this, b);
|
ButtonUp(this, b);
|
||||||
}
|
|
||||||
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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ namespace OpenTK.Platform.X11
|
||||||
{
|
{
|
||||||
AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);
|
AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);
|
||||||
|
|
||||||
//using (System.Windows.Forms.Control c = new System.Windows.Forms.Control()) { }
|
// Bad idea - Windows.Forms will steal our events!
|
||||||
//Type xplatui = Type.GetType("System.Windows.Forms.XplatUIX11, System.Windows.Forms");
|
//Type xplatui = Type.GetType("System.Windows.Forms.XplatUIX11, System.Windows.Forms");
|
||||||
//defaultDisplay = (IntPtr)xplatui.GetField("DisplayHandle", System.Reflection.BindingFlags.Static |
|
//defaultDisplay = (IntPtr)xplatui.GetField("DisplayHandle", System.Reflection.BindingFlags.Static |
|
||||||
// System.Reflection.BindingFlags.NonPublic).GetValue(null);
|
// System.Reflection.BindingFlags.NonPublic).GetValue(null);
|
||||||
|
@ -1238,6 +1238,9 @@ XF86VidModeGetGammaRampSize(
|
||||||
Button3Mask = (1 << 10),
|
Button3Mask = (1 << 10),
|
||||||
Button4Mask = (1 << 11),
|
Button4Mask = (1 << 11),
|
||||||
Button5Mask = (1 << 12),
|
Button5Mask = (1 << 12),
|
||||||
|
Button6Mask = (1 << 13),
|
||||||
|
Button7Mask = (1 << 14),
|
||||||
|
Button8Mask = (1 << 15),
|
||||||
ShiftMask = (1 << 0),
|
ShiftMask = (1 << 0),
|
||||||
LockMask = (1 << 1),
|
LockMask = (1 << 1),
|
||||||
ControlMask = (1 << 2),
|
ControlMask = (1 << 2),
|
||||||
|
@ -1250,19 +1253,6 @@ XF86VidModeGetGammaRampSize(
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region public enum MouseButton
|
|
||||||
|
|
||||||
public enum MouseButton
|
|
||||||
{
|
|
||||||
Button1 = 1,
|
|
||||||
Button2 = 2,
|
|
||||||
Button3 = 3,
|
|
||||||
Button4 = 4,
|
|
||||||
Button5 = 5,
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
internal static partial class Functions
|
internal static partial class Functions
|
||||||
|
|
|
@ -73,8 +73,16 @@ namespace OpenTK.Platform.X11
|
||||||
public extern static int XUnmapSubwindows(IntPtr display, IntPtr window);
|
public extern static int XUnmapSubwindows(IntPtr display, IntPtr window);
|
||||||
[DllImport("libX11", EntryPoint = "XRootWindow")]
|
[DllImport("libX11", EntryPoint = "XRootWindow")]
|
||||||
public extern static IntPtr XRootWindow(IntPtr display, int screen_number);
|
public extern static IntPtr XRootWindow(IntPtr display, int screen_number);
|
||||||
|
|
||||||
[DllImport("libX11", EntryPoint = "XNextEvent")]
|
[DllImport("libX11", EntryPoint = "XNextEvent")]
|
||||||
public extern static IntPtr XNextEvent(IntPtr display, ref XEvent xevent);
|
public extern static IntPtr XNextEvent(IntPtr display, ref XEvent xevent);
|
||||||
|
[DllImport("libX11")]
|
||||||
|
public extern static Bool XWindowEvent(Display display, Window w, EventMask event_mask, ref XEvent event_return);
|
||||||
|
[DllImport("libX11")]
|
||||||
|
public extern static Bool XCheckWindowEvent(Display display, Window w, EventMask event_mask, ref XEvent event_return);
|
||||||
|
[DllImport("libX11")]
|
||||||
|
public extern static Bool XCheckTypedWindowEvent(Display display, Window w, XEventName event_type, ref XEvent event_return);
|
||||||
|
|
||||||
[DllImport("libX11")]
|
[DllImport("libX11")]
|
||||||
public extern static int XConnectionNumber(IntPtr diplay);
|
public extern static int XConnectionNumber(IntPtr diplay);
|
||||||
[DllImport("libX11")]
|
[DllImport("libX11")]
|
||||||
|
|
|
@ -228,15 +228,17 @@ namespace OpenTK.Platform.X11
|
||||||
public void ProcessEvents()
|
public void ProcessEvents()
|
||||||
{
|
{
|
||||||
// Process all pending events
|
// Process all pending events
|
||||||
while (true)
|
//while (true)
|
||||||
|
while (Functions.XCheckWindowEvent(window.Display, window.WindowHandle, window.EventMask, ref e) ||
|
||||||
|
Functions.XCheckTypedWindowEvent(window.Display, window.WindowHandle, XEventName.ClientMessage, ref e))
|
||||||
{
|
{
|
||||||
//pending = Functions.XPending(window.Display);
|
//pending = Functions.XPending(window.Display);
|
||||||
pending = API.Pending(window.Display);
|
//pending = API.Pending(window.Display);
|
||||||
|
|
||||||
if (pending == 0)
|
//if (pending == 0)
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
Functions.XNextEvent(window.Display, ref e);
|
//Functions.XNextEvent(window.Display, ref e);
|
||||||
|
|
||||||
//Debug.Print("Event: {0} ({1} pending)", e.type, pending);
|
//Debug.Print("Event: {0} ({1} pending)", e.type, pending);
|
||||||
|
|
||||||
|
|
|
@ -132,10 +132,10 @@ namespace OpenTK.Platform.X11
|
||||||
System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).GetValue(null);
|
System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).GetValue(null);
|
||||||
|
|
||||||
|
|
||||||
xplatui.GetField("CustomVisual", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic)
|
//xplatui.GetField("CustomVisual", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic)
|
||||||
.SetValue(null, visual);
|
// .SetValue(null, visual);
|
||||||
xplatui.GetField("CustomColormap", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic)
|
//xplatui.GetField("CustomColormap", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic)
|
||||||
.SetValue(null, Functions.XCreateColormap(display, root, visual, 0));
|
// .SetValue(null, Functions.XCreateColormap(display, root, visual, 0));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -155,19 +155,38 @@ namespace OpenTK.Platform.X11
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XEventName.ButtonPress:
|
case XEventName.ButtonPress:
|
||||||
if (e.ButtonEvent.button == (int)MouseButton.Button1) mouse[OpenTK.Input.MouseButton.Left] = true;
|
if (e.ButtonEvent.button == 1) mouse[OpenTK.Input.MouseButton.Left] = true;
|
||||||
else if (e.ButtonEvent.button == (int)MouseButton.Button2) mouse[OpenTK.Input.MouseButton.Middle] = true;
|
else if (e.ButtonEvent.button == 2) mouse[OpenTK.Input.MouseButton.Middle] = true;
|
||||||
else if (e.ButtonEvent.button == (int)MouseButton.Button3) mouse[OpenTK.Input.MouseButton.Right] = true;
|
else if (e.ButtonEvent.button == 3) mouse[OpenTK.Input.MouseButton.Right] = true;
|
||||||
else if (e.ButtonEvent.button == (int)MouseButton.Button4) mouse.Wheel++;
|
else if (e.ButtonEvent.button == 4) mouse.Wheel++;
|
||||||
else if (e.ButtonEvent.button == (int)MouseButton.Button5) mouse.Wheel--;
|
else if (e.ButtonEvent.button == 5) mouse.Wheel--;
|
||||||
|
else if (e.ButtonEvent.button == 6) mouse[OpenTK.Input.MouseButton.Button1] = true;
|
||||||
|
else if (e.ButtonEvent.button == 7) mouse[OpenTK.Input.MouseButton.Button2] = true;
|
||||||
|
else if (e.ButtonEvent.button == 8) mouse[OpenTK.Input.MouseButton.Button3] = true;
|
||||||
|
else if (e.ButtonEvent.button == 9) mouse[OpenTK.Input.MouseButton.Button4] = true;
|
||||||
|
else if (e.ButtonEvent.button == 10) mouse[OpenTK.Input.MouseButton.Button5] = true;
|
||||||
|
else if (e.ButtonEvent.button == 11) mouse[OpenTK.Input.MouseButton.Button6] = true;
|
||||||
|
else if (e.ButtonEvent.button == 12) mouse[OpenTK.Input.MouseButton.Button7] = true;
|
||||||
|
else if (e.ButtonEvent.button == 13) mouse[OpenTK.Input.MouseButton.Button8] = true;
|
||||||
|
else if (e.ButtonEvent.button == 14) mouse[OpenTK.Input.MouseButton.Button9] = true;
|
||||||
//if ((e.state & (int)X11.MouseMask.Button4Mask) != 0) m.Wheel++;
|
//if ((e.state & (int)X11.MouseMask.Button4Mask) != 0) m.Wheel++;
|
||||||
//if ((e.state & (int)X11.MouseMask.Button5Mask) != 0) m.Wheel--;
|
//if ((e.state & (int)X11.MouseMask.Button5Mask) != 0) m.Wheel--;
|
||||||
|
//Debug.Print("Button pressed: {0}", e.ButtonEvent.button);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XEventName.ButtonRelease:
|
case XEventName.ButtonRelease:
|
||||||
if (e.ButtonEvent.button == (int)MouseButton.Button1) mouse[OpenTK.Input.MouseButton.Left] = false;
|
if (e.ButtonEvent.button == 1) mouse[OpenTK.Input.MouseButton.Left] = false;
|
||||||
else if (e.ButtonEvent.button == (int)MouseButton.Button2) mouse[OpenTK.Input.MouseButton.Middle] = false;
|
else if (e.ButtonEvent.button == 2) mouse[OpenTK.Input.MouseButton.Middle] = false;
|
||||||
else if (e.ButtonEvent.button == (int)MouseButton.Button3) mouse[OpenTK.Input.MouseButton.Right] = false;
|
else if (e.ButtonEvent.button == 3) mouse[OpenTK.Input.MouseButton.Right] = false;
|
||||||
|
else if (e.ButtonEvent.button == 6) mouse[OpenTK.Input.MouseButton.Button1] = false;
|
||||||
|
else if (e.ButtonEvent.button == 7) mouse[OpenTK.Input.MouseButton.Button2] = false;
|
||||||
|
else if (e.ButtonEvent.button == 8) mouse[OpenTK.Input.MouseButton.Button3] = false;
|
||||||
|
else if (e.ButtonEvent.button == 9) mouse[OpenTK.Input.MouseButton.Button4] = false;
|
||||||
|
else if (e.ButtonEvent.button == 10) mouse[OpenTK.Input.MouseButton.Button5] = false;
|
||||||
|
else if (e.ButtonEvent.button == 11) mouse[OpenTK.Input.MouseButton.Button6] = false;
|
||||||
|
else if (e.ButtonEvent.button == 12) mouse[OpenTK.Input.MouseButton.Button7] = false;
|
||||||
|
else if (e.ButtonEvent.button == 13) mouse[OpenTK.Input.MouseButton.Button8] = false;
|
||||||
|
else if (e.ButtonEvent.button == 14) mouse[OpenTK.Input.MouseButton.Button9] = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XEventName.MotionNotify:
|
case XEventName.MotionNotify:
|
||||||
|
|
Loading…
Reference in a new issue