Mercurial > audlegacy-plugins
annotate src/evdev-plug/ed_internals.c @ 3047:4434b4c4a715
ported EsounD plugin
author | Andrew O. Shadoura <bugzilla@tut.by> |
---|---|
date | Fri, 17 Apr 2009 16:17:10 +0300 |
parents | 3134a0987162 |
children |
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 |
5e46b57d1eda
[svn] - added evdev-plug, written-from-scratch plugin that allows to control the player via event devices on linux systems
giacomo
parents:
diff
changeset
|
27 #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
|
28 #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
|
29 #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
|
30 #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
|
31 #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
|
32 #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
|
33 #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
|
34 #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
|
35 #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
|
36 /* 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
|
37 #include <stdarg.h> |
2971
3134a0987162
- changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
2596
diff
changeset
|
38 #include <audlegacy/plugin.h> |
3134a0987162
- changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
2596
diff
changeset
|
39 #include <audlegacy/i18n.h> |
2230 | 40 #include <glib.h> |
41 #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
|
42 |
5e46b57d1eda
[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 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
|
44 |
5e46b57d1eda
[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 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
|
46 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
|
47 |
5e46b57d1eda
[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 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
|
49 |
5e46b57d1eda
[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 /* 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
|
53 |
5e46b57d1eda
[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 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
|
55 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
|
56 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
|
57 { |
5e46b57d1eda
[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 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
|
59 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
|
60 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
|
61 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
|
62 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
|
63 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
|
64 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
|
65 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
|
66 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
|
67 } |
5e46b57d1eda
[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 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
|
71 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
|
72 { |
5e46b57d1eda
[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 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
|
74 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
|
75 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
|
76 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
|
77 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
|
78 } |
5e46b57d1eda
[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 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
|
82 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
|
83 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
|
84 { |
5e46b57d1eda
[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 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
|
86 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
|
87 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
|
88 |
5e46b57d1eda
[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 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
|
90 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
|
91 { |
5e46b57d1eda
[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 /* 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
|
93 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
|
94 "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
|
95 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
|
96 } |
5e46b57d1eda
[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 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
|
99 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
|
100 { |
5e46b57d1eda
[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 /* 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
|
102 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
|
103 "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
|
104 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
|
105 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
|
106 } |
5e46b57d1eda
[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 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
|
108 |
5e46b57d1eda
[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 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
|
110 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
|
111 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
|
112 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
|
113 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
|
114 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
|
115 |
5e46b57d1eda
[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 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
|
117 } |
5e46b57d1eda
[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 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
|
121 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
|
122 { |
5e46b57d1eda
[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 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
|
124 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
|
125 |
5e46b57d1eda
[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 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
|
127 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
|
128 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
|
129 |
5e46b57d1eda
[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 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
|
131 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
|
132 |
5e46b57d1eda
[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 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
|
134 } |
5e46b57d1eda
[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 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
|
138 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
|
139 { |
5e46b57d1eda
[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 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
|
141 { |
5e46b57d1eda
[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 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
|
143 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
|
144 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
|
145 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
|
146 } |
5e46b57d1eda
[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 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
|
149 ( 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
|
150 ( 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
|
151 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
|
152 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
|
153 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
|
154 } |
5e46b57d1eda
[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 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
|
158 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
|
159 { |
5e46b57d1eda
[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 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
|
161 { |
5e46b57d1eda
[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 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
|
163 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
|
164 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
|
165 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
|
166 } |
5e46b57d1eda
[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 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
|
169 ( 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
|
170 ( 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
|
171 ( 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
|
172 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
|
173 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
|
174 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
|
175 } |
5e46b57d1eda
[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 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
|
179 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
|
180 { |
5e46b57d1eda
[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 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
|
182 { |
5e46b57d1eda
[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 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
|
184 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
|
185 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
|
186 } |
5e46b57d1eda
[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 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
|
188 { |
5e46b57d1eda
[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 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
|
190 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
|
191 /* 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
|
192 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
|
193 (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
|
194 |
5e46b57d1eda
[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 /* 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
|
196 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
|
197 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
|
198 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
|
199 } |
5e46b57d1eda
[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 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
|
204 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
|
205 { |
5e46b57d1eda
[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 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
|
207 ( 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
|
208 { |
5e46b57d1eda
[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 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
|
210 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
|
211 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
|
212 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
|
213 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
|
214 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
|
215 } |
5e46b57d1eda
[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 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
|
217 { |
5e46b57d1eda
[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 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
|
219 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
|
220 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
|
221 } |
5e46b57d1eda
[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 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
|
226 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
|
227 { |
5e46b57d1eda
[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 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
|
229 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
|
230 { |
5e46b57d1eda
[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 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
|
232 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
|
233 { |
5e46b57d1eda
[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 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
|
235 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
|
236 } |
5e46b57d1eda
[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 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
|
238 } |
5e46b57d1eda
[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 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
|
240 } |
5e46b57d1eda
[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 |
2230 | 243 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
|
244 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
|
245 { |
5e46b57d1eda
[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 /* 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
|
247 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
|
248 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
|
249 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
|
250 { |
5e46b57d1eda
[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 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
|
252 |
5e46b57d1eda
[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 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
|
254 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
|
255 |
5e46b57d1eda
[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 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
|
257 |
5e46b57d1eda
[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 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
|
259 } |
5e46b57d1eda
[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 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
|
264 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
|
265 { |
5e46b57d1eda
[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 /* 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
|
267 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
|
268 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
|
269 { |
5e46b57d1eda
[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 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
|
271 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
|
272 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
|
273 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
|
274 } |
5e46b57d1eda
[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 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
|
276 } |
5e46b57d1eda
[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 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
|
280 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
|
281 { |
5e46b57d1eda
[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 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
|
283 { |
5e46b57d1eda
[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 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
|
285 { |
5e46b57d1eda
[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 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
|
287 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
|
288 |
5e46b57d1eda
[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 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
|
290 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
|
291 { |
5e46b57d1eda
[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 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
|
293 { |
5e46b57d1eda
[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 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
|
295 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
|
296 |
5e46b57d1eda
[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 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
|
298 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
|
299 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
|
300 |
5e46b57d1eda
[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 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
|
302 { |
5e46b57d1eda
[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 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
|
304 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
|
305 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
|
306 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
|
307 |
5e46b57d1eda
[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 /* 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
|
309 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
|
310 { |
5e46b57d1eda
[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 /* 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
|
312 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
|
313 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
|
314 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
|
315 } |
5e46b57d1eda
[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 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
|
320 } |
2187 | 321 default: |
322 ; | |
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
|
323 } |
5e46b57d1eda
[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 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
|
326 } |
5e46b57d1eda
[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 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
|
330 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
|
331 { |
5e46b57d1eda
[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 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
|
333 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
|
334 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
|
335 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
|
336 |
5e46b57d1eda
[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 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
|
338 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
|
339 { |
5e46b57d1eda
[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 /* 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
|
341 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
|
342 "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
|
343 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
|
344 } |
5e46b57d1eda
[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 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
|
347 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
|
348 { |
5e46b57d1eda
[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 /* 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
|
350 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
|
351 "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
|
352 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
|
353 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
|
354 } |
5e46b57d1eda
[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 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
|
356 |
5e46b57d1eda
[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 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
|
358 { |
5e46b57d1eda
[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 /* 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
|
360 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
|
361 "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
|
362 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
|
363 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
|
364 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
|
365 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
|
366 } |
5e46b57d1eda
[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 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
|
368 { |
5e46b57d1eda
[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 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
|
370 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
|
371 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
|
372 |
5e46b57d1eda
[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 /* 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
|
374 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
|
375 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
|
376 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
|
377 |
5e46b57d1eda
[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 /* 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
|
379 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
|
380 "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
|
381 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
|
382 |
5e46b57d1eda
[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 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
|
384 { |
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
|
385 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
|
386 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
|
387 |
5e46b57d1eda
[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 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
|
389 { |
5e46b57d1eda
[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 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
|
391 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
|
392 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
|
393 |
5e46b57d1eda
[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 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
|
395 { |
5e46b57d1eda
[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 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
|
397 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
|
398 &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
|
399 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
|
400 } |
5e46b57d1eda
[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 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
|
403 { |
5e46b57d1eda
[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 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
|
405 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
|
406 &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
|
407 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
|
408 } |
5e46b57d1eda
[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 |
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
|
410 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
|
411 { |
5e46b57d1eda
[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 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
|
413 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
|
414 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
|
415 &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
|
416 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
|
417 |
5e46b57d1eda
[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 /* let's check if the filename actually exists in /dev */ |
2187 | 419 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
|
420 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
|
421 { |
5e46b57d1eda
[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 /* it doesn't exist, mark as invalid device by nullifying device_file*/ |
2187 | 423 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
|
424 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
|
425 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
|
426 } |
5e46b57d1eda
[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 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
|
428 { |
5e46b57d1eda
[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 /* 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
|
430 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
|
431 } |
5e46b57d1eda
[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 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
|
433 } |
5e46b57d1eda
[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 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
|
436 { |
5e46b57d1eda
[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 /* 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
|
438 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
|
439 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
|
440 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
|
441 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
|
442 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
|
443 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
|
444 } |
5e46b57d1eda
[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 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
|
447 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
|
448 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
|
449 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
|
450 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
|
451 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
|
452 |
5e46b57d1eda
[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 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
|
454 } |
5e46b57d1eda
[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 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
|
456 { |
5e46b57d1eda
[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 /* 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
|
458 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
|
459 } |
5e46b57d1eda
[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 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
|
462 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
|
463 } |
5e46b57d1eda
[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 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
|
468 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
|
469 { |
5e46b57d1eda
[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 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
|
471 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
|
472 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
|
473 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
|
474 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
|
475 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
|
476 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
|
477 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
|
478 |
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
|
479 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
|
480 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
|
481 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
|
482 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
|
483 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
|
484 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
|
485 |
5e46b57d1eda
[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 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
|
487 { |
5e46b57d1eda
[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 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
|
489 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
|
490 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
|
491 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
|
492 } |
5e46b57d1eda
[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 /* 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
|
495 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
|
496 |
5e46b57d1eda
[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 /* 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
|
498 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
|
499 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
|
500 { |
5e46b57d1eda
[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 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
|
502 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
|
503 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
|
504 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
|
505 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
|
506 |
5e46b57d1eda
[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 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
|
508 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
|
509 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
|
510 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
|
511 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
|
512 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
|
513 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
|
514 |
5e46b57d1eda
[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 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
|
516 { |
5e46b57d1eda
[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 /* 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
|
518 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
|
519 |
5e46b57d1eda
[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 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
|
521 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
|
522 |
5e46b57d1eda
[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 /* 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
|
524 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
|
525 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
|
526 |
5e46b57d1eda
[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 /* 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
|
528 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
|
529 /* 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
|
530 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
|
531 } |
5e46b57d1eda
[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 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
|
533 { |
5e46b57d1eda
[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 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
|
535 " , 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
|
536 } |
5e46b57d1eda
[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 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
|
539 } |
5e46b57d1eda
[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 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
|
542 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
|
543 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
|
544 } |
5e46b57d1eda
[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 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
|
548 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
|
549 { |
5e46b57d1eda
[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 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
|
551 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
|
552 { |
5e46b57d1eda
[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 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
|
554 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
|
555 } |
5e46b57d1eda
[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 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
|
557 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
|
558 } |
5e46b57d1eda
[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 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
|
562 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
|
563 { |
5e46b57d1eda
[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 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
|
565 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
|
566 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
|
567 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
|
568 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
|
569 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
|
570 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
|
571 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
|
572 |
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
|
573 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
|
574 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
|
575 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
|
576 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
|
577 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
|
578 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
|
579 |
5e46b57d1eda
[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 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
|
581 { |
5e46b57d1eda
[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 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
|
583 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
|
584 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
|
585 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
|
586 } |
5e46b57d1eda
[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 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
|
589 |
5e46b57d1eda
[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 /* 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
|
591 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
|
592 |
5e46b57d1eda
[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 /* 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
|
594 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
|
595 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
|
596 { |
5e46b57d1eda
[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 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
|
598 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
|
599 |
5e46b57d1eda
[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 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
|
601 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
|
602 { |
5e46b57d1eda
[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 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
|
604 ", 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
|
605 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
|
606 } |
5e46b57d1eda
[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 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
|
609 { |
5e46b57d1eda
[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 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
|
611 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
|
612 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
|
613 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
|
614 |
5e46b57d1eda
[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 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
|
616 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
|
617 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
|
618 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
|
619 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
|
620 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
|
621 |
5e46b57d1eda
[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 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
|
623 { |
5e46b57d1eda
[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 /* 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
|
625 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
|
626 } |
5e46b57d1eda
[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 /* 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
|
629 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
|
630 { |
5e46b57d1eda
[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 /* 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
|
632 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
|
633 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
|
634 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
|
635 |
5e46b57d1eda
[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 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
|
637 { |
5e46b57d1eda
[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 /* 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
|
639 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
|
640 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
|
641 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
|
642 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
|
643 { |
5e46b57d1eda
[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 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
|
645 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
|
646 } |
5e46b57d1eda
[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 /* 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
|
650 } |
5e46b57d1eda
[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 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
|
652 { |
5e46b57d1eda
[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 /* 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
|
654 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
|
655 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
|
656 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
|
657 { |
5e46b57d1eda
[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 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
|
659 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
|
660 } |
5e46b57d1eda
[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 /* 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
|
665 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
|
666 } |
5e46b57d1eda
[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 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
|
669 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
|
670 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
|
671 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
|
672 } |
5e46b57d1eda
[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 /* 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
|
676 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
|
677 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
|
678 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
|
679 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
|
680 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
|
681 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
|
682 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
|
683 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
|
684 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
|
685 { |
5e46b57d1eda
[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 /* 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
|
687 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
|
688 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
|
689 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
|
690 |
5e46b57d1eda
[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 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
|
692 { |
5e46b57d1eda
[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 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
|
694 |
5e46b57d1eda
[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 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
|
696 { |
5e46b57d1eda
[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 /* 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
|
698 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
|
699 { |
5e46b57d1eda
[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 /* 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
|
701 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
|
702 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
|
703 { |
5e46b57d1eda
[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 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
|
705 *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
|
706 } |
5e46b57d1eda
[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 /* 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
|
708 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
|
709 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
|
710 /* 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
|
711 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
|
712 } |
5e46b57d1eda
[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 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
|
714 { |
5e46b57d1eda
[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 /* 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
|
716 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
|
717 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
|
718 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
|
719 { |
5e46b57d1eda
[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 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
|
721 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
|
722 ( 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
|
723 ( 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
|
724 { |
5e46b57d1eda
[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 /* 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
|
726 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
|
727 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
|
728 { |
5e46b57d1eda
[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 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
|
730 *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
|
731 } |
5e46b57d1eda
[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 /* 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
|
733 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
|
734 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
|
735 /* 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
|
736 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
|
737 } |
5e46b57d1eda
[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 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
|
739 } |
5e46b57d1eda
[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 /* 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
|
742 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
|
743 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
|
744 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
|
745 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
|
746 *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
|
747 |
5e46b57d1eda
[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 /* 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
|
749 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
|
750 { |
5e46b57d1eda
[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 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
|
752 *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
|
753 } |
5e46b57d1eda
[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 /* 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
|
756 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
|
757 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
|
758 /* 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
|
759 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
|
760 } |
5e46b57d1eda
[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 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
|
764 } |
5e46b57d1eda
[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 /* 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
|
767 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
|
768 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
|
769 } |
5e46b57d1eda
[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 /* 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
|
774 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
|
775 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
|
776 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
|
777 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
|
778 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
|
779 { |
5e46b57d1eda
[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 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
|
781 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
|
782 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
|
783 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
|
784 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
|
785 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
|
786 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
|
787 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
|
788 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
|
789 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
|
790 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
|
791 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
|
792 } |
5e46b57d1eda
[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 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
|
795 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
|
796 { |
5e46b57d1eda
[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 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
|
798 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
|
799 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
|
800 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
|
801 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
|
802 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
|
803 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
|
804 |
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
|
805 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
|
806 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
|
807 |
5e46b57d1eda
[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 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
|
809 |
5e46b57d1eda
[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 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
|
811 |
5e46b57d1eda
[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 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
|
813 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
|
814 { |
5e46b57d1eda
[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 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
|
816 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
|
817 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
|
818 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
|
819 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
|
820 /* 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
|
821 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
|
822 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
|
823 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
|
824 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
|
825 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
|
826 } |
5e46b57d1eda
[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 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
|
829 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
|
830 { |
4fec4a3ca1a4
[svn] - evdev-plug: check that the player local datadir exists before attempting to create evdev-plug.conf
giacomo
parents:
435
diff
changeset
|
831 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
|
832 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
|
833 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
|
834 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
|
835 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
|
836 } |
4fec4a3ca1a4
[svn] - evdev-plug: check that the player local datadir exists before attempting to create evdev-plug.conf
giacomo
parents:
435
diff
changeset
|
837 else |
4fec4a3ca1a4
[svn] - evdev-plug: check that the player local datadir exists before attempting to create evdev-plug.conf
giacomo
parents:
435
diff
changeset
|
838 { |
4fec4a3ca1a4
[svn] - evdev-plug: check that the player local datadir exists before attempting to create evdev-plug.conf
giacomo
parents:
435
diff
changeset
|
839 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
|
840 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
|
841 } |
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
|
842 |
5e46b57d1eda
[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 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
|
844 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
|
845 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
|
846 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
|
847 } |
5e46b57d1eda
[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 /* 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
|
851 |
5e46b57d1eda
[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 /* 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
|
854 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
|
855 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
|
856 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
|
857 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
|
858 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
|
859 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
|
860 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
|
861 { |
5e46b57d1eda
[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 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
|
863 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
|
864 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
|
865 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
|
866 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
|
867 |
5e46b57d1eda
[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 /* 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
|
869 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
|
870 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
|
871 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
|
872 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
|
873 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
|
874 |
5e46b57d1eda
[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 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
|
876 |
5e46b57d1eda
[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 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
|
878 ( ( 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
|
879 { |
5e46b57d1eda
[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 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
|
881 { |
5e46b57d1eda
[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 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
|
883 { |
5e46b57d1eda
[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 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
|
885 *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
|
886 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
|
887 { |
5e46b57d1eda
[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 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
|
889 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
|
890 ", 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
|
891 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
|
892 } |
5e46b57d1eda
[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 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
|
894 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
|
895 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
|
896 } |
5e46b57d1eda
[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 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
|
899 { |
5e46b57d1eda
[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 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
|
901 *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
|
902 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
|
903 { |
5e46b57d1eda
[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 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
|
905 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
|
906 ", 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
|
907 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
|
908 } |
5e46b57d1eda
[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 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
|
910 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
|
911 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
|
912 } |
5e46b57d1eda
[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 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
|
915 { |
5e46b57d1eda
[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 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
|
917 *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
|
918 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
|
919 { |
5e46b57d1eda
[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 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
|
921 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
|
922 ", 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
|
923 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
|
924 } |
5e46b57d1eda
[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 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
|
926 } |
5e46b57d1eda
[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 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
|
929 { |
5e46b57d1eda
[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 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
|
931 *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
|
932 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
|
933 { |
5e46b57d1eda
[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 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
|
935 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
|
936 ", 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
|
937 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
|
938 } |
5e46b57d1eda
[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 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
|
940 } |
5e46b57d1eda
[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 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
|
943 { |
5e46b57d1eda
[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 /* 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
|
945 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
|
946 ", 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
|
947 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
|
948 } |
5e46b57d1eda
[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 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
|
953 |
5e46b57d1eda
[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 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
|
955 { |
5e46b57d1eda
[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 /* 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
|
957 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
|
958 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
|
959 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
|
960 } |
5e46b57d1eda
[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 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
|
962 { |
5e46b57d1eda
[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 /* 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
|
964 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
|
965 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
|
966 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
|
967 { |
5e46b57d1eda
[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 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
|
969 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
|
970 *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
|
971 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
|
972 } |
5e46b57d1eda
[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 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
|
974 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
|
975 } |
5e46b57d1eda
[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 /* 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
|
980 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
|
981 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
|
982 { |
5e46b57d1eda
[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 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
|
984 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
|
985 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
|
986 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
|
987 |
5e46b57d1eda
[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 /* 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
|
989 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
|
990 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
|
991 { |
5e46b57d1eda
[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 /* 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
|
993 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
|
994 { |
5e46b57d1eda
[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 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
|
996 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
|
997 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
|
998 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
|
999 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
|
1000 { |
5e46b57d1eda
[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 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
|
1002 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
|
1003 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
|
1004 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
|
1005 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
|
1006 } |
5e46b57d1eda
[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 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
|
1008 } |
5e46b57d1eda
[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 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
|
1010 } |
5e46b57d1eda
[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 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
|
1013 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
|
1014 |
5e46b57d1eda
[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 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
|
1016 { |
5e46b57d1eda
[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 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
|
1018 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
|
1019 } |
5e46b57d1eda
[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 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
|
1022 } |