annotate src/lirc.c @ 680:2c9184126cf9

Fix formatted.SubjectDistance appearing twice in exif bar configuration.
author zas_
date Sat, 17 May 2008 22:37:04 +0000
parents 8268cbe682f1
children 6ca2c5fd7b13
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
1 #include "lirc.h"
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
2
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
3 #ifdef HAVE_LIRC
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
4 #include <lirc/lirc_client.h>
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
5 #include "layout_image.h"
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
6
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
7 gint lirc_fd = -1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
8 struct lirc_config *config = NULL;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
9 guint input_tag;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
10 GIOChannel *gio_chan;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
11
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
12 /*
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
13 *-----------------------------------------------------------------------------
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
14 * LIRC callback
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
15 *-----------------------------------------------------------------------------
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
610
33a375d16181 Make lirc_cleanup() and lirc_input_callback() static.
zas_
parents: 609
diff changeset
18 static void lirc_cleanup(void)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
19 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
20 if (config)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
21 {
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
22 g_source_remove(input_tag);
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
23 lirc_freeconfig(config);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
24 config = NULL;
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 if (lirc_fd != -1)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
27 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
28 lirc_deinit();
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
29 lirc_fd = -1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
30 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
31 if (gio_chan)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
32 {
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
33 g_io_channel_shutdown(gio_chan, TRUE, NULL);
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
34 g_io_channel_unref(gio_chan);
528
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 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
37
610
33a375d16181 Make lirc_cleanup() and lirc_input_callback() static.
zas_
parents: 609
diff changeset
38 static gboolean lirc_input_callback(GIOChannel *source, GIOCondition condition,
33a375d16181 Make lirc_cleanup() and lirc_input_callback() static.
zas_
parents: 609
diff changeset
39 gpointer data)
528
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 LayoutWindow *lw = data;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
42 gchar *ptr;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
43 gint ret;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
44 gint x = 0;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
45 gint y = 0;
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 /* LIRC code and corresponding geeqie command (and parameters)*/
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
48 gchar *code;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
49 gchar *cmd;
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 /* parameters for geeqie command */
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
52 gint i_parm;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
53 gfloat fl_parm;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
54
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
55 while ((ret = lirc_nextcode(&code)) == 0 && code)
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 while ((ret = lirc_code2char(config, code, &cmd)) == 0 && cmd)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
58 {
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
59 if (g_ascii_strncasecmp("LEFT", cmd, 4) == 0)
528
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 ptr = cmd + 4;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
62 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
63 i_parm = atoi(ptr);
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 if (i_parm <= 0) i_parm = 1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
66 x -= i_parm;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
67 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
68 else if (g_ascii_strncasecmp("RIGHT", cmd, 5) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
69 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
70 ptr = cmd + 5;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
71 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
72 i_parm = atoi(ptr);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
73
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
74 if (i_parm <= 0) i_parm = 1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
75 x += i_parm;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
76 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
77 else if (g_ascii_strncasecmp("UP", cmd, 2) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
78 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
79 ptr = cmd + 2;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
80 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
81 i_parm = atoi(ptr);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
82
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
83 if (i_parm <= 0) i_parm = 1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
84 y -= i_parm;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
85 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
86 else if (g_ascii_strncasecmp("DOWN", cmd, 4) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
87 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
88 ptr = cmd + 4;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
89 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
90 i_parm = atoi(ptr);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
91
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
92 if (i_parm <= 0) i_parm = 1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
93 y += i_parm;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
94 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
95 else if (g_ascii_strcasecmp("PREV", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
96 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
97 layout_image_prev(lw);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
98 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
99 else if (g_ascii_strcasecmp("NEXT", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
100 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
101 layout_image_next(lw);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
102 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
103 else if (g_ascii_strncasecmp("ZOOM_IN", cmd, 7) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
104 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
105 ptr = cmd + 7;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
106 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
107 fl_parm = atoi(ptr) / 10.0;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
108
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
109 if (fl_parm <= 0.01) fl_parm = get_zoom_increment();
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
110 layout_image_zoom_adjust(lw, fl_parm);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
111 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
112 else if (g_ascii_strncasecmp("ZOOM_OUT", cmd, 8) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
113 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
114 ptr = cmd + 8;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
115 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
116 fl_parm = atoi(ptr) / 10.0;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
117
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
118 if (fl_parm <= 0.01) fl_parm = get_zoom_increment();
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
119 layout_image_zoom_adjust(lw, -fl_parm);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
120 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
121 else if (g_ascii_strcasecmp("ZOOM_MAX", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
122 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
123 layout_image_zoom_set(lw, 0.0);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
124 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
125 else if (g_ascii_strncasecmp("SET_ZOOM", cmd, 8) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
126 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
127 ptr = cmd + 8;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
128 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
129 i_parm = atoi(ptr);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
130
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
131 if (i_parm <= 0) i_parm = 1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
132 layout_image_zoom_set(lw, 1.0);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
133 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
134 else if (g_ascii_strncasecmp("SET_INV_ZOOM", cmd, 12) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
135 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
136 ptr = cmd + 12;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
137 while (g_ascii_isspace(*ptr)) ptr++;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
138 i_parm = atoi(ptr);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
139
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
140 if (i_parm <= 0) i_parm = 1;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
141 layout_image_zoom_set(lw, -i_parm);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
142 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
143 else if (g_ascii_strcasecmp("FIRST", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
144 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
145 layout_image_first(lw);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
146 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
147 else if (g_ascii_strcasecmp("LAST", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
148 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
149 layout_image_last(lw);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
150 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
151 else if (g_ascii_strcasecmp("PAUSE", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
152 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
153 layout_image_slideshow_pause_toggle(lw);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
154 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
155 else if (g_ascii_strcasecmp("ROTATE_90", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
156 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
157 layout_image_alter(lw, ALTER_ROTATE_90);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
158 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
159 else if (g_ascii_strcasecmp("ROTATE_90_CC", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
160 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
161 layout_image_alter(lw, ALTER_ROTATE_90_CC);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
162 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
163 else if (g_ascii_strcasecmp("INFO", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
164 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
165 layout_image_overlay_toggle(lw);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
166 }
603
e8b28413ffbf Replace deprecated functions by their counterparts:
zas_
parents: 528
diff changeset
167 else if (g_ascii_strcasecmp("EXIT", cmd) == 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
168 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
169 exit_program();
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
170 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
171 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
172 free(code);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
173 if (ret == -1) break;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
174 }
610
33a375d16181 Make lirc_cleanup() and lirc_input_callback() static.
zas_
parents: 609
diff changeset
175 if (x != 0 || y != 0)
528
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
176 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
177 layout_image_scroll(lw, x, y);
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
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
180 if (ret == -1)
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 /* something went badly wrong */
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
183 fprintf(stderr, _("disconnected from LIRC\n"));
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
184 lirc_cleanup();
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
185 return (gboolean)FALSE;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
186 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
187 return (gboolean)TRUE;
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 void layout_image_lirc_init(LayoutWindow *lw)
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 int flags;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
193
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
194 DEBUG_1("Initializing LIRC...");
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
195 lirc_fd = lirc_init(GQ_APPNAME_LC, get_debug_level() > 0);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
196 if (lirc_fd == -1)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
197 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
198 fprintf(stderr, _("Could not init LIRC support\n"));
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
199 return;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
200 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
201 if (lirc_readconfig(NULL, &config, NULL) == -1)
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
202 {
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
203 lirc_deinit();
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
204 fprintf(stderr,
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
205 _("could not read LIRC config file\n"
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
206 "please read the documentation of LIRC to \n"
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
207 "know how to create a proper config file\n"));
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
208 return;
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
209 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
210 gio_chan = g_io_channel_unix_new(lirc_fd);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
211 input_tag = g_io_add_watch(gio_chan, G_IO_IN,
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
212 lirc_input_callback, lw);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
213 fcntl(lirc_fd, F_SETOWN, getpid());
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
214 flags = fcntl(lirc_fd, F_GETFL, 0);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
215 if (flags != -1) fcntl(lirc_fd, F_SETFL, flags|O_NONBLOCK);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
216 fflush(stderr);
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
217 }
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
218
bf9c9e37adf4 Added LIRC patch written by Matteo Beniamino
nadvornik
parents:
diff changeset
219 #endif /* HAVE_LIRC */