summaryrefslogtreecommitdiff
path: root/legacy/ecore/src/lib/ecore_fb/ecore_fb.c
diff options
context:
space:
mode:
authorJorge Luis Zapata Muga <jorgeluis.zapata@gmail.com>2006-07-31 04:13:51 +0000
committerJorge Luis Zapata Muga <jorgeluis.zapata@gmail.com>2006-07-31 04:13:51 +0000
commitb297b42db638495778746961300820a81988f918 (patch)
tree1a1040348e77e1a7248fae7ead8ac49e64a3c0dc /legacy/ecore/src/lib/ecore_fb/ecore_fb.c
parent996645a4d619722eb0de6362c3f9731f74f769da (diff)
Ecore_Fb changes:
================ + remove of old ps2, touchscreen and keyboard input handlers + old code is kept on sperated files for backup in case someone needs it, but wont compile + addition of new linux input (evdev) handlers. (touchscreen is handled as an absolute axis device, no need for old code). It supports multiple input devices, you can have several mice for example. + new vt code, now it support allocating a new tty if root, or use current tty if normal user, correct vt switching on both cases + some more cleanups Ecore_Evas_Fb changes: ===================== + use the new ecore_fb SVN revision: 24326
Diffstat (limited to '')
-rw-r--r--legacy/ecore/src/lib/ecore_fb/ecore_fb.c1261
1 files changed, 21 insertions, 1240 deletions
diff --git a/legacy/ecore/src/lib/ecore_fb/ecore_fb.c b/legacy/ecore/src/lib/ecore_fb/ecore_fb.c
index 659b5f578c..a695dda15a 100644
--- a/legacy/ecore/src/lib/ecore_fb/ecore_fb.c
+++ b/legacy/ecore/src/lib/ecore_fb/ecore_fb.c
@@ -1,261 +1,21 @@
1#include "ecore_private.h"
2#include "Ecore.h"
3#include "ecore_fb_private.h"
4#include "Ecore_Fb.h" 1#include "Ecore_Fb.h"
5 2#include "ecore_fb_private.h"
6#ifdef HAVE_TSLIB
7#include <tslib.h>
8#include <errno.h>
9#endif
10
11#include <termios.h>
12#include <sys/types.h>
13#include <sys/stat.h>
14#include <sys/ioctl.h>
15#include <linux/kd.h>
16#include <linux/vt.h>
17#include <linux/fb.h>
18#include <sys/ioctl.h>
19#include <signal.h>
20
21typedef struct _Ecore_Fb_Ts_Event Ecore_Fb_Ts_Event;
22typedef struct _Ecore_Fb_Ts_Calibrate Ecore_Fb_Ts_Calibrate;
23typedef struct _Ecore_Fb_Ts_Backlight Ecore_Fb_Ts_Backlight;
24typedef struct _Ecore_Fb_Ts_Contrast Ecore_Fb_Ts_Contrast;
25typedef struct _Ecore_Fb_Ts_Led Ecore_Fb_Ts_Led;
26typedef struct _Ecore_Fb_Ts_Flite Ecore_Fb_Ts_Flite;
27typedef struct _Ecore_Fb_Ps2_Event Ecore_Fb_Ps2_Event;
28
29struct _Ecore_Fb_Ts_Event
30{
31 unsigned short pressure;
32 unsigned short x;
33 unsigned short y;
34 unsigned short _unused;
35};
36
37struct _Ecore_Fb_Ts_Calibrate
38{
39 int xscale;
40 int xtrans;
41 int yscale;
42 int ytrans;
43 int xyswap;
44};
45
46struct _Ecore_Fb_Ts_Backlight
47{
48 int on;
49 unsigned char brightness;
50};
51
52struct _Ecore_Fb_Ts_Contrast
53{
54 unsigned char contrast;
55};
56
57struct _Ecore_Fb_Ts_Led
58{
59 unsigned char on;
60 unsigned char blink_time;
61 unsigned char on_time;
62 unsigned char off_time;
63};
64
65struct _Ecore_Fb_Ts_Flite
66{
67 unsigned char mode;
68 unsigned char pwr;
69 unsigned char brightness;
70};
71
72struct _Ecore_Fb_Ps2_Event
73{
74 unsigned char button;
75 unsigned char x;
76 unsigned char y;
77 unsigned char z;
78};
79
80#ifdef HAVE_TSLIB
81struct tsdev *_ecore_fb_tslib_tsdev = NULL;
82struct ts_sample _ecore_fb_tslib_event;
83#endif
84 3
85static void _ecore_fb_size_get(int *w, int *h); 4static void _ecore_fb_size_get(int *w, int *h);
86static int _ecore_fb_ts_fd_handler(void *data, Ecore_Fd_Handler *fd_handler);
87static int _ecore_fb_kbd_fd_handler(void *data, Ecore_Fd_Handler *fd_handler);
88static int _ecore_fb_ps2_fd_handler(void *data, Ecore_Fd_Handler *fd_handler);
89static void _ecore_fb_event_free_key_down(void *data, void *ev);
90static void _ecore_fb_event_free_key_up(void *data, void *ev);
91static int _ecore_fb_signal_usr_handler(void *data, int type, void *ev);
92static void _ecore_fb_vt_switch(int vt);
93 5
94EAPI int ECORE_FB_EVENT_KEY_DOWN = 0; 6EAPI int ECORE_FB_EVENT_KEY_DOWN = 0;
95EAPI int ECORE_FB_EVENT_KEY_UP = 0; 7EAPI int ECORE_FB_EVENT_KEY_UP = 0;
96EAPI int ECORE_FB_EVENT_MOUSE_BUTTON_DOWN = 0; 8EAPI int ECORE_FB_EVENT_MOUSE_BUTTON_DOWN = 0;
97EAPI int ECORE_FB_EVENT_MOUSE_BUTTON_UP = 0; 9EAPI int ECORE_FB_EVENT_MOUSE_BUTTON_UP = 0;
98EAPI int ECORE_FB_EVENT_MOUSE_MOVE = 0; 10EAPI int ECORE_FB_EVENT_MOUSE_MOVE = 0;
11EAPI int ECORE_FB_EVENT_MOUSE_WHEEL = 0;
99 12
100static Ecore_Event_Handler *_ecore_fb_user_handler = NULL;
101static Ecore_Event_Filter *_ecore_fb_filter_handler = NULL;
102static Ecore_Fd_Handler *_ecore_fb_ts_fd_handler_handle = NULL;
103static Ecore_Fd_Handler *_ecore_fb_kbd_fd_handler_handle = NULL;
104static int _ecore_fb_init_count = 0; 13static int _ecore_fb_init_count = 0;
105static int _ecore_fb_ts_fd = 0;
106static int _ecore_fb_ps2_fd = 0;
107static int _ecore_fb_kbd_fd = 0;
108static int _ecore_fb_tty_fd = 0;
109static int _ecore_fb_console_w = 0; 14static int _ecore_fb_console_w = 0;
110static int _ecore_fb_console_h = 0; 15static int _ecore_fb_console_h = 0;
111static int _ecore_fb_ts_event_byte_count = 0;
112static int _ecore_fb_ps2_event_byte_count = 0;
113static Ecore_Fb_Ts_Event _ecore_fb_ts_event;
114static Ecore_Fb_Ps2_Event _ecore_fb_ps2_event;
115static int _ecore_fb_tty_prev_mode = 0;
116static int _ecore_fb_tty_prev_kd_mode = 0;
117static struct termios _ecore_fb_tty_prev_tio_mode;
118static struct vt_mode _ecore_fb_vt_prev_mode;
119static int _ecore_fb_current_vt = 0;
120static int _ecore_fb_ctrl = 0;
121static int _ecore_fb_alt = 0;
122static int _ecore_fb_shift = 0;
123static int _ecore_fb_lock = 0;
124
125static void (*_ecore_fb_func_fb_lost) (void *data) = NULL;
126static void *_ecore_fb_func_fb_lost_data = NULL;
127static void (*_ecore_fb_func_fb_gain) (void *data) = NULL;
128static void *_ecore_fb_func_fb_gain_data = NULL;
129 16
130static void *_ecore_fb_event_filter_start(void *data);
131static int _ecore_fb_event_filter_filter(void *data, void *loop_data, int type, void *event);
132static void _ecore_fb_event_filter_end(void *data, void *loop_data);
133
134static double _ecore_fb_double_click_time = 0.25; 17static double _ecore_fb_double_click_time = 0.25;
135 18
136static struct _Ecore_Fb_Ts_Calibrate _ecore_fb_ts_cal = {1,1,0,0,0};
137static int _ecore_fb_ts_apply_cal = 0;
138
139static const char *_ecore_fb_kbd_syms[128 * 6] =
140{
141#include "ecore_fb_keytab.h"
142};
143
144static const char *_ecore_fb_btn_syms[128] =
145{
146 "0x00",
147 "Escape",
148 "F1",
149 "F2",
150 "F3",
151 "F4",
152 "Up",
153 "Right",
154 "Left",
155 "Down",
156 "Return",
157 "0x1b",
158 "0x1c",
159 "0x1d",
160 "0x1e",
161 "0x1f",
162 "0x20",
163 "0x21",
164 "0x22",
165 "0x23",
166 "0x24",
167 "0x25",
168 "0x26",
169 "0x27",
170 "0x28",
171 "0x29",
172 "0x2a",
173 "0x2b",
174 "0x2c",
175 "0x2d",
176 "0x2e",
177 "0x2f",
178 "0x30",
179 "0x31",
180 "0x32",
181 "0x33",
182 "0x34",
183 "0x35",
184 "0x36",
185 "0x37",
186 "0x38",
187 "0x39",
188 "0x3a",
189 "0x3b",
190 "0x3c",
191 "0x3d",
192 "0x3e",
193 "0x3f",
194 "0x40",
195 "0x41",
196 "0x42",
197 "0x43",
198 "0x44",
199 "0x45",
200 "0x46",
201 "0x47",
202 "0x48",
203 "0x49",
204 "0x4a",
205 "0x4b",
206 "0x4c",
207 "0x4d",
208 "0x4e",
209 "0x4f",
210 "0x50",
211 "0x51",
212 "0x52",
213 "0x53",
214 "0x54",
215 "0x55",
216 "0x56",
217 "0x57",
218 "0x58",
219 "0x59",
220 "0x5a",
221 "0x5b",
222 "0x5c",
223 "0x5d",
224 "0x5e",
225 "0x5f",
226 "0x60",
227 "0x61",
228 "0x62",
229 "0x63",
230 "0x64",
231 "0x65",
232 "0x66",
233 "0x67",
234 "0x68",
235 "0x69",
236 "0x6a",
237 "0x6b",
238 "0x6c",
239 "0x6d",
240 "0x6e",
241 "0x6f",
242 "0x70",
243 "0x71",
244 "0x72",
245 "0x73",
246 "0x74",
247 "0x75",
248 "0x76",
249 "0x77",
250 "0x78",
251 "0x79",
252 "0x7a",
253 "0x7b",
254 "0x7c",
255 "0x7d",
256 "0x7e",
257 "0x7f"
258};
259 19
260/** 20/**
261 * @defgroup Ecore_FB_Library_Group Framebuffer Library Functions 21 * @defgroup Ecore_FB_Library_Group Framebuffer Library Functions
@@ -273,158 +33,18 @@ static const char *_ecore_fb_btn_syms[128] =
273EAPI int 33EAPI int
274ecore_fb_init(const char *name __UNUSED__) 34ecore_fb_init(const char *name __UNUSED__)
275{ 35{
276 int prev_flags; 36 if(!_ecore_fb_init_count)
277#ifdef HAVE_TSLIB 37 {
278 char *tslib_tsdevice = NULL; 38 if(!ecore_fb_vt_init()) return 0;
279#endif 39 ECORE_FB_EVENT_KEY_DOWN = ecore_event_type_new();
280 40 ECORE_FB_EVENT_KEY_UP = ecore_event_type_new();
281 _ecore_fb_init_count++; 41 ECORE_FB_EVENT_MOUSE_BUTTON_DOWN = ecore_event_type_new();
282 if (_ecore_fb_init_count > 1) return _ecore_fb_init_count; 42 ECORE_FB_EVENT_MOUSE_BUTTON_UP = ecore_event_type_new();
283#ifdef HAVE_TSLIB 43 ECORE_FB_EVENT_MOUSE_MOVE = ecore_event_type_new();
284 if ( ( tslib_tsdevice = getenv("TSLIB_TSDEVICE") ) != NULL ) 44 ECORE_FB_EVENT_MOUSE_WHEEL = ecore_event_type_new();
285 { 45 _ecore_fb_size_get(&_ecore_fb_console_w, &_ecore_fb_console_h);
286 printf( "ECORE_FB: TSLIB_TSDEVICE = '%s'\n", tslib_tsdevice ); 46 }
287 _ecore_fb_tslib_tsdev = ts_open( tslib_tsdevice, 1 ); /* 1 = nonblocking, 0 = blocking */ 47 return ++_ecore_fb_init_count;
288
289 if ( !_ecore_fb_tslib_tsdev )
290 {
291 printf( "ECORE_FB: Can't ts_open (%s)\n", strerror( errno ) );
292 return 0;
293 }
294
295 if ( ts_config( _ecore_fb_tslib_tsdev ) )
296 {
297 printf( "ECORE_FB: Can't ts_config (%s)\n", strerror( errno ) );
298 return 0;
299 }
300 _ecore_fb_ts_fd = ts_fd( _ecore_fb_tslib_tsdev );
301 if ( _ecore_fb_ts_fd < 0 )
302 {
303 printf( "ECORE_FB: Can't open touchscreen (%s)\n", strerror( errno ) );
304 return 0;
305 }
306 }
307#else
308 _ecore_fb_ts_fd = open("/dev/touchscreen/0", O_RDONLY);
309#endif
310 if (_ecore_fb_ts_fd >= 0)
311 {
312 prev_flags = fcntl(_ecore_fb_ts_fd, F_GETFL);
313 fcntl(_ecore_fb_ts_fd, F_SETFL, prev_flags | O_NONBLOCK);
314 _ecore_fb_ts_fd_handler_handle = ecore_main_fd_handler_add(_ecore_fb_ts_fd,
315 ECORE_FD_READ,
316 _ecore_fb_ts_fd_handler, NULL,
317 NULL, NULL);
318 if (!_ecore_fb_ts_fd_handler_handle)
319 {
320 close(_ecore_fb_ts_fd);
321 }
322 }
323 if (_ecore_fb_ts_fd < 0)
324 {
325 _ecore_fb_ps2_fd = open("/dev/psaux", O_RDWR);
326 if (_ecore_fb_ps2_fd >= 0)
327 {
328 prev_flags = fcntl(_ecore_fb_ps2_fd, F_GETFL);
329 fcntl(_ecore_fb_ps2_fd, F_SETFL, prev_flags | O_NONBLOCK);
330 _ecore_fb_ts_fd_handler_handle = ecore_main_fd_handler_add(_ecore_fb_ps2_fd,
331 ECORE_FD_READ,
332 _ecore_fb_ps2_fd_handler, NULL,
333 NULL, NULL);
334 if (!_ecore_fb_ts_fd_handler_handle)
335 {
336 close(_ecore_fb_ps2_fd);
337 }
338 }
339 }
340 _ecore_fb_kbd_fd = open("/dev/touchscreen/key", O_RDONLY);
341 _ecore_fb_tty_fd = open("/dev/tty0", O_RDONLY);
342 if (_ecore_fb_tty_fd >= 0)
343 {
344 struct termios tio;
345 struct vt_mode new_vtmode;
346 int vtno;
347
348 if ((ioctl(_ecore_fb_tty_fd, VT_OPENQRY, &vtno) != -1))
349 {
350 char buf[64];
351
352 _ecore_fb_current_vt = vtno;
353 ioctl(_ecore_fb_tty_fd, VT_ACTIVATE, _ecore_fb_current_vt);
354 close(_ecore_fb_tty_fd);
355 snprintf(buf, sizeof(buf), "/dev/tty%i", _ecore_fb_current_vt);
356/* FIXME: switch away works.. but switch to the allocated vt doesnt */
357/* printf("%s\n", buf); */
358 _ecore_fb_tty_fd = open(buf, O_RDWR);
359 if (_ecore_fb_current_vt == 1)
360 {
361 Ecore_Event_Signal_User *e;
362
363 e = _ecore_event_signal_user_new();
364 if (e)
365 {
366 e->number = 2;
367 ecore_event_add(ECORE_EVENT_SIGNAL_USER, e, NULL, NULL);
368 }
369 }
370 }
371 tcgetattr(_ecore_fb_tty_fd, &_ecore_fb_tty_prev_tio_mode);
372 ioctl(_ecore_fb_tty_fd, KDGETMODE, &_ecore_fb_tty_prev_kd_mode);
373 ioctl(_ecore_fb_tty_fd, KDGKBMODE, &_ecore_fb_tty_prev_mode);
374 ioctl(_ecore_fb_tty_fd, VT_GETMODE, &_ecore_fb_vt_prev_mode);
375 tio.c_iflag = tio.c_oflag = tio.c_cflag = tio.c_lflag = 0;
376 tio.c_cc[VTIME] = 0;
377 tio.c_cc[VMIN] = 1;
378 new_vtmode.mode = VT_PROCESS;
379 new_vtmode.waitv = 0;
380 new_vtmode.relsig = SIGUSR1;
381 new_vtmode.acqsig = SIGUSR2;
382 tcsetattr(_ecore_fb_tty_fd, TCSAFLUSH, &tio);
383 ioctl(_ecore_fb_tty_fd, KDSETMODE, KD_GRAPHICS);
384 ioctl(_ecore_fb_tty_fd, KDSKBMODE, K_MEDIUMRAW);
385 ioctl(_ecore_fb_tty_fd, VT_SETMODE, &new_vtmode);
386 }
387 if (_ecore_fb_kbd_fd <= 0) _ecore_fb_kbd_fd = _ecore_fb_tty_fd;
388 if (_ecore_fb_kbd_fd >= 0)
389 {
390 prev_flags = fcntl(_ecore_fb_kbd_fd, F_GETFL);
391 fcntl(_ecore_fb_kbd_fd, F_SETFL, prev_flags | O_NONBLOCK);
392 _ecore_fb_kbd_fd_handler_handle = ecore_main_fd_handler_add(_ecore_fb_kbd_fd,
393 ECORE_FD_READ,
394 _ecore_fb_kbd_fd_handler, NULL,
395 NULL, NULL);
396 if (!_ecore_fb_kbd_fd_handler_handle)
397 {
398 tcsetattr(_ecore_fb_tty_fd, TCSAFLUSH, &_ecore_fb_tty_prev_tio_mode);
399 ioctl(_ecore_fb_tty_fd, KDSETMODE, _ecore_fb_tty_prev_kd_mode);
400 ioctl(_ecore_fb_tty_fd, KDSKBMODE, _ecore_fb_tty_prev_mode);
401 close(_ecore_fb_tty_fd);
402 close(_ecore_fb_ts_fd);
403 close(_ecore_fb_kbd_fd);
404 if (_ecore_fb_ps2_fd > 0) close(_ecore_fb_ps2_fd);
405 if (_ecore_fb_tty_fd != _ecore_fb_kbd_fd)
406 close(_ecore_fb_tty_fd);
407 ecore_main_fd_handler_del(_ecore_fb_ts_fd_handler_handle);
408 _ecore_fb_ts_fd_handler_handle = NULL;
409 _ecore_fb_init_count--;
410 return 0;
411 }
412 }
413 if (!ECORE_FB_EVENT_KEY_DOWN)
414 {
415 ECORE_FB_EVENT_KEY_DOWN = ecore_event_type_new();
416 ECORE_FB_EVENT_KEY_UP = ecore_event_type_new();
417 ECORE_FB_EVENT_MOUSE_BUTTON_DOWN = ecore_event_type_new();
418 ECORE_FB_EVENT_MOUSE_BUTTON_UP = ecore_event_type_new();
419 ECORE_FB_EVENT_MOUSE_MOVE = ecore_event_type_new();
420
421 }
422 _ecore_fb_size_get(&_ecore_fb_console_w, &_ecore_fb_console_h);
423 _ecore_fb_user_handler = ecore_event_handler_add(ECORE_EVENT_SIGNAL_USER,
424 _ecore_fb_signal_usr_handler,
425 NULL);
426 _ecore_fb_filter_handler = ecore_event_filter_add(_ecore_fb_event_filter_start, _ecore_fb_event_filter_filter, _ecore_fb_event_filter_end, NULL);
427 return _ecore_fb_init_count;
428} 48}
429 49
430/** 50/**
@@ -436,81 +56,15 @@ ecore_fb_init(const char *name __UNUSED__)
436EAPI int 56EAPI int
437ecore_fb_shutdown(void) 57ecore_fb_shutdown(void)
438{ 58{
439 _ecore_fb_init_count--; 59 _ecore_fb_init_count--;
440 if (_ecore_fb_init_count > 0) return _ecore_fb_init_count; 60 if(!_ecore_fb_init_count)
441 if (_ecore_fb_init_count < 0) 61 {
442 { 62 ecore_fb_vt_shutdown();
443 _ecore_fb_init_count = 0; 63 return 0;
444 return 0; 64 }
445 } 65 return _ecore_fb_init_count;
446 if (_ecore_fb_tty_fd != 0)
447 {
448 tcsetattr(_ecore_fb_tty_fd, TCSAFLUSH, &_ecore_fb_tty_prev_tio_mode);
449 ioctl(_ecore_fb_tty_fd, KDSETMODE, _ecore_fb_tty_prev_kd_mode);
450 ioctl(_ecore_fb_tty_fd, KDSKBMODE, _ecore_fb_tty_prev_mode);
451 ioctl(_ecore_fb_tty_fd, VT_SETMODE, &_ecore_fb_vt_prev_mode);
452 close(_ecore_fb_tty_fd);
453 if (_ecore_fb_tty_fd == _ecore_fb_kbd_fd) _ecore_fb_kbd_fd = 0;
454 }
455 if (_ecore_fb_ps2_fd > 0) close(_ecore_fb_ps2_fd);
456 if (_ecore_fb_ts_fd >= 0) close(_ecore_fb_ts_fd);
457 if (_ecore_fb_kbd_fd >= 0) close(_ecore_fb_kbd_fd);
458 if (_ecore_fb_ts_fd_handler_handle)
459 ecore_main_fd_handler_del(_ecore_fb_ts_fd_handler_handle);
460 if (_ecore_fb_kbd_fd_handler_handle)
461 ecore_main_fd_handler_del(_ecore_fb_kbd_fd_handler_handle);
462 if (_ecore_fb_user_handler)
463 ecore_event_handler_del(_ecore_fb_user_handler);
464 ecore_event_filter_del(_ecore_fb_filter_handler);
465 _ecore_fb_ts_fd = 0;
466 _ecore_fb_kbd_fd = 0;
467 _ecore_fb_tty_fd = 0;
468 _ecore_fb_ps2_fd = 0;
469 _ecore_fb_ts_fd_handler_handle = NULL;
470 _ecore_fb_filter_handler = NULL;
471 _ecore_fb_kbd_fd_handler_handle = NULL;
472 _ecore_fb_user_handler = NULL;
473 _ecore_fb_ctrl = 0;
474 _ecore_fb_alt = 0;
475 return _ecore_fb_init_count;
476} 66}
477 67
478/**
479 * @defgroup Ecore_FB_Click_Group Framebuffer Double Click Functions
480 *
481 * Functions that deal with the double click time of the framebuffer.
482 */
483
484/**
485 * Sets the timeout for a double and triple clicks to be flagged.
486 *
487 * This sets the time between clicks before the double_click flag is
488 * set in a button down event. If 3 clicks occur within double this
489 * time, the triple_click flag is also set.
490 *
491 * @param t The time in seconds
492 * @ingroup Ecore_FB_Click_Group
493 */
494EAPI void
495ecore_fb_double_click_time_set(double t)
496{
497 if (t < 0.0) t = 0.0;
498 _ecore_fb_double_click_time = t;
499}
500
501/**
502 * Retrieves the double and triple click flag timeout.
503 *
504 * See @ref ecore_x_double_click_time_set for more information.
505 *
506 * @return The timeout for double clicks in seconds.
507 * @ingroup Ecore_FB_Click_Group
508 */
509EAPI double
510ecore_fb_double_click_time_get(void)
511{
512 return _ecore_fb_double_click_time;
513}
514 68
515/** 69/**
516 * Retrieves the width and height of the current frame buffer in pixels. 70 * Retrieves the width and height of the current frame buffer in pixels.
@@ -524,267 +78,6 @@ ecore_fb_size_get(int *w, int *h)
524 if (h) *h = _ecore_fb_console_h; 78 if (h) *h = _ecore_fb_console_h;
525} 79}
526 80
527/**
528 * @defgroup Ecore_FB_Calibrate_Group Framebuffer Calibration Functions
529 *
530 * Functions that calibrate the screen.
531 */
532
533/**
534 * Calibrates the touschreen using the given parameters.
535 * @param xscale X scaling, where 256 = 1.0
536 * @param xtrans X translation.
537 * @param yscale Y scaling.
538 * @param ytrans Y translation.
539 * @param xyswap Swap X & Y flag.
540 * @ingroup Ecore_FB_Calibrate_Group
541 */
542EAPI void
543ecore_fb_touch_screen_calibrate_set(int xscale, int xtrans, int yscale, int ytrans, int xyswap)
544{
545 Ecore_Fb_Ts_Calibrate cal;
546
547 if (_ecore_fb_ts_fd < 0) return;
548 cal.xscale = xscale;
549 cal.xtrans = xtrans;
550 cal.yscale = yscale;
551 cal.ytrans = ytrans;
552 cal.xyswap = xyswap;
553 if (ioctl(_ecore_fb_ts_fd, TS_SET_CAL, (void *)&cal))
554 {
555 _ecore_fb_ts_cal = cal;
556 _ecore_fb_ts_apply_cal = 1;
557 }
558}
559
560/**
561 * Retrieves the calibration parameters of the touchscreen.
562 * @param xscale Pointer to an integer in which to store the X scaling.
563 * Note that 256 = 1.0.
564 * @param xtrans Pointer to an integer in which to store the X translation.
565 * @param yscale Pointer to an integer in which to store the Y scaling.
566 * @param ytrans Pointer to an integer in which to store the Y translation.
567 * @param xyswap Pointer to an integer in which to store the Swap X & Y flag.
568 * @ingroup Ecore_FB_Calibrate_Group
569 */
570EAPI void
571ecore_fb_touch_screen_calibrate_get(int *xscale, int *xtrans, int *yscale, int *ytrans, int *xyswap)
572{
573 Ecore_Fb_Ts_Calibrate cal;
574
575 if (_ecore_fb_ts_fd < 0) return;
576 if (!_ecore_fb_ts_apply_cal)
577 {
578 if (ioctl(_ecore_fb_ts_fd, TS_GET_CAL, (void *)&cal))
579 _ecore_fb_ts_cal = cal;
580 }
581 else
582 cal = _ecore_fb_ts_cal;
583 if (xscale) *xscale = cal.xscale;
584 if (xtrans) *xtrans = cal.xtrans;
585 if (yscale) *yscale = cal.yscale;
586 if (ytrans) *ytrans = cal.ytrans;
587 if (xyswap) *xyswap = cal.xyswap;
588}
589
590/**
591 * @defgroup Ecore_FB_Backlight_Group Framebuffer Backlight Functions
592 *
593 * Functions that deal with the backlight of a framebuffer's screen.
594 */
595
596/**
597 * Turns on or off the backlight.
598 * @param on @c 1 to turn the backlight on. @c 0 to turn it off.
599 * @ingroup Ecore_FB_Backlight_Group
600 */
601EAPI void
602ecore_fb_backlight_set(int on)
603{
604 Ecore_Fb_Ts_Backlight bl;
605
606 if (_ecore_fb_ts_fd < 0) return;
607 ioctl(_ecore_fb_ts_fd, TS_GET_BACKLIGHT, &bl);
608 bl.on = on;
609 ioctl(_ecore_fb_ts_fd, TS_SET_BACKLIGHT, &bl);
610}
611
612/**
613 * Retrieves the backlight state.
614 * @return Whether the backlight is on.
615 * @ingroup Ecore_FB_Backlight_Group
616 */
617EAPI int
618ecore_fb_backlight_get(void)
619{
620 Ecore_Fb_Ts_Backlight bl;
621
622 if (_ecore_fb_ts_fd < 0) return 1;
623 ioctl(_ecore_fb_ts_fd, TS_GET_BACKLIGHT, &bl);
624 return bl.on;
625}
626
627/**
628 * Sets the backlight brightness.
629 * @param br Brightness between 0.0 to 1.0, where 0.0 is darkest and 1.0
630 * is brightest.
631 * @ingroup Ecore_FB_Backlight_Group
632 */
633EAPI void
634ecore_fb_backlight_brightness_set(double br)
635{
636 Ecore_Fb_Ts_Backlight bl;
637 int val;
638
639 if (br < 0) br = 0;
640 if (br > 1) br = 1;
641 val = (int)(255.0 * br);
642 ioctl(_ecore_fb_ts_fd, TS_GET_BACKLIGHT, &bl);
643 bl.brightness = val;
644 ioctl(_ecore_fb_ts_fd, TS_SET_BACKLIGHT, &bl);
645}
646
647/**
648 * Retrieves the backlight brightness.
649 * @return The current backlight brigntess, where 0.0 is the darkest and
650 * 1.0 is the brightest.
651 * @ingroup Ecore_FB_Backlight_Group
652 */
653EAPI double
654ecore_fb_backlight_brightness_get(void)
655{
656 Ecore_Fb_Ts_Backlight bl;
657
658 if (_ecore_fb_ts_fd < 0) return 1.0;
659 ioctl(_ecore_fb_ts_fd, TS_GET_BACKLIGHT, &bl);
660 return (double)bl.brightness / 255.0;
661}
662
663/**
664 * @defgroup Ecore_FB_LED_Group Framebuffer LED Functions
665 *
666 * Functions that deal with the light emitting diode connected to the
667 * current framebuffer.
668 */
669
670/**
671 * Sets whether the current framebuffer's LED to the given state.
672 * @param on @c 1 to indicate the LED should be on, @c 0 if it should be off.
673 * @ingroup Ecore_FB_LED_Group
674 */
675EAPI void
676ecore_fb_led_set(int on)
677{
678 Ecore_Fb_Ts_Led led;
679
680 if (_ecore_fb_ts_fd < 0) return;
681 if (on) led.on = 1;
682 else led.on = 0;
683 ioctl(_ecore_fb_ts_fd, LED_ON, &led);
684}
685
686/**
687 * Makes the LED of the current framebuffer blink.
688 * @param speed Number to give the speed on the blink.
689 * @ingroup Ecore_FB_LED_Group
690 * @todo Documentation: Work out what speed the units are in.
691 */
692EAPI void
693ecore_fb_led_blink_set(double speed)
694{
695 Ecore_Fb_Ts_Led led;
696
697 if (_ecore_fb_ts_fd < 0) return;
698 led.on = 1;
699 led.on_time = (unsigned char)(speed * 10);
700 led.off_time = (unsigned char)(speed * 10);
701 led.blink_time = 255;
702 ioctl(_ecore_fb_ts_fd, LED_ON, &led);
703}
704
705/**
706 * @defgroup Ecore_FB_Contrast_Group Framebuffer Contrast Functions
707 *
708 * Values that set and retrieve the contrast of a framebuffer screen.
709 */
710
711/**
712 * Sets the contrast used by the framebuffer screen.
713 * @param cr Value between 0 and 1 that gives the new contrast of the screen.
714 * @ingroup Ecore_FB_Contrast_Group
715 */
716EAPI void
717ecore_fb_contrast_set(double cr)
718{
719 Ecore_Fb_Ts_Contrast ct;
720 int val;
721
722 if (cr < 0) cr = 0;
723 if (cr > 1) cr = 1;
724 val = (int)(255.0 * cr);
725 ct.contrast = val;
726 ioctl(_ecore_fb_ts_fd, TS_SET_CONTRAST, &ct);
727}
728
729/**
730 * Retrieves the contrast currently being used by the framebuffer screen.
731 * @return A value between 0 and 1 that represents the current contrast of the
732 * screen.
733 * @ingroup Ecore_FB_Contrast_Group
734 */
735EAPI double
736ecore_fb_contrast_get(void)
737{
738 Ecore_Fb_Ts_Contrast ct;
739
740 if (_ecore_fb_ts_fd < 0) return 1.0;
741 ioctl(_ecore_fb_ts_fd, TS_GET_CONTRAST, &ct);
742 return (double)ct.contrast / 255.0;
743}
744
745/**
746 * To be documented.
747 *
748 * FIXME: To be fixed.
749 */
750EAPI double
751ecore_fb_light_sensor_get(void)
752{
753 Ecore_Fb_Ts_Flite fl;
754
755 if (_ecore_fb_ts_fd < 0) return 0.0;
756 fl.mode = 3;
757 fl.brightness = 0;
758 ioctl(_ecore_fb_ts_fd, FLITE_ON, &fl);
759 return (double)fl.brightness / 255.0;
760}
761
762/**
763 * To be documented.
764 *
765 * FIXME: To be fixed.
766 * @todo Documentation: Find out what this does.
767 */
768EAPI void
769ecore_fb_callback_gain_set(void (*func) (void *data), void *data)
770{
771 _ecore_fb_func_fb_gain = func;
772 _ecore_fb_func_fb_gain_data = data;
773}
774
775/**
776 * To be documented.
777 *
778 * FIXME: To be fixed.
779 * @todo Documentation: Find out what this does.
780 */
781EAPI void
782ecore_fb_callback_lose_set(void (*func) (void *data), void *data)
783{
784 _ecore_fb_func_fb_lost = func;
785 _ecore_fb_func_fb_lost_data = data;
786}
787
788static void 81static void
789_ecore_fb_size_get(int *w, int *h) 82_ecore_fb_size_get(int *w, int *h)
790{ 83{
@@ -808,515 +101,3 @@ _ecore_fb_size_get(int *w, int *h)
808 if (w) *w = fb_var.xres; 101 if (w) *w = fb_var.xres;
809 if (h) *h = fb_var.yres; 102 if (h) *h = fb_var.yres;
810} 103}
811
812static int
813_ecore_fb_ts_fd_handler(void *data __UNUSED__, Ecore_Fd_Handler *fd_handler __UNUSED__)
814{
815 static int prev_x = 0, prev_y = 0, prev_pressure = 0;
816 static double last_time = 0;
817 static double last_last_time = 0;
818 int v = 0;
819
820 do
821 {
822 int x, y, pressure;
823 int num;
824 char *ptr;
825 double t;
826 int did_triple = 0;
827
828#ifdef HAVE_TSLIB
829 if ( _ecore_fb_ts_apply_cal )
830 num = ts_read_raw( _ecore_fb_tslib_tsdev, &_ecore_fb_tslib_event, 1 );
831 else
832 num = ts_read( _ecore_fb_tslib_tsdev, &_ecore_fb_tslib_event, 1 );
833 if ( num != 1 )
834 {
835 return 1; /* no more samples at this time */
836 }
837 x = _ecore_fb_tslib_event.x;
838 y = _ecore_fb_tslib_event.y;
839 pressure = _ecore_fb_tslib_event.pressure;
840 v = 1; /* loop, there might be more samples */
841#else
842 ptr = (char *)&(_ecore_fb_ts_event);
843 ptr += _ecore_fb_ts_event_byte_count;
844 num = sizeof(Ecore_Fb_Ts_Event) - _ecore_fb_ts_event_byte_count;
845 v = read(_ecore_fb_ts_fd, ptr, num);
846 if (v < 0) return 1;
847 _ecore_fb_ts_event_byte_count += v;
848 if (v < num) return 1;
849 t = ecore_time_get();
850 _ecore_fb_ts_event_byte_count = 0;
851 if (_ecore_fb_ts_apply_cal)
852 {
853 x = ((_ecore_fb_ts_cal.xscale * _ecore_fb_ts_event.x) >> 8) + _ecore_fb_ts_cal.xtrans;
854 y = ((_ecore_fb_ts_cal.yscale * _ecore_fb_ts_event.y) >> 8) + _ecore_fb_ts_cal.ytrans;
855 }
856 else
857 {
858 x = _ecore_fb_ts_event.x;
859 y = _ecore_fb_ts_event.y;
860 }
861 pressure = _ecore_fb_ts_event.pressure;
862#endif
863 /* add event to queue */
864 /* always add a move event */
865 if ((pressure) || (prev_pressure))
866 {
867 /* MOVE: mouse is down and was */
868 Ecore_Fb_Event_Mouse_Move *e;
869
870 e = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Move));
871 if (!e) goto retry;
872 e->x = x;
873 e->y = y;
874 ecore_event_add(ECORE_FB_EVENT_MOUSE_MOVE, e, NULL, NULL);
875 }
876 if ((pressure) && (!prev_pressure))
877 {
878 /* DOWN: mouse is down, but was not now */
879 Ecore_Fb_Event_Mouse_Button_Down *e;
880
881 e = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Down));
882 if (!e) goto retry;
883 e->x = x;
884 e->y = y;
885 e->button = 1;
886 if ((t - last_time) <= _ecore_fb_double_click_time)
887 e->double_click = 1;
888 if ((t - last_last_time) <= (2 * _ecore_fb_double_click_time))
889 {
890 did_triple = 1;
891 e->triple_click = 1;
892 }
893 ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_DOWN, e, NULL, NULL);
894 }
895 else if ((!pressure) && (prev_pressure))
896 {
897 /* UP: mouse was down, but is not now */
898 Ecore_Fb_Event_Mouse_Button_Up *e;
899
900 e = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Up));
901 if (!e) goto retry;
902 e->x = prev_x;
903 e->y = prev_y;
904 e->button = 1;
905 ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_UP, e, NULL, NULL);
906 }
907 if (did_triple)
908 {
909 last_time = 0;
910 last_last_time = 0;
911 }
912 else
913 {
914 last_last_time = last_time;
915 last_time = t;
916 }
917 retry:
918 prev_x = x;
919 prev_y = y;
920 prev_pressure = pressure;
921 }
922 while (v > 0);
923 return 1;
924}
925
926static int
927_ecore_fb_kbd_fd_handler(void *data __UNUSED__, Ecore_Fd_Handler *fd_handler __UNUSED__)
928{
929 int v = 0;
930
931 do
932 {
933 unsigned char buf;
934
935 v = read(_ecore_fb_kbd_fd, &buf, 1);
936 if (v < 0) return 1;
937 if (v < 1) return 1;
938 if (buf & 0x80)
939 {
940 /* DOWN */
941 int vt_switch = -1;
942 Ecore_Fb_Event_Key_Down *e;
943
944 e = calloc(1, sizeof(Ecore_Fb_Event_Key_Down));
945 if (!e) goto retry;
946 if (_ecore_fb_kbd_fd == _ecore_fb_tty_fd)
947 {
948 int add = 0;
949
950 if (_ecore_fb_shift) add = 1;
951 else if (_ecore_fb_lock) add = 2;
952 e->keyname = strdup(_ecore_fb_kbd_syms[(buf & 0x7f) * 6]);
953 e->keysymbol = strdup(_ecore_fb_kbd_syms[((buf & 0x7f) * 6) + add]);
954 e->key_compose = strdup(_ecore_fb_kbd_syms[((buf & 0x7f) * 6) + 3 + add]);
955 }
956 else
957 e->keyname = strdup(_ecore_fb_btn_syms[buf & 0x7f]);
958 if (!e->keyname)
959 {
960 free(e);
961 goto retry;
962 }
963 ecore_event_add(ECORE_FB_EVENT_KEY_DOWN, e, _ecore_fb_event_free_key_down, NULL);
964 if (!strcmp(e->keyname, "Control_L"))
965 _ecore_fb_ctrl++;
966 else if (!strcmp(e->keyname, "Control_R"))
967 _ecore_fb_ctrl++;
968 else if (!strcmp(e->keyname, "Alt_L"))
969 _ecore_fb_alt++;
970 else if (!strcmp(e->keyname, "Alt_R"))
971 _ecore_fb_alt++;
972 else if (!strcmp(e->keyname, "Shift_L"))
973 _ecore_fb_shift++;
974 else if (!strcmp(e->keyname, "Shift_R"))
975 _ecore_fb_shift++;
976 else if (!strcmp(e->keyname, "Caps_Lock"))
977 _ecore_fb_lock++;
978 else if (!strcmp(e->keyname, "F1")) vt_switch = 0;
979 else if (!strcmp(e->keyname, "F2")) vt_switch = 1;
980 else if (!strcmp(e->keyname, "F3")) vt_switch = 2;
981 else if (!strcmp(e->keyname, "F4")) vt_switch = 3;
982 else if (!strcmp(e->keyname, "F5")) vt_switch = 4;
983 else if (!strcmp(e->keyname, "F6")) vt_switch = 5;
984 else if (!strcmp(e->keyname, "F7")) vt_switch = 6;
985 else if (!strcmp(e->keyname, "F8")) vt_switch = 7;
986 else if (!strcmp(e->keyname, "F9")) vt_switch = 8;
987 else if (!strcmp(e->keyname, "F10")) vt_switch = 9;
988 else if (!strcmp(e->keyname, "F11")) vt_switch = 10;
989 else if (!strcmp(e->keyname, "F12")) vt_switch = 11;
990 if (_ecore_fb_ctrl > 2) _ecore_fb_ctrl = 2;
991 if (_ecore_fb_alt > 2) _ecore_fb_alt = 2;
992 if ((vt_switch >= 0) &&
993 (_ecore_fb_ctrl) &&
994 (_ecore_fb_alt))
995 _ecore_fb_vt_switch(vt_switch);
996 }
997 else
998 {
999 /* UP */
1000 Ecore_Fb_Event_Key_Up *e;
1001
1002 e = calloc(1, sizeof(Ecore_Fb_Event_Key_Up));
1003 if (!e) goto retry;
1004 if (_ecore_fb_kbd_fd == _ecore_fb_tty_fd)
1005 {
1006 int add = 0;
1007
1008 if (_ecore_fb_shift) add = 1;
1009 else if (_ecore_fb_lock) add = 2;
1010 e->keyname = strdup(_ecore_fb_kbd_syms[(buf & 0x7f) * 6]);
1011 e->keysymbol = strdup(_ecore_fb_kbd_syms[((buf & 0x7f) * 6) + add]);
1012 e->key_compose = strdup(_ecore_fb_kbd_syms[((buf & 0x7f) * 6) + 3 + add]);
1013 }
1014 else
1015 e->keyname = strdup(_ecore_fb_btn_syms[buf & 0x7f]);
1016 if (!e->keyname)
1017 {
1018 free(e);
1019 goto retry;
1020 }
1021 ecore_event_add(ECORE_FB_EVENT_KEY_UP, e, _ecore_fb_event_free_key_up, NULL);
1022 if (!strcmp(e->keyname, "Control_L"))
1023 _ecore_fb_ctrl--;
1024 else if (!strcmp(e->keyname, "Control_R"))
1025 _ecore_fb_ctrl--;
1026 else if (!strcmp(e->keyname, "Alt_L"))
1027 _ecore_fb_alt--;
1028 else if (!strcmp(e->keyname, "Alt_R"))
1029 _ecore_fb_alt--;
1030 else if (!strcmp(e->keyname, "Shift_L"))
1031 _ecore_fb_shift--;
1032 else if (!strcmp(e->keyname, "Shift_R"))
1033 _ecore_fb_shift--;
1034 else if (!strcmp(e->keyname, "Caps_Lock"))
1035 _ecore_fb_lock--;
1036 if (_ecore_fb_ctrl < 0) _ecore_fb_ctrl = 0;
1037 if (_ecore_fb_alt < 0) _ecore_fb_alt = 0;
1038 if (_ecore_fb_shift < 0) _ecore_fb_shift = 0;
1039 if (_ecore_fb_lock < 0) _ecore_fb_lock = 0;
1040 }
1041 retry:
1042 ;
1043 }
1044 while (v > 0);
1045 return 1;
1046}
1047
1048static int
1049_ecore_fb_ps2_fd_handler(void *data __UNUSED__, Ecore_Fd_Handler *fd_handler __UNUSED__)
1050{
1051 static int prev_x = 0, prev_y = 0, prev_button = 0;
1052 static double last_time = 0;
1053 static double last_last_time = 0;
1054 int v = 0;
1055
1056 do
1057 {
1058 int x, y, button, i;
1059 int num;
1060 char *ptr;
1061 double t;
1062 int did_triple = 0;
1063
1064 ptr = (char *)&(_ecore_fb_ps2_event);
1065 ptr += _ecore_fb_ps2_event_byte_count;
1066 num = sizeof(Ecore_Fb_Ps2_Event) - _ecore_fb_ps2_event_byte_count;
1067 v = read(_ecore_fb_ps2_fd, ptr, num);
1068 if (v < 0) return 1;
1069 _ecore_fb_ps2_event_byte_count += v;
1070 if (v < num) return 1;
1071 t = ecore_time_get();
1072 _ecore_fb_ps2_event_byte_count = 0;
1073 if (_ecore_fb_ps2_event.button & 0x10)
1074 x = prev_x + (0xffffff00 | _ecore_fb_ps2_event.x);
1075 else
1076 x = prev_x + _ecore_fb_ps2_event.x;
1077 if (_ecore_fb_ps2_event.button & 0x20)
1078 y = prev_y - (0xffffff00 | _ecore_fb_ps2_event.y);
1079 else
1080 y = prev_y - _ecore_fb_ps2_event.y;
1081 button = _ecore_fb_ps2_event.button & 0x7;
1082 if (x < 0) x = 0;
1083 if (y < 0) y = 0;
1084 if (x >= _ecore_fb_console_w) x = _ecore_fb_console_w - 1;
1085 if (y >= _ecore_fb_console_h) y = _ecore_fb_console_h - 1;
1086 /* add event to queue */
1087 /* always add a move event */
1088 if (1)
1089 {
1090 /* MOVE: mouse is down and was */
1091 Ecore_Fb_Event_Mouse_Move *e;
1092
1093 e = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Move));
1094 if (!e) goto retry;
1095 e->x = x;
1096 e->y = y;
1097 ecore_event_add(ECORE_FB_EVENT_MOUSE_MOVE, e, NULL, NULL);
1098 }
1099 for (i = 1; i <= 3; i++)
1100 {
1101 int mask;
1102
1103 mask = 1 << (i - 1);
1104 if (((button & mask)) && (!(prev_button & mask)))
1105 {
1106 /* DOWN: mouse is down, but was not now */
1107 Ecore_Fb_Event_Mouse_Button_Down *e;
1108
1109 e = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Down));
1110 if (!e) goto retry;
1111 e->x = x;
1112 e->y = y;
1113 e->button = 1;
1114 if ((t - last_time) <= _ecore_fb_double_click_time)
1115 e->double_click = 1;
1116 if ((t - last_last_time) <= (2 * _ecore_fb_double_click_time))
1117 {
1118 did_triple = 1;
1119 e->triple_click = 1;
1120 }
1121 ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_DOWN, e, NULL, NULL);
1122 }
1123 else if ((!(button & mask)) && ((prev_button & mask)))
1124 {
1125 /* UP: mouse was down, but is not now */
1126 Ecore_Fb_Event_Mouse_Button_Up *e;
1127
1128 e = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Up));
1129 if (!e) goto retry;
1130 e->x = x;
1131 e->y = y;
1132 e->button = 1;
1133 ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_UP, e, NULL, NULL);
1134 }
1135 }
1136 if (did_triple)
1137 {
1138 last_time = 0;
1139 last_last_time = 0;
1140 }
1141 else
1142 {
1143 last_last_time = last_time;
1144 last_time = t;
1145 }
1146 retry:
1147 prev_x = x;
1148 prev_y = y;
1149 prev_button = button;
1150 }
1151 while (v > 0);
1152 return 1;
1153}
1154
1155static void
1156_ecore_fb_event_free_key_down(void *data __UNUSED__, void *ev)
1157{
1158 Ecore_Fb_Event_Key_Up *e;
1159
1160 e = ev;
1161 free(e->keyname);
1162 if (e->keysymbol) free(e->keysymbol);
1163 if (e->key_compose) free(e->key_compose);
1164 free(e);
1165}
1166
1167static void
1168_ecore_fb_event_free_key_up(void *data __UNUSED__, void *ev)
1169{
1170 Ecore_Fb_Event_Key_Up *e;
1171
1172 e = ev;
1173 free(e->keyname);
1174 if (e->keysymbol) free(e->keysymbol);
1175 if (e->key_compose) free(e->key_compose);
1176 free(e);
1177}
1178
1179static int
1180_ecore_fb_signal_usr_handler(void *data __UNUSED__, int type __UNUSED__, void *ev)
1181{
1182 Ecore_Event_Signal_User *e;
1183
1184 e = (Ecore_Event_Signal_User *)ev;
1185 if (e->number == 1)
1186 {
1187 /* release */
1188 if (_ecore_fb_func_fb_lost)
1189 _ecore_fb_func_fb_lost(_ecore_fb_func_fb_lost_data);
1190 if (_ecore_fb_ps2_fd > 0) close(_ecore_fb_ps2_fd);
1191 if (_ecore_fb_ts_fd >= 0) close(_ecore_fb_ts_fd);
1192 if (_ecore_fb_ts_fd_handler_handle)
1193 ecore_main_fd_handler_del(_ecore_fb_ts_fd_handler_handle);
1194 _ecore_fb_ps2_fd = 0;
1195 _ecore_fb_ts_fd = 0;
1196 _ecore_fb_ts_fd_handler_handle = NULL;
1197 ioctl(_ecore_fb_tty_fd, VT_RELDISP, 1);
1198 }
1199 else if (e->number == 2)
1200 {
1201 int prev_flags;
1202
1203 /* gain */
1204 if (_ecore_fb_func_fb_gain)
1205 _ecore_fb_func_fb_gain(_ecore_fb_func_fb_gain_data);
1206 if (!_ecore_fb_ts_fd)
1207 {
1208 _ecore_fb_ts_fd = open("/dev/touchscreen/0", O_RDONLY);
1209 if (_ecore_fb_ts_fd >= 0)
1210 {
1211 prev_flags = fcntl(_ecore_fb_ts_fd, F_GETFL);
1212 fcntl(_ecore_fb_ts_fd, F_SETFL, prev_flags | O_NONBLOCK);
1213 _ecore_fb_ts_fd_handler_handle = ecore_main_fd_handler_add(_ecore_fb_ts_fd,
1214 ECORE_FD_READ,
1215 _ecore_fb_ts_fd_handler, NULL,
1216 NULL, NULL);
1217 if (!_ecore_fb_ts_fd_handler_handle)
1218 {
1219 close(_ecore_fb_ts_fd);
1220 }
1221 }
1222 }
1223 if (_ecore_fb_ts_fd < 0)
1224 {
1225 if (!_ecore_fb_ps2_fd)
1226 {
1227 _ecore_fb_ps2_fd = open("/dev/psaux", O_RDWR);
1228 if (_ecore_fb_ps2_fd >= 0)
1229 {
1230 prev_flags = fcntl(_ecore_fb_ps2_fd, F_GETFL);
1231 fcntl(_ecore_fb_ps2_fd, F_SETFL, prev_flags | O_NONBLOCK);
1232 _ecore_fb_ts_fd_handler_handle = ecore_main_fd_handler_add(_ecore_fb_ps2_fd,
1233 ECORE_FD_READ,
1234 _ecore_fb_ps2_fd_handler, NULL,
1235 NULL, NULL);
1236 if (!_ecore_fb_ts_fd_handler_handle)
1237 {
1238 close(_ecore_fb_ps2_fd);
1239 }
1240 }
1241 }
1242 }
1243 if (_ecore_fb_tty_fd != 0)
1244 {
1245 struct termios tio;
1246 struct vt_mode new_vtmode;
1247
1248 tio.c_iflag = tio.c_oflag = tio.c_cflag = tio.c_lflag = 0;
1249 tio.c_cc[VTIME] = 0;
1250 tio.c_cc[VMIN] = 1;
1251 new_vtmode.mode = VT_PROCESS;
1252 new_vtmode.waitv = 0;
1253 new_vtmode.relsig = SIGUSR1;
1254 new_vtmode.acqsig = SIGUSR2;
1255 tcsetattr(_ecore_fb_tty_fd, TCSAFLUSH, &tio);
1256 ioctl(_ecore_fb_tty_fd, KDSETMODE, KD_GRAPHICS);
1257 ioctl(_ecore_fb_tty_fd, KDSKBMODE, K_MEDIUMRAW);
1258 ioctl(_ecore_fb_tty_fd, VT_SETMODE, &new_vtmode);
1259 }
1260 }
1261 return 1;
1262}
1263
1264static void
1265_ecore_fb_vt_switch(int vt)
1266{
1267 vt++;
1268 if (_ecore_fb_tty_fd != 0)
1269 {
1270 if (vt != _ecore_fb_current_vt)
1271 {
1272 tcsetattr(_ecore_fb_tty_fd, TCSAFLUSH, &_ecore_fb_tty_prev_tio_mode);
1273 ioctl(_ecore_fb_tty_fd, KDSETMODE, _ecore_fb_tty_prev_kd_mode);
1274 ioctl(_ecore_fb_tty_fd, KDSKBMODE, _ecore_fb_tty_prev_mode);
1275 }
1276 }
1277 ioctl(_ecore_fb_tty_fd, VT_ACTIVATE, vt);
1278}
1279
1280typedef struct _Ecore_Fb_Filter_Data Ecore_Fb_Filter_Data;
1281
1282struct _Ecore_Fb_Filter_Data
1283{
1284 int last_event_type;
1285};
1286
1287static void *
1288_ecore_fb_event_filter_start(void *data __UNUSED__)
1289{
1290 Ecore_Fb_Filter_Data *filter_data;
1291
1292 filter_data = calloc(1, sizeof(Ecore_Fb_Filter_Data));
1293 return filter_data;
1294}
1295
1296static int
1297_ecore_fb_event_filter_filter(void *data __UNUSED__, void *loop_data,int type, void *event __UNUSED__)
1298{
1299 Ecore_Fb_Filter_Data *filter_data;
1300
1301 filter_data = loop_data;
1302 if (!filter_data) return 1;
1303 if (type == ECORE_FB_EVENT_MOUSE_MOVE)
1304 {
1305 if ((filter_data->last_event_type) == ECORE_FB_EVENT_MOUSE_MOVE)
1306 {
1307 filter_data->last_event_type = type;
1308 return 0;
1309 }
1310 }
1311 filter_data->last_event_type = type;
1312 return 1;
1313}
1314
1315static void
1316_ecore_fb_event_filter_end(void *data __UNUSED__, void *loop_data)
1317{
1318 Ecore_Fb_Filter_Data *filter_data;
1319
1320 filter_data = loop_data;
1321 if (filter_data) free(filter_data);
1322}