summaryrefslogtreecommitdiffstats
path: root/input
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2011-04-25 09:43:59 +0300
committerUoti Urpala <uau@mplayer2.org>2011-05-02 00:43:31 +0300
commit23cb82907220d0c2724a0ec92bde437cbcd67d6a (patch)
tree1c1ea8667a2da5b6ddb5dd8e2f0c6f6558304ab5 /input
parent3e86228fad309b54869bf2a3314756933ba74e43 (diff)
downloadmpv-23cb82907220d0c2724a0ec92bde437cbcd67d6a.tar.bz2
mpv-23cb82907220d0c2724a0ec92bde437cbcd67d6a.tar.xz
input: move all key code lists to input/keycodes.h
Move the definitions of all special key codes (those not passed by ASCII value) to input/keycodes.h. Before they were spread between osdep/keycodes.h, input/joystick.h, input/mouse.h and input/ar.h, plus some special values in input.h. This was especially inconvenient as the codes had to be coordinated to not conflict between the files. The change requires a bit of ugliness as appleir.c includes <linux/input.h> which contains various conflicting KEY_* definitions. Work around this by adding a special preprocessor variable which can be used to avoid defining these in keycodes.h.
Diffstat (limited to 'input')
-rw-r--r--input/appleir.c4
-rw-r--r--input/ar.c1
-rw-r--r--input/ar.h12
-rw-r--r--input/input.c3
-rw-r--r--input/input.h7
-rw-r--r--input/joystick.h34
-rw-r--r--input/keycodes.h194
-rw-r--r--input/mouse.h46
8 files changed, 200 insertions, 101 deletions
diff --git a/input/appleir.c b/input/appleir.c
index aca666110c..c64bc9648d 100644
--- a/input/appleir.c
+++ b/input/appleir.c
@@ -39,6 +39,10 @@
#include "mp_msg.h"
+// keycodes.h defines would conflict with linux/input.h ones
+#define AR_DEFINES_ONLY
+#include "keycodes.h"
+
#define EVDEV_MAX_EVENTS 32
/* ripped from AppleIR driver */
diff --git a/input/ar.c b/input/ar.c
index d7cac43178..2f3fe16b24 100644
--- a/input/ar.c
+++ b/input/ar.c
@@ -31,6 +31,7 @@
#include "input.h"
#include "ar.h"
+#include "keycodes.h"
extern int slave_mode;
diff --git a/input/ar.h b/input/ar.h
index 12944f84e1..56b88d5823 100644
--- a/input/ar.h
+++ b/input/ar.h
@@ -23,18 +23,6 @@
#ifndef MPLAYER_AR_H
#define MPLAYER_AR_H
-#define AR_BASE 0x500
-#define AR_PLAY (AR_BASE + 0)
-#define AR_PLAY_HOLD (AR_BASE + 1)
-#define AR_NEXT (AR_BASE + 2)
-#define AR_NEXT_HOLD (AR_BASE + 3)
-#define AR_PREV (AR_BASE + 4)
-#define AR_PREV_HOLD (AR_BASE + 5)
-#define AR_MENU (AR_BASE + 6)
-#define AR_MENU_HOLD (AR_BASE + 7)
-#define AR_VUP (AR_BASE + 8)
-#define AR_VDOWN (AR_BASE + 9)
-
/* MacOSX Driver */
int mp_input_ar_init(void);
int mp_input_ar_read(void *ctx, int fd);
diff --git a/input/input.c b/input/input.c
index 1dc57960db..f5e2d3824d 100644
--- a/input/input.c
+++ b/input/input.c
@@ -31,12 +31,11 @@
#include <ctype.h>
#include "input.h"
-#include "mouse.h"
#ifdef MP_DEBUG
#include <assert.h>
#endif
#include "mp_fifo.h"
-#include "osdep/keycodes.h"
+#include "keycodes.h"
#include "osdep/timer.h"
#include "libavutil/avstring.h"
#include "mp_msg.h"
diff --git a/input/input.h b/input/input.h
index d922655950..2e48679856 100644
--- a/input/input.h
+++ b/input/input.h
@@ -182,13 +182,6 @@ typedef enum {
//! Input will be available if you try again
#define MP_INPUT_RETRY -4
-// For the key's drivers, if possible you can send key up and key down
-// events. Key up is the default, to send a key down you must use the
-// OR operator between the key code and MP_KEY_DOWN.
-#define MP_KEY_DOWN (1<<29)
-// Use this when the key shouldn't be auto-repeated (like mouse buttons)
-#define MP_NO_REPEAT_KEY (1<<28)
-
#ifndef MP_MAX_KEY_DOWN
#define MP_MAX_KEY_DOWN 32
#endif
diff --git a/input/joystick.h b/input/joystick.h
index 996f0fed21..b9480eb686 100644
--- a/input/joystick.h
+++ b/input/joystick.h
@@ -19,40 +19,6 @@
#ifndef MPLAYER_JOYSTICK_H
#define MPLAYER_JOYSTICK_H
-#define JOY_BASE (0x100+128)
-#define JOY_AXIS0_PLUS (JOY_BASE+0)
-#define JOY_AXIS0_MINUS (JOY_BASE+1)
-#define JOY_AXIS1_PLUS (JOY_BASE+2)
-#define JOY_AXIS1_MINUS (JOY_BASE+3)
-#define JOY_AXIS2_PLUS (JOY_BASE+4)
-#define JOY_AXIS2_MINUS (JOY_BASE+5)
-#define JOY_AXIS3_PLUS (JOY_BASE+6)
-#define JOY_AXIS3_MINUS (JOY_BASE+7)
-#define JOY_AXIS4_PLUS (JOY_BASE+8)
-#define JOY_AXIS4_MINUS (JOY_BASE+9)
-#define JOY_AXIS5_PLUS (JOY_BASE+10)
-#define JOY_AXIS5_MINUS (JOY_BASE+11)
-#define JOY_AXIS6_PLUS (JOY_BASE+12)
-#define JOY_AXIS6_MINUS (JOY_BASE+13)
-#define JOY_AXIS7_PLUS (JOY_BASE+14)
-#define JOY_AXIS7_MINUS (JOY_BASE+15)
-#define JOY_AXIS8_PLUS (JOY_BASE+16)
-#define JOY_AXIS8_MINUS (JOY_BASE+17)
-#define JOY_AXIS9_PLUS (JOY_BASE+18)
-#define JOY_AXIS9_MINUS (JOY_BASE+19)
-
-#define JOY_BTN_BASE ((0x100+148)|MP_NO_REPEAT_KEY)
-#define JOY_BTN0 (JOY_BTN_BASE+0)
-#define JOY_BTN1 (JOY_BTN_BASE+1)
-#define JOY_BTN2 (JOY_BTN_BASE+2)
-#define JOY_BTN3 (JOY_BTN_BASE+3)
-#define JOY_BTN4 (JOY_BTN_BASE+4)
-#define JOY_BTN5 (JOY_BTN_BASE+5)
-#define JOY_BTN6 (JOY_BTN_BASE+6)
-#define JOY_BTN7 (JOY_BTN_BASE+7)
-#define JOY_BTN8 (JOY_BTN_BASE+8)
-#define JOY_BTN9 (JOY_BTN_BASE+9)
-
int mp_input_joystick_init(char* dev);
int mp_input_joystick_read(void *ctx, int fd);
diff --git a/input/keycodes.h b/input/keycodes.h
new file mode 100644
index 0000000000..31a9161826
--- /dev/null
+++ b/input/keycodes.h
@@ -0,0 +1,194 @@
+/*
+ * KEY code definitions for keys/events not passed by ASCII value
+ *
+ * This file is part of MPlayer.
+ *
+ * MPlayer is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MPlayer is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with MPlayer; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef MPLAYER_KEYCODES_H
+#define MPLAYER_KEYCODES_H
+
+// For appleir.c which includes another header with KEY_ENTER etc defines
+#ifndef AR_DEFINES_ONLY
+
+#define KEY_ENTER 13
+#define KEY_TAB 9
+
+#define KEY_BASE 0x100
+
+/* Function keys */
+#define KEY_F (KEY_BASE+64)
+
+/* Control keys */
+#define KEY_CTRL (KEY_BASE)
+#define KEY_BACKSPACE (KEY_CTRL+0)
+#define KEY_DELETE (KEY_CTRL+1)
+#define KEY_INSERT (KEY_CTRL+2)
+#define KEY_HOME (KEY_CTRL+3)
+#define KEY_END (KEY_CTRL+4)
+#define KEY_PAGE_UP (KEY_CTRL+5)
+#define KEY_PAGE_DOWN (KEY_CTRL+6)
+#define KEY_ESC (KEY_CTRL+7)
+
+/* Control keys short name */
+#define KEY_BS KEY_BACKSPACE
+#define KEY_DEL KEY_DELETE
+#define KEY_INS KEY_INSERT
+#define KEY_PGUP KEY_PAGE_UP
+#define KEY_PGDOWN KEY_PAGE_DOWN
+#define KEY_PGDWN KEY_PAGE_DOWN
+
+/* Cursor movement */
+#define KEY_CRSR (KEY_BASE+16)
+#define KEY_RIGHT (KEY_CRSR+0)
+#define KEY_LEFT (KEY_CRSR+1)
+#define KEY_DOWN (KEY_CRSR+2)
+#define KEY_UP (KEY_CRSR+3)
+
+/* Multimedia keyboard/remote keys */
+#define KEY_MM_BASE (0x100+384)
+#define KEY_POWER (KEY_MM_BASE+0)
+#define KEY_MENU (KEY_MM_BASE+1)
+#define KEY_PLAY (KEY_MM_BASE+2)
+#define KEY_PAUSE (KEY_MM_BASE+3)
+#define KEY_PLAYPAUSE (KEY_MM_BASE+4)
+#define KEY_STOP (KEY_MM_BASE+5)
+#define KEY_FORWARD (KEY_MM_BASE+6)
+#define KEY_REWIND (KEY_MM_BASE+7)
+#define KEY_NEXT (KEY_MM_BASE+8)
+#define KEY_PREV (KEY_MM_BASE+9)
+#define KEY_VOLUME_UP (KEY_MM_BASE+10)
+#define KEY_VOLUME_DOWN (KEY_MM_BASE+11)
+#define KEY_MUTE (KEY_MM_BASE+12)
+
+/* Keypad keys */
+#define KEY_KEYPAD (KEY_BASE+32)
+#define KEY_KP0 (KEY_KEYPAD+0)
+#define KEY_KP1 (KEY_KEYPAD+1)
+#define KEY_KP2 (KEY_KEYPAD+2)
+#define KEY_KP3 (KEY_KEYPAD+3)
+#define KEY_KP4 (KEY_KEYPAD+4)
+#define KEY_KP5 (KEY_KEYPAD+5)
+#define KEY_KP6 (KEY_KEYPAD+6)
+#define KEY_KP7 (KEY_KEYPAD+7)
+#define KEY_KP8 (KEY_KEYPAD+8)
+#define KEY_KP9 (KEY_KEYPAD+9)
+#define KEY_KPDEC (KEY_KEYPAD+10)
+#define KEY_KPINS (KEY_KEYPAD+11)
+#define KEY_KPDEL (KEY_KEYPAD+12)
+#define KEY_KPENTER (KEY_KEYPAD+13)
+
+
+// Joystick input module
+#define JOY_BASE (0x100+128)
+#define JOY_AXIS0_PLUS (JOY_BASE+0)
+#define JOY_AXIS0_MINUS (JOY_BASE+1)
+#define JOY_AXIS1_PLUS (JOY_BASE+2)
+#define JOY_AXIS1_MINUS (JOY_BASE+3)
+#define JOY_AXIS2_PLUS (JOY_BASE+4)
+#define JOY_AXIS2_MINUS (JOY_BASE+5)
+#define JOY_AXIS3_PLUS (JOY_BASE+6)
+#define JOY_AXIS3_MINUS (JOY_BASE+7)
+#define JOY_AXIS4_PLUS (JOY_BASE+8)
+#define JOY_AXIS4_MINUS (JOY_BASE+9)
+#define JOY_AXIS5_PLUS (JOY_BASE+10)
+#define JOY_AXIS5_MINUS (JOY_BASE+11)
+#define JOY_AXIS6_PLUS (JOY_BASE+12)
+#define JOY_AXIS6_MINUS (JOY_BASE+13)
+#define JOY_AXIS7_PLUS (JOY_BASE+14)
+#define JOY_AXIS7_MINUS (JOY_BASE+15)
+#define JOY_AXIS8_PLUS (JOY_BASE+16)
+#define JOY_AXIS8_MINUS (JOY_BASE+17)
+#define JOY_AXIS9_PLUS (JOY_BASE+18)
+#define JOY_AXIS9_MINUS (JOY_BASE+19)
+
+#define JOY_BTN_BASE ((0x100+148)|MP_NO_REPEAT_KEY)
+#define JOY_BTN0 (JOY_BTN_BASE+0)
+#define JOY_BTN1 (JOY_BTN_BASE+1)
+#define JOY_BTN2 (JOY_BTN_BASE+2)
+#define JOY_BTN3 (JOY_BTN_BASE+3)
+#define JOY_BTN4 (JOY_BTN_BASE+4)
+#define JOY_BTN5 (JOY_BTN_BASE+5)
+#define JOY_BTN6 (JOY_BTN_BASE+6)
+#define JOY_BTN7 (JOY_BTN_BASE+7)
+#define JOY_BTN8 (JOY_BTN_BASE+8)
+#define JOY_BTN9 (JOY_BTN_BASE+9)
+
+
+// Mouse events from VOs
+#define MOUSE_BASE ((0x100+256)|MP_NO_REPEAT_KEY)
+#define MOUSE_BTN0 (MOUSE_BASE+0)
+#define MOUSE_BTN1 (MOUSE_BASE+1)
+#define MOUSE_BTN2 (MOUSE_BASE+2)
+#define MOUSE_BTN3 (MOUSE_BASE+3)
+#define MOUSE_BTN4 (MOUSE_BASE+4)
+#define MOUSE_BTN5 (MOUSE_BASE+5)
+#define MOUSE_BTN6 (MOUSE_BASE+6)
+#define MOUSE_BTN7 (MOUSE_BASE+7)
+#define MOUSE_BTN8 (MOUSE_BASE+8)
+#define MOUSE_BTN9 (MOUSE_BASE+9)
+#define MOUSE_BTN_END (MOUSE_BASE+10)
+
+#define MOUSE_BASE_DBL (0x300|MP_NO_REPEAT_KEY)
+#define MOUSE_BTN0_DBL (MOUSE_BASE_DBL+0)
+#define MOUSE_BTN1_DBL (MOUSE_BASE_DBL+1)
+#define MOUSE_BTN2_DBL (MOUSE_BASE_DBL+2)
+#define MOUSE_BTN3_DBL (MOUSE_BASE_DBL+3)
+#define MOUSE_BTN4_DBL (MOUSE_BASE_DBL+4)
+#define MOUSE_BTN5_DBL (MOUSE_BASE_DBL+5)
+#define MOUSE_BTN6_DBL (MOUSE_BASE_DBL+6)
+#define MOUSE_BTN7_DBL (MOUSE_BASE_DBL+7)
+#define MOUSE_BTN8_DBL (MOUSE_BASE_DBL+8)
+#define MOUSE_BTN9_DBL (MOUSE_BASE_DBL+9)
+#define MOUSE_BTN_DBL_END (MOUSE_BASE_DBL+10)
+
+
+#endif // AR_DEFINES_ONLY
+
+// Apple Remote input module
+#define AR_BASE 0x500
+#define AR_PLAY (AR_BASE + 0)
+#define AR_PLAY_HOLD (AR_BASE + 1)
+#define AR_NEXT (AR_BASE + 2)
+#define AR_NEXT_HOLD (AR_BASE + 3)
+#define AR_PREV (AR_BASE + 4)
+#define AR_PREV_HOLD (AR_BASE + 5)
+#define AR_MENU (AR_BASE + 6)
+#define AR_MENU_HOLD (AR_BASE + 7)
+#define AR_VUP (AR_BASE + 8)
+#define AR_VDOWN (AR_BASE + 9)
+
+#ifndef AR_DEFINES_ONLY
+
+
+/* Special keys */
+#define KEY_INTERN (0x1000)
+#define KEY_CLOSE_WIN (KEY_INTERN+0)
+
+/* Modifiers added to individual keys */
+#define KEY_MODIFIER_SHIFT 0x2000
+#define KEY_MODIFIER_CTRL 0x4000
+#define KEY_MODIFIER_ALT 0x8000
+#define KEY_MODIFIER_META 0x10000
+
+#endif // AR_DEFINES_ONLY
+
+// Use this when the key shouldn't be auto-repeated (like mouse buttons)
+#define MP_NO_REPEAT_KEY (1<<28)
+
+#define MP_KEY_DOWN (1<<29)
+
+#endif /* MPLAYER_KEYCODES_H */
diff --git a/input/mouse.h b/input/mouse.h
deleted file mode 100644
index 789cac96c3..0000000000
--- a/input/mouse.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * This file is part of MPlayer.
- *
- * MPlayer is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * MPlayer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef MPLAYER_MOUSE_H
-#define MPLAYER_MOUSE_H
-
-#define MOUSE_BASE ((0x100+256)|MP_NO_REPEAT_KEY)
-#define MOUSE_BTN0 (MOUSE_BASE+0)
-#define MOUSE_BTN1 (MOUSE_BASE+1)
-#define MOUSE_BTN2 (MOUSE_BASE+2)
-#define MOUSE_BTN3 (MOUSE_BASE+3)
-#define MOUSE_BTN4 (MOUSE_BASE+4)
-#define MOUSE_BTN5 (MOUSE_BASE+5)
-#define MOUSE_BTN6 (MOUSE_BASE+6)
-#define MOUSE_BTN7 (MOUSE_BASE+7)
-#define MOUSE_BTN8 (MOUSE_BASE+8)
-#define MOUSE_BTN9 (MOUSE_BASE+9)
-
-#define MOUSE_BASE_DBL (0x300|MP_NO_REPEAT_KEY)
-#define MOUSE_BTN0_DBL (MOUSE_BASE_DBL+0)
-#define MOUSE_BTN1_DBL (MOUSE_BASE_DBL+1)
-#define MOUSE_BTN2_DBL (MOUSE_BASE_DBL+2)
-#define MOUSE_BTN3_DBL (MOUSE_BASE_DBL+3)
-#define MOUSE_BTN4_DBL (MOUSE_BASE_DBL+4)
-#define MOUSE_BTN5_DBL (MOUSE_BASE_DBL+5)
-#define MOUSE_BTN6_DBL (MOUSE_BASE_DBL+6)
-#define MOUSE_BTN7_DBL (MOUSE_BASE_DBL+7)
-#define MOUSE_BTN8_DBL (MOUSE_BASE_DBL+8)
-#define MOUSE_BTN9_DBL (MOUSE_BASE_DBL+9)
-
-#endif /* MPLAYER_MOUSE_H */