2010-05-25 22:38:44 +00:00
|
|
|
|
/* GDK - The GIMP Drawing Kit
|
|
|
|
|
* Copyright (C) 2009 Carlos Garnacho <carlosg@gnome.org>
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2010-05-25 22:38:44 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
2010-12-21 06:32:01 +00:00
|
|
|
|
#include "gdkx11devicemanager-xi2.h"
|
2010-12-16 03:09:35 +00:00
|
|
|
|
#include "gdkinternals.h"
|
|
|
|
|
#include "gdkprivate-x11.h"
|
2018-02-07 05:00:01 +00:00
|
|
|
|
#include "gdkdisplay-x11.h"
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2011-07-14 15:43:59 +00:00
|
|
|
|
/* Defines for VCP/VCK, to be used too
|
|
|
|
|
* for the core protocol device manager
|
|
|
|
|
*/
|
|
|
|
|
#define VIRTUAL_CORE_POINTER_ID 2
|
|
|
|
|
#define VIRTUAL_CORE_KEYBOARD_ID 3
|
|
|
|
|
|
2019-05-14 22:18:38 +00:00
|
|
|
|
GdkX11DeviceManagerXI2 *
|
2010-12-15 19:49:23 +00:00
|
|
|
|
_gdk_x11_device_manager_new (GdkDisplay *display)
|
2010-05-25 22:38:44 +00:00
|
|
|
|
{
|
2019-05-14 22:08:37 +00:00
|
|
|
|
int opcode, firstevent, firsterror;
|
|
|
|
|
Display *xdisplay;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2019-05-14 22:08:37 +00:00
|
|
|
|
xdisplay = GDK_DISPLAY_XDISPLAY (display);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2019-05-14 22:08:37 +00:00
|
|
|
|
if (XQueryExtension (xdisplay, "XInputExtension",
|
|
|
|
|
&opcode, &firstevent, &firsterror))
|
|
|
|
|
{
|
|
|
|
|
int major, minor;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2019-05-14 22:08:37 +00:00
|
|
|
|
major = 2;
|
|
|
|
|
minor = 3;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2019-05-14 22:08:37 +00:00
|
|
|
|
if (XIQueryVersion (xdisplay, &major, &minor) != BadRequest)
|
|
|
|
|
{
|
|
|
|
|
GdkX11DeviceManagerXI2 *device_manager_xi2;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2019-05-14 22:08:37 +00:00
|
|
|
|
GDK_DISPLAY_NOTE (display, INPUT, g_message ("Creating XI2 device manager"));
|
2010-09-19 02:57:36 +00:00
|
|
|
|
|
2019-05-14 22:08:37 +00:00
|
|
|
|
device_manager_xi2 = g_object_new (GDK_TYPE_X11_DEVICE_MANAGER_XI2,
|
|
|
|
|
"display", display,
|
|
|
|
|
"opcode", opcode,
|
|
|
|
|
"major", major,
|
|
|
|
|
"minor", minor,
|
|
|
|
|
NULL);
|
2010-05-25 22:38:44 +00:00
|
|
|
|
|
2019-05-14 22:18:38 +00:00
|
|
|
|
return device_manager_xi2;
|
2010-05-25 22:38:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-14 22:04:13 +00:00
|
|
|
|
g_error ("XInput2 support not found on display");
|
2010-05-25 22:38:44 +00:00
|
|
|
|
}
|
2011-07-14 15:43:59 +00:00
|
|
|
|
|
2021-05-20 03:39:18 +00:00
|
|
|
|
/**
|
2011-07-14 15:49:44 +00:00
|
|
|
|
* gdk_x11_device_manager_lookup:
|
2021-05-20 03:39:18 +00:00
|
|
|
|
* @device_manager: (type GdkX11DeviceManagerXI2): a `GdkDeviceManager`
|
2011-07-14 15:49:44 +00:00
|
|
|
|
* @device_id: a device ID, as understood by the XInput2 protocol
|
|
|
|
|
*
|
2021-05-20 03:39:18 +00:00
|
|
|
|
* Returns the `GdkDevice` that wraps the given device ID.
|
2011-07-14 15:49:44 +00:00
|
|
|
|
*
|
2021-05-19 11:24:34 +00:00
|
|
|
|
* Returns: (transfer none) (nullable) (type GdkX11DeviceXI2): The
|
2021-05-20 03:39:18 +00:00
|
|
|
|
* `GdkDevice` wrapping the device ID, or %NULL if the given ID
|
|
|
|
|
* doesn’t currently represent a device.
|
|
|
|
|
*/
|
2011-07-14 15:49:44 +00:00
|
|
|
|
GdkDevice *
|
2019-05-14 22:18:38 +00:00
|
|
|
|
gdk_x11_device_manager_lookup (GdkX11DeviceManagerXI2 *device_manager,
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int device_id)
|
2011-07-14 15:49:44 +00:00
|
|
|
|
{
|
2019-05-14 22:04:13 +00:00
|
|
|
|
g_return_val_if_fail (GDK_IS_X11_DEVICE_MANAGER_XI2 (device_manager), NULL);
|
2011-07-14 15:49:44 +00:00
|
|
|
|
|
2019-05-14 22:04:13 +00:00
|
|
|
|
return _gdk_x11_device_manager_xi2_lookup (GDK_X11_DEVICE_MANAGER_XI2 (device_manager),
|
|
|
|
|
device_id);
|
2011-07-14 15:49:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-07-14 15:43:59 +00:00
|
|
|
|
/**
|
|
|
|
|
* gdk_x11_device_get_id:
|
2021-05-18 21:05:26 +00:00
|
|
|
|
* @device: (type GdkX11DeviceXI2): a `GdkDevice`
|
2011-07-14 15:43:59 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns the device ID as seen by XInput2.
|
|
|
|
|
*
|
2021-05-18 21:05:26 +00:00
|
|
|
|
* Returns: the XInput2 device ID
|
|
|
|
|
*/
|
2020-07-24 13:54:49 +00:00
|
|
|
|
int
|
2011-07-14 15:43:59 +00:00
|
|
|
|
gdk_x11_device_get_id (GdkDevice *device)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GDK_IS_DEVICE (device), 0);
|
|
|
|
|
|
2019-05-14 22:04:13 +00:00
|
|
|
|
return _gdk_x11_device_xi2_get_id (GDK_X11_DEVICE_XI2 (device));
|
2011-07-14 15:43:59 +00:00
|
|
|
|
}
|