summaryrefslogtreecommitdiff
path: root/src/client/interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/interface.c')
-rwxr-xr-xsrc/client/interface.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/client/interface.c b/src/client/interface.c
index 2c45110..37aa361 100755
--- a/src/client/interface.c
+++ b/src/client/interface.c
@@ -6,6 +6,7 @@
#include "interface.h"
#include "screen.h"
+#include "keyboardBuffer.h"
// window surface
static SDL_Surface *screen;
@@ -19,6 +20,9 @@ static Uint32 g_win_flags = SDL_HWSURFACE|SDL_DOUBLEBUF;
static bool_t isInterfaceInit = FALSE;
+// flag, kterym se ridi zarazovani klaves do bufferu
+bool_t keyboardBufferEnabled = FALSE;
+
bool_t isInterfaceInicialized()
{
return isInterfaceInit;
@@ -37,6 +41,14 @@ static Uint32 TimerCallback(Uint32 interval, void *param)
return interval;
}
+void enableKeyboardBuffer(){
+ keyboardBufferEnabled=TRUE;
+}
+
+void disableKeyboardBuffer(){
+ keyboardBufferEnabled=FALSE;
+}
+
int initSDL()
{
printf("init SDL..\n");
@@ -70,9 +82,11 @@ int initSDL()
SDL_WM_SetCaption(WINDOW_TITLE, NULL);
//SDL_ShowCursor(0);
- SDL_EnableKeyRepeat(1,1);
+ SDL_EnableKeyRepeat(0,1);
timer = SDL_AddTimer(INTERVAL, TimerCallback, NULL);
+ initKeyboardBuffer(KEYBOARD_BUFFER_SIZE);
+
srand((unsigned)time(NULL));
isInterfaceInit = TRUE;
@@ -199,6 +213,9 @@ int eventAction()
break;
default:
+ //neni potreba vyuzivat frontu stale
+ if (keyboardBufferEnabled==TRUE)
+ pushKeyToKeyboardBuffer(event.key.keysym);
break;
}
break;
@@ -252,6 +269,9 @@ void eventSDL()
void quitSDL()
{
printf("quit SDL..\n");
+ quitKeyboardBuffer();
+
SDL_Quit();
+
isInterfaceInit = FALSE;
}