2 * Copyright (c) 2009 Ryan Huffman
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 * Ryan Huffman (ryanhuffman@gmail.com)
28 #include <xf86Xinput.h>
29 #include <X11/extensions/XIproto.h>
30 #include <X11/extensions/XInput2.h>
32 #include <xf86_OSlib.h>
40 /* InputInfoPtr for main tuio device */
41 static InputInfoPtr g_pInfo
;
42 static int pipefd
[2] = {-1, -1};
44 /* Module Functions */
46 TuioPlug(pointer
, pointer
, int *, int *);
51 /* Driver Functions */
53 TuioPreInit(InputDriverPtr
, IDevPtr
, int);
56 TuioUnInit(InputDriverPtr
, InputInfoPtr
, int);
59 TuioObjReadInput(InputInfoPtr pInfo
);
62 TuioReadInput(InputInfoPtr
);
65 TuioControl(DeviceIntPtr
, int);
67 /* Internal Functions */
69 _hal_create_devices(InputInfoPtr pInfo
, int num
);
72 _init_buttons(DeviceIntPtr device
);
75 _init_axes(DeviceIntPtr device
);
78 _tuio_lo_2dcur_handle(const char *path
,
86 _free_tuiodev(TuioDevicePtr pTuio
);
93 /* Object and Subdev list manipulation functions */
95 _object_get(ObjectPtr head
, int id
);
101 _object_add(ObjectPtr
*obj_list
, ObjectPtr obj
);
104 _object_remove(ObjectPtr
*obj_list
, int id
);
107 _subdev_add(InputInfoPtr pInfo
, SubDevicePtr subdev
);
110 _subdev_remove(InputInfoPtr pInfo
, SubDevicePtr
*subdev_list
);
113 _subdev_remove_sd(SubDevicePtr
*subdev_list
, SubDevicePtr subdev
);
116 _hal_remove_device(InputInfoPtr pInfo
);
118 /* Driver information */
119 static XF86ModuleVersionInfo TuioVersionRec
=
125 XORG_VERSION_CURRENT
,
126 PACKAGE_VERSION_MAJOR
, PACKAGE_VERSION_MINOR
, PACKAGE_VERSION_PATCHLEVEL
,
133 _X_EXPORT InputDriverRec TUIO
=
144 _X_EXPORT XF86ModuleData tuioModuleData
=
152 TuioPlug(pointer module
,
157 xf86AddInputDriver(&TUIO
, module
, 0);
165 TuioUnplug(pointer p
)
170 * Pre-initialization of new device
171 * This can be entered by either a "core" tuio device
172 * or an extension "Object" device that is used for routing individual object
176 TuioPreInit(InputDriverPtr drv
,
181 TuioDevicePtr pTuio
= NULL
;
185 int num_subdev
, tuio_port
;
187 if (!(pInfo
= xf86AllocateInput(drv
, 0)))
190 /* If Type == Object, this is a device for an object to use */
191 type
= xf86CheckStrOption(dev
->commonOptions
, "Type", NULL
);
193 if (type
!= NULL
&& strcmp(type
, "Object") == 0) {
194 xf86Msg(X_INFO
, "%s: TUIO subdevice found\n", dev
->identifier
);
198 if (!(pTuio
= xcalloc(1, sizeof(TuioDeviceRec
)))) {
199 xf86DeleteInput(pInfo
, 0);
204 pInfo
->private = pTuio
;
206 pTuio
->num_subdev
= 0;
208 /* Get the number of subdevices we need to create */
209 num_subdev
= xf86CheckIntOption(dev
->commonOptions
, "SubDevices",
211 if (num_subdev
> MAX_SUBDEVICES
) {
212 num_subdev
= MAX_SUBDEVICES
;
213 } else if (num_subdev
< MIN_SUBDEVICES
) {
214 num_subdev
= MIN_SUBDEVICES
;
216 pTuio
->init_num_subdev
= num_subdev
;
218 /* Get the TUIO port number to use */
219 tuio_port
= xf86CheckIntOption(dev
->commonOptions
, "Port", DEFAULT_PORT
);
220 if (tuio_port
< 0 || tuio_port
> 65535) {
221 xf86Msg(X_INFO
, "%s: Invalid port number (%i), defaulting to %i\n",
222 dev
->identifier
, tuio_port
, DEFAULT_PORT
);
223 tuio_port
= DEFAULT_PORT
;
225 xf86Msg(X_INFO
, "%s: TUIO UDP Port set to %i\n",
226 dev
->identifier
, tuio_port
);
227 pTuio
->tuio_port
= tuio_port
;
229 /* Get setting for checking fseq numbers in TUIO packets */
230 pTuio
->fseq_threshold
= xf86CheckIntOption(dev
->commonOptions
,
231 "FseqThreshold", 100);
232 if (pTuio
->fseq_threshold
< 0) {
233 pTuio
->fseq_threshold
= 0;
235 xf86Msg(X_INFO
, "%s: FseqThreshold set to %i\n",
236 dev
->identifier
, pTuio
->fseq_threshold
);
238 /* Get setting for whether to send button events or not with
239 * object add & remove */
240 pTuio
->post_button_events
= xf86CheckBoolOption(dev
->commonOptions
,
241 "PostButtonEvents", True
);
244 /* Allocate device storage and add to device list */
245 subdev
= xcalloc(1, sizeof(SubDeviceRec
));
246 subdev
->pInfo
= pInfo
;
247 _subdev_add(g_pInfo
, subdev
);
249 /* Set up InputInfoPtr */
250 pInfo
->name
= xstrdup(dev
->identifier
);
252 pInfo
->type_name
= XI_TOUCHSCREEN
; /* FIXME: Correct type? */
253 pInfo
->conf_idev
= dev
;
254 pInfo
->read_input
= pTuio
? TuioReadInput
: TuioObjReadInput
; /* Set callback */
255 pInfo
->device_control
= TuioControl
; /* Set callback */
256 pInfo
->switch_mode
= NULL
;
258 /* Process common device options */
259 xf86CollectInputOptions(pInfo
, NULL
, NULL
);
260 xf86ProcessCommonOptions(pInfo
, pInfo
->options
);
262 pInfo
->flags
|= XI86_OPEN_ON_INIT
;
263 pInfo
->flags
|= XI86_CONFIGURED
;
272 TuioUnInit(InputDriverPtr drv
,
276 xf86DeleteInput(pInfo
, 0);
280 * Empty callback for object device.
283 TuioObjReadInput(InputInfoPtr pInfo
) {
288 * Handle new TUIO data on the socket
291 TuioReadInput(InputInfoPtr pInfo
)
293 TuioDevicePtr pTuio
= pInfo
->private;
294 ObjectPtr
*obj_list
= &pTuio
->obj_list
;
295 ObjectPtr obj
= pTuio
->obj_list
;
296 SubDevicePtr
*subdev_list
= &pTuio
->subdev_list
;
300 while (xf86WaitForInput(pInfo
->fd
, 0) > 0)
302 /* The liblo handler will set this flag if anything was processed */
303 pTuio
->processed
= 0;
305 /* liblo will receive a message and call the appropriate
306 * handlers (i.e. _tuio_lo_cur2d_hande()) */
307 lo_server_recv_noblock(pTuio
->server
, 0);
309 /* During the processing of the previous message/bundle,
310 * any "active" messages will be handled by flagging
311 * the listed object ids. Now that processing is done,
312 * remove any dead object ids and set any pending changes.
313 * Also check to make sure the processed data was newer than
314 * the last processed data */
315 if (pTuio
->processed
&&
316 (pTuio
->fseq_new
> pTuio
->fseq_old
||
317 pTuio
->fseq_old
- pTuio
->fseq_new
> pTuio
->fseq_threshold
)) {
319 while (obj
!= NULL
) {
321 if (obj
->subdev
&& pTuio
->post_button_events
) {
322 /* Post button "up" event */
323 xf86PostButtonEvent(obj
->subdev
->pInfo
->dev
, TRUE
, 1, FALSE
, 0, 0);
326 obj
= _object_remove(obj_list
, obj
->id
);
327 _subdev_add(pInfo
, obj
->subdev
);
332 /* Object is alive. Check to see if an update has been set.
333 * If it has been updated and it has a subdevice to send
334 * events on, send the event) */
335 if (obj
->pending
.set
&& obj
->subdev
) {
336 obj
->x
= obj
->pending
.x
;
337 obj
->y
= obj
->pending
.y
;
338 obj
->pending
.set
= False
;
340 /* OKAY FOR NOW, maybe update with a better range? */
341 /* TODO: Add more valuators with additional information */
342 valuators
[0] = obj
->x
* 0x7FFFFFFF;
343 valuators
[1] = obj
->y
* 0x7FFFFFFF;
345 xf86PostMotionEventP(obj
->subdev
->pInfo
->dev
,
346 TRUE
, /* is_absolute */
347 0, /* first_valuator */
348 2, /* num_valuators */
351 if (obj
->pending
.button
) {
352 xf86PostButtonEvent(obj
->subdev
->pInfo
->dev
, TRUE
, 1, TRUE
, 0, 0);
353 obj
->pending
.button
= False
;
356 obj
->alive
= 0; /* Reset for next message */
360 pTuio
->fseq_old
= pTuio
->fseq_new
;
366 * Handle device state changes
369 TuioControl(DeviceIntPtr device
,
372 InputInfoPtr pInfo
= device
->public.devicePrivate
;
373 TuioDevicePtr pTuio
= pInfo
->private;
380 xf86Msg(X_INFO
, "%s: Init\n", pInfo
->name
);
381 _init_buttons(device
);
384 /* If this is a "core" device, create object devices */
386 _hal_create_devices(pInfo
, pTuio
->init_num_subdev
);
390 case DEVICE_ON
: /* Open socket and start listening! */
391 xf86Msg(X_INFO
, "%s: On.\n", pInfo
->name
);
392 if (device
->public.on
)
395 /* If this is an object device, use a dummy pipe */
397 if (pipefd
[0] == -1) {
398 SYSCALL(res
= pipe(pipefd
));
400 xf86Msg(X_ERROR
, "%s: failed to open pipe\n",
406 pInfo
->fd
= pipefd
[0];
412 asprintf(&tuio_port
, "%i", pTuio
->tuio_port
);
413 pTuio
->server
= lo_server_new_with_proto(tuio_port
, LO_UDP
, _lo_error
);
414 if (pTuio
->server
== NULL
) {
415 xf86Msg(X_ERROR
, "%s: Error allocating new lo_server\n",
420 /* Register to receive all /tuio/2Dcur messages */
421 lo_server_add_method(pTuio
->server
, "/tuio/2Dcur", NULL
,
422 _tuio_lo_2dcur_handle
, pInfo
);
424 pInfo
->fd
= lo_server_get_socket_fd(pTuio
->server
);
426 xf86FlushInput(pInfo
->fd
);
428 finish
: xf86AddEnabledDevice(pInfo
);
429 device
->public.on
= TRUE
;
433 xf86Msg(X_INFO
, "%s: Off\n", pInfo
->name
);
434 if (!device
->public.on
)
437 xf86RemoveEnabledDevice(pInfo
);
440 lo_server_free(pTuio
->server
);
444 device
->public.on
= FALSE
;
448 xf86Msg(X_INFO
, "%s: Close\n", pInfo
->name
);
449 _hal_remove_device(pInfo
);
457 * Initialize the device properties
464 * Free a TuioDeviceRec
467 _free_tuiodev(TuioDevicePtr pTuio
) {
468 ObjectPtr obj
= pTuio
->obj_list
;
471 while (obj
!= NULL
) {
481 * Handles OSC messages in the /tuio/2Dcur address space
484 _tuio_lo_2dcur_handle(const char *path
,
490 InputInfoPtr pInfo
= user_data
;
491 TuioDevicePtr pTuio
= pInfo
->private;
492 ObjectPtr
*obj_list
= &pTuio
->obj_list
;
493 ObjectPtr obj
, objtemp
;
498 xf86Msg(X_ERROR
, "%s: Error in /tuio/cur2d (argc == 0)\n",
501 } else if(*types
!= 's') {
502 xf86Msg(X_ERROR
, "%s: Error in /tuio/cur2d (types[0] != 's')\n",
507 /* Flag as being processed, used in TuioReadInput() */
508 pTuio
->processed
= 1;
510 /* Parse message type */
511 /* Set message type: */
512 if (strcmp((char *)argv
[0], "set") == 0) {
514 /* Simple type check */
515 if (strcmp(types
, "sifffff")) {
516 xf86Msg(X_ERROR
, "%s: Error in /tuio/cur2d set msg (types == %s)\n",
521 obj
= _object_get(*obj_list
, argv
[1]->i
);
523 /* If not found, create a new object */
525 obj
= _object_new(argv
[1]->i
);
526 _object_add(obj_list
, obj
);
527 obj
->subdev
= _subdev_remove(pInfo
, &pTuio
->subdev_list
);
528 if (obj
->subdev
&& pTuio
->post_button_events
)
529 obj
->pending
.button
= True
;
532 obj
->pending
.x
= argv
[2]->f
;
533 obj
->pending
.y
= argv
[3]->f
;
534 obj
->pending
.set
= True
;
536 } else if (strcmp((char *)argv
[0], "alive") == 0) {
537 /* Mark all objects that are still alive */
539 while (obj
!= NULL
) {
540 for (i
=1; i
<argc
; i
++) {
541 if (argv
[i
]->i
== obj
->id
) {
549 } else if (strcmp((char *)argv
[0], "fseq") == 0) {
550 /* Simple type check */
551 if (strcmp(types
, "si")) {
552 xf86Msg(X_ERROR
, "%s: Error in /tuio/cur2d fseq msg (types == %s)\n",
556 pTuio
->fseq_new
= argv
[1]->i
;
563 * liblo error handler
570 xf86Msg(X_ERROR
, "liblo: %s\n", msg
);
574 * Retrieves an object from a list based on its id.
576 * @return NULL if not found.
579 _object_get(ObjectPtr head
, int id
) {
580 ObjectPtr obj
= head
;
582 while (obj
!= NULL
&& obj
->id
!= id
) {
590 * Allocates and inserts a new object at the beginning of a list.
591 * Pointer to the new object is returned.
592 * Doesn't check for duplicate ids, so call _object_get() beforehand
593 * to make sure it doesn't exist already!!
595 * @return ptr to newly inserted object
598 _object_new(int id
) {
599 ObjectPtr new_obj
= xcalloc(1, sizeof(ObjectRec
));
602 new_obj
->alive
= True
;
608 * Adds a SubDevice to the beginning of the subdev_list list
611 _object_add(ObjectPtr
*obj_list
, ObjectPtr obj
) {
613 if (obj_list
== NULL
|| obj
== NULL
)
616 if (*obj_list
!= NULL
) {
617 obj
->next
= *obj_list
;
624 * Removes an Object with a specific id from a list.
627 _object_remove(ObjectPtr
*obj_list
, int id
) {
628 ObjectPtr obj
= *obj_list
;
631 if (obj
== NULL
) return; /* Empty list */
633 if (obj
->id
== id
) { /* Remove from head */
634 *obj_list
= obj
->next
;
636 while (obj
->next
!= NULL
) {
637 if (obj
->next
->id
== id
) {
639 obj
->next
= objtmp
->next
;
653 * Adds a SubDevice to the beginning of the subdev_list list
656 _subdev_add(InputInfoPtr pInfo
, SubDevicePtr subdev
) {
657 TuioDevicePtr pTuio
= pInfo
->private;
658 SubDevicePtr
*subdev_list
= &pTuio
->subdev_list
;
659 ObjectPtr obj
= pTuio
->obj_list
;
661 if (subdev_list
== NULL
|| subdev
== NULL
)
664 /* First check to see if there are any objects that don't have a
665 * subdevice that we can assign this subdevice to */
666 while (obj
!= NULL
) {
667 if (obj
->subdev
== NULL
) {
668 obj
->subdev
= subdev
;
669 if (pTuio
->post_button_events
)
670 obj
->pending
.button
= True
;
671 obj
->pending
.set
= True
;
677 /* No subdevice-less objects, add to front of subdev list */
678 if (*subdev_list
!= NULL
) {
679 subdev
->next
= *subdev_list
;
681 *subdev_list
= subdev
;
685 * Removes a SubDevice from the subdev_list list
688 _subdev_remove(InputInfoPtr pInfo
, SubDevicePtr
*subdev_list
) {
691 if (subdev_list
== NULL
|| *subdev_list
== NULL
) {
692 _hal_create_devices(pInfo
, 1); /* Create one new subdevice */
696 subdev
= *subdev_list
;
697 *subdev_list
= subdev
->next
;
704 * Init the button map device. We only use one button.
707 _init_buttons(DeviceIntPtr device
)
709 InputInfoPtr pInfo
= device
->public.devicePrivate
;
716 map
= xcalloc(numbuttons
, sizeof(CARD8
));
717 labels
= xcalloc(numbuttons
, sizeof(Atom
));
718 for (i
=0; i
<numbuttons
; i
++)
721 if (!InitButtonClassDeviceStruct(device
, numbuttons
/* 1 button */,
722 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
726 xf86Msg(X_ERROR
, "%s: Failed to register buttons.\n", pInfo
->name
);
735 * Init valuators for device, use x/y coordinates.
738 _init_axes(DeviceIntPtr device
)
740 InputInfoPtr pInfo
= device
->public.devicePrivate
;
742 const int num_axes
= 2;
745 atoms
= xcalloc(num_axes
, sizeof(Atom
));
747 if (!InitValuatorClassDeviceStruct(device
,
749 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
752 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 3
755 GetMotionHistorySize(),
759 /* Use absolute mode. Currently, TUIO coords are mapped to the
760 * full screen area */
761 pInfo
->dev
->valuator
->mode
= Absolute
;
762 if (!InitAbsoluteClassDeviceStruct(device
))
765 for (i
= 0; i
< num_axes
; i
++)
767 xf86InitValuatorAxisStruct(device
, i
,
768 #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
771 0, 0x7FFFFFFF, 1, 1, 1);
772 xf86InitValuatorDefaults(device
, i
);
778 * New device creation through hal
779 * I referenced the wacom hal-setup patch while writing this:
780 * http://cvs.fedoraproject.org/viewvc/rpms/linuxwacom/devel/linuxwacom-0.8.2.2-hal-setup.patch?revision=1.1&view=markup
782 * @return 0 if successful, 1 if failure
785 _hal_create_devices(InputInfoPtr pInfo
, int num
) {
786 TuioDevicePtr pTuio
= pInfo
->private;
788 DBusConnection
*conn
;
794 /* We need a new device to send motion/button events through.
795 * There isn't a great way to do this right now without native
796 * blob events, so just hack it out for now. Woot. */
798 /* Open connection to dbus and create contex */
799 dbus_error_init(&error
);
800 if ((conn
= dbus_bus_get(DBUS_BUS_SYSTEM
, &error
)) == NULL
) {
801 xf86Msg(X_ERROR
, "%s: Failed to open dbus connection: %s\n",
802 pInfo
->name
, error
.message
);
806 if ((ctx
= libhal_ctx_new()) == NULL
) {
807 xf86Msg(X_ERROR
, "%s: Failed to obtain hal context\n",
812 dbus_error_init(&error
);
813 libhal_ctx_set_dbus_connection(ctx
, conn
);
814 if (!libhal_ctx_init(ctx
, &error
)) {
815 xf86Msg(X_ERROR
, "%s: Failed to initialize hal context: %s\n",
816 pInfo
->name
, error
.message
);
820 /* Create new devices through hal */
821 for (i
=0; i
<num
; i
++) {
823 dbus_error_init(&error
);
824 newdev
= libhal_new_device(ctx
, &error
);
825 if (dbus_error_is_set(&error
) == TRUE
) {
826 xf86Msg(X_ERROR
, "%s: Failed to create input device: %s\n",
827 pInfo
->name
, error
.message
);
831 dbus_error_init(&error
);
832 libhal_device_set_property_string(ctx
, newdev
, "input.device",
833 "tuio_subdevice", &error
);
834 if (dbus_error_is_set(&error
) == TRUE
) {
835 xf86Msg(X_ERROR
, "%s: Failed to set hal property: %s\n",
836 pInfo
->name
, error
.message
);
840 dbus_error_init(&error
);
841 libhal_device_set_property_bool(ctx
, newdev
, "RequireEnable",
843 if (dbus_error_is_set(&error
) == TRUE
) {
844 xf86Msg(X_ERROR
, "%s: Failed to set hal property: %s\n",
845 pInfo
->name
, error
.message
);
849 dbus_error_init(&error
);
850 libhal_device_set_property_string(ctx
, newdev
,
851 "input.x11_driver", "tuio",
853 if (dbus_error_is_set(&error
) == TRUE
) {
854 xf86Msg(X_ERROR
, "%s: Failed to set hal property: %s\n",
855 pInfo
->name
, error
.message
);
859 /* Set "Type" property. This will be used in TuioPreInit to determine
860 * whether the new device is a subdev or not */
861 dbus_error_init(&error
);
862 libhal_device_set_property_string(ctx
, newdev
,
863 "input.x11_options.Type",
865 if (dbus_error_is_set(&error
) == TRUE
) {
866 xf86Msg(X_ERROR
, "%s: Failed to set hal property: %s\n",
867 pInfo
->name
, error
.message
);
871 asprintf(&name
, "%s subdev %i", pInfo
->name
, pTuio
->num_subdev
);
874 dbus_error_init(&error
);
875 libhal_device_set_property_string(ctx
, newdev
,
876 "info.product", name
,
878 if (dbus_error_is_set(&error
) == TRUE
) {
879 xf86Msg(X_ERROR
, "%s: Failed to set hal property: %s\n",
880 pInfo
->name
, error
.message
);
884 /* Finalize creation of new device */
885 dbus_error_init(&error
);
886 libhal_device_commit_to_gdl(ctx
, newdev
, "/org/freedesktop/Hal/devices/tuio_subdev", &error
);
887 if (dbus_error_is_set (&error
) == TRUE
) {
888 xf86Msg(X_ERROR
, "%s: Failed to add input device: %s\n",
889 pInfo
->name
, error
.message
);
897 if (!libhal_ctx_shutdown(ctx
, &error
)) {
898 xf86Msg(X_ERROR
, "%s: Unable to shutdown hal context: %s\n",
899 pInfo
->name
, error
.message
);
902 libhal_ctx_free(ctx
);
908 _hal_remove_device(InputInfoPtr pInfo
) {
910 DBusConnection
*conn
;
915 xf86Msg(X_INFO
, "%s: Removing subdevice\n",
918 /* Open connection to dbus and create contex */
919 dbus_error_init(&error
);
920 if ((conn
= dbus_bus_get(DBUS_BUS_SYSTEM
, &error
)) == NULL
) {
921 xf86Msg(X_ERROR
, "%s: Failed to open dbus connection: %s\n",
922 pInfo
->name
, error
.message
);
926 if ((ctx
= libhal_ctx_new()) == NULL
) {
927 xf86Msg(X_ERROR
, "%s: Failed to obtain hal context\n",
932 dbus_error_init(&error
);
933 libhal_ctx_set_dbus_connection(ctx
, conn
);
934 if (!libhal_ctx_init(ctx
, &error
)) {
935 xf86Msg(X_ERROR
, "%s: Failed to initialize hal context: %s\n",
936 pInfo
->name
, error
.message
);
940 devices
= libhal_manager_find_device_string_match(ctx
, "info.product",
944 if (dbus_error_is_set(&error
) == TRUE
) {
945 xf86Msg(X_ERROR
, "%s: Failed when trying to find device: %s\n",
946 pInfo
->name
, error
.message
);
950 if (num_devices
== 0) {
951 xf86Msg(X_ERROR
, "%s: Unable to find subdevice in HAL GDL\n",
954 for (i
=0; i
<num_devices
; i
++) {
955 xf86Msg(X_INFO
, "%s: Removing subdevice with udi '%s'\n",
956 pInfo
->name
, devices
[i
]);
957 if (!libhal_remove_device(ctx
, devices
[i
], &error
)) {
958 xf86Msg(X_ERROR
, "%s: Unable to remove subdevice: %s\n",
959 pInfo
->name
, error
.message
);
964 if (!libhal_ctx_shutdown(ctx
, &error
)) {
965 xf86Msg(X_ERROR
, "%s: Unable to shutdown hal context: %s\n",
966 pInfo
->name
, error
.message
);
969 libhal_ctx_free(ctx
);