annotate src/lirc.c @ 1668:9e168ba1b0b9

fixed an use of uninitialized value
author nadvornik
date Tue, 30 Jun 2009 20:15:33 +0000
parents 24ef7b610ed6
children d8e9d0cc640e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1305
2abdd6e50120 Glibification.
zas_
parents: 1265
diff changeset
1 /*
2abdd6e50120 Glibification.
zas_
parents: 1265
diff changeset
2 * Geeqie
2abdd6e50120 Glibification.
zas_
parents: 1265
diff changeset
3 * Copyright (C) 2008 - 2009 The Geeqie Team
2abdd6e50120 Glibification.
zas_
parents: 1265
diff changeset
4 *
2abdd6e50120 Glibification.
zas_
parents: 1265
diff changeset
5 */
2abdd6e50120 Glibification.
zas_
parents: 1265
diff changeset
6
2abdd6e50120 Glibification.
zas_
parents: 1265
diff changeset
7 #include <glib/gprintf.h>
2abdd6e50120 Glibification.
zas_
parents: 1265
diff changeset
8
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
9 #include "lirc.h"
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
10
1022
9962b24b6b43 Move miscellaneous functions to their own files (new misc.[ch]).
zas_
parents: 1000
diff changeset
11 #include "misc.h"
9962b24b6b43 Move miscellaneous functions to their own files (new misc.[ch]).
zas_
parents: 1000
diff changeset
12
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
13 #ifdef HAVE_LIRC
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
14 #include <lirc/lirc_client.h>
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
15 #include "layout_image.h"
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
16
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
17 gint lirc_fd = -1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
18 struct lirc_config *config = NULL;
1523
24a12aa0cb54 Fix up event source ids type: gint -> guint.
zas_
parents: 1305
diff changeset
19 guint input_tag = 0; /* event source id */
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
20 GIOChannel *gio_chan;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
21
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
22 /*
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
23 *-----------------------------------------------------------------------------
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
24 * LIRC callback
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
25 *-----------------------------------------------------------------------------
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
26 */
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
27
610
33a375d16181 Make lirc_cleanup() and lirc_input_callback() static.
zas_
parents: 609
diff changeset
28 static void lirc_cleanup(void)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
29 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
30 if (config)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
31 {
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
32 g_source_remove(input_tag);
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
33 lirc_freeconfig(config);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
34 config = NULL;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
35 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
36 if (lirc_fd != -1)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
37 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
38 lirc_deinit();
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
39 lirc_fd = -1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
40 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
41 if (gio_chan)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
42 {
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
43 g_io_channel_shutdown(gio_chan, TRUE, NULL);
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
44 g_io_channel_unref(gio_chan);
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
45 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
46 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
47
610
33a375d16181 Make lirc_cleanup() and lirc_input_callback() static.
zas_
parents: 609
diff changeset
48 static gboolean lirc_input_callback(GIOChannel *source, GIOCondition condition,
33a375d16181 Make lirc_cleanup() and lirc_input_callback() static.
zas_
parents: 609
diff changeset
49 gpointer data)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
50 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
51 LayoutWindow *lw = data;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
52 gchar *ptr;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
53 gint ret;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
54 gint x = 0;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
55 gint y = 0;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
56
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
57 /* LIRC code and corresponding geeqie command (and parameters)*/
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
58 gchar *code;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
59 gchar *cmd;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
60
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
61 /* parameters for geeqie command */
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
62 gint i_parm;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
63 gfloat fl_parm;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
64
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
65 while ((ret = lirc_nextcode(&code)) == 0 && code)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
66 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
67 while ((ret = lirc_code2char(config, code, &cmd)) == 0 && cmd)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
68 {
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
69 if (g_ascii_strncasecmp("LEFT", cmd, 4) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
70 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
71 ptr = cmd + 4;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
72 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
73 i_parm = atoi(ptr);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
74
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
75 if (i_parm <= 0) i_parm = 1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
76 x -= i_parm;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
77 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
78 else if (g_ascii_strncasecmp("RIGHT", cmd, 5) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
79 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
80 ptr = cmd + 5;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
81 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
82 i_parm = atoi(ptr);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
83
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
84 if (i_parm <= 0) i_parm = 1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
85 x += i_parm;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
86 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
87 else if (g_ascii_strncasecmp("UP", cmd, 2) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
88 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
89 ptr = cmd + 2;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
90 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
91 i_parm = atoi(ptr);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
92
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
93 if (i_parm <= 0) i_parm = 1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
94 y -= i_parm;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
95 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
96 else if (g_ascii_strncasecmp("DOWN", cmd, 4) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
97 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
98 ptr = cmd + 4;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
99 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
100 i_parm = atoi(ptr);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
101
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
102 if (i_parm <= 0) i_parm = 1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
103 y += i_parm;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
104 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
105 else if (g_ascii_strcasecmp("PREV", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
106 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
107 layout_image_prev(lw);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
108 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
109 else if (g_ascii_strcasecmp("NEXT", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
110 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
111 layout_image_next(lw);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
112 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
113 else if (g_ascii_strncasecmp("ZOOM_IN", cmd, 7) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
114 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
115 ptr = cmd + 7;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
116 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
117 fl_parm = atoi(ptr) / 10.0;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
118
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
119 if (fl_parm <= 0.01) fl_parm = get_zoom_increment();
1047
81ec7d977d5f use SHIFT for connected scroll and zoom
nadvornik
parents: 1022
diff changeset
120 layout_image_zoom_adjust(lw, fl_parm, FALSE);
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
121 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
122 else if (g_ascii_strncasecmp("ZOOM_OUT", cmd, 8) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
123 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
124 ptr = cmd + 8;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
125 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
126 fl_parm = atoi(ptr) / 10.0;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
127
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
128 if (fl_parm <= 0.01) fl_parm = get_zoom_increment();
1047
81ec7d977d5f use SHIFT for connected scroll and zoom
nadvornik
parents: 1022
diff changeset
129 layout_image_zoom_adjust(lw, -fl_parm, FALSE);
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
130 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
131 else if (g_ascii_strcasecmp("ZOOM_MAX", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
132 {
1047
81ec7d977d5f use SHIFT for connected scroll and zoom
nadvornik
parents: 1022
diff changeset
133 layout_image_zoom_set(lw, 0.0, FALSE);
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
134 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
135 else if (g_ascii_strncasecmp("SET_ZOOM", cmd, 8) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
136 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
137 ptr = cmd + 8;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
138 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
139 i_parm = atoi(ptr);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
140
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
141 if (i_parm <= 0) i_parm = 1;
1047
81ec7d977d5f use SHIFT for connected scroll and zoom
nadvornik
parents: 1022
diff changeset
142 layout_image_zoom_set(lw, 1.0, FALSE);
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
143 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
144 else if (g_ascii_strncasecmp("SET_INV_ZOOM", cmd, 12) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
145 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
146 ptr = cmd + 12;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
147 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
148 i_parm = atoi(ptr);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
149
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
150 if (i_parm <= 0) i_parm = 1;
1047
81ec7d977d5f use SHIFT for connected scroll and zoom
nadvornik
parents: 1022
diff changeset
151 layout_image_zoom_set(lw, -i_parm, FALSE);
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
152 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
153 else if (g_ascii_strcasecmp("FIRST", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
154 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
155 layout_image_first(lw);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
156 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
157 else if (g_ascii_strcasecmp("LAST", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
158 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
159 layout_image_last(lw);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
160 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
161 else if (g_ascii_strcasecmp("PAUSE", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
162 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
163 layout_image_slideshow_pause_toggle(lw);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
164 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
165 else if (g_ascii_strcasecmp("ROTATE_90", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
166 {
1580
24ef7b610ed6 Backed out changeset 3d9f5c078521
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1566
diff changeset
167 layout_image_alter(lw, ALTER_ROTATE_90);
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
168 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
169 else if (g_ascii_strcasecmp("ROTATE_90_CC", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
170 {
1580
24ef7b610ed6 Backed out changeset 3d9f5c078521
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1566
diff changeset
171 layout_image_alter(lw, ALTER_ROTATE_90_CC);
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
172 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
173 else if (g_ascii_strcasecmp("INFO", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
174 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
175 layout_image_overlay_toggle(lw);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
176 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
177 else if (g_ascii_strcasecmp("EXIT", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
178 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
179 exit_program();
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
180 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
181 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
182 free(code);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
183 if (ret == -1) break;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
184 }
610
33a375d16181 Make lirc_cleanup() and lirc_input_callback() static.
zas_
parents: 609
diff changeset
185 if (x != 0 || y != 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
186 {
1265
0b94f0e6e3d0 fixed compilation with lirc
nadvornik
parents: 1055
diff changeset
187 layout_image_scroll(lw, x, y, FALSE);
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
188 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
189
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
190 if (ret == -1)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
191 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
192 /* something went badly wrong */
1305
2abdd6e50120 Glibification.
zas_
parents: 1265
diff changeset
193 g_fprintf(stderr, _("disconnected from LIRC\n"));
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
194 lirc_cleanup();
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
195 return (gboolean)FALSE;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
196 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
197 return (gboolean)TRUE;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
198 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
199
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
200 void layout_image_lirc_init(LayoutWindow *lw)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
201 {
1000
4fe8f9656107 For the sake of consistency, use glib basic types everywhere.
zas_
parents: 995
diff changeset
202 gint flags;
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
203
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
204 DEBUG_1("Initializing LIRC...");
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
205 lirc_fd = lirc_init(GQ_APPNAME_LC, get_debug_level() > 0);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
206 if (lirc_fd == -1)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
207 {
1305
2abdd6e50120 Glibification.
zas_
parents: 1265
diff changeset
208 g_fprintf(stderr, _("Could not init LIRC support\n"));
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
209 return;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
210 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
211 if (lirc_readconfig(NULL, &config, NULL) == -1)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
212 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
213 lirc_deinit();
1305
2abdd6e50120 Glibification.
zas_
parents: 1265
diff changeset
214 g_fprintf(stderr,
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
215 _("could not read LIRC config file\n"
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
216 "please read the documentation of LIRC to \n"
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
217 "know how to create a proper config file\n"));
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
218 return;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
219 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
220 gio_chan = g_io_channel_unix_new(lirc_fd);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
221 input_tag = g_io_add_watch(gio_chan, G_IO_IN,
995
6ca2c5fd7b13 Whitespaces cleanup.
zas_
parents: 671
diff changeset
222 lirc_input_callback, lw);
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
223 fcntl(lirc_fd, F_SETOWN, getpid());
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
224 flags = fcntl(lirc_fd, F_GETFL, 0);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
225 if (flags != -1) fcntl(lirc_fd, F_SETFL, flags|O_NONBLOCK);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
226 fflush(stderr);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
227 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
228
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
229 #endif /* HAVE_LIRC */
1055
1646720364cf Adding a vim modeline to all files - patch by Klaus Ethgen
nadvornik
parents: 1047
diff changeset
230 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */