mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-02-02 05:11:09 +00:00
[X11] Fixed absolute motion valuators
This commit is contained in:
parent
5a5607eaa5
commit
9ae778a00f
|
@ -60,21 +60,6 @@ namespace OpenTK.Platform.X11
|
|||
public string Name;
|
||||
}
|
||||
|
||||
// Atoms
|
||||
//static readonly IntPtr ButtonLeft;
|
||||
//static readonly IntPtr ButtonMiddle;
|
||||
////static readonly IntPtr ButtonRight;
|
||||
//static readonly IntPtr ButtonWheelUp;
|
||||
//static readonly IntPtr ButtonWheelDown;
|
||||
//static readonly IntPtr ButtonWheelLeft;
|
||||
//static readonly IntPtr ButtonWheelRight;
|
||||
static readonly IntPtr RelX;
|
||||
static readonly IntPtr RelY;
|
||||
//static readonly IntPtr RelHorizScroll;
|
||||
//static readonly IntPtr RelVertScroll;
|
||||
//static readonly IntPtr RelHorizWheel;
|
||||
//static readonly IntPtr RelVertWheel;
|
||||
|
||||
long cursor_x, cursor_y; // For GetCursorState()
|
||||
List<XIMouse> devices = new List<XIMouse>(); // list of connected mice
|
||||
Dictionary<int, int> rawids = new Dictionary<int, int>(); // maps hardware device ids to XIMouse ids
|
||||
|
@ -93,31 +78,6 @@ namespace OpenTK.Platform.X11
|
|||
{
|
||||
using (new XLock(API.DefaultDisplay))
|
||||
{
|
||||
// Mouse
|
||||
//ButtonLeft = Functions.XInternAtom(API.DefaultDisplay, "Button Left", false);
|
||||
//ButtonMiddle = Functions.XInternAtom(API.DefaultDisplay, "Button Middle", false);
|
||||
//ButtonRight = Functions.XInternAtom(API.DefaultDisplay, "Button Right", false);
|
||||
//ButtonWheelUp = Functions.XInternAtom(API.DefaultDisplay, "Button Wheel Up", false);
|
||||
//ButtonWheelDown = Functions.XInternAtom(API.DefaultDisplay, "Button Wheel Down", false);
|
||||
//ButtonWheelLeft = Functions.XInternAtom(API.DefaultDisplay, "Button Horiz Wheel Left", false);
|
||||
//ButtonWheelRight = Functions.XInternAtom(API.DefaultDisplay, "Button Horiz Wheel Right", false);
|
||||
RelX = Functions.XInternAtom(API.DefaultDisplay, "Rel X", false);
|
||||
RelY = Functions.XInternAtom(API.DefaultDisplay, "Rel Y", false);
|
||||
//RelHorizWheel = Functions.XInternAtom(API.DefaultDisplay, "Rel Horiz Wheel", false);
|
||||
//RelVertWheel = Functions.XInternAtom(API.DefaultDisplay, "Rel Vert Wheel", false);
|
||||
//RelHorizScroll = Functions.XInternAtom(API.DefaultDisplay, "Rel Horiz Scroll", false);
|
||||
//RelVertScroll = Functions.XInternAtom(API.DefaultDisplay, "Rel Vert Scroll", false);
|
||||
|
||||
// Multitouch
|
||||
//TouchX = Functions.XInternAtom(API.DefaultDisplay, "Abs MT Position X", false);
|
||||
//TouchY = Functions.XInternAtom(API.DefaultDisplay, "Abs MT Position Y", false);
|
||||
//TouchMajor = Functions.XInternAtom(API.DefaultDisplay, "Abs MT Touch Major", false);
|
||||
//TouchMinor = Functions.XInternAtom(API.DefaultDisplay, "Abs MT Touch Minor", false);
|
||||
//TouchPressure = Functions.XInternAtom(API.DefaultDisplay, "Abs MT Pressure", false);
|
||||
//TouchId = Functions.XInternAtom(API.DefaultDisplay, "Abs MT Tracking ID", false);
|
||||
//TouchMaxContacts = Functions.XInternAtom(API.DefaultDisplay, "Max Contacts", false);
|
||||
|
||||
// Custom
|
||||
ExitAtom = Functions.XInternAtom(API.DefaultDisplay, "Exit Input Thread Message", false);
|
||||
}
|
||||
}
|
||||
|
@ -391,17 +351,32 @@ namespace OpenTK.Platform.X11
|
|||
|
||||
case XIClassType.Valuator:
|
||||
{
|
||||
// We use relative x/y valuators for mouse movement.
|
||||
// Iff these are not available, we fall back to
|
||||
// absolute x/y valuators.
|
||||
XIValuatorClassInfo* valuator = (XIValuatorClassInfo*)class_info;
|
||||
if (valuator->label == RelX)
|
||||
if (valuator->label == XI.RelativeX)
|
||||
{
|
||||
Debug.WriteLine("\tRelative X movement");
|
||||
d.MotionX = *valuator;
|
||||
}
|
||||
else if (valuator->label == RelY)
|
||||
else if (valuator->label == XI.RelativeY)
|
||||
{
|
||||
Debug.WriteLine("\tRelative Y movement");
|
||||
d.MotionY = *valuator;
|
||||
}
|
||||
else if (valuator->label == XI.AbsoluteX)
|
||||
{
|
||||
Debug.WriteLine("\tAbsolute X movement");
|
||||
if (d.MotionX.number == -1)
|
||||
d.MotionX = *valuator;
|
||||
}
|
||||
else if (valuator->label == XI.AbsoluteY)
|
||||
{
|
||||
Debug.WriteLine("\tAbsolute X movement");
|
||||
if (d.MotionY.number == -1)
|
||||
d.MotionY = *valuator;
|
||||
}
|
||||
else
|
||||
{
|
||||
IntPtr label = Functions.XGetAtomName(window.Display, valuator->label);
|
||||
|
@ -575,8 +550,14 @@ namespace OpenTK.Platform.X11
|
|||
if (d.ScrollY.number != -1)
|
||||
v = ReadRawValue(ref raw, d.ScrollY.number) / d.ScrollY.increment;
|
||||
|
||||
d.State.X += (int)Math.Round(x);
|
||||
d.State.Y += (int)Math.Round(y);
|
||||
if (d.MotionX.mode == XIMode.Relative)
|
||||
d.State.X += (int)Math.Round(x);
|
||||
else
|
||||
d.State.X = (int)Math.Round(x);
|
||||
if (d.MotionY.mode == XIMode.Absolute)
|
||||
d.State.Y += (int)Math.Round(y);
|
||||
else
|
||||
d.State.Y = (int)Math.Round(y);
|
||||
|
||||
// Note: OpenTK follows the windows scrolling convention where
|
||||
// (+h, +v) = (right, up). XI2 uses (+h, +v) = (right, down)
|
||||
|
|
Loading…
Reference in a new issue