monitor: move key_defs[] table and introduce two help functions

This patch added two help functions to convert key/code to index of
mapping table, those functions will return Q_KEY_CODE_MAX if the
code/key is invalid.

Patch also moved key_defs[] to input.c, and removed useless KeyDef struct.
Key's index in QKeyCode enmu is same as keycode's index in new key_defs[].
Monitor functions were changed to access key_defs[] directly.

key_defs[] is used in do_send_key(), so export key_defs[]. It will be
changed to static in next patch.

Signed-off-by: Amos Kong <akong@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
Amos Kong 2012-08-31 10:56:25 +08:00 committed by Luiz Capitulino
parent 411656f48d
commit 1048c88f03
3 changed files with 203 additions and 172 deletions

View file

@ -6,6 +6,7 @@
#include "notify.h"
#include "monitor.h"
#include "trace.h"
#include "qapi-types.h"
/* keyboard/mouse support */
@ -397,4 +398,9 @@ static inline int vnc_display_pw_expire(DisplayState *ds, time_t expires)
/* curses.c */
void curses_display_init(DisplayState *ds, int full_screen);
/* input.c */
extern const int key_defs[];
int index_from_key(const char *key);
int index_from_keycode(int code);
#endif