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 int _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;
59 ptr = (char *)&(_ecore_fb_ps2_event);
60 ptr += _ecore_fb_ps2_event_byte_count;
61 num = sizeof(Ecore_Fb_Ps2_Event) - _ecore_fb_ps2_event_byte_count;
62 v = read(_ecore_fb_ps2_fd, ptr, num);
64 _ecore_fb_ps2_event_byte_count += v;
65 if (v < num) return 1;
67 _ecore_fb_ps2_event_byte_count = 0;
68 if (_ecore_fb_ps2_event.button & 0x10)
69 x = prev_x + (0xffffff00 | _ecore_fb_ps2_event.x);
71 x = prev_x + _ecore_fb_ps2_event.x;
72 if (_ecore_fb_ps2_event.button & 0x20)
73 y = prev_y - (0xffffff00 | _ecore_fb_ps2_event.y);
75 y = prev_y - _ecore_fb_ps2_event.y;
76 button = _ecore_fb_ps2_event.button & 0x7;
79 if (x >= _ecore_fb_console_w) x = _ecore_fb_console_w - 1;
80 if (y >= _ecore_fb_console_h) y = _ecore_fb_console_h - 1;
81 /* add event to queue */
82 /* always add a move event */
85 /* MOVE: mouse is down and was */
86 Ecore_Fb_Event_Mouse_Move *e;
88 e = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Move));
92 ecore_event_add(ECORE_FB_EVENT_MOUSE_MOVE, e, NULL, NULL);
94 for (i = 1; i <= 3; i++)
99 if (((button & mask)) && (!(prev_button & mask)))
101 /* DOWN: mouse is down, but was not now */
102 Ecore_Fb_Event_Mouse_Button_Down *e;
104 e = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Down));
109 if ((t - last_time) <= _ecore_fb_double_click_time)
111 if ((t - last_last_time) <= (2 * _ecore_fb_double_click_time))
116 ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_DOWN, e, NULL, NULL);
118 else if ((!(button & mask)) && ((prev_button & mask)))
120 /* UP: mouse was down, but is not now */
121 Ecore_Fb_Event_Mouse_Button_Up *e;
123 e = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Up));
128 ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_UP, e, NULL, NULL);
138 last_last_time = last_time;
144 prev_button = button;
150 * @defgroup Ecore_FB_Click_Group Framebuffer Double Click Functions
152 * Functions that deal with the double click time of the framebuffer.
156 * Sets the timeout for a double and triple clicks to be flagged.
158 * This sets the time between clicks before the double_click flag is
159 * set in a button down event. If 3 clicks occur within double this
160 * time, the triple_click flag is also set.
162 * @param t The time in seconds
163 * @ingroup Ecore_FB_Click_Group
166 ecore_fb_double_click_time_set(double t)
168 if (t < 0.0) t = 0.0;
169 _ecore_fb_double_click_time = t;
173 * Retrieves the double and triple click flag timeout.
175 * See @ref ecore_x_double_click_time_set for more information.
177 * @return The timeout for double clicks in seconds.
178 * @ingroup Ecore_FB_Click_Group
181 ecore_fb_double_click_time_get(void)
183 return _ecore_fb_double_click_time;