2
* Licensed under the GNU General Public License Version 2
4
* Copyright (C) 2009 Red Hat <mjg@redhat.com>
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
29
#include <sys/ioctl.h>
31
#include <hal/libhal.h>
33
static LibHalContext *ctx = NULL;
37
main (int argc, char **argv)
50
fprintf (stderr, "hal-setup-wacom: Failed to get UDI\n");
54
asprintf (&newudi, "%s_subdev", udi);
56
dbus_error_init (&error);
57
if ((ctx = libhal_ctx_init_direct (&error)) == NULL) {
58
fprintf (stderr, "hal-setup-wacom: Unable to initialise libhal context: %s\n", error.message);
62
dbus_error_init (&error);
63
if (!libhal_device_addon_is_ready (ctx, udi, &error)) {
67
dbus_error_init (&error);
70
device = libhal_device_get_property_string (ctx, udi, "input.device",
72
if (dbus_error_is_set (&error) == TRUE) {
74
"hal-setup-wacom: Failed to get input device: '%s'\n",
79
/* Is there a forcedevice? */
80
dbus_error_init (&error);
81
forcedev = libhal_device_get_property_string
82
(ctx, udi, "input.x11_options.ForceDevice", &error);
84
dbus_error_init (&error);
85
name = libhal_device_get_property_string (ctx, udi, "info.product",
88
dbus_error_init (&error);
89
types = libhal_device_get_property_strlist (ctx, udi, "wacom.types",
92
if (dbus_error_is_set (&error) == TRUE) {
94
"hal-setup-wacom: Failed to get wacom types: '%s'\n",
99
/* Set up the extra devices */
100
for (i=0; types[i] != NULL; i++) {
103
dbus_error_init (&error);
104
tmpdev = libhal_new_device(ctx, &error);
105
if (dbus_error_is_set (&error) == TRUE) {
107
"hal-setup-wacom: Failed to create input device: '%s'\n",
111
dbus_error_init (&error);
112
libhal_device_set_property_string (ctx, tmpdev, "input.device",
114
dbus_error_init (&error);
115
libhal_device_set_property_string (ctx, tmpdev,
116
"input.x11_driver", "wacom",
118
dbus_error_init (&error);
119
libhal_device_set_property_string (ctx, tmpdev,
120
"input.x11_options.Type",
122
dbus_error_init (&error);
123
libhal_device_set_property_string (ctx, tmpdev, "info.parent",
125
dbus_error_init (&error);
126
libhal_device_property_strlist_append (ctx, tmpdev,
130
dbus_error_init (&error);
131
libhal_device_set_property_string (ctx, tmpdev,
132
"input.x11_options.ForceDevice",
136
dbus_error_init (&error);
137
asprintf (&subname, "%s %s", name, types[i]);
138
libhal_device_set_property_string (ctx, tmpdev,
143
dbus_error_init (&error);
144
libhal_device_commit_to_gdl (ctx, tmpdev, newudi, &error);
146
if (dbus_error_is_set (&error) == TRUE) {
148
"hal-setup-wacom: Failed to add input device: '%s'\n",