/*
- * (C) Gražvydas "notaz" Ignotas, 2010
+ * (C) Gražvydas "notaz" Ignotas, 2010-2012
*
* This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
* See the COPYING file in the top-level directory.
#include <time.h>
#include <errno.h>
#include <linux/input.h>
+#ifdef STANDALONE
#include <SDL/SDL.h>
+#else
+#include "SDL.h"
+#endif
#if SDL_INPUT_TSLIB
#include <tslib.h>
#endif
-#include "omapsdl.h"
+#include "osdl.h"
/* XXX: these should go to private data */
static int osdl_evdev_devs[32];
[KEY_G] = SDLK_g, [KEY_EQUAL] = SDLK_EQUALS,
[KEY_H] = SDLK_h, [KEY_GRAVE] = SDLK_BACKQUOTE, /* ` */
[KEY_I] = SDLK_i, /* [KEY_BRIGHTNESSUP] */
- [KEY_J] = SDLK_j, /* [KEY_F13] */ /* ’ */
- [KEY_K] = SDLK_k, /* [KEY_F18] */ /* £ (pound) */
- [KEY_L] = SDLK_l, /* [KEY_YEN] */
+ [KEY_J] = SDLK_j, [KEY_F13] = SDLK_WORLD_4, /* ’ (not on def SDL) */
+ [KEY_K] = SDLK_k, [KEY_F18] = SDLK_WORLD_3, /* £ (pound) */
+ [KEY_L] = SDLK_l, [KEY_YEN] = SDLK_WORLD_5,
[KEY_M] = SDLK_m, [KEY_F23] = SDLK_EURO,
[KEY_N] = SDLK_n, [KEY_F22] = SDLK_DOLLAR, /* $ */
[KEY_O] = SDLK_o, [KEY_F11] = SDLK_F11,
[KEY_Z] = SDLK_z, [KEY_SLASH] = SDLK_SLASH, /* / */
[KEY_SPACE] = SDLK_SPACE, [KEY_TAB] = SDLK_TAB,
[KEY_BACKSPACE] = SDLK_BACKSPACE, [KEY_INSERT] = SDLK_INSERT,
- [KEY_FN] = SDLK_MODE,
+ [KEY_FN] = SDLK_WORLD_95,
[KEY_DOT] = SDLK_PERIOD, [KEY_F21] = SDLK_COLON, /* : */
[KEY_ENTER] = SDLK_RETURN,
[KEY_LEFTSHIFT] = SDLK_LSHIFT, [KEY_CAPSLOCK] = SDLK_CAPSLOCK,
}
int omapsdl_input_get_events(int timeout_ms,
- int (*key_cb)(void *cb_arg, int sdl_kc, int is_pressed),
+ int (*key_cb)(void *cb_arg, int sdl_kc, int sdl_sc, int is_pressed),
int (*ts_cb)(void *cb_arg, int x, int y, unsigned int pressure),
void *cb_arg)
{
break;
}
- if (ev.type != EV_KEY)
- continue; /* not key event */
+ if (ev.type != EV_KEY || key_cb == NULL)
+ continue; /* not key event or not needed */
if ((unsigned int)ev.value > 1)
continue; /* not key up/down */
if ((unsigned int)ev.code >= ARRAY_SIZE(osdl_evdev_map))
sdl_kc = osdl_evdev_map[ev.code];
if (sdl_kc == 0)
continue; /* not mapped */
- ret = key_cb(cb_arg, sdl_kc, ev.value);
+ /* scancode note: stock SDL doesn't do +8 in fbcon driver */
+ ret = key_cb(cb_arg, sdl_kc, ev.code + 8, ev.value);
if (ret != 0)
return ret;
}
struct key_event {
int sdl_kc;
+ int sdl_sc;
int is_pressed;
};
-static int do_key_cb(void *cb_arg, int sdl_kc, int is_pressed)
+static int do_key_cb(void *cb_arg, int sdl_kc, int sdl_sc, int is_pressed)
{
struct key_event *ev = cb_arg;
ev->sdl_kc = sdl_kc;
+ ev->sdl_sc = sdl_sc;
ev->is_pressed = is_pressed;
return 1; /* done */
// event->key.which =
event->key.state = ev.is_pressed ? SDL_PRESSED : SDL_RELEASED;
event->key.keysym.sym = ev.sdl_kc;
+ event->key.keysym.scancode = ev.sdl_sc;
// event->key.keysym.mod
return 1;