SDL  2.0
keyboard.c File Reference
#include "../../SDL_internal.h"
#include "../../events/SDL_keyboard_c.h"
#include "SDL_scancode.h"
#include "SDL_events.h"
#include "sdl_qnx.h"
#include <sys/keycodes.h>
+ Include dependency graph for keyboard.c:

Go to the source code of this file.

Functions

void handleKeyboardEvent (screen_event_t event)

Variables

static int key_to_sdl []

Function Documentation

void handleKeyboardEvent ( screen_event_t  event)

Called from the event dispatcher when a keyboard event is encountered. Translates the event such that it can be handled by SDL.

Parameters
eventScreen keyboard event

Definition at line 99 of file keyboard.c.

References key_to_sdl, SDL_PRESSED, SDL_RELEASED, SDL_SendKeyboardKey(), and SDL_TABLESIZE.

Referenced by pumpEvents().

{
int val;
SDL_Scancode scancode;
// Get the key value.
if (screen_get_event_property_iv(event, SCREEN_PROPERTY_SYM, &val) < 0) {
return;
}
// Skip unrecognized keys.
if ((val < 0) || (val >= SDL_TABLESIZE(key_to_sdl))) {
return;
}
// Translate to an SDL scan code.
scancode = key_to_sdl[val];
if (scancode == 0) {
return;
}
// Get event flags (key state).
if (screen_get_event_property_iv(event, SCREEN_PROPERTY_FLAGS, &val) < 0) {
return;
}
// Propagate the event to SDL.
// FIXME:
// Need to handle more key states (such as key combinations).
if (val & KEY_DOWN) {
} else {
}
}

Variable Documentation

int key_to_sdl[]
static

A map thta translates Screen key names to SDL scan codes. This map is incomplete, but should include most major keys.

Definition at line 33 of file keyboard.c.

Referenced by handleKeyboardEvent().