2006-07-30 21:13:51 -07:00
|
|
|
typedef struct _Ecore_Fb_Ps2_Event Ecore_Fb_Ps2_Event;
|
|
|
|
struct _Ecore_Fb_Ps2_Event
|
|
|
|
{
|
|
|
|
unsigned char button;
|
|
|
|
unsigned char x;
|
|
|
|
unsigned char y;
|
|
|
|
unsigned char z;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int _ecore_fb_ps2_event_byte_count = 0;
|
|
|
|
static Ecore_Fb_Ps2_Event _ecore_fb_ps2_event;
|
|
|
|
static int _ecore_fb_ps2_fd = 0;
|
Fix callback signatures
The change from returning int to Eina_Bool left several call sites with
warnings because they were not updated. Here they are fixed by using
Coccinelle, a tool that allows us to automate tasks like that. This
commit was generated from the following semantic patch:
virtual org
@r1@
identifier fn!=NULL, fn2;
expression E1, E2, E3;
@@
(
ecore_event_handler_add(E1, fn, ...)
|
ecore_event_filter_add(E1, fn, ...)
|
ecore_idler_add(fn, ...)
|
ecore_idle_enterer_add(E1, fn, ...)
|
ecore_idle_enterer_before_add(E1, fn, ...)
|
ecore_idle_exiter_add(E1, fn, ...)
|
ecore_main_fd_handler_add(E1, E2, fn, E3, fn2, ...)
|
ecore_main_win32_handler_add(E1, fn, ...)
|
ecore_timer_add(E1, fn, ...)
|
ecore_timer_loop_add(E1, fn, ...)
|
ecore_animator_add(fn, ...)
|
ecore_poller_add(E1, E2, fn, ...)
)
@r2@
identifier r1.fn;
identifier ret;
typedef Eina_Bool;
position p;
@@
- int
+ Eina_Bool
fn@p(...) {
<...
(
- return 1;
+ return EINA_TRUE;
|
- return 0;
+ return EINA_FALSE;
|
- int
+ Eina_Bool
ret;
...
return <+...ret...+>;
|
return ...;
)
...>
}
@r3@
identifier r1.fn2;
identifier ret;
position p;
@@
- int
+ Eina_Bool
fn2@p(...) {
...
(
- return 1;
+ return EINA_TRUE;
|
- return 0;
+ return EINA_FALSE;
|
- int
+ Eina_Bool
ret;
...
return <+...ret...+>;
|
return ...;
)
...
}
@r4@
identifier r1.fn;
@@
- int
+ Eina_Bool
fn(...);
@r5@
identifier r1.fn2;
@@
- int
+ Eina_Bool
fn2(...);
@script:python depends on org@
p << r2.p;
f << r1.fn;
@@
import sys
msg="WARNING: wrong callback %s! ( %s:%s )" % (f, p[0].file,p[0].line)
print >> sys.stderr, msg
@script:python depends on org@
p << r3.p;
f << r1.fn2;
@@
import sys
msg="WARNING: wrong callback %s! ( %s:%s )" % (f, p[0].file,p[0].line)
print >> sys.stderr, msg
SVN revision: 49985
2010-07-01 18:38:05 -07:00
|
|
|
static Eina_Bool _ecore_fb_ps2_fd_handler(void *data, Ecore_Fd_Handler *fd_handler);
|
2006-07-30 21:13:51 -07:00
|
|
|
|
|
|
|
int
|
|
|
|
ecore_fb_ps2_init(void)
|
|
|
|
{
|
|
|
|
_ecore_fb_ps2_fd = open("/dev/psaux", O_RDWR);
|
|
|
|
if (_ecore_fb_ps2_fd >= 0)
|
|
|
|
{
|
2010-09-30 00:24:46 -07:00
|
|
|
prev_flags = fcntl(_ecore_fb_ps2_fd, F_GETFL);
|
2010-09-18 20:26:59 -07:00
|
|
|
fcntl(_ecore_fb_ps2_fd, F_SETFL, prev_flags | O_NONBLOCK);
|
2011-04-20 07:15:33 -07:00
|
|
|
_ecore_fb_ts_fd_handler_handle = ecore_main_fd_handler_add(_ecore_fb_ps2_fd,
|
2010-09-18 20:26:59 -07:00
|
|
|
ECORE_FD_READ,
|
2010-09-30 00:24:46 -07:00
|
|
|
_ecore_fb_ps2_fd_handler, NULL, NULL, NULL);
|
|
|
|
if (!_ecore_fb_ts_fd_handler_handle)
|
2010-09-18 20:26:59 -07:00
|
|
|
{
|
|
|
|
close(_ecore_fb_ps2_fd);
|
|
|
|
return 0;
|
|
|
|
}
|
2010-09-30 00:24:46 -07:00
|
|
|
return 1;
|
2006-07-30 21:13:51 -07:00
|
|
|
}
|
2011-04-20 07:15:33 -07:00
|
|
|
return 0;
|
2006-07-30 21:13:51 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ecore_fb_ps2_shutdown(void)
|
|
|
|
{
|
|
|
|
if (_ecore_fb_ps2_fd > 0) close(_ecore_fb_ps2_fd);
|
|
|
|
_ecore_fb_ps2_fd = 0;
|
|
|
|
}
|
|
|
|
|
2010-07-05 17:08:52 -07:00
|
|
|
static Eina_Bool
|
2012-11-25 01:55:32 -08:00
|
|
|
_ecore_fb_ps2_fd_handler(void *data EINA_UNUSED, Ecore_Fd_Handler *fd_handler EINA_UNUSED)
|
2006-07-30 21:13:51 -07:00
|
|
|
{
|
|
|
|
static int prev_x = 0, prev_y = 0, prev_button = 0;
|
|
|
|
static double last_time = 0;
|
|
|
|
static double last_last_time = 0;
|
|
|
|
int v = 0;
|
2011-04-20 07:15:33 -07:00
|
|
|
|
2006-07-30 21:13:51 -07:00
|
|
|
do
|
|
|
|
{
|
2010-09-30 00:24:46 -07:00
|
|
|
int x, y, button, i;
|
|
|
|
int num;
|
|
|
|
char *ptr;
|
|
|
|
double t;
|
2010-10-04 02:02:43 -07:00
|
|
|
static int did_double = 0;
|
|
|
|
static int did_triple = 0;
|
2011-04-20 07:15:33 -07:00
|
|
|
|
2010-09-30 00:24:46 -07:00
|
|
|
ptr = (char *)&(_ecore_fb_ps2_event);
|
|
|
|
ptr += _ecore_fb_ps2_event_byte_count;
|
|
|
|
num = sizeof(Ecore_Fb_Ps2_Event) - _ecore_fb_ps2_event_byte_count;
|
|
|
|
v = read(_ecore_fb_ps2_fd, ptr, num);
|
|
|
|
if (v < 0) return EINA_TRUE;
|
|
|
|
_ecore_fb_ps2_event_byte_count += v;
|
|
|
|
if (v < num) return EINA_TRUE;
|
2012-03-28 22:57:41 -07:00
|
|
|
t = ecore_loop_time_get();
|
2010-09-30 00:24:46 -07:00
|
|
|
_ecore_fb_ps2_event_byte_count = 0;
|
|
|
|
if (_ecore_fb_ps2_event.button & 0x10)
|
2010-09-18 20:26:59 -07:00
|
|
|
x = prev_x + (0xffffff00 | _ecore_fb_ps2_event.x);
|
2010-09-30 00:24:46 -07:00
|
|
|
else
|
2010-09-18 20:26:59 -07:00
|
|
|
x = prev_x + _ecore_fb_ps2_event.x;
|
2010-09-30 00:24:46 -07:00
|
|
|
if (_ecore_fb_ps2_event.button & 0x20)
|
2010-09-18 20:26:59 -07:00
|
|
|
y = prev_y - (0xffffff00 | _ecore_fb_ps2_event.y);
|
2010-09-30 00:24:46 -07:00
|
|
|
else
|
2010-09-18 20:26:59 -07:00
|
|
|
y = prev_y - _ecore_fb_ps2_event.y;
|
2010-09-30 00:24:46 -07:00
|
|
|
button = _ecore_fb_ps2_event.button & 0x7;
|
|
|
|
if (x < 0) x = 0;
|
|
|
|
if (y < 0) y = 0;
|
|
|
|
if (x >= _ecore_fb_console_w) x = _ecore_fb_console_w - 1;
|
|
|
|
if (y >= _ecore_fb_console_h) y = _ecore_fb_console_h - 1;
|
|
|
|
/* add event to queue */
|
|
|
|
/* always add a move event */
|
|
|
|
if (1)
|
|
|
|
{
|
|
|
|
/* MOVE: mouse is down and was */
|
2012-03-28 22:57:41 -07:00
|
|
|
Ecore_Event_Mouse_Move *e;
|
2011-04-20 07:15:33 -07:00
|
|
|
|
2010-09-30 00:24:46 -07:00
|
|
|
e = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Move));
|
|
|
|
if (!e) goto retry;
|
|
|
|
e->x = x;
|
|
|
|
e->y = y;
|
2012-03-28 22:57:41 -07:00
|
|
|
e->root.x = e->x;
|
|
|
|
e->root.y = e->y;
|
|
|
|
e->window = 1;
|
|
|
|
e->event_window = e->window;
|
|
|
|
e->root_window = e->window;
|
|
|
|
e->same_screen = 1;
|
|
|
|
e->timestamp = ecore_loop_time_get() * 1000.0;
|
|
|
|
ecore_event_add(ECORE_EVENT_MOUSE_MOVE, e, NULL, NULL);
|
2010-09-30 00:24:46 -07:00
|
|
|
}
|
|
|
|
for (i = 1; i <= 3; i++)
|
|
|
|
{
|
|
|
|
int mask;
|
2011-04-20 07:15:33 -07:00
|
|
|
|
2010-09-30 00:24:46 -07:00
|
|
|
mask = 1 << (i - 1);
|
|
|
|
if (((button & mask)) && (!(prev_button & mask)))
|
|
|
|
{
|
|
|
|
/* DOWN: mouse is down, but was not now */
|
2012-03-28 22:57:41 -07:00
|
|
|
Ecore_Event_Mouse_Button *e;
|
2011-04-20 07:15:33 -07:00
|
|
|
|
2012-03-28 22:57:41 -07:00
|
|
|
e = calloc(1, sizeof(Ecore_Event_Mouse_Button));
|
2010-09-30 00:24:46 -07:00
|
|
|
if (!e) goto retry;
|
|
|
|
e->x = x;
|
|
|
|
e->y = y;
|
2012-03-28 22:57:41 -07:00
|
|
|
e->root.x = e->x;
|
|
|
|
e->root.y = e->y;
|
2010-10-04 02:02:43 -07:00
|
|
|
e->button = i;
|
2012-03-28 22:57:41 -07:00
|
|
|
e->window = 1;
|
|
|
|
e->event_window = e->window;
|
|
|
|
e->root_window = e->window;
|
|
|
|
e->same_screen = 1;
|
2010-09-30 00:24:46 -07:00
|
|
|
if ((t - last_time) <= _ecore_fb_double_click_time)
|
2010-10-04 02:02:43 -07:00
|
|
|
{
|
|
|
|
e->double_click = 1;
|
|
|
|
did_double = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
did_double = 0;
|
|
|
|
did_triple = 0;
|
|
|
|
}
|
2010-09-30 00:24:46 -07:00
|
|
|
if ((t - last_last_time) <= (2 * _ecore_fb_double_click_time))
|
|
|
|
{
|
|
|
|
did_triple = 1;
|
|
|
|
e->triple_click = 1;
|
|
|
|
}
|
2010-10-04 02:02:43 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
did_triple = 0;
|
|
|
|
}
|
2012-03-28 22:57:41 -07:00
|
|
|
e->timestamp = ecore_loop_time_get() * 1000.0;
|
|
|
|
ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, e, NULL, NULL);
|
2010-09-30 00:24:46 -07:00
|
|
|
}
|
|
|
|
else if ((!(button & mask)) && ((prev_button & mask)))
|
|
|
|
{
|
|
|
|
/* UP: mouse was down, but is not now */
|
2012-03-28 22:57:41 -07:00
|
|
|
Ecore_Event_Mouse_Button *e;
|
2011-04-20 07:15:33 -07:00
|
|
|
|
2012-03-28 22:57:41 -07:00
|
|
|
e = calloc(1, sizeof(Ecore_Event_Mouse_Button));
|
2010-09-30 00:24:46 -07:00
|
|
|
if (!e) goto retry;
|
|
|
|
e->x = x;
|
|
|
|
e->y = y;
|
2012-03-28 22:57:41 -07:00
|
|
|
e->root.x = e->x;
|
|
|
|
e->root.y = e->y;
|
2010-10-04 02:02:43 -07:00
|
|
|
e->button = i;
|
2012-03-28 22:57:41 -07:00
|
|
|
e->window = 1;
|
|
|
|
e->event_window = e->window;
|
|
|
|
e->root_window = e->window;
|
|
|
|
e->same_screen = 1;
|
2010-10-04 02:02:43 -07:00
|
|
|
if (did_double)
|
|
|
|
e->double_click = 1;
|
|
|
|
if (did_triple)
|
|
|
|
e->triple_click = 1;
|
2012-03-28 22:57:41 -07:00
|
|
|
e->timestamp = ecore_loop_time_get() * 1000.0;
|
|
|
|
ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, e, NULL, NULL);
|
2010-09-30 00:24:46 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (did_triple)
|
|
|
|
{
|
|
|
|
last_time = 0;
|
|
|
|
last_last_time = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
last_last_time = last_time;
|
|
|
|
last_time = t;
|
|
|
|
}
|
2011-04-20 07:15:33 -07:00
|
|
|
retry:
|
2010-09-30 00:24:46 -07:00
|
|
|
prev_x = x;
|
|
|
|
prev_y = y;
|
|
|
|
prev_button = button;
|
2006-07-30 21:13:51 -07:00
|
|
|
}
|
|
|
|
while (v > 0);
|
2010-07-05 17:08:52 -07:00
|
|
|
return EINA_TRUE;
|
2006-07-30 21:13:51 -07:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @defgroup Ecore_FB_Click_Group Framebuffer Double Click Functions
|
|
|
|
*
|
|
|
|
* Functions that deal with the double click time of the framebuffer.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the timeout for a double and triple clicks to be flagged.
|
2011-04-20 07:15:33 -07:00
|
|
|
*
|
2006-07-30 21:13:51 -07:00
|
|
|
* This sets the time between clicks before the double_click flag is
|
|
|
|
* set in a button down event. If 3 clicks occur within double this
|
|
|
|
* time, the triple_click flag is also set.
|
|
|
|
*
|
|
|
|
* @param t The time in seconds
|
|
|
|
* @ingroup Ecore_FB_Click_Group
|
|
|
|
*/
|
|
|
|
EAPI void
|
|
|
|
ecore_fb_double_click_time_set(double t)
|
|
|
|
{
|
|
|
|
if (t < 0.0) t = 0.0;
|
|
|
|
_ecore_fb_double_click_time = t;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves the double and triple click flag timeout.
|
|
|
|
*
|
|
|
|
* See @ref ecore_x_double_click_time_set for more information.
|
|
|
|
*
|
|
|
|
* @return The timeout for double clicks in seconds.
|
|
|
|
* @ingroup Ecore_FB_Click_Group
|
|
|
|
*/
|
|
|
|
EAPI double
|
|
|
|
ecore_fb_double_click_time_get(void)
|
|
|
|
{
|
|
|
|
return _ecore_fb_double_click_time;
|
|
|
|
}
|
|
|
|
|