summaryrefslogtreecommitdiff
path: root/src/client/interface.c
diff options
context:
space:
mode:
authororoborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-08-23 11:44:09 +0000
committeroroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-08-23 11:44:09 +0000
commitc30b18c500bd0abb3362df66448febda36ff80d0 (patch)
tree10d762326878e5991eac9d7c788cde2f3b0d0fd2 /src/client/interface.c
parent9c72004fada0af13e4c9b4682c733056a777dc59 (diff)
- hotKey API
- screen-split sa da prepinat klavesou [F3] - TCP pouziva v setsockopt parameter SO_REUSEADDR git-svn-id: http://opensvn.csie.org/tuxanci_ng@243 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/client/interface.c')
-rwxr-xr-xsrc/client/interface.c57
1 files changed, 31 insertions, 26 deletions
diff --git a/src/client/interface.c b/src/client/interface.c
index eb8168f..0a0b005 100755
--- a/src/client/interface.c
+++ b/src/client/interface.c
@@ -7,6 +7,7 @@
#include "interface.h"
#include "screen.h"
#include "keyboardBuffer.h"
+#include "hotKey.h"
// window surface
static SDL_Surface *screen;
@@ -49,6 +50,28 @@ void disableKeyboardBuffer(){
keyboardBufferEnabled=FALSE;
}
+void hotkey_screen()
+{
+ if(g_win_flags & SDL_FULLSCREEN)
+ g_win_flags &= ~SDL_FULLSCREEN;
+ else
+ g_win_flags |= SDL_FULLSCREEN;
+
+ if( SDL_WM_ToggleFullScreen(screen) == 0 )
+ {
+ fprintf(stderr, _("Unable to switch to FULLSCREEN mode!\n"));
+
+ SDL_FreeSurface(screen);
+ screen = SDL_SetVideoMode(WINDOW_SIZE_X, WINDOW_SIZE_Y, WIN_BPP, g_win_flags);
+
+ if(screen == NULL)
+ {
+ fprintf(stderr, _("Unable to switch to WINDOW mode! Error: %s\n"), SDL_GetError());
+ return;
+ }
+ }
+}
+
int initSDL()
{
#ifdef DEBUG
@@ -87,7 +110,10 @@ int initSDL()
timer = SDL_AddTimer(INTERVAL, TimerCallback, NULL);
initKeyboardBuffer(KEYBOARD_BUFFER_SIZE);
-
+
+ initHotKey();
+ registerHotKey(SDLK_F1, hotkey_screen);
+
srand((unsigned)time(NULL));
isInterfaceInit = TRUE;
@@ -110,30 +136,6 @@ void interfaceRefresh()
//SDL_UpdateRect(screen, 400, 0, 400, 600);
}
-int toggleFullscreen()
-{
- if(g_win_flags & SDL_FULLSCREEN)
- g_win_flags &= ~SDL_FULLSCREEN;
- else
- g_win_flags |= SDL_FULLSCREEN;
-
- if( SDL_WM_ToggleFullScreen(screen) == 0 )
- {
- fprintf(stderr, _("Unable to switch to FULLSCREEN mode!\n"));
-
- SDL_FreeSurface(screen);
- screen = SDL_SetVideoMode(WINDOW_SIZE_X, WINDOW_SIZE_Y, WIN_BPP, g_win_flags);
-
- if(screen == NULL)
- {
- fprintf(stderr, _("Unable to switch to WINDOW mode! Error: %s\n"), SDL_GetError());
- return 0;
- }
- }
-
- return 1;
-}
-
void getMousePosition(int *x, int *y)
{
SDL_GetMouseState(x, y);
@@ -210,10 +212,11 @@ int eventAction()
return 0;
break;
*/
+/*
case SDLK_F1:
if(!toggleFullscreen())return 0;
break;
-
+*/
default:
//neni potreba vyuzivat frontu stale
if (keyboardBufferEnabled==TRUE)
@@ -228,6 +231,7 @@ int eventAction()
case USR_EVT_TIMER:
drawScreen();
eventScreen();
+ eventHotKey();
switchScreen();
break;
@@ -273,6 +277,7 @@ void quitSDL()
#ifdef DEBUG
printf(_("Quitting SDL\n"));
#endif
+ quitHotKey();
quitKeyboardBuffer();
SDL_Quit();