aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ecore/src/lib/ecore_fb/ecore_fb_li.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/ecore/src/lib/ecore_fb/ecore_fb_li.c')
-rw-r--r--libraries/ecore/src/lib/ecore_fb/ecore_fb_li.c708
1 files changed, 0 insertions, 708 deletions
diff --git a/libraries/ecore/src/lib/ecore_fb/ecore_fb_li.c b/libraries/ecore/src/lib/ecore_fb/ecore_fb_li.c
deleted file mode 100644
index 3850792..0000000
--- a/libraries/ecore/src/lib/ecore_fb/ecore_fb_li.c
+++ /dev/null
@@ -1,708 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <stdlib.h>
6
7#include "Ecore_Fb.h"
8#include "ecore_fb_private.h"
9
10#define CLICK_THRESHOLD_DEFAULT 0.25
11
12static Eina_List *_ecore_fb_li_devices = NULL;
13
14static const char *_ecore_fb_li_kbd_syms[128 * 6] =
15{
16#include "ecore_fb_keytable.h"
17};
18
19/* Initial Copyright (C) Brad Hards (1999-2002),
20 * this function is used to tell if "bit" is set in "array"
21 * it selects a byte from the array, and does a boolean AND
22 * operation with a byte that only has the relevant bit set.
23 * eg. to check for the 12th bit, we do (array[1] & 1<<4).
24 * Moved to static inline in order to force compiler to otimized
25 * the unsued part away or force a link error if long has an unexpected
26 * size.
27 * - bigeasy
28 */
29extern int long_has_neither_32_nor_64_bits(void);
30static inline int
31test_bit(int bit, unsigned long *array)
32{
33 if (sizeof(long) == 4)
34 return array[bit / 32] & (1 << (bit % 32));
35 else if (sizeof(long) == 8)
36 return array[bit / 64] & (1 << (bit % 64));
37 else long_has_neither_32_nor_64_bits();
38}
39
40static void
41_ecore_fb_li_device_event_key(Ecore_Fb_Input_Device *dev, struct input_event *iev)
42{
43 if (!dev->listen) return;
44
45 /* check for basic keyboard keys */
46 if ((iev->code >= KEY_ESC) && (iev->code <= KEY_COMPOSE))
47 {
48 int offset = 0;
49 const char *keyname = _ecore_fb_li_kbd_syms[iev->code * 6];
50 /* check the key table */
51 if (iev->value)
52 {
53 /* its a repeated key, dont increment */
54 if (iev->value == 2)
55 return;
56 if (!strcmp(keyname, "Control_L"))
57 dev->keyboard.ctrl++;
58 else if (!strcmp(keyname, "Control_R"))
59 dev->keyboard.ctrl++;
60 else if (!strcmp(keyname, "Alt_L"))
61 dev->keyboard.alt++;
62 else if (!strcmp(keyname, "Alt_R"))
63 dev->keyboard.alt++;
64 else if (!strcmp(keyname, "Shift_L"))
65 dev->keyboard.shift++;
66 else if (!strcmp(keyname, "Shift_R"))
67 dev->keyboard.shift++;
68 else if (!strcmp(keyname, "Caps_Lock"))
69 dev->keyboard.lock = !dev->keyboard.lock;
70 if (dev->keyboard.ctrl > 2) dev->keyboard.ctrl = 2;
71 if (dev->keyboard.alt > 2) dev->keyboard.alt = 2;
72 if (dev->keyboard.shift > 2) dev->keyboard.shift = 2;
73 if (dev->keyboard.lock > 1) dev->keyboard.lock = 1;
74 }
75 else
76 {
77 if (!strcmp(keyname, "Control_L"))
78 dev->keyboard.ctrl--;
79 else if (!strcmp(keyname, "Control_R"))
80 dev->keyboard.ctrl--;
81 else if (!strcmp(keyname, "Alt_L"))
82 dev->keyboard.alt--;
83 else if (!strcmp(keyname, "Alt_R"))
84 dev->keyboard.alt--;
85 else if (!strcmp(keyname, "Shift_L"))
86 dev->keyboard.shift--;
87 else if (!strcmp(keyname, "Shift_R"))
88 dev->keyboard.shift--;
89 if (dev->keyboard.ctrl < 0) dev->keyboard.ctrl = 0;
90 if (dev->keyboard.alt < 0) dev->keyboard.alt = 0;
91 if (dev->keyboard.shift < 0) dev->keyboard.shift = 0;
92 if (dev->keyboard.lock < 0) dev->keyboard.lock = 0;
93 }
94
95 /* sending ecore_input_evas events */
96 Ecore_Event_Key *e;
97
98 if (dev->keyboard.shift) offset = 1;
99 else if (dev->keyboard.lock) offset = 2;
100
101 const char *key = _ecore_fb_li_kbd_syms[(iev->code * 6) + offset];
102 const char *compose = _ecore_fb_li_kbd_syms[(iev->code * 6) + 3 + offset];
103
104 e = calloc(1, sizeof(Ecore_Event_Key) + strlen(key) +
105 strlen(keyname) + (compose ? strlen(compose) : 0) + 3);
106 e->keyname = (char *)(e + 1);
107 e->key = e->keyname + strlen(keyname) + 1;
108 e->compose = (compose) ? e->key + strlen(key) + 1 : NULL;
109 e->string = e->compose;
110
111 strcpy((char *)e->keyname, keyname);
112 strcpy((char *)e->key, key);
113 if (compose)
114 strcpy((char *)e->compose, compose);
115
116 e->modifiers = 0;
117 if (dev->keyboard.shift)
118 e->modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
119 if (dev->keyboard.ctrl) e->modifiers |= ECORE_EVENT_MODIFIER_CTRL;
120 if (dev->keyboard.alt) e->modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
121 if (dev->keyboard.lock) e->modifiers |= ECORE_EVENT_LOCK_CAPS;
122
123 e->timestamp = ecore_time_get();
124 e->window = (Ecore_Window)dev->window;
125 e->event_window = (Ecore_Window)dev->window;
126 e->root_window = (Ecore_Window)dev->window;
127 e->same_screen = 1;
128
129 if (iev->value)
130 ecore_event_add(ECORE_EVENT_KEY_DOWN, e, NULL, NULL);
131 else
132 ecore_event_add(ECORE_EVENT_KEY_UP, e, NULL, NULL);
133 }
134 /* check for mouse button events */
135 else if ((iev->code >= BTN_MOUSE) && (iev->code < BTN_JOYSTICK))
136 {
137 int button;
138 Ecore_Event_Mouse_Button *e;
139 double current = ecore_time_get();
140
141 button = ((iev->code & 0x00F) + 1);
142 if (iev->value)
143 {
144 dev->mouse.did_double = EINA_FALSE;
145 dev->mouse.did_triple = EINA_FALSE;
146
147 if (((current - dev->mouse.prev) <= dev->mouse.threshold) &&
148 (button == dev->mouse.prev_button))
149 {
150 dev->mouse.did_double = EINA_TRUE;
151 if (((current - dev->mouse.last) <= (2 * dev->mouse.threshold)) &&
152 (button == dev->mouse.last_button))
153 {
154 dev->mouse.did_triple = EINA_TRUE;
155 /* reset */
156 dev->mouse.prev = 0;
157 dev->mouse.last = 0;
158 current = 0;
159 }
160 }
161 dev->mouse.last = dev->mouse.prev;
162 dev->mouse.prev = current;
163 dev->mouse.last_button = dev->mouse.prev_button;
164 dev->mouse.prev_button = button;
165 }
166
167 e = calloc(1, sizeof(Ecore_Event_Mouse_Button));
168 if (!e)
169 return;
170
171 e->timestamp = current;
172 e->window = (Ecore_Window)dev->window;
173 e->event_window = (Ecore_Window)dev->window;
174 e->root_window = (Ecore_Window)dev->window;
175 e->same_screen = 1;
176
177 e->modifiers = 0;
178 if (dev->keyboard.shift)
179 e->modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
180 if (dev->keyboard.ctrl) e->modifiers |= ECORE_EVENT_MODIFIER_CTRL;
181 if (dev->keyboard.alt) e->modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
182 if (dev->keyboard.lock) e->modifiers |= ECORE_EVENT_LOCK_CAPS;
183
184 e->x = dev->mouse.x;
185 e->y = dev->mouse.y;
186 e->root.x = e->x;
187 e->root.y = e->y;
188 e->buttons = button;
189
190 if (dev->mouse.did_double)
191 e->double_click = 1;
192 if (dev->mouse.did_triple)
193 e->triple_click = 1;
194
195 if (iev->value)
196 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, e, NULL, NULL);
197 else
198 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, e, NULL, NULL);
199 }
200}
201
202static void
203_ecore_fb_li_device_event_rel(Ecore_Fb_Input_Device *dev, struct input_event *iev)
204{
205 if (!dev->listen) return;
206 /* dispatch the button events if they are queued */
207 switch (iev->code)
208 {
209 case REL_X:
210 case REL_Y:
211 {
212 Ecore_Event_Mouse_Move *e;
213 if(iev->code == REL_X)
214 {
215 dev->mouse.x += iev->value;
216 if(dev->mouse.x > dev->mouse.w - 1)
217 dev->mouse.x = dev->mouse.w;
218 else if(dev->mouse.x < 0)
219 dev->mouse.x = 0;
220 }
221 else
222 {
223 dev->mouse.y += iev->value;
224 if(dev->mouse.y > dev->mouse.h - 1)
225 dev->mouse.y = dev->mouse.h;
226 else if(dev->mouse.y < 0)
227 dev->mouse.y = 0;
228 }
229
230 e = calloc(1, sizeof(Ecore_Event_Mouse_Move));
231 if (!e)
232 return;
233
234 e->window = (Ecore_Window)dev->window;
235 e->event_window = (Ecore_Window)dev->window;
236 e->root_window = (Ecore_Window)dev->window;
237 e->same_screen = 1;
238
239 e->modifiers = 0;
240 if (dev->keyboard.shift) e->modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
241 if (dev->keyboard.ctrl) e->modifiers |= ECORE_EVENT_MODIFIER_CTRL;
242 if (dev->keyboard.alt) e->modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
243 if (dev->keyboard.lock) e->modifiers |= ECORE_EVENT_LOCK_CAPS;
244
245 e->x = dev->mouse.x;
246 e->y = dev->mouse.y;
247 e->root.x = e->x;
248 e->root.y = e->y;
249
250 e->timestamp = ecore_time_get();
251
252 ecore_event_add(ECORE_EVENT_MOUSE_MOVE, e, NULL, NULL);
253
254 break;
255 }
256 case REL_WHEEL:
257 case REL_HWHEEL:
258 {
259 Ecore_Event_Mouse_Wheel *e;
260
261 e = calloc(1, sizeof(Ecore_Event_Mouse_Wheel));
262 if (!e)
263 return;
264
265 e->x = dev->mouse.x;
266 e->y = dev->mouse.y;
267 if (iev->code == REL_HWHEEL) e->direction = 1;
268 e->z = iev->value;
269 e->root.x = dev->mouse.x;
270 e->root.y = dev->mouse.y;
271
272 e->window = (Ecore_Window)dev->window;
273 e->event_window = (Ecore_Window)dev->window;
274 e->root_window = (Ecore_Window)dev->window;
275 e->same_screen = 1;
276
277 e->modifiers = 0;
278 if (dev->keyboard.shift) e->modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
279 if (dev->keyboard.ctrl) e->modifiers |= ECORE_EVENT_MODIFIER_CTRL;
280 if (dev->keyboard.alt) e->modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
281 if (dev->keyboard.lock) e->modifiers |= ECORE_EVENT_LOCK_CAPS;
282
283 e->timestamp = ecore_time_get();
284
285 ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, e, NULL, NULL);
286
287 break;
288 }
289 default:
290 break;
291 }
292}
293
294static void
295_ecore_fb_li_device_event_abs(Ecore_Fb_Input_Device *dev, struct input_event *iev)
296{
297 static int prev_pressure = 0;
298 int pressure;
299
300 if (!dev->listen) return;
301 switch (iev->code)
302 {
303 case ABS_X:
304 if (dev->mouse.w != 0)
305 {
306 int tmp;
307
308 tmp = (int)((double)(iev->value - dev->mouse.min_w) / dev->mouse.rel_w);
309 if (tmp < 0) dev->mouse.x = 0;
310 else if (tmp > dev->mouse.w) dev->mouse.x = dev->mouse.w;
311 else dev->mouse.x = tmp;
312 dev->mouse.event = ECORE_EVENT_MOUSE_MOVE;
313 }
314 break;
315
316 case ABS_Y:
317 if(dev->mouse.h != 0)
318 {
319 int tmp;
320
321 tmp = (int)((double)(iev->value - dev->mouse.min_h) / dev->mouse.rel_h);
322 if (tmp < 0) dev->mouse.y = 0;
323 else if (tmp > dev->mouse.h) dev->mouse.y = dev->mouse.h;
324 else dev->mouse.y = tmp;
325 dev->mouse.event = ECORE_EVENT_MOUSE_MOVE;
326 }
327 break;
328
329 case ABS_PRESSURE:
330 pressure = iev->value;
331 if ((pressure) && (!prev_pressure))
332 {
333 /* DOWN: mouse is down, but was not before */
334 dev->mouse.event = ECORE_EVENT_MOUSE_BUTTON_DOWN;
335 }
336 else if ((!pressure) && (prev_pressure))
337 {
338 /* UP: mouse was down, but is not now */
339 dev->mouse.event = ECORE_EVENT_MOUSE_BUTTON_UP;
340 }
341 prev_pressure = pressure;
342 break;
343 }
344}
345
346static void
347_ecore_fb_li_device_event_syn(Ecore_Fb_Input_Device *dev, struct input_event *iev __UNUSED__)
348{
349 if (!dev->listen) return;
350
351 if (dev->mouse.event == ECORE_EVENT_MOUSE_MOVE)
352 {
353 Ecore_Event_Mouse_Move *ev;
354 ev = calloc(1,sizeof(Ecore_Event_Mouse_Move));
355 ev->x = dev->mouse.x;
356 ev->y = dev->mouse.y;
357 ev->root.x = ev->x;
358 ev->root.y = ev->y;
359 ev->timestamp = ecore_time_get();
360 }
361 else if (dev->mouse.event == ECORE_EVENT_MOUSE_BUTTON_DOWN)
362 {
363 Ecore_Event_Mouse_Button *ev;
364 ev = calloc(1, sizeof(Ecore_Event_Mouse_Button));
365 ev->x = dev->mouse.x;
366 ev->y = dev->mouse.y;
367 ev->root.x = ev->x;
368 ev->root.y = ev->y;
369 ev->buttons = 1;
370 ev->timestamp = ecore_time_get();
371 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, ev, NULL, NULL);
372 }
373 else if (dev->mouse.event == ECORE_EVENT_MOUSE_BUTTON_UP)
374 {
375 Ecore_Event_Mouse_Button *ev;
376 ev = calloc(1, sizeof(Ecore_Event_Mouse_Button));
377 ev->x = dev->mouse.x;
378 ev->y = dev->mouse.y;
379 ev->root.x = ev->x;
380 ev->root.y = ev->y;
381 ev->buttons = 1;
382 ev->timestamp = ecore_time_get();
383 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev, NULL, NULL);
384 }
385}
386
387static Eina_Bool
388_ecore_fb_li_device_fd_callback(void *data, Ecore_Fd_Handler *fdh __UNUSED__)
389{
390 Ecore_Fb_Input_Device *dev;
391 struct input_event ev[64];
392 int len;
393 int i;
394
395 dev = (Ecore_Fb_Input_Device*)data;
396 /* read up to 64 events at once */
397 len = read(dev->fd, &ev, sizeof(ev));
398 for(i = 0; i < (int)(len / sizeof(ev[0])); i++)
399 {
400 switch(ev[i].type)
401 {
402 case EV_SYN:
403 _ecore_fb_li_device_event_syn(dev, &ev[i]);
404 break;
405 case EV_ABS:
406 _ecore_fb_li_device_event_abs(dev, &ev[i]);
407 break;
408 case EV_REL:
409 _ecore_fb_li_device_event_rel(dev, &ev[i]);
410 break;
411 case EV_KEY:
412 _ecore_fb_li_device_event_key(dev, &ev[i]);
413 break;
414 default:
415 break;
416 }
417 }
418 return EINA_TRUE;
419}
420
421/**
422 * @addtogroup Ecore_FB_Group Ecore_FB - Frame buffer convenience functions.
423 *
424 * @{
425 */
426
427/**
428 * @brief Set the listen mode for an input device .
429 *
430 * @param dev The device to set the mode of.
431 * @param listen EINA_FALSE to disable listening mode, EINA_TRUE to enable it.
432 *
433 * This function enables or disables listening on the input device @p
434 * dev. If @p listen is #EINA_FALSE, listening mode is disabled, if it
435 * is #EINA_TRUE, it is enabled.
436 */
437EAPI void
438ecore_fb_input_device_listen(Ecore_Fb_Input_Device *dev, Eina_Bool listen)
439{
440 if (!dev) return;
441 if ((listen && dev->listen) || (!listen && !dev->listen)) return;
442 if (listen)
443 {
444 /* if the device already had a handler */
445 if (!dev->handler)
446 dev->handler = ecore_main_fd_handler_add(dev->fd, ECORE_FD_READ, _ecore_fb_li_device_fd_callback, dev, NULL, NULL);
447
448 }
449 dev->listen = listen;
450}
451
452#ifndef EV_CNT
453# define EV_CNT (EV_MAX+1)
454#endif
455
456/**
457 * @brief Associates an input device with the given @ref Ecore_Evas_Group.
458 *
459 * @param dev The input being associated with an @ref Ecore_Evas_Group (not @c NULL).
460 * @param window The window which this input is being associated to.
461 * @c NULL will remove any previous association.
462 *
463 * Events generated by this device will have a pointer to @p window. If this @p
464 * window is registered with ecore_event_window_register() or
465 * ecore_evas_input_event_register(), respective evas events will be delivered
466 * by the ecore_input_evas system. An example can be seen in the following code:
467 *
468 * @code
469 * Ecore_Evas *ee = ecore_evas_new(NULL, 0, 0, 800, 600, NULL);
470 *
471 * ecore_evas_input_event_register(ee);
472 *
473 * device = ecore_fb_input_device_open(device_path);
474 * if (device)
475 * ecore_fb_input_device_window_set(device, ee);
476 *
477 * @endcode
478 *
479 * On the previous code, all input captured on the mentioned device will be
480 * delivered to the @c Ecore_Evas @c ee.
481 *
482 * @since 1.1
483 */
484EAPI void
485ecore_fb_input_device_window_set(Ecore_Fb_Input_Device *dev, void *window)
486{
487 if (!dev) return;
488
489 dev->window = window;
490}
491
492/**
493 * @brief Open an input device.
494 *
495 * @param dev The device to open.
496 * @return The @ref Ecore_Fb_Input_Device object that has been opened.
497 *
498 * This function opens the input device named @p dev and returns the
499 * object for it, or returns @c NULL on failure.
500 */
501EAPI Ecore_Fb_Input_Device *
502ecore_fb_input_device_open(const char *dev)
503{
504 Ecore_Fb_Input_Device *device;
505 unsigned long event_type_bitmask[EV_CNT / 32 + 1];
506 int event_type;
507 int fd;
508
509 if (!dev) return NULL;
510 device = calloc(1, sizeof(Ecore_Fb_Input_Device));
511 if (!device) return NULL;
512
513 if ((fd = open(dev, O_RDONLY, O_NONBLOCK)) < 0)
514 {
515 fprintf(stderr, "[ecore_fb_li:device_open] %s %s", dev, strerror(errno));
516 goto error_open;
517 }
518 /* query capabilities */
519 if (ioctl(fd, EVIOCGBIT(0, EV_MAX), event_type_bitmask) < 0)
520 {
521 fprintf(stderr,"[ecore_fb_li:device_open] query capabilities %s %s", dev, strerror(errno));
522 goto error_caps;
523 }
524 /* query name */
525 device->info.name = calloc(256, sizeof(char));
526 if (ioctl(fd, EVIOCGNAME(sizeof(char) * 256), device->info.name) < 0)
527 {
528 fprintf(stderr, "[ecore_fb_li:device_open] get name %s %s", dev, strerror(errno));
529 strcpy(device->info.name, "Unknown");
530 }
531 device->fd = fd;
532 device->info.dev = strdup(dev);
533 /* common */
534 device->mouse.threshold = CLICK_THRESHOLD_DEFAULT;
535
536 /* set info */
537 for (event_type = 0; event_type < EV_MAX; event_type++)
538 {
539 if(!test_bit(event_type, event_type_bitmask))
540 continue;
541 switch (event_type)
542 {
543 case EV_SYN:
544 break;
545 case EV_KEY:
546 device->info.cap |= ECORE_FB_INPUT_DEVICE_CAP_KEYS_OR_BUTTONS;
547 break;
548 case EV_REL:
549 device->info.cap |= ECORE_FB_INPUT_DEVICE_CAP_RELATIVE;
550 break;
551 case EV_ABS:
552 device->info.cap |= ECORE_FB_INPUT_DEVICE_CAP_ABSOLUTE;
553 break;
554 case EV_MSC:
555 case EV_LED:
556 case EV_SND:
557 case EV_REP:
558 case EV_FF :
559 case EV_FF_STATUS:
560 case EV_PWR:
561 default:
562 break;
563 }
564 }
565
566 _ecore_fb_li_devices = eina_list_append(_ecore_fb_li_devices, device);
567 return device;
568
569error_caps:
570 close(fd);
571error_open:
572 free(device);
573 return NULL;
574}
575
576/**
577 * @brief Close the given device.
578 *
579 * @param dev The device to close
580 *
581 * This function closes the device @p dev. If @p dev is @c NULL, this
582 * function does nothing.
583 */
584EAPI void
585ecore_fb_input_device_close(Ecore_Fb_Input_Device *dev)
586{
587 if (!dev || dev->fd < 0) return;
588 /* close the fd */
589 close(dev->fd);
590 /* remove the element from the list */
591 _ecore_fb_li_devices = eina_list_remove(_ecore_fb_li_devices, dev);
592 free(dev);
593}
594
595
596/**
597 * @brief Set the axis size of the given device.
598 *
599 * @param dev The device to set the axis size to.
600 * @param w The width of the axis.
601 * @param h The height of the axis.
602 *
603 * This function sets set the width @p w and height @p h of the axis
604 * of device @p dev. If @p dev is a relative input device, a width and
605 * height must set for it. If its absolute set the ioctl correctly, if
606 * not, unsupported device.
607 */
608EAPI void
609ecore_fb_input_device_axis_size_set(Ecore_Fb_Input_Device *dev, int w, int h)
610{
611 if (!dev) return;
612 if ((w < 0) || (h < 0)) return;
613 /* FIXME
614 * this code is for a touchscreen device,
615 * make it configurable (ABSOLUTE | RELATIVE)
616 */
617 if (dev->info.cap & ECORE_FB_INPUT_DEVICE_CAP_ABSOLUTE)
618 {
619 /* FIXME looks like some kernels dont include this struct */
620 struct input_absinfo abs_features;
621
622 ioctl(dev->fd, EVIOCGABS(ABS_X), &abs_features);
623 dev->mouse.min_w = abs_features.minimum;
624 dev->mouse.rel_w = (double)(abs_features.maximum - abs_features.minimum)/(double)(w);
625
626 ioctl(dev->fd, EVIOCGABS(ABS_Y), &abs_features);
627 dev->mouse.min_h = abs_features.minimum;
628 dev->mouse.rel_h = (double)(abs_features.maximum - abs_features.minimum)/(double)(h);
629 }
630 else if (!(dev->info.cap & ECORE_FB_INPUT_DEVICE_CAP_RELATIVE))
631 return;
632
633 /* update the local values */
634 if (dev->mouse.x > w - 1) dev->mouse.x = w -1;
635 if (dev->mouse.y > h - 1) dev->mouse.y = h -1;
636 dev->mouse.w = w;
637 dev->mouse.h = h;
638}
639
640/**
641 * @brief Retrieve the name of the given device.
642 *
643 * @param dev The device to get the name from.
644 * @return The name of the device.
645 *
646 * This function returns the name of the device @p dev. If @p dev is
647 * @c NULL, this function returns @c NULL.
648 */
649EAPI const char *
650ecore_fb_input_device_name_get(Ecore_Fb_Input_Device *dev)
651{
652 if (!dev) return NULL;
653 return dev->info.name;
654}
655
656/**
657 * @brief Retrieve the capability of the given device.
658 *
659 * @param dev The device to get the name from.
660 * @return The capability of the device.
661 *
662 * This function returns the capability of the device @p dev. If @p dev is
663 * @c NULL, this function returns #ECORE_FB_INPUT_DEVICE_CAP_NONE.
664 */
665EAPI Ecore_Fb_Input_Device_Cap
666ecore_fb_input_device_cap_get(Ecore_Fb_Input_Device *dev)
667{
668 if (!dev) return ECORE_FB_INPUT_DEVICE_CAP_NONE;
669 return dev->info.cap;
670}
671
672/**
673 * @brief Set the threshold of mouse clicks of the given device.
674 *
675 * @param dev The device to set the threshodl mouse click to.
676 * @param threshold The threshold value.
677 *
678 * This function sets the threshold of mouse clicks of the device
679 * @p dev to @p threshold. If @p dev is @c NULL, this function does
680 * nothing.
681 */
682EAPI void
683ecore_fb_input_device_threshold_click_set(Ecore_Fb_Input_Device *dev, double threshold)
684{
685 if (!dev) return;
686 if ((threshold == dev->mouse.threshold) || (threshold == 0)) return;
687 dev->mouse.threshold = threshold;
688}
689
690/**
691 * @brief Get the threshold of mouse clicks of the given device.
692 *
693 * @param dev The device to set the threshodl mouse click from.
694 * @return The threshold value.
695 *
696 * This function returns the threshold of mouse clicks of the device
697 * @p dev. If @p dev is @c NULL, this function returns 0.0.
698 */
699EAPI double
700ecore_fb_input_device_threshold_click_get(Ecore_Fb_Input_Device *dev)
701{
702 if (!dev) return 0;
703 return dev->mouse.threshold;
704}
705
706/**
707 * @}
708 */