summaryrefslogtreecommitdiff
path: root/src/lib/ecore_fb/ecore_fb_ps2.c
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-04 20:44:19 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2013-01-04 20:44:19 +0000
commit7abf31c88264c2a7692ce61c7985bc49e979163e (patch)
tree18a1ab5303d3656fa701fb15ce73670b99d7b295 /src/lib/ecore_fb/ecore_fb_ps2.c
parent06c3306d3c8ca75a591dcd5555b758263b220a74 (diff)
efl/ecore_fb: remove deprecated files.
SVN revision: 82240
Diffstat (limited to '')
-rw-r--r--src/lib/ecore_fb/ecore_fb_ps2.c224
1 files changed, 0 insertions, 224 deletions
diff --git a/src/lib/ecore_fb/ecore_fb_ps2.c b/src/lib/ecore_fb/ecore_fb_ps2.c
deleted file mode 100644
index 7931ef74e7..0000000000
--- a/src/lib/ecore_fb/ecore_fb_ps2.c
+++ /dev/null
@@ -1,224 +0,0 @@
1typedef struct _Ecore_Fb_Ps2_Event Ecore_Fb_Ps2_Event;
2struct _Ecore_Fb_Ps2_Event
3{
4 unsigned char button;
5 unsigned char x;
6 unsigned char y;
7 unsigned char z;
8};
9
10static int _ecore_fb_ps2_event_byte_count = 0;
11static Ecore_Fb_Ps2_Event _ecore_fb_ps2_event;
12static int _ecore_fb_ps2_fd = 0;
13static Eina_Bool _ecore_fb_ps2_fd_handler(void *data, Ecore_Fd_Handler *fd_handler);
14
15int
16ecore_fb_ps2_init(void)
17{
18 _ecore_fb_ps2_fd = open("/dev/psaux", O_RDWR);
19 if (_ecore_fb_ps2_fd >= 0)
20 {
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,
24 ECORE_FD_READ,
25 _ecore_fb_ps2_fd_handler, NULL, NULL, NULL);
26 if (!_ecore_fb_ts_fd_handler_handle)
27 {
28 close(_ecore_fb_ps2_fd);
29 return 0;
30 }
31 return 1;
32 }
33 return 0;
34}
35
36void
37ecore_fb_ps2_shutdown(void)
38{
39 if (_ecore_fb_ps2_fd > 0) close(_ecore_fb_ps2_fd);
40 _ecore_fb_ps2_fd = 0;
41}
42
43static Eina_Bool
44_ecore_fb_ps2_fd_handler(void *data EINA_UNUSED, Ecore_Fd_Handler *fd_handler EINA_UNUSED)
45{
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;
49 int v = 0;
50
51 do
52 {
53 int x, y, button, i;
54 int num;
55 char *ptr;
56 double t;
57 static int did_double = 0;
58 static int did_triple = 0;
59
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;
67 t = ecore_loop_time_get();
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);
71 else
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);
75 else
76 y = prev_y - _ecore_fb_ps2_event.y;
77 button = _ecore_fb_ps2_event.button & 0x7;
78 if (x < 0) x = 0;
79 if (y < 0) y = 0;
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 */
84 if (1)
85 {
86 /* MOVE: mouse is down and was */
87 Ecore_Event_Mouse_Move *e;
88
89 e = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Move));
90 if (!e) goto retry;
91 e->x = x;
92 e->y = y;
93 e->root.x = e->x;
94 e->root.y = e->y;
95 e->window = 1;
96 e->event_window = e->window;
97 e->root_window = e->window;
98 e->same_screen = 1;
99 e->timestamp = ecore_loop_time_get() * 1000.0;
100 ecore_event_add(ECORE_EVENT_MOUSE_MOVE, e, NULL, NULL);
101 }
102 for (i = 1; i <= 3; i++)
103 {
104 int mask;
105
106 mask = 1 << (i - 1);
107 if (((button & mask)) && (!(prev_button & mask)))
108 {
109 /* DOWN: mouse is down, but was not now */
110 Ecore_Event_Mouse_Button *e;
111
112 e = calloc(1, sizeof(Ecore_Event_Mouse_Button));
113 if (!e) goto retry;
114 e->x = x;
115 e->y = y;
116 e->root.x = e->x;
117 e->root.y = e->y;
118 e->button = i;
119 e->window = 1;
120 e->event_window = e->window;
121 e->root_window = e->window;
122 e->same_screen = 1;
123 if ((t - last_time) <= _ecore_fb_double_click_time)
124 {
125 e->double_click = 1;
126 did_double = 1;
127 }
128 else
129 {
130 did_double = 0;
131 did_triple = 0;
132 }
133 if ((t - last_last_time) <= (2 * _ecore_fb_double_click_time))
134 {
135 did_triple = 1;
136 e->triple_click = 1;
137 }
138 else
139 {
140 did_triple = 0;
141 }
142 e->timestamp = ecore_loop_time_get() * 1000.0;
143 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, e, NULL, NULL);
144 }
145 else if ((!(button & mask)) && ((prev_button & mask)))
146 {
147 /* UP: mouse was down, but is not now */
148 Ecore_Event_Mouse_Button *e;
149
150 e = calloc(1, sizeof(Ecore_Event_Mouse_Button));
151 if (!e) goto retry;
152 e->x = x;
153 e->y = y;
154 e->root.x = e->x;
155 e->root.y = e->y;
156 e->button = i;
157 e->window = 1;
158 e->event_window = e->window;
159 e->root_window = e->window;
160 e->same_screen = 1;
161 if (did_double)
162 e->double_click = 1;
163 if (did_triple)
164 e->triple_click = 1;
165 e->timestamp = ecore_loop_time_get() * 1000.0;
166 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, e, NULL, NULL);
167 }
168 }
169 if (did_triple)
170 {
171 last_time = 0;
172 last_last_time = 0;
173 }
174 else
175 {
176 last_last_time = last_time;
177 last_time = t;
178 }
179 retry:
180 prev_x = x;
181 prev_y = y;
182 prev_button = button;
183 }
184 while (v > 0);
185 return EINA_TRUE;
186}
187/**
188 * @defgroup Ecore_FB_Click_Group Framebuffer Double Click Functions
189 * @ingroup Ecore_FB_Group
190 *
191 * Functions that deal with the double click time of the framebuffer.
192 */
193
194/**
195 * Sets the timeout for a double and triple clicks to be flagged.
196 *
197 * This sets the time between clicks before the double_click flag is
198 * set in a button down event. If 3 clicks occur within double this
199 * time, the triple_click flag is also set.
200 *
201 * @param t The time in seconds
202 * @ingroup Ecore_FB_Click_Group
203 */
204EAPI void
205ecore_fb_double_click_time_set(double t)
206{
207 if (t < 0.0) t = 0.0;
208 _ecore_fb_double_click_time = t;
209}
210
211/**
212 * Retrieves the double and triple click flag timeout.
213 *
214 * See @ref ecore_x_double_click_time_set for more information.
215 *
216 * @return The timeout for double clicks in seconds.
217 * @ingroup Ecore_FB_Click_Group
218 */
219EAPI double
220ecore_fb_double_click_time_get(void)
221{
222 return _ecore_fb_double_click_time;
223}
224