1 typedef struct _Ecore_Fb_Ps2_Event Ecore_Fb_Ps2_Event;
2 struct _Ecore_Fb_Ps2_Event
10 static int _ecore_fb_ps2_event_byte_count = 0;
11 static Ecore_Fb_Ps2_Event _ecore_fb_ps2_event;
12 static int _ecore_fb_ps2_fd = 0;
13 static Eina_Bool _ecore_fb_ps2_fd_handler(void *data, Ecore_Fd_Handler *fd_handler);
16 ecore_fb_ps2_init(void)
18 _ecore_fb_ps2_fd = open("/dev/psaux", O_RDWR);
19 if (_ecore_fb_ps2_fd >= 0)
21 prev_flags = fcntl(_ecore_fb_ps2_fd, F_GETFL);
22 fcntl(_ecore_fb_ps2_fd, F_SETFL, prev_flags | O_NONBLOCK);
23 _ecore_fb_ts_fd_handler_handle = ecore_main_fd_handler_add(_ecore_fb_ps2_fd,
25 _ecore_fb_ps2_fd_handler, NULL, NULL, NULL);
26 if (!_ecore_fb_ts_fd_handler_handle)
28 close(_ecore_fb_ps2_fd);
37 ecore_fb_ps2_shutdown(void)
39 if (_ecore_fb_ps2_fd > 0) close(_ecore_fb_ps2_fd);
44 _ecore_fb_ps2_fd_handler(void *data __UNUSED__, Ecore_Fd_Handler *fd_handler __UNUSED__)
46 static int prev_x = 0, prev_y = 0, prev_button = 0;
47 static double last_time = 0;
48 static double last_last_time = 0;
57 static int did_double = 0;
58 static int did_triple = 0;
60 ptr = (char *)&(_ecore_fb_ps2_event);
61 ptr += _ecore_fb_ps2_event_byte_count;
62 num = sizeof(Ecore_Fb_Ps2_Event) - _ecore_fb_ps2_event_byte_count;
63 v = read(_ecore_fb_ps2_fd, ptr, num);
64 if (v < 0) return EINA_TRUE;
65 _ecore_fb_ps2_event_byte_count += v;
66 if (v < num) return EINA_TRUE;
68 _ecore_fb_ps2_event_byte_count = 0;
69 if (_ecore_fb_ps2_event.button & 0x10)
70 x = prev_x + (0xffffff00 | _ecore_fb_ps2_event.x);
72 x = prev_x + _ecore_fb_ps2_event.x;
73 if (_ecore_fb_ps2_event.button & 0x20)
74 y = prev_y - (0xffffff00 | _ecore_fb_ps2_event.y);
76 y = prev_y - _ecore_fb_ps2_event.y;
77 button = _ecore_fb_ps2_event.button & 0x7;
80 if (x >= _ecore_fb_console_w) x = _ecore_fb_console_w - 1;
81 if (y >= _ecore_fb_console_h) y = _ecore_fb_console_h - 1;
82 /* add event to queue */
83 /* always add a move event */
86 /* MOVE: mouse is down and was */
87 Ecore_Fb_Event_Mouse_Move *e;
89 e = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Move));
93 ecore_event_add(ECORE_FB_EVENT_MOUSE_MOVE, e, NULL, NULL);
95 for (i = 1; i <= 3; i++)
100 if (((button & mask)) && (!(prev_button & mask)))
102 /* DOWN: mouse is down, but was not now */
103 Ecore_Fb_Event_Mouse_Button_Down *e;
105 e = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Down));
110 if ((t - last_time) <= _ecore_fb_double_click_time)
120 if ((t - last_last_time) <= (2 * _ecore_fb_double_click_time))
129 ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_DOWN, e, NULL, NULL);
131 else if ((!(button & mask)) && ((prev_button & mask)))
133 /* UP: mouse was down, but is not now */
134 Ecore_Fb_Event_Mouse_Button_Up *e;
136 e = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Up));
145 ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_UP, e, NULL, NULL);
155 last_last_time = last_time;
161 prev_button = button;
167 * @defgroup Ecore_FB_Click_Group Framebuffer Double Click Functions
169 * Functions that deal with the double click time of the framebuffer.
173 * Sets the timeout for a double and triple clicks to be flagged.
175 * This sets the time between clicks before the double_click flag is
176 * set in a button down event. If 3 clicks occur within double this
177 * time, the triple_click flag is also set.
179 * @param t The time in seconds
180 * @ingroup Ecore_FB_Click_Group
183 ecore_fb_double_click_time_set(double t)
185 if (t < 0.0) t = 0.0;
186 _ecore_fb_double_click_time = t;
190 * Retrieves the double and triple click flag timeout.
192 * See @ref ecore_x_double_click_time_set for more information.
194 * @return The timeout for double clicks in seconds.
195 * @ingroup Ecore_FB_Click_Group
198 ecore_fb_double_click_time_get(void)
200 return _ecore_fb_double_click_time;