XInput2: Request XInput 2.1
We need XInput 2.1 to get raw events on the root window even while another client has a grab. We currently use raw events for relative mouse input, and upcoming commits will use raw events for buttons and keys.
This commit is contained in:
parent
a902480cb0
commit
46540ea42b
|
@ -5,12 +5,14 @@
|
||||||
|
|
||||||
#include <X11/XKBlib.h>
|
#include <X11/XKBlib.h>
|
||||||
|
|
||||||
|
#include <X11/extensions/XInput2.h>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
|
||||||
|
#include "Common/Logging/Log.h"
|
||||||
#include "Common/StringUtil.h"
|
#include "Common/StringUtil.h"
|
||||||
|
|
||||||
#include "Core/Host.h"
|
#include "Core/Host.h"
|
||||||
|
@ -54,6 +56,14 @@
|
||||||
// more cleanly separate each scroll wheel click, but risks dropping some inputs
|
// more cleanly separate each scroll wheel click, but risks dropping some inputs
|
||||||
#define SCROLL_AXIS_DECAY 1.1f
|
#define SCROLL_AXIS_DECAY 1.1f
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
// We need XInput 2.1 to get raw events on the root window even while another
|
||||||
|
// client has a grab. If we request 2.2 or later, the server will not generate
|
||||||
|
// emulated button presses from touch events, so we want exactly 2.1.
|
||||||
|
constexpr int XINPUT_MAJOR = 2, XINPUT_MINOR = 1;
|
||||||
|
} // namespace
|
||||||
|
|
||||||
namespace ciface::XInput2
|
namespace ciface::XInput2
|
||||||
{
|
{
|
||||||
// This function will add zero or more KeyboardMouse objects to devices.
|
// This function will add zero or more KeyboardMouse objects to devices.
|
||||||
|
@ -67,13 +77,18 @@ void PopulateDevices(void* const hwnd)
|
||||||
|
|
||||||
// verify that the XInput extension is available
|
// verify that the XInput extension is available
|
||||||
if (!XQueryExtension(dpy, "XInputExtension", &xi_opcode, &event, &error))
|
if (!XQueryExtension(dpy, "XInputExtension", &xi_opcode, &event, &error))
|
||||||
|
{
|
||||||
|
WARN_LOG_FMT(CONTROLLERINTERFACE, "XInput extension not available (XQueryExtension)");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// verify that the XInput extension is at at least version 2.0
|
int major = XINPUT_MAJOR, minor = XINPUT_MINOR;
|
||||||
int major = 2, minor = 0;
|
if (XIQueryVersion(dpy, &major, &minor) != Success || major < XINPUT_MAJOR ||
|
||||||
|
(major == XINPUT_MAJOR && minor < XINPUT_MINOR))
|
||||||
if (XIQueryVersion(dpy, &major, &minor) != Success)
|
{
|
||||||
|
WARN_LOG_FMT(CONTROLLERINTERFACE, "XInput extension not available (XIQueryVersion)");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// register all master devices with Dolphin
|
// register all master devices with Dolphin
|
||||||
|
|
||||||
|
@ -160,6 +175,9 @@ KeyboardMouse::KeyboardMouse(Window window, int opcode, int pointer, int keyboar
|
||||||
// "context."
|
// "context."
|
||||||
m_display = XOpenDisplay(nullptr);
|
m_display = XOpenDisplay(nullptr);
|
||||||
|
|
||||||
|
int major = XINPUT_MAJOR, minor = XINPUT_MINOR;
|
||||||
|
XIQueryVersion(m_display, &major, &minor);
|
||||||
|
|
||||||
// should always be 1
|
// should always be 1
|
||||||
int unused;
|
int unused;
|
||||||
XIDeviceInfo* const pointer_device = XIQueryDevice(m_display, pointer_deviceid, &unused);
|
XIDeviceInfo* const pointer_device = XIQueryDevice(m_display, pointer_deviceid, &unused);
|
||||||
|
|
Loading…
Reference in New Issue