Try fixing pointer barrier code, also make X errors more verbose
This commit is contained in:
parent
ec66447c20
commit
778c880d54
|
@ -61,10 +61,15 @@ namespace BizHawk.Bizware.Input
|
|||
try
|
||||
{
|
||||
(major, minor) = (2, 1);
|
||||
if (XIQueryVersion(Display, ref major, ref minor) != 0
|
||||
|| major * 100 + minor < 201)
|
||||
var queryVersionStatus = XIQueryVersion(Display, ref major, ref minor);
|
||||
if (queryVersionStatus != Status.Success)
|
||||
{
|
||||
Console.Error.WriteLine("XInput2 version is not at least 2.1, relative mouse input will not work");
|
||||
Console.Error.WriteLine($"Failed to query XInput2 version (got {queryVersionStatus}), relative mouse input will not work");
|
||||
_supportsXInput2 = false;
|
||||
}
|
||||
else if (major * 100 + minor < 201)
|
||||
{
|
||||
Console.Error.WriteLine($"XInput2 version is not at least 2.1 (got {major}.{minor}), relative mouse input will not work");
|
||||
_supportsXInput2 = false;
|
||||
}
|
||||
}
|
||||
|
@ -211,7 +216,7 @@ namespace BizHawk.Bizware.Input
|
|||
}
|
||||
}
|
||||
|
||||
_ = XFreeEventData(Display, ref evt.xcookie);
|
||||
XFreeEventData(Display, ref evt.xcookie);
|
||||
}
|
||||
|
||||
return ((int)mouseDeltaX, (int)mouseDeltaY);
|
||||
|
@ -230,65 +235,67 @@ namespace BizHawk.Bizware.Input
|
|||
var keyboard = XkbAllocKeyboard(Display);
|
||||
if (keyboard != null)
|
||||
{
|
||||
_ = XkbGetNames(Display, 0x3FF, keyboard);
|
||||
var names = Marshal.PtrToStructure<XkbNamesRec>(keyboard->names);
|
||||
|
||||
for (int i = keyboard->min_key_code; i <= keyboard->max_key_code; i++)
|
||||
if (XkbGetNames(Display, 0x3FF, keyboard) == Status.Success)
|
||||
{
|
||||
var name = new string(names.keys[i].name, 0, 4);
|
||||
var key = name switch
|
||||
{
|
||||
"TLDE" => DistinctKey.OemTilde,
|
||||
"AE01" => DistinctKey.D1,
|
||||
"AE02" => DistinctKey.D2,
|
||||
"AE03" => DistinctKey.D3,
|
||||
"AE04" => DistinctKey.D4,
|
||||
"AE05" => DistinctKey.D5,
|
||||
"AE06" => DistinctKey.D6,
|
||||
"AE07" => DistinctKey.D7,
|
||||
"AE08" => DistinctKey.D8,
|
||||
"AE09" => DistinctKey.D9,
|
||||
"AE10" => DistinctKey.D0,
|
||||
"AE11" => DistinctKey.OemMinus,
|
||||
"AE12" => DistinctKey.OemPlus,
|
||||
"AD01" => DistinctKey.Q,
|
||||
"AD02" => DistinctKey.W,
|
||||
"AD03" => DistinctKey.E,
|
||||
"AD04" => DistinctKey.R,
|
||||
"AD05" => DistinctKey.T,
|
||||
"AD06" => DistinctKey.Y,
|
||||
"AD07" => DistinctKey.U,
|
||||
"AD08" => DistinctKey.I,
|
||||
"AD09" => DistinctKey.O,
|
||||
"AD10" => DistinctKey.P,
|
||||
"AD11" => DistinctKey.OemOpenBrackets,
|
||||
"AD12" => DistinctKey.OemCloseBrackets,
|
||||
"AC01" => DistinctKey.A,
|
||||
"AC02" => DistinctKey.S,
|
||||
"AC03" => DistinctKey.D,
|
||||
"AC04" => DistinctKey.F,
|
||||
"AC05" => DistinctKey.G,
|
||||
"AC06" => DistinctKey.H,
|
||||
"AC07" => DistinctKey.J,
|
||||
"AC08" => DistinctKey.K,
|
||||
"AC09" => DistinctKey.L,
|
||||
"AC10" => DistinctKey.OemSemicolon,
|
||||
"AC11" => DistinctKey.OemQuotes,
|
||||
"AB01" => DistinctKey.Z,
|
||||
"AB02" => DistinctKey.X,
|
||||
"AB03" => DistinctKey.C,
|
||||
"AB04" => DistinctKey.V,
|
||||
"AB05" => DistinctKey.B,
|
||||
"AB06" => DistinctKey.N,
|
||||
"AB07" => DistinctKey.M,
|
||||
"AB08" => DistinctKey.OemComma,
|
||||
"AB09" => DistinctKey.OemPeriod,
|
||||
"AB10" => DistinctKey.OemQuestion,
|
||||
"BKSL" => DistinctKey.OemPipe,
|
||||
_ => DistinctKey.Unknown,
|
||||
};
|
||||
var names = Marshal.PtrToStructure<XkbNamesRec>(keyboard->names);
|
||||
|
||||
KeyEnumMap[i] = key;
|
||||
for (int i = keyboard->min_key_code; i <= keyboard->max_key_code; i++)
|
||||
{
|
||||
var name = new string(names.keys[i].name, 0, 4);
|
||||
var key = name switch
|
||||
{
|
||||
"TLDE" => DistinctKey.OemTilde,
|
||||
"AE01" => DistinctKey.D1,
|
||||
"AE02" => DistinctKey.D2,
|
||||
"AE03" => DistinctKey.D3,
|
||||
"AE04" => DistinctKey.D4,
|
||||
"AE05" => DistinctKey.D5,
|
||||
"AE06" => DistinctKey.D6,
|
||||
"AE07" => DistinctKey.D7,
|
||||
"AE08" => DistinctKey.D8,
|
||||
"AE09" => DistinctKey.D9,
|
||||
"AE10" => DistinctKey.D0,
|
||||
"AE11" => DistinctKey.OemMinus,
|
||||
"AE12" => DistinctKey.OemPlus,
|
||||
"AD01" => DistinctKey.Q,
|
||||
"AD02" => DistinctKey.W,
|
||||
"AD03" => DistinctKey.E,
|
||||
"AD04" => DistinctKey.R,
|
||||
"AD05" => DistinctKey.T,
|
||||
"AD06" => DistinctKey.Y,
|
||||
"AD07" => DistinctKey.U,
|
||||
"AD08" => DistinctKey.I,
|
||||
"AD09" => DistinctKey.O,
|
||||
"AD10" => DistinctKey.P,
|
||||
"AD11" => DistinctKey.OemOpenBrackets,
|
||||
"AD12" => DistinctKey.OemCloseBrackets,
|
||||
"AC01" => DistinctKey.A,
|
||||
"AC02" => DistinctKey.S,
|
||||
"AC03" => DistinctKey.D,
|
||||
"AC04" => DistinctKey.F,
|
||||
"AC05" => DistinctKey.G,
|
||||
"AC06" => DistinctKey.H,
|
||||
"AC07" => DistinctKey.J,
|
||||
"AC08" => DistinctKey.K,
|
||||
"AC09" => DistinctKey.L,
|
||||
"AC10" => DistinctKey.OemSemicolon,
|
||||
"AC11" => DistinctKey.OemQuotes,
|
||||
"AB01" => DistinctKey.Z,
|
||||
"AB02" => DistinctKey.X,
|
||||
"AB03" => DistinctKey.C,
|
||||
"AB04" => DistinctKey.V,
|
||||
"AB05" => DistinctKey.B,
|
||||
"AB06" => DistinctKey.N,
|
||||
"AB07" => DistinctKey.M,
|
||||
"AB08" => DistinctKey.OemComma,
|
||||
"AB09" => DistinctKey.OemPeriod,
|
||||
"AB10" => DistinctKey.OemQuestion,
|
||||
"BKSL" => DistinctKey.OemPipe,
|
||||
_ => DistinctKey.Unknown,
|
||||
};
|
||||
|
||||
KeyEnumMap[i] = key;
|
||||
}
|
||||
}
|
||||
|
||||
XkbFreeKeyboard(keyboard, 0, true);
|
||||
|
|
|
@ -4873,11 +4873,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
try
|
||||
{
|
||||
var (major, minor) = (5, 0);
|
||||
if (XfixesImports.XFixesQueryVersion(_x11Display, ref major, ref minor) != 0
|
||||
|| major * 100 + minor < 500)
|
||||
if (!XfixesImports.XFixesQueryVersion(_x11Display, out var major, out var minor))
|
||||
{
|
||||
Console.Error.WriteLine("XFixes version is not at least 5.0, mouse capture will not lock the mouse cursor");
|
||||
Console.Error.WriteLine("Failed to query XFixes version, mouse capture will not lock the mouse cursor");
|
||||
_hasXFixes = false;
|
||||
}
|
||||
else if (major * 100 + minor < 500)
|
||||
{
|
||||
Console.Error.WriteLine($"XFixes version is not at least 5.0 (got {major}.{minor}), mouse capture will not lock the mouse cursor");
|
||||
_hasXFixes = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,10 @@ namespace BizHawk.Common
|
|||
{
|
||||
private const string XFIXES = "libXfixes.so.3";
|
||||
|
||||
// docs claims this returns Status, actually returns Bool (1 is success, 0 is failure)
|
||||
[DllImport(XFIXES)]
|
||||
public static extern int XFixesQueryVersion(IntPtr display, ref int major_version_inout, ref int minor_version_inout);
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool XFixesQueryVersion(IntPtr display, out int major_version_return, out int minor_version_return);
|
||||
|
||||
[Flags]
|
||||
public enum BarrierDirection : int
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace BizHawk.Common
|
|||
private const string XI2 = "libXi.so.6";
|
||||
|
||||
[DllImport(XI2)]
|
||||
public static extern int XIQueryVersion(IntPtr display, ref int major_version_inout, ref int minor_version_inout);
|
||||
public static extern XlibImports.Status XIQueryVersion(IntPtr display, ref int major_version_inout, ref int minor_version_inout);
|
||||
|
||||
public enum XIEvents
|
||||
{
|
||||
|
@ -64,8 +64,16 @@ namespace BizHawk.Common
|
|||
public IntPtr mask;
|
||||
}
|
||||
|
||||
// weird status XISelectEvents uses...
|
||||
public enum XIStatus : int
|
||||
{
|
||||
Success = 0,
|
||||
NoSuchExtension = 1,
|
||||
MiscError = -1,
|
||||
}
|
||||
|
||||
[DllImport(XI2)]
|
||||
public static extern int XISelectEvents(IntPtr display, IntPtr win, ref XIEventMask masks, int num_masks);
|
||||
public static extern XIStatus XISelectEvents(IntPtr display, IntPtr win, ref XIEventMask masks, int num_masks);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public unsafe struct XIValuatorState
|
||||
|
|
|
@ -47,6 +47,28 @@ namespace BizHawk.Common
|
|||
}
|
||||
}
|
||||
|
||||
public enum Status : int
|
||||
{
|
||||
Success = 0,
|
||||
BadRequest = 1,
|
||||
BadValue = 2,
|
||||
BadWindow = 3,
|
||||
BadPixmap = 4,
|
||||
BadAtom = 5,
|
||||
BadCursor = 6,
|
||||
BadFont = 7,
|
||||
BadMatch = 8,
|
||||
BadDrawable = 9,
|
||||
BadAccess = 10,
|
||||
BadAlloc = 11,
|
||||
BadColor = 12,
|
||||
BadGC = 13,
|
||||
BadIDChoice = 14,
|
||||
BadName = 15,
|
||||
BadLength = 16,
|
||||
BadImplementation = 17
|
||||
}
|
||||
|
||||
[DllImport(XLIB)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool XQueryExtension(IntPtr display, string name, out int major_opcode_return, out int first_event_return, out int first_error_return);
|
||||
|
@ -136,7 +158,7 @@ namespace BizHawk.Common
|
|||
public static extern bool XGetEventData(IntPtr display, ref XGenericEventCookie cookie);
|
||||
|
||||
[DllImport(XLIB)]
|
||||
public static extern int XFreeEventData(IntPtr display, ref XGenericEventCookie cookie);
|
||||
public static extern void XFreeEventData(IntPtr display, ref XGenericEventCookie cookie);
|
||||
|
||||
[Flags]
|
||||
public enum EventMask : uint
|
||||
|
@ -685,7 +707,7 @@ namespace BizHawk.Common
|
|||
public static extern unsafe void XkbFreeKeyboard(XkbDescRec* xkb, int which, [MarshalAs(UnmanagedType.Bool)] bool free_all);
|
||||
|
||||
[DllImport(XLIB)]
|
||||
public static extern unsafe int XkbGetNames(IntPtr display, uint which, XkbDescRec* xkb);
|
||||
public static extern unsafe Status XkbGetNames(IntPtr display, uint which, XkbDescRec* xkb);
|
||||
|
||||
[DllImport(XLIB)]
|
||||
public static extern Keysym XkbKeycodeToKeysym(IntPtr display, int keycode, int group, int level);
|
||||
|
|
Loading…
Reference in New Issue