File: 
 
[RetroPC.NET] / 
np2 / 
sdl / 
taskmng.c
 Revision 
1.1: 
download - view: 
text, 
annotated - 
select for diffs
Fri Nov 21 15:51:13 2003 JST (21 years, 11 months ago) by 
yui
Branches: 
MAIN
CVS tags: 
VER_0_82_x64,
VER_0_82,
VER_0_81A,
VER_0_81,
VER_0_80,
VER_0_79,
VER_0_78,
VER_0_77,
VER_0_76,
VER_0_75,
VER_0_74,
VER_0_73,
VER_0_72,
HEAD
debuneko- (T.Yui)
#include	"compiler.h"
// #include	<signal.h>
#include	"inputmng.h"
#include	"taskmng.h"
#include	"sdlkbd.h"
#include	"vramhdl.h"
#include	"menubase.h"
#include	"sysmenu.h"
	BOOL	task_avail;
void sighandler(int signo) {
	(void)signo;
	task_avail = FALSE;
}
void taskmng_initialize(void) {
	task_avail = TRUE;
}
void taskmng_exit(void) {
	task_avail = FALSE;
}
void taskmng_rol(void) {
	SDL_Event	e;
	if ((!task_avail) || (!SDL_PollEvent(&e))) {
		return;
	}
	switch(e.type) {
		case SDL_MOUSEMOTION:
			if (menuvram == NULL) {
			}
			else {
				menubase_moving(e.motion.x, e.motion.y, 0);
			}
			break;
		case SDL_MOUSEBUTTONUP:
			switch(e.button.button) {
				case SDL_BUTTON_LEFT:
					if (menuvram == NULL) {
						sysmenu_menuopen(0, e.button.x, e.button.y);
					}
					else {
						menubase_moving(e.button.x, e.button.y, 2);
					}
					break;
				case SDL_BUTTON_RIGHT:
					break;
			}
			break;
		case SDL_MOUSEBUTTONDOWN:
			switch(e.button.button) {
				case SDL_BUTTON_LEFT:
					if (menuvram == NULL) {
					}
					else {
						menubase_moving(e.button.x, e.button.y, 1);
					}
					break;
				case SDL_BUTTON_RIGHT:
					break;
			}
			break;
		case SDL_KEYDOWN:
			if (e.key.keysym.sym == SDLK_F11) {
				if (menuvram == NULL) {
					sysmenu_menuopen(0, 0, 0);
				}
				else {
					menubase_close();
				}
			}
			else {
				sdlkbd_keydown(e.key.keysym.sym);
			}
			break;
		case SDL_KEYUP:
			sdlkbd_keyup(e.key.keysym.sym);
			break;
		case SDL_QUIT:
			task_avail = FALSE;
			break;
	}
}
BOOL taskmng_sleep(UINT32 tick) {
	UINT32	base;
	base = GETTICK();
	while((task_avail) && ((GETTICK() - base) < tick)) {
		taskmng_rol();
#ifndef WIN32
		usleep(960);
#else
		Sleep(1);
#endif
	}
	return(task_avail);
}
RetroPC.NET-CVS <cvs@retropc.net>