2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "osdep/timer.h"
23 #include "input/input.h"
24 #include "input/keycodes.h"
32 struct input_ctx
*input
;
34 unsigned last_down_time
;
37 struct mp_fifo
*mp_fifo_create(struct input_ctx
*input
, struct MPOpts
*opts
)
39 struct mp_fifo
*fifo
= talloc_zero(NULL
, struct mp_fifo
);
45 static void put_double(struct mp_fifo
*fifo
, int code
)
47 if (code
>= MOUSE_BTN0
&& code
< MOUSE_BTN_END
)
48 mp_input_feed_key(fifo
->input
, code
- MOUSE_BTN0
+ MOUSE_BTN0_DBL
);
51 void mplayer_put_key(struct mp_fifo
*fifo
, int code
)
53 unsigned now
= GetTimerMS();
54 int doubleclick_time
= fifo
->opts
->doubleclick_time
;
55 // ignore system-doubleclick if we generate these events ourselves
57 && (code
& ~MP_KEY_DOWN
) >= MOUSE_BTN0_DBL
58 && (code
& ~MP_KEY_DOWN
) < MOUSE_BTN_DBL_END
)
60 mp_input_feed_key(fifo
->input
, code
);
61 if (code
& MP_KEY_DOWN
) {
63 if (fifo
->last_key_down
== code
64 && now
- fifo
->last_down_time
< doubleclick_time
)
65 put_double(fifo
, code
);
66 fifo
->last_key_down
= code
;
67 fifo
->last_down_time
= now
;