2011-04-25 06:43:59 +00:00
|
|
|
/*
|
2015-04-13 07:36:54 +00:00
|
|
|
* This file is part of mpv.
|
2011-04-25 06:43:59 +00:00
|
|
|
*
|
2017-06-20 17:58:29 +00:00
|
|
|
* mpv is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2011-04-25 06:43:59 +00:00
|
|
|
*
|
2015-04-13 07:36:54 +00:00
|
|
|
* mpv is distributed in the hope that it will be useful,
|
2011-04-25 06:43:59 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2017-06-20 17:58:29 +00:00
|
|
|
* GNU Lesser General Public License for more details.
|
2011-04-25 06:43:59 +00:00
|
|
|
*
|
2017-06-20 17:58:29 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
2011-04-25 06:43:59 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MPLAYER_KEYCODES_H
|
|
|
|
#define MPLAYER_KEYCODES_H
|
|
|
|
|
2014-05-09 19:49:25 +00:00
|
|
|
// Keys in the range [0, MP_KEY_BASE) follow unicode.
|
2013-12-26 16:10:35 +00:00
|
|
|
// Special keys come after this.
|
2012-01-14 13:09:26 +00:00
|
|
|
#define MP_KEY_BASE (1<<21)
|
|
|
|
|
2013-02-12 00:34:04 +00:00
|
|
|
#define MP_KEY_ENTER 13
|
|
|
|
#define MP_KEY_TAB 9
|
2011-04-25 06:43:59 +00:00
|
|
|
|
|
|
|
/* Control keys */
|
2013-09-01 17:36:19 +00:00
|
|
|
#define MP_KEY_BACKSPACE (MP_KEY_BASE+0)
|
|
|
|
#define MP_KEY_DELETE (MP_KEY_BASE+1)
|
|
|
|
#define MP_KEY_INSERT (MP_KEY_BASE+2)
|
|
|
|
#define MP_KEY_HOME (MP_KEY_BASE+3)
|
|
|
|
#define MP_KEY_END (MP_KEY_BASE+4)
|
|
|
|
#define MP_KEY_PAGE_UP (MP_KEY_BASE+5)
|
|
|
|
#define MP_KEY_PAGE_DOWN (MP_KEY_BASE+6)
|
|
|
|
#define MP_KEY_ESC (MP_KEY_BASE+7)
|
|
|
|
#define MP_KEY_PRINT (MP_KEY_BASE+8)
|
2011-04-25 06:43:59 +00:00
|
|
|
|
|
|
|
/* Control keys short name */
|
2013-09-01 17:36:19 +00:00
|
|
|
#define MP_KEY_BS MP_KEY_BACKSPACE
|
|
|
|
#define MP_KEY_DEL MP_KEY_DELETE
|
|
|
|
#define MP_KEY_INS MP_KEY_INSERT
|
|
|
|
#define MP_KEY_PGUP MP_KEY_PAGE_UP
|
|
|
|
#define MP_KEY_PGDOWN MP_KEY_PAGE_DOWN
|
|
|
|
#define MP_KEY_PGDWN MP_KEY_PAGE_DOWN
|
2011-04-25 06:43:59 +00:00
|
|
|
|
|
|
|
/* Cursor movement */
|
2013-09-01 17:36:19 +00:00
|
|
|
#define MP_KEY_CRSR (MP_KEY_BASE+0x10)
|
|
|
|
#define MP_KEY_RIGHT (MP_KEY_CRSR+0)
|
|
|
|
#define MP_KEY_LEFT (MP_KEY_CRSR+1)
|
|
|
|
#define MP_KEY_DOWN (MP_KEY_CRSR+2)
|
|
|
|
#define MP_KEY_UP (MP_KEY_CRSR+3)
|
2011-04-25 06:43:59 +00:00
|
|
|
|
2013-09-01 17:59:38 +00:00
|
|
|
/* Multimedia/internet keyboard/remote keys */
|
2013-09-01 17:36:19 +00:00
|
|
|
#define MP_KEY_MM_BASE (MP_KEY_BASE+0x20)
|
|
|
|
#define MP_KEY_POWER (MP_KEY_MM_BASE+0)
|
|
|
|
#define MP_KEY_MENU (MP_KEY_MM_BASE+1)
|
|
|
|
#define MP_KEY_PLAY (MP_KEY_MM_BASE+2)
|
|
|
|
#define MP_KEY_PAUSE (MP_KEY_MM_BASE+3)
|
|
|
|
#define MP_KEY_PLAYPAUSE (MP_KEY_MM_BASE+4)
|
|
|
|
#define MP_KEY_STOP (MP_KEY_MM_BASE+5)
|
|
|
|
#define MP_KEY_FORWARD (MP_KEY_MM_BASE+6)
|
|
|
|
#define MP_KEY_REWIND (MP_KEY_MM_BASE+7)
|
|
|
|
#define MP_KEY_NEXT (MP_KEY_MM_BASE+8)
|
|
|
|
#define MP_KEY_PREV (MP_KEY_MM_BASE+9)
|
|
|
|
#define MP_KEY_VOLUME_UP (MP_KEY_MM_BASE+10)
|
|
|
|
#define MP_KEY_VOLUME_DOWN (MP_KEY_MM_BASE+11)
|
|
|
|
#define MP_KEY_MUTE (MP_KEY_MM_BASE+12)
|
2013-09-01 17:59:38 +00:00
|
|
|
#define MP_KEY_HOMEPAGE (MP_KEY_MM_BASE+13)
|
|
|
|
#define MP_KEY_WWW (MP_KEY_MM_BASE+14)
|
|
|
|
#define MP_KEY_MAIL (MP_KEY_MM_BASE+15)
|
|
|
|
#define MP_KEY_FAVORITES (MP_KEY_MM_BASE+16)
|
|
|
|
#define MP_KEY_SEARCH (MP_KEY_MM_BASE+17)
|
|
|
|
#define MP_KEY_SLEEP (MP_KEY_MM_BASE+18)
|
2015-02-14 02:50:26 +00:00
|
|
|
#define MP_KEY_CANCEL (MP_KEY_MM_BASE+19)
|
2017-07-25 13:51:40 +00:00
|
|
|
#define MP_KEY_RECORD (MP_KEY_MM_BASE+20)
|
|
|
|
#define MP_KEY_CHANNEL_UP (MP_KEY_MM_BASE+21)
|
|
|
|
#define MP_KEY_CHANNEL_DOWN (MP_KEY_MM_BASE+22)
|
2011-04-25 06:43:59 +00:00
|
|
|
|
2012-01-14 13:09:26 +00:00
|
|
|
/* Function keys */
|
2013-02-12 00:34:04 +00:00
|
|
|
#define MP_KEY_F (MP_KEY_BASE+0x40)
|
2012-01-14 13:09:26 +00:00
|
|
|
|
2011-04-25 06:43:59 +00:00
|
|
|
/* Keypad keys */
|
2013-09-01 17:36:19 +00:00
|
|
|
#define MP_KEY_KEYPAD (MP_KEY_BASE+0x60)
|
|
|
|
#define MP_KEY_KP0 (MP_KEY_KEYPAD+0)
|
|
|
|
#define MP_KEY_KP1 (MP_KEY_KEYPAD+1)
|
|
|
|
#define MP_KEY_KP2 (MP_KEY_KEYPAD+2)
|
|
|
|
#define MP_KEY_KP3 (MP_KEY_KEYPAD+3)
|
|
|
|
#define MP_KEY_KP4 (MP_KEY_KEYPAD+4)
|
|
|
|
#define MP_KEY_KP5 (MP_KEY_KEYPAD+5)
|
|
|
|
#define MP_KEY_KP6 (MP_KEY_KEYPAD+6)
|
|
|
|
#define MP_KEY_KP7 (MP_KEY_KEYPAD+7)
|
|
|
|
#define MP_KEY_KP8 (MP_KEY_KEYPAD+8)
|
|
|
|
#define MP_KEY_KP9 (MP_KEY_KEYPAD+9)
|
|
|
|
#define MP_KEY_KPDEC (MP_KEY_KEYPAD+10)
|
|
|
|
#define MP_KEY_KPINS (MP_KEY_KEYPAD+11)
|
|
|
|
#define MP_KEY_KPDEL (MP_KEY_KEYPAD+12)
|
|
|
|
#define MP_KEY_KPENTER (MP_KEY_KEYPAD+13)
|
2011-04-25 06:43:59 +00:00
|
|
|
|
|
|
|
// Mouse events from VOs
|
2017-09-02 14:00:52 +00:00
|
|
|
#define MP_MBTN_BASE ((MP_KEY_BASE+0xA0)|MP_NO_REPEAT_KEY|MP_KEY_EMIT_ON_UP)
|
|
|
|
#define MP_MBTN_LEFT (MP_MBTN_BASE+0)
|
|
|
|
#define MP_MBTN_MID (MP_MBTN_BASE+1)
|
|
|
|
#define MP_MBTN_RIGHT (MP_MBTN_BASE+2)
|
|
|
|
#define MP_WHEEL_UP (MP_MBTN_BASE+3)
|
|
|
|
#define MP_WHEEL_DOWN (MP_MBTN_BASE+4)
|
|
|
|
#define MP_WHEEL_LEFT (MP_MBTN_BASE+5)
|
|
|
|
#define MP_WHEEL_RIGHT (MP_MBTN_BASE+6)
|
|
|
|
#define MP_MBTN_BACK (MP_MBTN_BASE+7)
|
|
|
|
#define MP_MBTN_FORWARD (MP_MBTN_BASE+8)
|
|
|
|
#define MP_MBTN9 (MP_MBTN_BASE+9)
|
|
|
|
#define MP_MBTN10 (MP_MBTN_BASE+10)
|
|
|
|
#define MP_MBTN11 (MP_MBTN_BASE+11)
|
|
|
|
#define MP_MBTN12 (MP_MBTN_BASE+12)
|
|
|
|
#define MP_MBTN13 (MP_MBTN_BASE+13)
|
|
|
|
#define MP_MBTN14 (MP_MBTN_BASE+14)
|
|
|
|
#define MP_MBTN15 (MP_MBTN_BASE+15)
|
|
|
|
#define MP_MBTN16 (MP_MBTN_BASE+16)
|
|
|
|
#define MP_MBTN17 (MP_MBTN_BASE+17)
|
|
|
|
#define MP_MBTN18 (MP_MBTN_BASE+18)
|
|
|
|
#define MP_MBTN19 (MP_MBTN_BASE+19)
|
|
|
|
#define MP_MBTN_END (MP_MBTN_BASE+20)
|
2013-02-12 00:34:04 +00:00
|
|
|
|
input: handle mouse movement differently
Before this commit, mouse movement events emitted a special command
("set_mouse_pos"), which was specially handled in command.c. This was
once special-cased to the dvdnav and menu code, and did nothing after
libmenu and dvdnav were removed.
Change it so that mouse movement triggers a pseudo-key ("MOUSE_MOVE"),
which then can be bound to an arbitrary command. The mouse position is
now managed in input.c. A command which actually needs the mouse
position can use either mp_input_get_mouse_pos() or mp_get_osd_mouse_pos()
to query it. The former returns raw window-space coordinates, while the
latter returns coordinates transformed to OSD- space. (Both are the same
for most VOs, except vo_xv and vo_x11, which can't render OSD in
window-space. These require extra code for mapping mouse position.)
As of this commit, there is still nothing that uses mouse movement, so
MOUSE_MOVE is mapped to "ignore" to silence warnings when moving the
mouse (much like MOUSE_BTN0).
Extend the concept of input sections. Allow multiple sections to be
active at once, and organize them as stack. Bindings from the top of
the stack are preferred to lower ones.
Each section has a mouse input section associated, inside which mouse
events are associated with the bindings. If the mouse pointer is
outside of a section's mouse area, mouse events will be dispatched to
an input section lower on the stack of active sections. This is intended
for scripting, which is to be added later. Two scripts could occupy
different areas of the screen without conflicting with each other. (If
it turns out that this mechanism is useless, we'll just remove it
again.)
2013-04-26 00:13:30 +00:00
|
|
|
#define MP_KEY_IS_MOUSE_BTN_SINGLE(code) \
|
2017-09-02 14:00:52 +00:00
|
|
|
((code) >= MP_MBTN_BASE && (code) < MP_MBTN_END)
|
|
|
|
#define MP_KEY_IS_WHEEL(code) \
|
2017-09-03 10:46:06 +00:00
|
|
|
((code) >= MP_WHEEL_UP && (code) <= MP_WHEEL_RIGHT)
|
input: handle mouse movement differently
Before this commit, mouse movement events emitted a special command
("set_mouse_pos"), which was specially handled in command.c. This was
once special-cased to the dvdnav and menu code, and did nothing after
libmenu and dvdnav were removed.
Change it so that mouse movement triggers a pseudo-key ("MOUSE_MOVE"),
which then can be bound to an arbitrary command. The mouse position is
now managed in input.c. A command which actually needs the mouse
position can use either mp_input_get_mouse_pos() or mp_get_osd_mouse_pos()
to query it. The former returns raw window-space coordinates, while the
latter returns coordinates transformed to OSD- space. (Both are the same
for most VOs, except vo_xv and vo_x11, which can't render OSD in
window-space. These require extra code for mapping mouse position.)
As of this commit, there is still nothing that uses mouse movement, so
MOUSE_MOVE is mapped to "ignore" to silence warnings when moving the
mouse (much like MOUSE_BTN0).
Extend the concept of input sections. Allow multiple sections to be
active at once, and organize them as stack. Bindings from the top of
the stack are preferred to lower ones.
Each section has a mouse input section associated, inside which mouse
events are associated with the bindings. If the mouse pointer is
outside of a section's mouse area, mouse events will be dispatched to
an input section lower on the stack of active sections. This is intended
for scripting, which is to be added later. Two scripts could occupy
different areas of the screen without conflicting with each other. (If
it turns out that this mechanism is useless, we'll just remove it
again.)
2013-04-26 00:13:30 +00:00
|
|
|
|
2017-09-02 14:00:52 +00:00
|
|
|
#define MP_MBTN_DBL_BASE ((MP_KEY_BASE+0xC0)|MP_NO_REPEAT_KEY)
|
|
|
|
#define MP_MBTN_LEFT_DBL (MP_MBTN_DBL_BASE+0)
|
|
|
|
#define MP_MBTN_MID_DBL (MP_MBTN_DBL_BASE+1)
|
|
|
|
#define MP_MBTN_RIGHT_DBL (MP_MBTN_DBL_BASE+2)
|
|
|
|
#define MP_MBTN_DBL_END (MP_MBTN_DBL_BASE+20)
|
2011-04-25 06:43:59 +00:00
|
|
|
|
input: handle mouse movement differently
Before this commit, mouse movement events emitted a special command
("set_mouse_pos"), which was specially handled in command.c. This was
once special-cased to the dvdnav and menu code, and did nothing after
libmenu and dvdnav were removed.
Change it so that mouse movement triggers a pseudo-key ("MOUSE_MOVE"),
which then can be bound to an arbitrary command. The mouse position is
now managed in input.c. A command which actually needs the mouse
position can use either mp_input_get_mouse_pos() or mp_get_osd_mouse_pos()
to query it. The former returns raw window-space coordinates, while the
latter returns coordinates transformed to OSD- space. (Both are the same
for most VOs, except vo_xv and vo_x11, which can't render OSD in
window-space. These require extra code for mapping mouse position.)
As of this commit, there is still nothing that uses mouse movement, so
MOUSE_MOVE is mapped to "ignore" to silence warnings when moving the
mouse (much like MOUSE_BTN0).
Extend the concept of input sections. Allow multiple sections to be
active at once, and organize them as stack. Bindings from the top of
the stack are preferred to lower ones.
Each section has a mouse input section associated, inside which mouse
events are associated with the bindings. If the mouse pointer is
outside of a section's mouse area, mouse events will be dispatched to
an input section lower on the stack of active sections. This is intended
for scripting, which is to be added later. Two scripts could occupy
different areas of the screen without conflicting with each other. (If
it turns out that this mechanism is useless, we'll just remove it
again.)
2013-04-26 00:13:30 +00:00
|
|
|
#define MP_KEY_IS_MOUSE_BTN_DBL(code) \
|
2017-09-02 14:00:52 +00:00
|
|
|
((code) >= MP_MBTN_DBL_BASE && (code) < MP_MBTN_DBL_END)
|
input: handle mouse movement differently
Before this commit, mouse movement events emitted a special command
("set_mouse_pos"), which was specially handled in command.c. This was
once special-cased to the dvdnav and menu code, and did nothing after
libmenu and dvdnav were removed.
Change it so that mouse movement triggers a pseudo-key ("MOUSE_MOVE"),
which then can be bound to an arbitrary command. The mouse position is
now managed in input.c. A command which actually needs the mouse
position can use either mp_input_get_mouse_pos() or mp_get_osd_mouse_pos()
to query it. The former returns raw window-space coordinates, while the
latter returns coordinates transformed to OSD- space. (Both are the same
for most VOs, except vo_xv and vo_x11, which can't render OSD in
window-space. These require extra code for mapping mouse position.)
As of this commit, there is still nothing that uses mouse movement, so
MOUSE_MOVE is mapped to "ignore" to silence warnings when moving the
mouse (much like MOUSE_BTN0).
Extend the concept of input sections. Allow multiple sections to be
active at once, and organize them as stack. Bindings from the top of
the stack are preferred to lower ones.
Each section has a mouse input section associated, inside which mouse
events are associated with the bindings. If the mouse pointer is
outside of a section's mouse area, mouse events will be dispatched to
an input section lower on the stack of active sections. This is intended
for scripting, which is to be added later. Two scripts could occupy
different areas of the screen without conflicting with each other. (If
it turns out that this mechanism is useless, we'll just remove it
again.)
2013-04-26 00:13:30 +00:00
|
|
|
|
2013-06-02 22:52:40 +00:00
|
|
|
// Apple Remote input module
|
|
|
|
#define MP_AR_BASE (MP_KEY_BASE+0xE0)
|
|
|
|
#define MP_AR_PLAY (MP_AR_BASE + 0)
|
|
|
|
#define MP_AR_PLAY_HOLD (MP_AR_BASE + 1)
|
|
|
|
#define MP_AR_CENTER (MP_AR_BASE + 2)
|
|
|
|
#define MP_AR_CENTER_HOLD (MP_AR_BASE + 3)
|
|
|
|
#define MP_AR_NEXT (MP_AR_BASE + 4)
|
|
|
|
#define MP_AR_NEXT_HOLD (MP_AR_BASE + 5)
|
|
|
|
#define MP_AR_PREV (MP_AR_BASE + 6)
|
|
|
|
#define MP_AR_PREV_HOLD (MP_AR_BASE + 7)
|
|
|
|
#define MP_AR_MENU (MP_AR_BASE + 8)
|
|
|
|
#define MP_AR_MENU_HOLD (MP_AR_BASE + 9)
|
|
|
|
#define MP_AR_VUP (MP_AR_BASE + 10)
|
|
|
|
#define MP_AR_VUP_HOLD (MP_AR_BASE + 11)
|
|
|
|
#define MP_AR_VDOWN (MP_AR_BASE + 12)
|
|
|
|
#define MP_AR_VDOWN_HOLD (MP_AR_BASE + 13)
|
|
|
|
|
2015-02-13 20:42:39 +00:00
|
|
|
// Reserved area. Can be used for keys that have no explicit names assigned,
|
|
|
|
// but should be mappable by the user anyway.
|
|
|
|
#define MP_KEY_UNKNOWN_RESERVED_START (MP_KEY_BASE+0x10000)
|
|
|
|
#define MP_KEY_UNKNOWN_RESERVED_LAST (MP_KEY_BASE+0x20000-1)
|
|
|
|
|
2011-04-25 06:43:59 +00:00
|
|
|
/* Special keys */
|
2015-02-13 20:42:39 +00:00
|
|
|
#define MP_KEY_INTERN (MP_KEY_BASE+0x20000)
|
2013-02-12 00:34:04 +00:00
|
|
|
#define MP_KEY_CLOSE_WIN (MP_KEY_INTERN+0)
|
input: handle mouse movement differently
Before this commit, mouse movement events emitted a special command
("set_mouse_pos"), which was specially handled in command.c. This was
once special-cased to the dvdnav and menu code, and did nothing after
libmenu and dvdnav were removed.
Change it so that mouse movement triggers a pseudo-key ("MOUSE_MOVE"),
which then can be bound to an arbitrary command. The mouse position is
now managed in input.c. A command which actually needs the mouse
position can use either mp_input_get_mouse_pos() or mp_get_osd_mouse_pos()
to query it. The former returns raw window-space coordinates, while the
latter returns coordinates transformed to OSD- space. (Both are the same
for most VOs, except vo_xv and vo_x11, which can't render OSD in
window-space. These require extra code for mapping mouse position.)
As of this commit, there is still nothing that uses mouse movement, so
MOUSE_MOVE is mapped to "ignore" to silence warnings when moving the
mouse (much like MOUSE_BTN0).
Extend the concept of input sections. Allow multiple sections to be
active at once, and organize them as stack. Bindings from the top of
the stack are preferred to lower ones.
Each section has a mouse input section associated, inside which mouse
events are associated with the bindings. If the mouse pointer is
outside of a section's mouse area, mouse events will be dispatched to
an input section lower on the stack of active sections. This is intended
for scripting, which is to be added later. Two scripts could occupy
different areas of the screen without conflicting with each other. (If
it turns out that this mechanism is useless, we'll just remove it
again.)
2013-04-26 00:13:30 +00:00
|
|
|
// Generated by input.c (VOs use mp_input_set_mouse_pos())
|
|
|
|
#define MP_KEY_MOUSE_MOVE ((MP_KEY_INTERN+1)|MP_NO_REPEAT_KEY)
|
2013-06-19 16:19:45 +00:00
|
|
|
#define MP_KEY_MOUSE_LEAVE ((MP_KEY_INTERN+2)|MP_NO_REPEAT_KEY)
|
2015-02-17 05:50:57 +00:00
|
|
|
#define MP_KEY_MOUSE_ENTER ((MP_KEY_INTERN+3)|MP_NO_REPEAT_KEY)
|
input: handle mouse movement differently
Before this commit, mouse movement events emitted a special command
("set_mouse_pos"), which was specially handled in command.c. This was
once special-cased to the dvdnav and menu code, and did nothing after
libmenu and dvdnav were removed.
Change it so that mouse movement triggers a pseudo-key ("MOUSE_MOVE"),
which then can be bound to an arbitrary command. The mouse position is
now managed in input.c. A command which actually needs the mouse
position can use either mp_input_get_mouse_pos() or mp_get_osd_mouse_pos()
to query it. The former returns raw window-space coordinates, while the
latter returns coordinates transformed to OSD- space. (Both are the same
for most VOs, except vo_xv and vo_x11, which can't render OSD in
window-space. These require extra code for mapping mouse position.)
As of this commit, there is still nothing that uses mouse movement, so
MOUSE_MOVE is mapped to "ignore" to silence warnings when moving the
mouse (much like MOUSE_BTN0).
Extend the concept of input sections. Allow multiple sections to be
active at once, and organize them as stack. Bindings from the top of
the stack are preferred to lower ones.
Each section has a mouse input section associated, inside which mouse
events are associated with the bindings. If the mouse pointer is
outside of a section's mouse area, mouse events will be dispatched to
an input section lower on the stack of active sections. This is intended
for scripting, which is to be added later. Two scripts could occupy
different areas of the screen without conflicting with each other. (If
it turns out that this mechanism is useless, we'll just remove it
again.)
2013-04-26 00:13:30 +00:00
|
|
|
|
2015-02-18 20:09:35 +00:00
|
|
|
#define MP_KEY_IS_MOUSE_CLICK(code) \
|
|
|
|
(MP_KEY_IS_MOUSE_BTN_SINGLE(code) || MP_KEY_IS_MOUSE_BTN_DBL(code))
|
input: handle mouse movement differently
Before this commit, mouse movement events emitted a special command
("set_mouse_pos"), which was specially handled in command.c. This was
once special-cased to the dvdnav and menu code, and did nothing after
libmenu and dvdnav were removed.
Change it so that mouse movement triggers a pseudo-key ("MOUSE_MOVE"),
which then can be bound to an arbitrary command. The mouse position is
now managed in input.c. A command which actually needs the mouse
position can use either mp_input_get_mouse_pos() or mp_get_osd_mouse_pos()
to query it. The former returns raw window-space coordinates, while the
latter returns coordinates transformed to OSD- space. (Both are the same
for most VOs, except vo_xv and vo_x11, which can't render OSD in
window-space. These require extra code for mapping mouse position.)
As of this commit, there is still nothing that uses mouse movement, so
MOUSE_MOVE is mapped to "ignore" to silence warnings when moving the
mouse (much like MOUSE_BTN0).
Extend the concept of input sections. Allow multiple sections to be
active at once, and organize them as stack. Bindings from the top of
the stack are preferred to lower ones.
Each section has a mouse input section associated, inside which mouse
events are associated with the bindings. If the mouse pointer is
outside of a section's mouse area, mouse events will be dispatched to
an input section lower on the stack of active sections. This is intended
for scripting, which is to be added later. Two scripts could occupy
different areas of the screen without conflicting with each other. (If
it turns out that this mechanism is useless, we'll just remove it
again.)
2013-04-26 00:13:30 +00:00
|
|
|
|
2015-02-18 20:09:35 +00:00
|
|
|
#define MP_KEY_IS_MOUSE_MOVE(code) \
|
|
|
|
((code) == MP_KEY_MOUSE_MOVE || (code) == MP_KEY_MOUSE_ENTER || \
|
|
|
|
(code) == MP_KEY_MOUSE_LEAVE)
|
|
|
|
|
|
|
|
// Whether to dispatch the key binding by current mouse position.
|
input: handle mouse movement differently
Before this commit, mouse movement events emitted a special command
("set_mouse_pos"), which was specially handled in command.c. This was
once special-cased to the dvdnav and menu code, and did nothing after
libmenu and dvdnav were removed.
Change it so that mouse movement triggers a pseudo-key ("MOUSE_MOVE"),
which then can be bound to an arbitrary command. The mouse position is
now managed in input.c. A command which actually needs the mouse
position can use either mp_input_get_mouse_pos() or mp_get_osd_mouse_pos()
to query it. The former returns raw window-space coordinates, while the
latter returns coordinates transformed to OSD- space. (Both are the same
for most VOs, except vo_xv and vo_x11, which can't render OSD in
window-space. These require extra code for mapping mouse position.)
As of this commit, there is still nothing that uses mouse movement, so
MOUSE_MOVE is mapped to "ignore" to silence warnings when moving the
mouse (much like MOUSE_BTN0).
Extend the concept of input sections. Allow multiple sections to be
active at once, and organize them as stack. Bindings from the top of
the stack are preferred to lower ones.
Each section has a mouse input section associated, inside which mouse
events are associated with the bindings. If the mouse pointer is
outside of a section's mouse area, mouse events will be dispatched to
an input section lower on the stack of active sections. This is intended
for scripting, which is to be added later. Two scripts could occupy
different areas of the screen without conflicting with each other. (If
it turns out that this mechanism is useless, we'll just remove it
again.)
2013-04-26 00:13:30 +00:00
|
|
|
#define MP_KEY_DEPENDS_ON_MOUSE_POS(code) \
|
2017-09-02 14:00:52 +00:00
|
|
|
(MP_KEY_IS_MOUSE_CLICK(code) || (code) == MP_KEY_MOUSE_MOVE)
|
2011-04-25 06:43:59 +00:00
|
|
|
|
2014-07-27 20:00:55 +00:00
|
|
|
#define MP_KEY_IS_MOUSE(code) \
|
2017-09-02 14:00:52 +00:00
|
|
|
(MP_KEY_IS_MOUSE_CLICK(code) || MP_KEY_IS_MOUSE_MOVE(code))
|
2014-07-27 20:00:55 +00:00
|
|
|
|
2015-12-23 18:13:45 +00:00
|
|
|
// No input source should generate this.
|
|
|
|
#define MP_KEY_UNMAPPED (MP_KEY_INTERN+4)
|
|
|
|
|
2014-05-09 19:49:25 +00:00
|
|
|
// Emit a command even on key-up (normally key-up is ignored). This means by
|
|
|
|
// default they binding will be triggered on key-up instead of key-down.
|
|
|
|
// This is a fixed part of the keycode, not a modifier than can change.
|
2014-08-26 18:39:23 +00:00
|
|
|
#define MP_KEY_EMIT_ON_UP (1u<<22)
|
2014-04-18 15:49:51 +00:00
|
|
|
|
|
|
|
// Use this when the key shouldn't be auto-repeated (like mouse buttons)
|
|
|
|
// Also means both key-down key-up events produce emit bound commands.
|
2014-05-09 19:49:25 +00:00
|
|
|
// This is a fixed part of the keycode, not a modifier than can change.
|
2014-08-26 18:39:23 +00:00
|
|
|
#define MP_NO_REPEAT_KEY (1u<<23)
|
2014-04-18 15:49:51 +00:00
|
|
|
|
2011-04-25 06:43:59 +00:00
|
|
|
/* Modifiers added to individual keys */
|
2014-08-26 18:39:23 +00:00
|
|
|
#define MP_KEY_MODIFIER_SHIFT (1u<<24)
|
|
|
|
#define MP_KEY_MODIFIER_CTRL (1u<<25)
|
|
|
|
#define MP_KEY_MODIFIER_ALT (1u<<26)
|
|
|
|
#define MP_KEY_MODIFIER_META (1u<<27)
|
2011-04-25 06:43:59 +00:00
|
|
|
|
input: fix handling of MP_KEY_STATE_DOWN
VOs can use the MP_KEY_STATE_DOWN modifier to pass key up/down events to
input.c, instead of just simple key presses. This allows doing key auto-
repeat handling in input.c, if the VO doesn't want to do that.
One issue is that so far, this code has been used only for mouse events,
even though the code was originally written with keyboard keys in mind.
One difference between mouse keys and keyboard keys is that the initial
key down should not generate an input command with mouse buttons
(input.c did that), while keyboard events should (input.c didn't do
that). Likewise, releasing a key should generate input commands for
mouse buttons releases, but not for the keyboard.
Change the code so mouse buttons (recognized via the MP_NO_REPEAT_KEY
flag) follow the old hehavior, while other keys generate input commands
on key down, but not on key release.
Note that a key release event is posted either using
MP_INPUT_RELEASE_ALL, or a normal key press event after having sent a an
event with MP_KEY_STATE_DOWN. This is probably a bit confusing, and a
MP_KEY_STATE_RELEASE should be added.
Fix shift-handling with MP_KEY_STATE_DOWN as well.
2013-04-03 23:11:05 +00:00
|
|
|
// Flag for key events. Multiple down events are idempotent. Release keys by
|
2013-07-01 21:54:59 +00:00
|
|
|
// sending the key code with KEY_STATE_UP set, or by sending
|
|
|
|
// MP_INPUT_RELEASE_ALL as key code.
|
2014-08-26 18:39:23 +00:00
|
|
|
#define MP_KEY_STATE_DOWN (1u<<28)
|
input: handle mouse movement differently
Before this commit, mouse movement events emitted a special command
("set_mouse_pos"), which was specially handled in command.c. This was
once special-cased to the dvdnav and menu code, and did nothing after
libmenu and dvdnav were removed.
Change it so that mouse movement triggers a pseudo-key ("MOUSE_MOVE"),
which then can be bound to an arbitrary command. The mouse position is
now managed in input.c. A command which actually needs the mouse
position can use either mp_input_get_mouse_pos() or mp_get_osd_mouse_pos()
to query it. The former returns raw window-space coordinates, while the
latter returns coordinates transformed to OSD- space. (Both are the same
for most VOs, except vo_xv and vo_x11, which can't render OSD in
window-space. These require extra code for mapping mouse position.)
As of this commit, there is still nothing that uses mouse movement, so
MOUSE_MOVE is mapped to "ignore" to silence warnings when moving the
mouse (much like MOUSE_BTN0).
Extend the concept of input sections. Allow multiple sections to be
active at once, and organize them as stack. Bindings from the top of
the stack are preferred to lower ones.
Each section has a mouse input section associated, inside which mouse
events are associated with the bindings. If the mouse pointer is
outside of a section's mouse area, mouse events will be dispatched to
an input section lower on the stack of active sections. This is intended
for scripting, which is to be added later. Two scripts could occupy
different areas of the screen without conflicting with each other. (If
it turns out that this mechanism is useless, we'll just remove it
again.)
2013-04-26 00:13:30 +00:00
|
|
|
|
2013-07-01 21:54:59 +00:00
|
|
|
// Flag for key events. Releases a key previously held down with
|
2014-05-09 19:49:25 +00:00
|
|
|
// MP_KEY_STATE_DOWN. Do not send redundant UP events and do not forget to
|
2013-07-01 21:54:59 +00:00
|
|
|
// release keys at all with UP. If input is unreliable, use MP_INPUT_RELEASE_ALL
|
|
|
|
// or don't use MP_KEY_STATE_DOWN in the first place.
|
2014-08-26 18:39:23 +00:00
|
|
|
#define MP_KEY_STATE_UP (1u<<29)
|
2011-04-25 06:43:59 +00:00
|
|
|
|
2014-05-09 19:49:25 +00:00
|
|
|
#define MP_KEY_MODIFIER_MASK (MP_KEY_MODIFIER_SHIFT | MP_KEY_MODIFIER_CTRL | \
|
|
|
|
MP_KEY_MODIFIER_ALT | MP_KEY_MODIFIER_META | \
|
|
|
|
MP_KEY_STATE_DOWN | MP_KEY_STATE_UP)
|
|
|
|
|
2014-08-26 18:39:28 +00:00
|
|
|
// Makes adjustments like turning "shift+z" into "Z"
|
|
|
|
int mp_normalize_keycode(int keycode);
|
|
|
|
|
2013-12-26 16:10:35 +00:00
|
|
|
// Get input key from its name.
|
|
|
|
int mp_input_get_key_from_name(const char *name);
|
|
|
|
|
2013-12-30 21:44:56 +00:00
|
|
|
// Return given key (plus modifiers) as talloc'ed name.
|
|
|
|
char *mp_input_get_key_name(int key);
|
2013-12-26 16:10:35 +00:00
|
|
|
|
|
|
|
// Combination of multiple keys to string.
|
2014-02-17 01:30:17 +00:00
|
|
|
char *mp_input_get_key_combo_name(const int *keys, int max);
|
2013-12-26 16:10:35 +00:00
|
|
|
|
|
|
|
// String containing combination of multiple string to keys.
|
|
|
|
int mp_input_get_keys_from_string(char *str, int max_num_keys,
|
|
|
|
int *out_num_keys, int *keys);
|
|
|
|
|
|
|
|
struct mp_log;
|
|
|
|
void mp_print_key_list(struct mp_log *out);
|
|
|
|
|
2011-04-25 06:43:59 +00:00
|
|
|
#endif /* MPLAYER_KEYCODES_H */
|