A few changes to allow for better keyboard state detection

This commit is contained in:
Mark Vejvoda
2010-04-02 17:37:04 +00:00
parent 198d2aeb98
commit 02d0781b40
4 changed files with 35 additions and 3 deletions

View File

@@ -18,7 +18,7 @@
#include "sdl_private.h"
#include "noimpl.h"
#include "util.h"
#include "SDL_syswm.h"
#include "SDL_syswm.h"
#include "leak_dumper.h"
using namespace Shared::Util;
@@ -40,6 +40,7 @@ Vec2i Window::mousePos;
MouseState Window::mouseState;
bool Window::isKeyPressedDown = false;
bool Window::isFullScreen = false;
SDL_keysym Window::keystate;
// ========== PUBLIC ==========
@@ -118,6 +119,7 @@ bool Window::handleEvent() {
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
Window::isKeyPressedDown = true;
keystate = event.key.keysym;
/* handle ALT+Return */
if(event.key.keysym.sym == SDLK_RETURN
&& (event.key.keysym.mod & (KMOD_LALT | KMOD_RALT))) {
@@ -125,6 +127,7 @@ bool Window::handleEvent() {
toggleFullscreen();
}
if(global_window) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
global_window->eventKeyDown(getKey(event.key.keysym));
global_window->eventKeyPress(static_cast<char>(event.key.keysym.unicode));
}
@@ -133,6 +136,7 @@ bool Window::handleEvent() {
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
Window::isKeyPressedDown = false;
keystate = event.key.keysym;
if(global_window) {
global_window->eventKeyUp(getKey(event.key.keysym));