config: Introduce InputAttributes in NewInputDeviceRequest
In order to give NewInputDeviceRequest more information, a new InputAttributes type is introduced. Currently, this collects the product and vendor name, device path, and sets booleans for attributes such as having keys and/or a pointer. Only the HAL backend fills in the attributes, though. Signed-off-by: Dan Nicholson <dbn.lists@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
This commit is contained in:
parent
c6e8637e29
commit
0711598dd3
|
@ -227,7 +227,8 @@ ChangeDeviceControl(ClientPtr client, DeviceIntPtr dev,
|
|||
*
|
||||
*/
|
||||
int
|
||||
NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
|
||||
NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
|
||||
DeviceIntPtr *pdev)
|
||||
{
|
||||
return BadValue;
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ add_device(DBusMessage *message, DBusMessage *reply, DBusError *error)
|
|||
dbus_message_iter_next(&iter);
|
||||
}
|
||||
|
||||
ret = NewInputDeviceRequest(options, &dev);
|
||||
ret = NewInputDeviceRequest(options, NULL, &dev);
|
||||
if (ret != Success) {
|
||||
DebugF("[config/dbus] NewInputDeviceRequest failed\n");
|
||||
goto unwind;
|
||||
|
|
25
config/hal.c
25
config/hal.c
|
@ -191,6 +191,7 @@ device_added(LibHalContext *hal_ctx, const char *udi)
|
|||
{
|
||||
char *path = NULL, *driver = NULL, *name = NULL, *config_info = NULL;
|
||||
InputOption *options = NULL, *tmpo = NULL;
|
||||
InputAttributes attrs = {0};
|
||||
DeviceIntPtr dev = NULL;
|
||||
DBusError error;
|
||||
struct xkb_options xkb_opts = {0};
|
||||
|
@ -215,10 +216,28 @@ device_added(LibHalContext *hal_ctx, const char *udi)
|
|||
LogMessage(X_WARNING,"config/hal: no driver or path specified for %s\n", udi);
|
||||
goto unwind;
|
||||
}
|
||||
attrs.device = xstrdup(path);
|
||||
|
||||
name = get_prop_string(hal_ctx, udi, "info.product");
|
||||
if (!name)
|
||||
name = xstrdup("(unnamed)");
|
||||
else
|
||||
attrs.product = xstrdup(name);
|
||||
|
||||
attrs.vendor = get_prop_string(hal_ctx, udi, "info.vendor");
|
||||
|
||||
if (libhal_device_query_capability(hal_ctx, udi, "input.keys", NULL))
|
||||
attrs.flags |= ATTR_KEYBOARD;
|
||||
if (libhal_device_query_capability(hal_ctx, udi, "input.mouse", NULL))
|
||||
attrs.flags |= ATTR_POINTER;
|
||||
if (libhal_device_query_capability(hal_ctx, udi, "input.joystick", NULL))
|
||||
attrs.flags |= ATTR_JOYSTICK;
|
||||
if (libhal_device_query_capability(hal_ctx, udi, "input.tablet", NULL))
|
||||
attrs.flags |= ATTR_TABLET;
|
||||
if (libhal_device_query_capability(hal_ctx, udi, "input.touchpad", NULL))
|
||||
attrs.flags |= ATTR_TOUCHPAD;
|
||||
if (libhal_device_query_capability(hal_ctx, udi, "input.touchscreen", NULL))
|
||||
attrs.flags |= ATTR_TOUCHSCREEN;
|
||||
|
||||
options = xcalloc(sizeof(*options), 1);
|
||||
if (!options){
|
||||
|
@ -400,7 +419,7 @@ device_added(LibHalContext *hal_ctx, const char *udi)
|
|||
|
||||
/* this isn't an error, but how else do you output something that the user can see? */
|
||||
LogMessage(X_INFO, "config/hal: Adding input device %s\n", name);
|
||||
if ((rc = NewInputDeviceRequest(options, &dev)) != Success) {
|
||||
if ((rc = NewInputDeviceRequest(options, &attrs, &dev)) != Success) {
|
||||
LogMessage(X_ERROR, "config/hal: NewInputDeviceRequest failed (%d)\n", rc);
|
||||
dev = NULL;
|
||||
goto unwind;
|
||||
|
@ -430,6 +449,10 @@ unwind:
|
|||
xfree(tmpo);
|
||||
}
|
||||
|
||||
xfree(attrs.product);
|
||||
xfree(attrs.vendor);
|
||||
xfree(attrs.device);
|
||||
|
||||
if (xkb_opts.layout)
|
||||
xfree(xkb_opts.layout);
|
||||
if (xkb_opts.rules)
|
||||
|
|
|
@ -103,7 +103,8 @@ void dmxUpdateWindowInfo(DMXUpdateType type, WindowPtr pWindow)
|
|||
}
|
||||
|
||||
int
|
||||
NewInputDeviceRequest (InputOption *options, DeviceIntPtr *pdev)
|
||||
NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
|
||||
DeviceIntPtr *pdev)
|
||||
{
|
||||
return BadRequest;
|
||||
}
|
||||
|
|
|
@ -2249,7 +2249,8 @@ ChangeDeviceControl(register ClientPtr client, DeviceIntPtr pDev,
|
|||
}
|
||||
|
||||
int
|
||||
NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
|
||||
NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
|
||||
DeviceIntPtr *pdev)
|
||||
{
|
||||
InputOption *option = NULL;
|
||||
KdPointerInfo *pi = NULL;
|
||||
|
|
|
@ -83,7 +83,7 @@ typedef enum {
|
|||
*/
|
||||
#define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 4)
|
||||
#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(7, 0)
|
||||
#define ABI_XINPUT_VERSION SET_ABI_VERSION(8, 0)
|
||||
#define ABI_XINPUT_VERSION SET_ABI_VERSION(9, 0)
|
||||
#define ABI_EXTENSION_VERSION SET_ABI_VERSION(3, 0)
|
||||
#define ABI_FONT_VERSION SET_ABI_VERSION(0, 6)
|
||||
|
||||
|
|
|
@ -568,7 +568,8 @@ unwind:
|
|||
}
|
||||
|
||||
int
|
||||
NewInputDeviceRequest (InputOption *options, DeviceIntPtr *pdev)
|
||||
NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
|
||||
DeviceIntPtr *pdev)
|
||||
{
|
||||
IDevRec *idev = NULL;
|
||||
InputOption *option = NULL;
|
||||
|
|
|
@ -230,7 +230,8 @@ ChangeDeviceControl(ClientPtr client, DeviceIntPtr dev,
|
|||
*
|
||||
*/
|
||||
int
|
||||
NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
|
||||
NewInputDeviceRequest(InputOption *options, InputAttributes *attrs,
|
||||
DeviceIntPtr *pdev)
|
||||
{
|
||||
DEBUG_LOG("NewInputDeviceRequest(%p, %p)\n", options, pdev);
|
||||
return BadValue;
|
||||
|
|
|
@ -52,6 +52,7 @@ SOFTWARE.
|
|||
#include "screenint.h"
|
||||
#include <X11/Xmd.h>
|
||||
#include <X11/Xproto.h>
|
||||
#include <stdint.h>
|
||||
#include "window.h" /* for WindowPtr */
|
||||
#include "xkbrules.h"
|
||||
#include "events.h"
|
||||
|
@ -210,6 +211,20 @@ typedef struct _InputOption {
|
|||
struct _InputOption *next;
|
||||
} InputOption;
|
||||
|
||||
typedef struct _InputAttributes {
|
||||
char *product;
|
||||
char *vendor;
|
||||
char *device;
|
||||
uint32_t flags;
|
||||
} InputAttributes;
|
||||
|
||||
#define ATTR_KEYBOARD (1<<0)
|
||||
#define ATTR_POINTER (1<<1)
|
||||
#define ATTR_JOYSTICK (1<<2)
|
||||
#define ATTR_TABLET (1<<3)
|
||||
#define ATTR_TOUCHPAD (1<<4)
|
||||
#define ATTR_TOUCHSCREEN (1<<5)
|
||||
|
||||
/* Key has been run through all input processing and events sent to clients. */
|
||||
#define KEY_PROCESSED 1
|
||||
/* Key has not been fully processed, no events have been sent. */
|
||||
|
@ -514,6 +529,7 @@ void FixUpEventFromWindow(DeviceIntPtr pDev,
|
|||
/* Implemented by the DDX. */
|
||||
extern _X_EXPORT int NewInputDeviceRequest(
|
||||
InputOption *options,
|
||||
InputAttributes *attrs,
|
||||
DeviceIntPtr *dev);
|
||||
extern _X_EXPORT void DeleteInputDeviceRequest(
|
||||
DeviceIntPtr dev);
|
||||
|
|
Loading…
Reference in New Issue