Mercurial > audlegacy-plugins
annotate src/evdev-plug/ed_internals.c @ 2497:ed6c81bd9016
Include cleanups, part #2.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 31 Mar 2008 14:55:14 +0300 |
parents | a48a1a3e835a |
children | bd3a24b39058 |
rev | line source |
---|---|
422
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
1 /* |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
2 * |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
3 * Author: Giacomo Lozito <james@develia.org>, (C) 2005-2007 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
4 * |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
5 * This program is free software; you can redistribute it and/or modify it |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License as published by the |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
7 * Free Software Foundation; either version 2 of the License, or (at your |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
8 * option) any later version. |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
9 * |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
10 * This program is distributed in the hope that it will be useful, but |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
11 * WITHOUT ANY WARRANTY; without even the implied warranty of |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
13 * General Public License for more details. |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
14 * |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License along |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
16 * with this program; if not, write to the Free Software Foundation, Inc., |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
18 * |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
19 */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
20 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
21 #include "ed_types.h" |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
22 #include "ed_internals.h" |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
23 #include "ed_actions.h" |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
24 #include "ed_bindings_store.h" |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
25 #include "ed_common.h" |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
26 |
435
c18fd1befd1f
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
422
diff
changeset
|
27 #include <audacious/util.h> |
422
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
28 #include <stdint.h> |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
29 #include <stdio.h> |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
30 #include <linux/input.h> |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
31 #include <sys/types.h> |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
32 #include <sys/stat.h> |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
33 #include <string.h> |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
34 #include <fcntl.h> |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
35 #include <unistd.h> |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
36 #include <regex.h> |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
37 /* for variadic */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
38 #include <stdarg.h> |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
39 |
527
d124034ebea3
[svn] - glib/gi18n.h -> audacious/i18n.h for automatic dgettext support
nenolod
parents:
438
diff
changeset
|
40 #include <audacious/i18n.h> |
2230 | 41 #include <glib.h> |
42 #include <glib/gstdio.h> | |
422
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
43 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
44 static gboolean ed_device_giofunc ( GIOChannel * , GIOCondition , gpointer ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
45 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
46 static gint ed_util_get_data_from_keyfile( GKeyFile * , gchar * , ... ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
47 static gpointer ed_util_get_bindings_from_keyfile( GKeyFile * , gchar * ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
48 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
49 extern GList *ed_device_listening_list; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
50 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
51 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
52 /* ***************** */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
53 /* internals */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
54 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
55 ed_device_info_t * |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
56 ed_device_info_new ( gchar * device_name , gchar * device_filename , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
57 gchar * device_phys , gint device_is_custom ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
58 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
59 ed_device_info_t *info = g_malloc(sizeof(ed_device_info_t)); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
60 info->name = g_strdup(device_name); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
61 info->filename = g_strdup(device_filename); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
62 info->phys = g_strdup(device_phys); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
63 info->is_custom = device_is_custom; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
64 info->is_active = FALSE; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
65 info->bindings = NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
66 info->reg = 0; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
67 return info; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
68 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
69 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
70 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
71 gint |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
72 ed_device_info_delete ( ed_device_info_t * info ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
73 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
74 g_free( info->phys ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
75 g_free( info->filename ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
76 g_free( info->name ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
77 g_free( info ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
78 return 0; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
79 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
80 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
81 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
82 ed_device_t * |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
83 ed_device_new ( gchar * device_name , gchar * device_filename , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
84 gchar * device_phys , gint device_is_custom ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
85 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
86 ed_device_t *event_device; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
87 GIOChannel *iochan; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
88 gint fd; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
89 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
90 fd = g_open( device_filename , O_RDONLY , 0 ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
91 if ( fd < 0 ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
92 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
93 /* an error occurred */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
94 g_warning( _("event-device-plugin: unable to open device file %s , skipping this device; check that " |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
95 "the file exists and that you have read permission for it\n") , device_filename ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
96 return NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
97 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
98 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
99 iochan = g_io_channel_unix_new( fd ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
100 if ( iochan == NULL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
101 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
102 /* an error occurred */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
103 g_warning( _("event-device-plugin: unable to create a io_channel for device file %s ," |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
104 "skipping this device\n") , device_filename ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
105 close( fd ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
106 return NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
107 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
108 g_io_channel_set_encoding( iochan , NULL , NULL ); /* binary data */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
109 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
110 event_device = g_malloc(sizeof(ed_device_t)); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
111 event_device->fd = fd; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
112 event_device->iochan = iochan; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
113 event_device->is_listening = FALSE; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
114 event_device->info = ed_device_info_new( |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
115 device_name , device_filename , device_phys , device_is_custom ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
116 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
117 return event_device; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
118 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
119 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
120 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
121 gint |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
122 ed_device_delete ( ed_device_t * event_device ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
123 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
124 if ( event_device->is_listening ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
125 ed_device_stop_listening( event_device ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
126 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
127 g_io_channel_shutdown( event_device->iochan , TRUE , NULL ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
128 g_io_channel_unref( event_device->iochan ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
129 close( event_device->fd ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
130 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
131 ed_device_info_delete( event_device->info ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
132 g_free( event_device ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
133 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
134 return 0; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
135 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
136 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
137 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
138 gboolean |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
139 ed_inputevent_check_equality( ed_inputevent_t *iev1 , ed_inputevent_t *iev2 ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
140 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
141 if (( iev1 == NULL ) || ( iev2 == NULL )) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
142 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
143 if (( iev1 == NULL ) && ( iev2 == NULL )) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
144 return TRUE; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
145 else |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
146 return FALSE; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
147 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
148 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
149 if ( ( iev1->code == iev2->code ) && |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
150 ( iev1->type == iev2->type ) && |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
151 ( iev1->value == iev2->value ) ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
152 return TRUE; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
153 else |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
154 return FALSE; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
155 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
156 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
157 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
158 gboolean |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
159 ed_device_info_check_equality( ed_device_info_t *info1 , ed_device_info_t *info2 ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
160 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
161 if (( info1 == NULL ) || ( info2 == NULL )) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
162 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
163 if (( info1 == NULL ) && ( info2 == NULL )) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
164 return TRUE; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
165 else |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
166 return FALSE; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
167 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
168 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
169 if ( ( strcmp(info1->name,info2->name) == 0 ) && |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
170 ( strcmp(info1->filename,info2->filename) == 0 ) && |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
171 ( strcmp(info1->phys,info2->phys) == 0 ) && |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
172 ( info1->is_custom == info2->is_custom ) ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
173 return TRUE; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
174 else |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
175 return FALSE; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
176 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
177 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
178 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
179 gint |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
180 ed_device_start_listening ( ed_device_t * event_device ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
181 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
182 if ( g_list_find( ed_device_listening_list , event_device ) != NULL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
183 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
184 DEBUGMSG( "called start listening for device \"%s\" ( %s - %s ) but device listening is already active!\n" , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
185 event_device->info->name , event_device->info->filename , event_device->info->phys ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
186 return -1; /* device listening is already active, do nothing */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
187 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
188 else |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
189 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
190 DEBUGMSG( "start listening for device \"%s\" ( %s - %s )\n" , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
191 event_device->info->name , event_device->info->filename , event_device->info->phys ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
192 /* add a watch that checks if there's data to read */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
193 event_device->iochan_sid = g_io_add_watch( event_device->iochan , G_IO_IN , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
194 (GIOFunc)ed_device_giofunc , event_device ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
195 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
196 /* add event_device to the list */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
197 ed_device_listening_list = g_list_append( ed_device_listening_list , event_device ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
198 event_device->is_listening = TRUE; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
199 return 0; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
200 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
201 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
202 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
203 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
204 gint |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
205 ed_device_stop_listening ( ed_device_t * event_device ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
206 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
207 if ( ( g_list_find( ed_device_listening_list , event_device ) != NULL ) && |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
208 ( event_device->is_listening == TRUE ) ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
209 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
210 DEBUGMSG( "stop listening for device \"%s\" ( %s - %s )\n" , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
211 event_device->info->name , event_device->info->filename , event_device->info->phys ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
212 g_source_remove( event_device->iochan_sid ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
213 ed_device_listening_list = g_list_remove( ed_device_listening_list , event_device ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
214 event_device->is_listening = FALSE; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
215 return 0; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
216 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
217 else |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
218 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
219 DEBUGMSG( "called stop listening for device \"%s\" ( %s - %s ) but device listening is not active!\n" , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
220 event_device->info->name , event_device->info->filename , event_device->info->phys ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
221 return -1; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
222 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
223 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
224 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
225 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
226 gint |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
227 ed_device_stop_listening_from_info ( ed_device_info_t * info ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
228 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
229 GList *list_iter = ed_device_listening_list; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
230 while ( list_iter != NULL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
231 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
232 ed_device_t *dev = list_iter->data; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
233 if ( ed_device_info_check_equality( dev->info , info ) == TRUE ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
234 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
235 ed_device_stop_listening( dev ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
236 return 0; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
237 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
238 list_iter = g_list_next( list_iter ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
239 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
240 return -1; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
241 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
242 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
243 |
2230 | 244 void |
422
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
245 ed_device_stop_listening_all ( gboolean delete_bindings ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
246 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
247 /* convenience function that stops listening for all |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
248 devices and also deletes bindings if requested */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
249 GList *list_iter = ed_device_listening_list; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
250 while ( list_iter != NULL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
251 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
252 ed_device_t *dev = list_iter->data; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
253 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
254 if (( delete_bindings == TRUE ) && ( dev->info->bindings != NULL )) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
255 ed_bindings_store_delete( dev->info->bindings ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
256 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
257 ed_device_delete( dev ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
258 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
259 list_iter = g_list_next( list_iter ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
260 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
261 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
262 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
263 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
264 gboolean |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
265 ed_device_check_listening_from_info ( ed_device_info_t * info ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
266 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
267 /* note: this must not alter the reg parameter of info */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
268 GList *list_iter = ed_device_listening_list; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
269 while ( list_iter != NULL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
270 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
271 ed_device_t *dev = list_iter->data; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
272 if ( ed_device_info_check_equality( dev->info , info ) == TRUE ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
273 return TRUE; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
274 list_iter = g_list_next( list_iter ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
275 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
276 return FALSE; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
277 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
278 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
279 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
280 static gboolean |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
281 ed_device_giofunc ( GIOChannel * iochan , GIOCondition cond , gpointer event_device ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
282 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
283 switch ( cond ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
284 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
285 case G_IO_IN: |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
286 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
287 gsize rb = 0; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
288 struct input_event inputev; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
289 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
290 if ( g_io_channel_read_chars( iochan , (gchar*)&inputev , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
291 sizeof(struct input_event) , &rb , NULL ) == G_IO_STATUS_NORMAL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
292 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
293 if ( rb == sizeof(struct input_event) ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
294 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
295 gint action_code = -1; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
296 ed_device_t *dev = event_device; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
297 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
298 DEBUGMSG( "event (%d,%d,%d) intercepted for device \"%s\" ( %s - %s )\n" , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
299 inputev.type , inputev.code , inputev.value , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
300 dev->info->name , dev->info->filename , dev->info->phys ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
301 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
302 if ( dev->info->bindings != NULL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
303 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
304 ed_inputevent_t ev; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
305 ev.type = inputev.type; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
306 ev.code = inputev.code; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
307 ev.value = inputev.value; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
308 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
309 /* lookup event type/code/value in the binding tree for this device */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
310 if ( ed_bindings_store_lookup( dev->info->bindings , &ev , &action_code ) == TRUE ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
311 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
312 /* this has been binded to an action, call the corresponding action */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
313 DEBUGMSG( "found action code %i for event (%d,%d,%d)\n" , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
314 action_code , inputev.type , inputev.code , inputev.value ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
315 ed_action_call( action_code , NULL ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
316 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
317 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
318 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
319 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
320 break; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
321 } |
2187 | 322 default: |
323 ; | |
422
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
324 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
325 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
326 return TRUE; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
327 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
328 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
329 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
330 GList * |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
331 ed_device_get_list_from_system ( void ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
332 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
333 GIOChannel *iochan; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
334 gchar *buffer; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
335 gsize buffer_len; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
336 gint fd = -1; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
337 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
338 fd = g_open( "/proc/bus/input/devices" , O_RDONLY , 0 ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
339 if ( fd < 0 ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
340 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
341 /* an error occurred */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
342 g_warning( _("event-device-plugin: unable to open /proc/bus/input/devices , automatic " |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
343 "detection of event devices won't work.\n") ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
344 return NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
345 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
346 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
347 iochan = g_io_channel_unix_new( fd ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
348 if ( iochan == NULL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
349 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
350 /* an error occurred */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
351 g_warning( _("event-device-plugin: unable to open a io_channel for /proc/bus/input/devices , " |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
352 "automatic detection of event devices won't work.\n") ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
353 close( fd ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
354 return NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
355 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
356 g_io_channel_set_encoding( iochan , "UTF-8" , NULL ); /* utf-8 text */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
357 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
358 if ( g_io_channel_read_to_end( iochan , &buffer , &buffer_len , NULL ) != G_IO_STATUS_NORMAL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
359 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
360 /* an error occurred */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
361 g_warning( _("event-device-plugin: an error occurred while reading /proc/bus/input/devices , " |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
362 "automatic detection of event devices won't work.\n") ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
363 g_io_channel_shutdown( iochan , TRUE , NULL ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
364 g_io_channel_unref( iochan ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
365 close( fd ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
366 return NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
367 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
368 else |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
369 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
370 regex_t preg; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
371 gint search_offset = 0; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
372 GList *system_devices_list = NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
373 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
374 /* we don't need these anymore */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
375 g_io_channel_shutdown( iochan , TRUE , NULL ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
376 g_io_channel_unref( iochan ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
377 close( fd ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
378 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
379 /* parse content of /proc/bus/input/devices */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
380 regcomp( &preg, |
2323
a48a1a3e835a
- fixed /proc/bus/input/devices parser error when there are multiple lines between phys and handlers, thanks to Checkryzhev Vitaly for report and patch
Giacomo Lozito <james@develia.org>
parents:
2230
diff
changeset
|
381 "I:[^\n]*\nN: Name=\"([^\n]*)\"\nP: Phys=([^\n]*)\n([^\n]+\n)*H: Handlers=[^\n]*(event[0-9]+)[^\n]*\n" , |
422
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
382 REG_ICASE | REG_EXTENDED ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
383 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
384 while ( search_offset > -1 ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
385 { |
2323
a48a1a3e835a
- fixed /proc/bus/input/devices parser error when there are multiple lines between phys and handlers, thanks to Checkryzhev Vitaly for report and patch
Giacomo Lozito <james@develia.org>
parents:
2230
diff
changeset
|
386 size_t nmatch = 5; |
a48a1a3e835a
- fixed /proc/bus/input/devices parser error when there are multiple lines between phys and handlers, thanks to Checkryzhev Vitaly for report and patch
Giacomo Lozito <james@develia.org>
parents:
2230
diff
changeset
|
387 regmatch_t submatch[5]; |
422
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
388 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
389 if ( regexec( &preg , &buffer[search_offset] , nmatch , submatch , 0 ) == 0 ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
390 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
391 GString *device_name = NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
392 GString *device_phys = NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
393 GString *device_file = NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
394 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
395 if ( submatch[1].rm_so != -1 ) /* check validity of name sub-expression */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
396 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
397 device_name = g_string_new( "" ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
398 g_string_append_len( device_name , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
399 &buffer[(search_offset + submatch[1].rm_so)] , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
400 submatch[1].rm_eo - submatch[1].rm_so ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
401 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
402 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
403 if ( submatch[2].rm_so != -1 ) /* check validity of physicalport sub-expression */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
404 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
405 device_phys = g_string_new( "" ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
406 g_string_append_len( device_phys , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
407 &buffer[(search_offset + submatch[2].rm_so)] , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
408 submatch[2].rm_eo - submatch[2].rm_so ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
409 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
410 |
2323
a48a1a3e835a
- fixed /proc/bus/input/devices parser error when there are multiple lines between phys and handlers, thanks to Checkryzhev Vitaly for report and patch
Giacomo Lozito <james@develia.org>
parents:
2230
diff
changeset
|
411 if ( submatch[4].rm_so != -1 ) /* check validity of filename sub-expression */ |
422
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
412 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
413 device_file = g_string_new( "" ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
414 GString *device_test = g_string_new( "" ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
415 g_string_append_len( device_file , |
2323
a48a1a3e835a
- fixed /proc/bus/input/devices parser error when there are multiple lines between phys and handlers, thanks to Checkryzhev Vitaly for report and patch
Giacomo Lozito <james@develia.org>
parents:
2230
diff
changeset
|
416 &buffer[(search_offset + submatch[4].rm_so)] , |
a48a1a3e835a
- fixed /proc/bus/input/devices parser error when there are multiple lines between phys and handlers, thanks to Checkryzhev Vitaly for report and patch
Giacomo Lozito <james@develia.org>
parents:
2230
diff
changeset
|
417 submatch[4].rm_eo - submatch[4].rm_so ); |
422
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
418 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
419 /* let's check if the filename actually exists in /dev */ |
2187 | 420 g_string_printf( device_test , "/dev/input/%s" , (char*)device_file->str ); |
422
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
421 if ( !g_file_test( device_test->str , G_FILE_TEST_EXISTS ) ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
422 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
423 /* it doesn't exist, mark as invalid device by nullifying device_file*/ |
2187 | 424 g_warning( _("event-device-plugin: device %s not found in /dev/input , skipping.\n") , (char*)device_file ); |
422
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
425 g_string_free( device_file , TRUE ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
426 device_file = NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
427 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
428 else |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
429 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
430 /* it does exist, mark as valid device by using the full path in device_file*/ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
431 g_string_assign( device_file , device_test->str ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
432 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
433 g_string_free( device_test , TRUE ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
434 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
435 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
436 if (( device_name != NULL ) && ( device_phys != NULL ) && ( device_file != NULL )) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
437 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
438 /* add item to the list */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
439 ed_device_info_t *info = ed_device_info_new( |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
440 device_name->str , device_file->str , device_phys->str , 0 ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
441 info->reg = 0; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
442 DEBUGMSG( "device found, name:\"%s\" , file \"%s\" , phys \"%s\"\n" , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
443 info->name , info->filename , info->phys ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
444 system_devices_list = g_list_append( system_devices_list , info ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
445 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
446 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
447 if ( device_name != NULL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
448 g_string_free( device_name , TRUE ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
449 if ( device_phys != NULL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
450 g_string_free( device_phys , TRUE ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
451 if ( device_file != NULL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
452 g_string_free( device_file , TRUE ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
453 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
454 search_offset += submatch[0].rm_eo; /* update offset for further search */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
455 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
456 else |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
457 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
458 /* no more valid devices found */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
459 search_offset = -1; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
460 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
461 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
462 regfree( &preg ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
463 return system_devices_list; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
464 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
465 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
466 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
467 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
468 GList * |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
469 ed_device_get_list_from_config ( void ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
470 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
471 GKeyFile *keyfile = NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
472 GList *config_devices_list = NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
473 gboolean is_loaded = FALSE; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
474 gchar **device_names = NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
475 gsize device_names_num = 0; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
476 gchar *config_pathfilename = NULL; |
435
c18fd1befd1f
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
422
diff
changeset
|
477 gchar *config_datadir = NULL; |
422
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
478 gint i = 0; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
479 |
435
c18fd1befd1f
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
422
diff
changeset
|
480 config_datadir = (gchar*)audacious_get_localdir(); |
c18fd1befd1f
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
422
diff
changeset
|
481 config_pathfilename = g_build_filename( config_datadir , PLAYER_LOCALRC_FILE , NULL ); |
c18fd1befd1f
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
422
diff
changeset
|
482 g_free( config_datadir ); |
422
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
483 keyfile = g_key_file_new(); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
484 is_loaded = g_key_file_load_from_file( keyfile , config_pathfilename , G_KEY_FILE_NONE , NULL ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
485 g_free( config_pathfilename ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
486 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
487 if ( is_loaded != TRUE ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
488 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
489 g_warning( _("event-device-plugin: unable to load config file %s , default settings will be used.\n") , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
490 PLAYER_LOCALRC_FILE ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
491 g_key_file_free( keyfile ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
492 return NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
493 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
494 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
495 /* remove ___plugin___ group that contains plugin settings */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
496 g_key_file_remove_group( keyfile , "___plugin___" , NULL ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
497 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
498 /* the other groups are devices; check them and run active ones */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
499 device_names = g_key_file_get_groups( keyfile , &device_names_num ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
500 while ( device_names[i] != NULL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
501 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
502 gint device_is_custom = 0; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
503 gchar *device_file = NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
504 gchar *device_phys = NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
505 gboolean device_is_active = FALSE; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
506 gint result = 0; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
507 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
508 result = ed_util_get_data_from_keyfile( |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
509 keyfile , device_names[i] , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
510 ED_CONFIG_INFO_FILENAME , &device_file , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
511 ED_CONFIG_INFO_PHYS , &device_phys , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
512 ED_CONFIG_INFO_ISCUSTOM , &device_is_custom , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
513 ED_CONFIG_INFO_ISACTIVE , &device_is_active , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
514 ED_CONFIG_INFO_END ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
515 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
516 if ( result == 0 ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
517 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
518 /* all information succesfully retrieved from config, create a ed_device_info_t */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
519 ed_device_info_t *info; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
520 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
521 info = ed_device_info_new( device_names[i] , device_file , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
522 device_phys , device_is_custom ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
523 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
524 /* pick bindings for this device */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
525 info->bindings = ed_util_get_bindings_from_keyfile( keyfile , device_names[i] ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
526 info->is_active = device_is_active; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
527 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
528 /* add this device to the config list */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
529 config_devices_list = g_list_append( config_devices_list , info ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
530 /* free information from config file, info has its own copies */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
531 g_free( device_file ); g_free( device_phys ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
532 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
533 else |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
534 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
535 g_warning( _("event-device-plugin: incomplete information in config file for device \"%s\"" |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
536 " , skipping.\n") , device_names[i] ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
537 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
538 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
539 i++; /* on with next */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
540 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
541 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
542 g_strfreev( device_names ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
543 g_key_file_free( keyfile ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
544 return config_devices_list; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
545 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
546 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
547 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
548 void |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
549 ed_device_free_list ( GList * system_devices_list ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
550 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
551 GList *list_iter = system_devices_list; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
552 while ( list_iter != NULL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
553 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
554 ed_device_info_delete( (ed_device_info_t*)list_iter->data ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
555 list_iter = g_list_next( list_iter ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
556 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
557 g_list_free( system_devices_list ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
558 return; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
559 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
560 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
561 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
562 void |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
563 ed_device_start_listening_from_config ( void ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
564 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
565 GKeyFile *keyfile = NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
566 gboolean is_loaded = FALSE; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
567 gchar **device_names = NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
568 gsize device_names_num = 0; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
569 gchar *config_pathfilename = NULL; |
435
c18fd1befd1f
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
422
diff
changeset
|
570 gchar *config_datadir = NULL; |
422
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
571 GList *system_devices_list = NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
572 gint i = 0; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
573 |
435
c18fd1befd1f
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
422
diff
changeset
|
574 config_datadir = (gchar*)audacious_get_localdir(); |
c18fd1befd1f
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
422
diff
changeset
|
575 config_pathfilename = g_build_filename( config_datadir , PLAYER_LOCALRC_FILE , NULL ); |
c18fd1befd1f
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
422
diff
changeset
|
576 g_free( config_datadir ); |
422
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
577 keyfile = g_key_file_new(); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
578 is_loaded = g_key_file_load_from_file( keyfile , config_pathfilename , G_KEY_FILE_NONE , NULL ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
579 g_free( config_pathfilename ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
580 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
581 if ( is_loaded != TRUE ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
582 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
583 g_warning( _("event-device-plugin: unable to load config file %s , default settings will be used.\n") , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
584 PLAYER_LOCALRC_FILE ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
585 g_key_file_free( keyfile ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
586 return; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
587 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
588 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
589 system_devices_list = ed_device_get_list_from_system(); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
590 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
591 /* remove ___plugin___ group that contains plugin settings */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
592 g_key_file_remove_group( keyfile , "___plugin___" , NULL ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
593 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
594 /* check available devices and run active ones */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
595 device_names = g_key_file_get_groups( keyfile , &device_names_num ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
596 while ( device_names[i] != NULL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
597 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
598 GError *gerr = NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
599 gboolean is_active; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
600 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
601 is_active = g_key_file_get_boolean( keyfile , device_names[i] , "is_active" , &gerr ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
602 if ( gerr != NULL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
603 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
604 g_warning( _("event-device-plugin: configuration, unable to get is_active value for device \"%s\"" |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
605 ", skipping it.\n") , device_names[i] ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
606 g_clear_error( &gerr ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
607 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
608 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
609 if ( is_active == TRUE ) /* only care about active devices at this time, ignore others */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
610 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
611 gint is_custom = 0; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
612 gchar *device_file = NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
613 gchar *device_phys = NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
614 gint result = 0; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
615 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
616 result = ed_util_get_data_from_keyfile( |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
617 keyfile , device_names[i] , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
618 ED_CONFIG_INFO_FILENAME , &device_file , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
619 ED_CONFIG_INFO_PHYS , &device_phys , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
620 ED_CONFIG_INFO_ISCUSTOM , &is_custom , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
621 ED_CONFIG_INFO_END ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
622 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
623 if ( result != 0 ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
624 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
625 /* something wrong, skip this device */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
626 i++; continue; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
627 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
628 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
629 /* unless this is a custom device, perform a device check */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
630 if ( is_custom != 1 ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
631 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
632 /* not a custom device, check it against system_devices_list |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
633 to see if its information should be updated or if it's not plugged at all */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
634 gint check_result = ed_device_check( |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
635 system_devices_list , device_names[i] , &device_file , &device_phys ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
636 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
637 if ( check_result == ED_DEVCHECK_OK ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
638 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
639 /* ok, we have an active not-custom device and it has been successfully |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
640 checked too; create a ed_device_t item for it */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
641 ed_device_t *dev = ed_device_new ( device_names[i] , device_file , device_phys , 0 ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
642 g_free( device_file ); g_free( device_phys ); /* not needed anymore */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
643 if ( dev != NULL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
644 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
645 dev->info->bindings = ed_util_get_bindings_from_keyfile( keyfile , device_names[i] ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
646 ed_device_start_listening ( dev ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
647 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
648 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
649 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
650 /* note: if check_result == ED_DEVCHECK_ABSENT, we simply skip this device */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
651 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
652 else |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
653 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
654 /* ok, we have an active custom device; create a ed_device_t item for it */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
655 ed_device_t *dev = ed_device_new ( device_names[i] , device_file , device_phys , 1 ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
656 g_free( device_file ); g_free( device_phys ); /* not needed anymore */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
657 if ( dev != NULL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
658 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
659 dev->info->bindings = ed_util_get_bindings_from_keyfile( keyfile , device_names[i] ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
660 ed_device_start_listening ( dev ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
661 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
662 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
663 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
664 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
665 /* on with next device name */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
666 i++; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
667 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
668 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
669 g_strfreev( device_names ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
670 ed_device_free_list( system_devices_list ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
671 g_key_file_free( keyfile ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
672 return; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
673 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
674 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
675 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
676 /* this function checks that a given event device (with device_name, |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
677 device_phys and device_file) exists in system_devices_list; device_phys |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
678 and device_file must be dynamically-allocated string, they could |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
679 be freed and reallocated if their information needs to be updated; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
680 it returns an integer, its value represents the performed operations */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
681 gint |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
682 ed_device_check ( GList * system_devices_list , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
683 gchar * device_name , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
684 gchar ** device_file , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
685 gchar ** device_phys ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
686 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
687 /* first, search in the list for a device, named device_name, |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
688 that has not been found in a previous ed_device_check |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
689 made with the same system_devices_list (info->reg == 0) */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
690 GList *list_iter = system_devices_list; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
691 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
692 while ( list_iter != NULL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
693 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
694 ed_device_info_t *info = list_iter->data; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
695 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
696 if ( ( info->reg == 0 ) && ( strcmp( device_name , info->name ) == 0 ) ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
697 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
698 /* found a device, check if it has the same physical address */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
699 if ( strcmp( *device_phys , info->phys ) == 0 ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
700 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
701 /* good, same device name and same physical |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
702 address; update device_file if necessary */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
703 if ( strcmp( *device_file , info->filename ) != 0 ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
704 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
705 g_free( *device_file ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
706 *device_file = g_strdup( info->filename ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
707 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
708 /* now mark it as "found" so it won't be searched in next |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
709 ed_device_check made with the same system_devices_list*/ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
710 info->reg = 1; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
711 /* everything done */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
712 return ED_DEVCHECK_OK; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
713 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
714 else |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
715 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
716 /* device found, but physical address is not the one from *device_phys; try to |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
717 search further in system_devices_list for a device with same name and address */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
718 GList *list_iter2 = g_list_next(list_iter); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
719 while ( list_iter2 != NULL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
720 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
721 ed_device_info_t *info2 = list_iter2->data; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
722 if ( ( info2->reg == 0 ) && |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
723 ( strcmp( device_name , info2->name ) == 0 ) && |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
724 ( strcmp( *device_phys , info2->phys ) == 0 ) ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
725 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
726 /* found a device with the same name and address, |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
727 so let's use it; update device_file if necessary */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
728 if ( strcmp( *device_file , info2->filename ) != 0 ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
729 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
730 g_free( *device_file ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
731 *device_file = g_strdup( info2->filename ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
732 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
733 /* now mark it as "found" so it won't be searched in next |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
734 ed_device_check made with the same system_devices_list */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
735 info2->reg = 1; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
736 /* everything done */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
737 return ED_DEVCHECK_OK; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
738 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
739 list_iter2 = g_list_next(list_iter2); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
740 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
741 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
742 /* if we get to this point, it means that there isn't any device named |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
743 device_name with physical address equal to *device_phys ; there is only |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
744 one (or more) device named device_name but with different physical |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
745 address; we'll use the first of those (alas the current content of info) */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
746 g_free( *device_phys ); /* free outdated device_phys */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
747 *device_phys = g_strdup( info->phys ); /* update it with the new one */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
748 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
749 /* update device_file if necessary */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
750 if ( strcmp( *device_file , info->filename ) != 0 ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
751 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
752 g_free( *device_file ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
753 *device_file = g_strdup( info->filename ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
754 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
755 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
756 /* now mark it as "found" so it won't be searched in next |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
757 ed_device_check made with the same system_devices_list*/ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
758 info->reg = 1; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
759 /* everything done */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
760 return ED_DEVCHECK_OK; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
761 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
762 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
763 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
764 list_iter = g_list_next(list_iter); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
765 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
766 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
767 /* the entire system_devices_list was searched, |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
768 but no device named device_name was found */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
769 return ED_DEVCHECK_ABSENT; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
770 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
771 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
772 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
773 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
774 /* config */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
775 static void |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
776 ed_config_save_from_list_bindings_foreach ( ed_inputevent_t * iev , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
777 gint action_code , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
778 gpointer keyfile , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
779 gpointer info_gp ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
780 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
781 gint int_list[4]; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
782 gchar *keyname; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
783 ed_device_info_t *info = info_gp; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
784 keyname = g_strdup_printf( "b%i" , info->reg ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
785 int_list[0] = action_code; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
786 int_list[1] = iev->type; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
787 int_list[2] = iev->code; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
788 int_list[3] = iev->value; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
789 g_key_file_set_integer_list( keyfile , info->name , keyname , int_list , 4 ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
790 g_free( keyname ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
791 info->reg++; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
792 return; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
793 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
794 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
795 gint |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
796 ed_config_save_from_list ( GList * config_devices_list ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
797 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
798 GKeyFile *keyfile; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
799 GList *iter_list = NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
800 gchar *keyfile_str = NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
801 gsize keyfile_str_len = 0; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
802 GIOChannel *iochan; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
803 gchar *config_pathfilename = NULL; |
435
c18fd1befd1f
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
422
diff
changeset
|
804 gchar *config_datadir = NULL; |
422
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
805 |
435
c18fd1befd1f
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
422
diff
changeset
|
806 config_datadir = (gchar*)audacious_get_localdir(); |
c18fd1befd1f
[svn] - added audacious_get_localdir() in util.c/h, returns a string with the full path of audacious local datadir
giacomo
parents:
422
diff
changeset
|
807 config_pathfilename = g_build_filename( config_datadir , PLAYER_LOCALRC_FILE , NULL ); |
422
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
808 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
809 keyfile = g_key_file_new(); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
810 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
811 g_key_file_set_string( keyfile , "___plugin___" , "config_ver" , ED_VERSION_CONFIG ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
812 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
813 iter_list = config_devices_list; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
814 while ( iter_list != NULL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
815 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
816 ed_device_info_t *info = iter_list->data; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
817 g_key_file_set_string( keyfile , info->name , "filename" , info->filename ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
818 g_key_file_set_string( keyfile , info->name , "phys" , info->phys ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
819 g_key_file_set_boolean( keyfile , info->name , "is_active" , info->is_active ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
820 g_key_file_set_integer( keyfile , info->name , "is_custom" , info->is_custom ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
821 /* use the info->reg field as a counter to list actions */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
822 info->reg = 0; /* init the counter */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
823 if ( info->bindings != NULL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
824 ed_bindings_store_foreach( info->bindings , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
825 ed_config_save_from_list_bindings_foreach , keyfile , info ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
826 iter_list = g_list_next( iter_list ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
827 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
828 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
829 keyfile_str = g_key_file_to_data( keyfile , &keyfile_str_len , NULL ); |
438
4fec4a3ca1a4
[svn] - evdev-plug: check that the player local datadir exists before attempting to create evdev-plug.conf
giacomo
parents:
435
diff
changeset
|
830 if ( g_file_test( config_datadir , G_FILE_TEST_IS_DIR ) == TRUE ) |
4fec4a3ca1a4
[svn] - evdev-plug: check that the player local datadir exists before attempting to create evdev-plug.conf
giacomo
parents:
435
diff
changeset
|
831 { |
4fec4a3ca1a4
[svn] - evdev-plug: check that the player local datadir exists before attempting to create evdev-plug.conf
giacomo
parents:
435
diff
changeset
|
832 iochan = g_io_channel_new_file( config_pathfilename , "w" , NULL ); |
4fec4a3ca1a4
[svn] - evdev-plug: check that the player local datadir exists before attempting to create evdev-plug.conf
giacomo
parents:
435
diff
changeset
|
833 g_io_channel_set_encoding( iochan , "UTF-8" , NULL ); |
4fec4a3ca1a4
[svn] - evdev-plug: check that the player local datadir exists before attempting to create evdev-plug.conf
giacomo
parents:
435
diff
changeset
|
834 g_io_channel_write_chars( iochan , keyfile_str , keyfile_str_len , NULL , NULL ); |
4fec4a3ca1a4
[svn] - evdev-plug: check that the player local datadir exists before attempting to create evdev-plug.conf
giacomo
parents:
435
diff
changeset
|
835 g_io_channel_shutdown( iochan , TRUE , NULL ); |
4fec4a3ca1a4
[svn] - evdev-plug: check that the player local datadir exists before attempting to create evdev-plug.conf
giacomo
parents:
435
diff
changeset
|
836 g_io_channel_unref( iochan ); |
4fec4a3ca1a4
[svn] - evdev-plug: check that the player local datadir exists before attempting to create evdev-plug.conf
giacomo
parents:
435
diff
changeset
|
837 } |
4fec4a3ca1a4
[svn] - evdev-plug: check that the player local datadir exists before attempting to create evdev-plug.conf
giacomo
parents:
435
diff
changeset
|
838 else |
4fec4a3ca1a4
[svn] - evdev-plug: check that the player local datadir exists before attempting to create evdev-plug.conf
giacomo
parents:
435
diff
changeset
|
839 { |
4fec4a3ca1a4
[svn] - evdev-plug: check that the player local datadir exists before attempting to create evdev-plug.conf
giacomo
parents:
435
diff
changeset
|
840 g_warning( _("event-device-plugin: unable to access local directory %s , settings will not be saved.\n") , |
4fec4a3ca1a4
[svn] - evdev-plug: check that the player local datadir exists before attempting to create evdev-plug.conf
giacomo
parents:
435
diff
changeset
|
841 config_datadir ); |
4fec4a3ca1a4
[svn] - evdev-plug: check that the player local datadir exists before attempting to create evdev-plug.conf
giacomo
parents:
435
diff
changeset
|
842 } |
422
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
843 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
844 g_free( keyfile_str ); |
438
4fec4a3ca1a4
[svn] - evdev-plug: check that the player local datadir exists before attempting to create evdev-plug.conf
giacomo
parents:
435
diff
changeset
|
845 g_free( config_datadir ); |
422
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
846 g_key_file_free( keyfile ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
847 return 0; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
848 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
849 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
850 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
851 /* utils */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
852 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
853 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
854 /* this picks information from a keyfile, using device_name |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
855 as group name; information must be requested by passing |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
856 a ed_config_info_t value and a corresponding container; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
857 list of requested information must be terminated with |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
858 ED_CONFIG_INFO_END; returns 0 if everything is found, |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
859 returns negative values if some information is missing */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
860 static gint |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
861 ed_util_get_data_from_keyfile( GKeyFile * keyfile , gchar * device_name , ... ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
862 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
863 GError *gerr = NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
864 gboolean is_failed = FALSE; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
865 ed_config_info_t info_code = ED_CONFIG_INFO_END; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
866 GList *temp_stringstore = NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
867 va_list ap; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
868 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
869 /* when we get a string value from g_key_file_get_string, we temporarily |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
870 store its container in temp_stringstore; if subsequent information |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
871 requests in the iteraton fails, we free the information in previous |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
872 container and nullify its content; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
873 this way, user will get complete information (return value 0) or |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
874 absent information (all string containers nullified, return value -1) */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
875 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
876 va_start( ap, device_name ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
877 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
878 while ( ( is_failed == FALSE ) && |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
879 ( ( info_code = va_arg( ap , ed_config_info_t ) ) != ED_CONFIG_INFO_END ) ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
880 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
881 switch ( info_code ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
882 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
883 case ED_CONFIG_INFO_FILENAME: |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
884 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
885 gchar **device_file = va_arg( ap , gchar ** ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
886 *device_file = g_key_file_get_string( keyfile , device_name , "filename" , &gerr ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
887 if ( gerr != NULL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
888 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
889 g_clear_error( &gerr ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
890 g_warning( _("event-device-plugin: configuration, unable to get filename value for device \"%s\"" |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
891 ", skipping it.\n") , device_name ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
892 is_failed = TRUE; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
893 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
894 else |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
895 temp_stringstore = g_list_append( temp_stringstore , device_file ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
896 break; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
897 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
898 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
899 case ED_CONFIG_INFO_PHYS: |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
900 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
901 gchar **device_phys = va_arg( ap , gchar ** ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
902 *device_phys = g_key_file_get_string( keyfile , device_name , "phys" , &gerr ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
903 if ( gerr != NULL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
904 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
905 g_clear_error( &gerr ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
906 g_warning( _("event-device-plugin: configuration, unable to get phys value for device \"%s\"" |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
907 ", skipping it.\n") , device_name ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
908 is_failed = TRUE; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
909 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
910 else |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
911 temp_stringstore = g_list_append( temp_stringstore , device_phys ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
912 break; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
913 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
914 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
915 case ED_CONFIG_INFO_ISCUSTOM: |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
916 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
917 gint *is_custom = va_arg( ap , gint * ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
918 *is_custom = g_key_file_get_integer( keyfile , device_name , "is_custom" , &gerr ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
919 if ( gerr != NULL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
920 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
921 g_clear_error( &gerr ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
922 g_warning( _("event-device-plugin: configuration, unable to get is_custom value for device \"%s\"" |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
923 ", skipping it.\n") , device_name ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
924 is_failed = TRUE; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
925 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
926 break; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
927 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
928 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
929 case ED_CONFIG_INFO_ISACTIVE: |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
930 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
931 gboolean *is_active = va_arg( ap , gboolean * ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
932 *is_active = g_key_file_get_boolean( keyfile , device_name , "is_active" , &gerr ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
933 if ( gerr != NULL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
934 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
935 g_clear_error( &gerr ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
936 g_warning( _("event-device-plugin: configuration, unable to get is_active value for device \"%s\"" |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
937 ", skipping it.\n") , device_name ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
938 is_failed = TRUE; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
939 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
940 break; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
941 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
942 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
943 default: |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
944 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
945 /* unexpected value in info_code, skipping */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
946 g_warning( _("event-device-plugin: configuration, unexpected value for device \"%s\"" |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
947 ", skipping it.\n") , device_name ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
948 is_failed = TRUE; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
949 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
950 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
951 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
952 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
953 va_end( ap ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
954 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
955 if ( is_failed == FALSE ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
956 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
957 /* temp_stringstore is not needed anymore, |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
958 do not change pointed containers */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
959 g_list_free( temp_stringstore ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
960 return 0; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
961 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
962 else |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
963 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
964 /* temp_stringstore is not needed anymore, |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
965 nullify pointed containers and free content */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
966 GList *list_iter = temp_stringstore; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
967 while ( list_iter != NULL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
968 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
969 gchar **container = list_iter->data; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
970 g_free( *container ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
971 *container = NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
972 list_iter = g_list_next( list_iter ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
973 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
974 g_list_free( temp_stringstore ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
975 return -1; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
976 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
977 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
978 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
979 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
980 /* this does just what its name says :) */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
981 static gpointer |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
982 ed_util_get_bindings_from_keyfile( GKeyFile * keyfile , gchar * device_name ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
983 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
984 ed_inputevent_t *iev = g_malloc(sizeof(ed_inputevent_t)); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
985 gpointer bindings = ed_bindings_store_new(); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
986 gchar **keys; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
987 gint j = 0; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
988 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
989 /* now get bindings for this device */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
990 keys = g_key_file_get_keys( keyfile , device_name , NULL , NULL ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
991 while ( keys[j] != NULL ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
992 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
993 /* in the config file, only bindings start with the 'b' character */ |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
994 if ( keys[j][0] == 'b' ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
995 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
996 gsize ilist_len = 0; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
997 gint *ilist; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
998 ilist = g_key_file_get_integer_list( keyfile , |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
999 device_name , keys[j] , &ilist_len , NULL ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
1000 if ( ilist_len > 3 ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
1001 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
1002 gint action_code = (gint)ilist[0]; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
1003 iev->type = (guint)ilist[1]; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
1004 iev->code = (guint)ilist[2]; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
1005 iev->value = (gint)ilist[3]; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
1006 ed_bindings_store_insert( bindings , iev , action_code ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
1007 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
1008 g_free( ilist ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
1009 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
1010 j++; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
1011 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
1012 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
1013 g_strfreev( keys ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
1014 g_free( iev ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
1015 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
1016 if ( ed_bindings_store_size( bindings ) == 0 ) |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
1017 { |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
1018 ed_bindings_store_delete( bindings ); |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
1019 bindings = NULL; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
1020 } |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
1021 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
1022 return bindings; |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
1023 } |