예제 #1
0
파일: widget.c 프로젝트: cgbarnwell/mvpmc
void
mvpw_hide(mvp_widget_t *widget)
{
	mvp_widget_t *top;

	if (widget) {
		if (widget == modal_focus) {
			if ((widget->below->type == MVPW_DIALOG) &&
			    widget->below->data.dialog.modal) {
				modal_focus = widget->below;
			} else {
				modal_focus = NULL;
			}
		}

		GrUnmapWindow(widget->wid);
		if(widget->show) (*widget->show)(widget, 0);
		if ((top=widget->below))
			widget->below->above = widget->above;
		if (widget->above) {
			top = widget->above;
			widget->above->below = widget->below;
		}

		if (modal_focus) {
			GrSetFocus(modal_focus->wid);
		} else if ((widget->above == NULL) && top) {
			GrSetFocus(top->wid);
		}

		widget->below = NULL;
		widget->above = NULL;
	}
}
예제 #2
0
static void
GrUnmapWindowWrapper(void *r)
{
	nxUnmapWindowReq *req = r;

	GrUnmapWindow(req->windowid);
}
예제 #3
0
void CContextWeather::ButtonDown(UINT usGpioFlag, UINT usEventEnum)
{
	DBGMSGC(DBG_WEATHER, "++\r\n");

	if(usEventEnum == MTM_GPIO_BUTTON_DOWN)
	{
	}
	else if(usEventEnum == MTM_GPIO_BUTTON_LONG)
	{
		if( CHK_FLAG(usGpioFlag, BIT_FLAG(GPIO_FRONT_RIGHT_TOP)|BIT_FLAG(GPIO_FRONT_RIGHT_BOTTOM)) ||
			CHK_FLAG(usGpioFlag, BIT_FLAG(GPIO_REAR_VOL_UP)|BIT_FLAG(GPIO_REAR_VOL_DOWN)) )
		{
			if (!CHK_FLAG(usGpioFlag, BIT_FLAG(GPIO_FRONT_RIGHT_MIDDLE))) {
				GrUnmapWindow(m_wid_ment);

				//Ment Scroll Window 영역이 까맣게 보이는 증상이 있어서 배경으로 다시 덮어줌
				RedrawImage(g_wid, g_gc, MENT_AREA_X, MENT_AREA_Y, MENT_AREA_WIDTH, MENT_AREA_HEIGHT, 
							MENT_AREA_X, MENT_AREA_Y, MENT_AREA_WIDTH, MENT_AREA_HEIGHT, WEATHER_OBJ_BG);

				g_state.ChangeState(STATE_SETUP);
			}
		}
	}

	DBGMSGC(DBG_WEATHER, "--\r\n");
}
예제 #4
0
static void
do_update(GR_EVENT_UPDATE *ep)
{
	mwin *	mwp;
	mwin *	tmwp;
	GR_WINDOW_INFO winfo;

	if (IsDecoration(ep->wid)) return;

	if ((mwp = FindWindow(ep->wid)) == NULL) {
		/* We have a new window */
		if (ep->utype != GR_UPDATE_MAP) return;
		if ((mwp = NewWindow(ep->wid)) == NULL) {
			GrError("malloc failed\n");
			return;
		}
		GrGetWindowInfo(ep->wid, &winfo);
		mwp->x = ep->x - winfo.bordersize;
		mwp->y = ep->y - winfo.bordersize;
		mwp->width = ep->width + 2 * winfo.bordersize;
		GrMoveWindow(mwp->wid, mwp->x + winfo.bordersize,
					mwp->y + DEC_HEIGHT +
						2 * winfo.bordersize);
		mwp->fid = GrNewWindow(GR_ROOT_WINDOW_ID, mwp->x + 1,
				mwp->y + 1, mwp->width - 2,
				DEC_HEIGHT - 2, 1, BLUE, BLACK);
		GrSelectEvents(mwp->fid, GR_EVENT_MASK_BUTTON_DOWN |
			GR_EVENT_MASK_BUTTON_UP | GR_EVENT_MASK_MOUSE_POSITION);
		GrMapWindow(mwp->fid);
	} else {
		switch (ep->utype) {
			case GR_UPDATE_UNMAP:
				GrUnmapWindow(mwp->fid);
				GrDestroyWindow(mwp->fid);
				if (mwins == mwp) {
					mwins = mwp->next;
				} else for(tmwp = mwins; tmwp; tmwp = tmwp->next) {
					if (tmwp->next == mwp) {
						tmwp->next = mwp->next;
					}
				}
				free(mwp);
				break;
			case GR_UPDATE_MOVE:
				GrGetWindowInfo(ep->wid, &winfo);
				if ((ep->x == (mwp->x + winfo.bordersize)) &&
					(ep->y == (mwp->y + winfo.bordersize
							+ DEC_HEIGHT))) {
					return;
				}
				mwp->x = ep->x - winfo.bordersize;
				mwp->y = ep->y - winfo.bordersize - DEC_HEIGHT;
				GrMoveWindow(mwp->fid, mwp->x + 1, mwp->y + 1);
			default:
				break;
		}
	}
}
예제 #5
0
int NX_LeaveFullScreen (_THIS)
{
    if (currently_fullscreen) {
        GrUnmapWindow (FSwindow) ;
        GrMapWindow (SDL_Window) ;
        GrRaiseWindow (SDL_Window) ;
        GrSetFocus (SDL_Window) ;
        currently_fullscreen = 0 ;
    }

    return 0 ;
}
예제 #6
0
void draw_pause_continue_button(nstate *state)
{
	if((state->running_buttons_mapped) && (state->state == STATE_STOPPED)) {
		GrUnmapWindow(state->pause_continue_button);
		GrUnmapWindow(state->anticlockwise_button);
		GrUnmapWindow(state->clockwise_button);
		GrUnmapWindow(state->left_button);
		GrUnmapWindow(state->right_button);
		GrUnmapWindow(state->drop_button);
		state->running_buttons_mapped = 0;
		return;
	}
	if((!state->running_buttons_mapped) && (state->state == STATE_RUNNING)){
		GrMapWindow(state->pause_continue_button);
		GrMapWindow(state->anticlockwise_button);
		GrMapWindow(state->clockwise_button);
		GrMapWindow(state->left_button);
		GrMapWindow(state->right_button);
		GrMapWindow(state->drop_button);
		state->running_buttons_mapped = 1;
		return;
	}
	if(!state->running_buttons_mapped) return;
	GrFillRect(state->pause_continue_button, state->buttongcb, 0, 0,
		PAUSE_CONTINUE_BUTTON_WIDTH, PAUSE_CONTINUE_BUTTON_HEIGHT);
	if(state->state == STATE_PAUSED) {
		GrText(state->pause_continue_button, state->buttongcf,
			TEXT_X_POSITION, TEXT_Y_POSITION, " Continue", 9, 0);
	} else {
		GrText(state->pause_continue_button, state->buttongcf,
			TEXT_X_POSITION, TEXT_Y_POSITION, "   Pause", 8, 0);
	}
}
예제 #7
0
int NX_EnterFullScreen (_THIS)
{
    if (! currently_fullscreen) {
        GR_SCREEN_INFO si ;

        GrGetScreenInfo (& si) ;
        GrResizeWindow (FSwindow, si.cols, si.rows) ;
        GrUnmapWindow (SDL_Window) ;
        GrMapWindow (FSwindow) ;
        GrRaiseWindow (FSwindow) ;
        GrSetFocus (FSwindow) ;
        currently_fullscreen = 1 ;      
    }

    return 1 ;
}
예제 #8
0
void CContextWeather::ButtonUp(UINT usGpioFlag, UINT usEventEnum)
{
	DBGMSGC(DBG_WEATHER, "++\r\n");

	if(usEventEnum == MTM_GPIO_BUTTON_UP)
	{
		switch(usGpioFlag)
		{
		case GPIO_FLAG_FRONT_LEFT_TOP:		//Weather
			if(g_pWallPad)
			{
				g_pWallPad->RequestWeatherInfo();	//날씨정보요청
			}
			break;
		case GPIO_FLAG_FRONT_LEFT_MIDDLE:	//Elevator
			g_state.ChangeState(STATE_ELEVATOR);
			break;
		case GPIO_FLAG_FRONT_LEFT_BOTTOM:	//Parking
			g_state.ChangeState(STATE_PARKING);
			break;
		case GPIO_FLAG_FRONT_RIGHT_TOP:		//Gas
			g_state.ChangeState(STATE_GAS);
			break;
		case GPIO_FLAG_FRONT_RIGHT_MIDDLE:	//Light
			g_state.ChangeState(STATE_LIGHT);
			break;
		case GPIO_FLAG_FRONT_RIGHT_BOTTOM:	//Security
			g_state.ChangeState(STATE_SECURITY);
			break;
		default:
			return;
		}

		if(usGpioFlag != GPIO_FLAG_FRONT_LEFT_TOP)
		{
			GrUnmapWindow(m_wid_ment);

			//Ment Scroll Window 영역이 까맣게 보이는 증상이 있어서 배경으로 다시 덮어줌
			RedrawImage(g_wid, g_gc, MENT_AREA_X, MENT_AREA_Y, MENT_AREA_WIDTH, MENT_AREA_HEIGHT, 
						MENT_AREA_X, MENT_AREA_Y, MENT_AREA_WIDTH, MENT_AREA_HEIGHT, WEATHER_OBJ_BG);
		}
	}

	DBGMSGC(DBG_WEATHER, "--\r\n");
}
예제 #9
0
파일: img_demo.c 프로젝트: EPiCS/reconos_v2
void
show_jpeg(int client, char *file, int show_time)
{
    GR_EVENT        event;          /* current event */
    GR_IMAGE_ID     id = 0;
    GR_SIZE         w = -1;
    GR_SIZE         h = -1;
    GR_IMAGE_INFO   info;
    GR_WINDOW_ID    w1;             /* id for large window */
    GR_GC_ID        gc1;            /* graphics context for text */
    GR_SCREEN_INFO  si;

    int time_left;
    bool ever_exposed = false;

#if !defined(HAVE_JPEG_SUPPORT) && !defined(HAVE_BMP_SUPPORT) && !defined(HAVE_GIF_SUPPORT)
    printf("Sorry, no image support compiled in\n");
    exit(1);        
#endif

    GrGetScreenInfo(&si);
    printf("Loading image: %s\n", file);
    if (access(file, F_OK) < 0) {
        fdprintf(client, "Can't access \"%s\": %s\n", file, strerror(errno));
        return;
    }
    id = GrLoadImageFromFile(file, 0);
    if (id) {
        GrGetImageInfo(id, &info);
    } else {
        // File exists, so why the error?
        int fd, len;
        char buf[64];
        fdprintf(client, "Can't load %s\n", file);
        if ((fd = open(file, O_RDONLY)) >= 0) {
            len = read(fd, buf, 64);
            if (len != 64) {
                diag_printf("Short read? len = %d\n", len);
            } else {
                diag_dump_buf(buf, len);
            }
            close(fd);
        } else {
            diag_printf("Can't oopen \"%s\": %s\n",  file, strerror(errno));
        }
        return;
    }

    w = info.width;
    h = info.height;
    if ((si.rows < info.height) || (si.cols < info.width)) {
        // Preserve aspect ratio
        if (si.cols < info.width) {
            w = si.cols;
            h = (si.cols * info.height) / info.width;
        }
        if (si.rows < h) {
            w = (si.rows * w) / h;
            h = si.rows;
        }
    }
    printf("Create window - orig %dx%d => %dx%d\n", info.width, info.height, w, h);
    fdprintf(client, "<INFO> Display \"%s\" - orig %dx%d => %dx%d\n", file, info.width, info.height, w, h);
    w1 = GrNewWindow(GR_ROOT_WINDOW_ID, 10, 10, w, h, 4, BLACK, WHITE);
    GrSelectEvents(w1, GR_EVENT_MASK_CLOSE_REQ|GR_EVENT_MASK_EXPOSURE);
    GrMapWindow(w1);
    gc1 = GrNewGC();
    GrSetGCForeground(gc1, WHITE);

#define TO_MS 50
    time_left = show_time * 1000;
    while (time_left > 0) {
        GrGetNextEventTimeout(&event, TO_MS);  // milliseconds
        switch(event.type) {
        case GR_EVENT_TYPE_CLOSE_REQ:
            GrDestroyWindow(w1);
            GrFreeImage(id);
            return;
            /* no return*/
        case GR_EVENT_TYPE_EXPOSURE:
            /*GrDrawImageFromFile(w1, gc1, 0, 0, w, h, argv[1],0);*/
            GrDrawImageToFit(w1, gc1, 0, 0, w, h, id);
            ever_exposed = true;
            break;
        default:
        case GR_EVENT_TYPE_NONE:
        case GR_EVENT_TYPE_TIMEOUT:
            time_left -= TO_MS;
            if ((time_left < 0) && !ever_exposed) {
                // Things get real cranky if we delete the window too fast!
                time_left = TO_MS;
            }
            break;
        }
    }    
    GrUnmapWindow(w1);
    GrDestroyWindow(w1);
    GrDestroyGC(gc1);
    GrFreeImage(id);
}
예제 #10
0
int
main(int ac,char **av)
{
	GR_WINDOW_ID 	w;
	GR_GC_ID	gc;
	GR_FONT_ID	font;
	GR_WINDOW_INFO wi;

	if (GrOpen() < 0) {
		GrError("Can't open graphics\n");
		return 1;
	}

	//w = GrNewWindowEx(GR_WM_PROPS_APPWINDOW|GR_WM_PROPS_NOBACKGROUND, "Nano-X Demo2",
		//GR_ROOT_WINDOW_ID, 20, 20, 320, 240, BLACK);
	w = GrNewWindowEx(GR_WM_PROPS_BORDER|GR_WM_PROPS_NOBACKGROUND, "Nano-X Demo2",
		GR_ROOT_WINDOW_ID, 20, 20, 320, 240, BLACK);

	gc = GrNewGC();
	//font = GrCreateFontEx("lubI24.pcf", 0, 0, NULL);
	font = GrCreateFontEx("helvB12.pcf.gz", 0, 0, NULL);
	GrSetGCFont(gc, font);

	GrSelectEvents(w, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_CLOSE_REQ
		| GR_EVENT_MASK_BUTTON_DOWN | GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_KEY_UP);
	GrMapWindow(w);
	GrSetFocus(w);

	// pass errors through main loop
	GrSetErrorHandler(NULL);

	for (;;) {
		GR_EVENT 	event;

		GrGetNextEvent(&event);

		switch (event.type) {
		case GR_EVENT_TYPE_EXPOSURE:
			GrSetGCForeground(gc,GrGetSysColor(GR_COLOR_APPWINDOW));
			GrFillRect(w, gc, event.exposure.x, event.exposure.y,
				event.exposure.width, event.exposure.height);
			GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_APPTEXT));
			GrSetGCUseBackground(gc, GR_FALSE);
			GrText(w, gc, 10, 30, "Hello World", -1, GR_TFASCII);
            GrRect(w, gc, 5, 5, 300, 60);
			GrGetWindowInfo(w, &wi);
			GrError("Exposure:wi.width:%d,wi.height:%d,wi.x:%d,wi.y:%d,wi.parent:%d\n",wi.width,wi.height,wi.x,wi.y,wi.parent);
			break;

		case GR_EVENT_TYPE_BUTTON_DOWN:
			// FIXME unmap window is broken
			GrUnmapWindow(w);
			GrFlush();
			GrMapWindow(w);

			//uncomment to test server error on bad syscall
			//GrMoveWindow(GR_ROOT_WINDOW_ID, 0, 0);

			GrGetWindowInfo(w, &wi);
			GrError("Button:  wi.width:%d,wi.height:%d,wi.x:%d,wi.y:%d,wi.parent:%d\n",wi.width,wi.height,wi.x,wi.y,wi.parent);
			break;

		case GR_EVENT_TYPE_ERROR:
			GrError("demo2: Error (%s) ", event.error.name);
			GrError(nxErrorStrings[event.error.code], event.error.id);
			break;

		case GR_EVENT_TYPE_CLOSE_REQ:
			GrClose();
			return 0;
		}
	}
	return 0;
}
예제 #11
0
static int keyman_handle_event(GR_EVENT * event)
{
	int ret = 0;
    switch( event->type )
    {
    case( GR_EVENT_TYPE_TIMER ):
	
	switch(GAMEN){
		
		
		case MENU:
			makemenu();
			
			MINIPHOTO(0,0,160,128);
			wlastkey.AR=0;wlastkey.AL=0;wlastkey.AU=0;wlastkey.AD=0;wlastkey.REE=0;wlastkey.PAU=0;
			break;
		case INGAME:
			
		
		
		
			if (wlastkey.AL==1){wnow.LR=-1;wnow.MUKI=-1;}
			else if(wlastkey.AR==1){wnow.LR=1;wnow.MUKI=1;}
			else {wnow.LR=0;}
			
			
			if(wlastkey.REE==1){
					if(wnow.JIMEN==ZIM){
					wnow.YKANSEI=-9;
					wnow.JIMEN=SORA;
					}
					else if (wnow.HASIGO==1){
					wnow.YKANSEI=-9;
					wnow.JIMEN=SORA;
					wnow.HASIGO=0;
					
					}
			}
			
			if (INIT(wnow.XLOC+8,wnow.YLOC+8,'G')==FALSE){wnow.HASIGO=0;}
			
			
			
			if (INIT(wnow.XLOC+8,wnow.YLOC+8,'G')== TRUE && wlastkey.AU !=0){
				wnow.HASIGO=1;
				wnow.shupict=2;
				//GrCopyArea(shu_pixmap,keyman_gc,0,0,16,16,yomipict_pixmap,32,112,0);
				wnow.XKANSEI=0;
				//wnow.YLOC=wnow.YLOC-3;
				}
			else if (INIT(wnow.XLOC+8,wnow.YLOC+8,'G')== TRUE && wlastkey.AD !=0){
				wnow.HASIGO=0;
				//GrCopyArea(shu_pixmap,keyman_gc,0,0,16,16,yomipict_pixmap,32,112,0);
				wnow.XKANSEI=0;
				//wnow.YLOC=wnow.YLOC+3;	
				}
				
			
			if (wnow.JIMEN==ZIM){wnow.XKANSEI=(0.9*wnow.XKANSEI)+(1*wnow.LR);}
			else {
				if (wnow.LR != 0){
				wnow.XKANSEI=(0.99*wnow.XKANSEI)+(0.3*wnow.LR);
				}
			}
			if (wnow.HASIGO==0 ){
				if (wnow.YKANSEI <= 6){
					wnow.YKANSEI++;
				}
			}
			else {wnow.YKANSEI=0;}
			
			
			

			
			wnow.XLOC=wnow.XLOC+wnow.XKANSEI;
			wnow.YLOC=wnow.YLOC+wnow.YKANSEI;
			
			
			if (wnow.NUPDW==-1 && ((wnow.MAPSCROLL) % 16)==0){wnow.YLOC=wnow.YLOC+16;}
			else if (wnow.NUPDW==1 && (wnow.MAPSCROLL % 16)==15){wnow.YLOC=wnow.YLOC-16;}
			
			
			
			if (wnow.MAPSCROLL>0 && wnow.MAPSCROLL<TATEHABA*16){
				wnow.MAPSCROLL=wnow.MAPSCROLL+wnow.NUPDW;
			}
			scr= (wnow.MAPSCROLL/16);
			ATARI2();
						
			
			if (wlastkey.AU != 1 && wlastkey.AD != 1){
			 if (wnow.MUKI==1){
			 wnow.shupict=0;
			 //GrCopyArea(shu_pixmap,keyman_gc,0,0,16,16,yomipict_pixmap,0,112,0);
			 }
			 else {
			 wnow.shupict=1;
			 //GrCopyArea(shu_pixmap,keyman_gc,0,0,16,16,yomipict_pixmap,16,112,0);
			 }
			}			
			
						
			if (wnow.NUPDW==-1 && wnow.YLOC>136){
				wdeady.sp=-20;
				wdeady.g=1.6;
				wdeady.nowt=128;
				GAMEN=END;
				wdeady.kaiten=0;
				ketumatu=0;
				wdeady.deadcount=1;}
				
			else if(wnow.NUPDW==1 && wnow.YLOC<0){
				wdeady.sp=12;
				wdeady.g=0;
				wdeady.nowt=-16;
				GAMEN=END;
				wdeady.kaiten=0;
				ketumatu=0;
				wdeady.deadcount=1;}
			else if (wnow.NUPDW==0 && (wnow.YLOC>136)) {
			
				wdeady.sp=-10;
				wdeady.g=1.6;
				wdeady.nowt=128;
				GAMEN=END;
				wdeady.kaiten=0;
				ketumatu=0;
				wdeady.deadcount=1;}
					
				
			
			GrCopyArea(mainmenu_pixmap,keyman_gc,0,0,160,128,allmap_pixmap,0,wnow.MAPSCROLL,0);
			kmbitmap();
			//GrCopyArea(mainmenu_pixmap,keyman_gc,wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)),160,128,shu_pixmap,0,0,0);
			hensu();		
			
			MINIPHOTO(0,0,160,128);
			if (wlastkey.PAU==1){GAMEN=PAUSE;}
			
			wlastkey.AR=0;wlastkey.AL=0;wlastkey.AU=0;wlastkey.AD=0;wlastkey.REE=0;wlastkey.PAU=0;
			break;
		case PAUSE:
			GrCopyArea(dialogall_pixmap,keyman_gc,0,0,96,80,dialog_pixmap,0,0,0);
			GrCopyArea(dialogall_pixmap,keyman_gc,3,24+(dialogkey*24),13,16,yomipict_pixmap,115,48,0);
			GrCopyArea(keyman_wid,keyman_gc,32+((screen_info.cols-160)/2),24+((screen_info.rows-128)/2),96,80,dialogall_pixmap,0,0,0);
			
			break;
		case END:
				if (ketumatu==0){
					wdeady.sp=wdeady.sp+wdeady.g;
					wdeady.nowt=wdeady.nowt+wdeady.sp;
					//sprintf(hensuu,"%d",wnow.MAPSCROLL+(wdeady.deadcount*wnow.NUPDW));
					
					if (wnow.MAPSCROLL+(wdeady.deadcount*wnow.NUPDW)>0 && wnow.MAPSCROLL+(wdeady.deadcount*wnow.NUPDW)<TATEHABA*16){
						GrCopyArea(mainmenu_pixmap,keyman_gc,0,0,160,128,allmap_pixmap,0,wnow.MAPSCROLL+(wdeady.deadcount*wnow.NUPDW),0);
					}
					
					GrCopyArea(shu_pixmap,keyman_gc,0,0,16,16,yomipict_pixmap,wdeady.kaiten*16,16,0);
					GrCopyArea(mainmenu_pixmap,keyman_gc,wnow.XLOC,wdeady.nowt,160,128,shu_pixmap,0,0,0);
					hensu();
					
					MINIPHOTO(0,0,160,128);
					if (wdeady.kaiten<7){wdeady.kaiten++;}else{wdeady.kaiten=0;}
					if (training==0){
						if (wdeady.deadcount>31){GAMEN=MENU;
					
						}   
					}
					else if (training==1){
						if (wdeady.deadcount>15){opencard();GAMEN=INGAME;
						}
						
					}
					wdeady.deadcount++;
				}
				else if (ketumatu==1){
					if (training==0){
					GAMEN=MENU;
					}
					if (training==1){
						if (tranum>=MAXTRA){
							GAMEN=MENU;
						}
						else{
							startgame();
							GAMEN=INGAME;
						}
					
					}
				}
			break;
		case NODATA:
			GrSetGCForeground(keyman_gc, WHITE);
			GrFillRect(keyman_wid,keyman_gc,0,0,160,128);
			
			GrSetGCForeground(keyman_gc, GRAY);
			GrLine(keyman_wid,keyman_gc,80,20,34,100);
			GrLine(keyman_wid,keyman_gc,80,20,126,100);
			GrLine(keyman_wid,keyman_gc,34,100,126,100);
			GrEllipse(keyman_wid,keyman_gc,80,55,5,20);
			GrEllipse(keyman_wid,keyman_gc,80,85,5,5);
			
			GrSetGCForeground(keyman_gc, BLACK);
			GrText(keyman_wid,keyman_gc,50,48,"Please Copy",-1,GR_TFASCII|GR_TFTOP);
			GrText(keyman_wid,keyman_gc,30,68,"KMData folder to /etc",-1,GR_TFASCII|GR_TFTOP);
			GrText(keyman_wid,keyman_gc,50,100,"Click to Quit",-1,GR_TFASCII|GR_TFTOP);
			break;
		}
		
			
	break;
	

    case( GR_EVENT_TYPE_KEY_DOWN ):
	
	switch(GAMEN){
		case INGAME:
			if (event->keystroke.ch==wsetkey.KLEFT){wlastkey.AL=1;}else{wlastkey.AL=0;}
			if (event->keystroke.ch==wsetkey.KRIGHT){wlastkey.AR=1;}else{wlastkey.AR=0;}
			if (event->keystroke.ch==wsetkey.KUP){wlastkey.AU=1;}else{wlastkey.AU=0;}
			if (event->keystroke.ch==wsetkey.KDOWN){wlastkey.AD=1;}else{wlastkey.AD=0;}
			if (event->keystroke.ch==wsetkey.KJUMP){wlastkey.REE=1;}else{wlastkey.REE=0;}
			if (event->keystroke.ch==wsetkey.KPAUSE){wlastkey.PAU=1;}else{wlastkey.PAU=0;}
			break;
		case MENU:
			switch( event->keystroke.ch )
			{
	    
			case '\r': /* action */
				switch (wmenukey.BA){
				case 0:if (wmenukey.KEY<2){wmenukey.KEY++;}else{wmenukey.KEY=1;}break;	
				case 1:if (wmenukey.STAGE<MAXSTAGE){wmenukey.STAGE++;}
						else {wmenukey.STAGE=1;}
						break;
				
				case 2: GAMEN=INGAME; 
					training=0;
					startgame();
					break;
				case 3:GAMEN=INGAME;
					tranum=0;
					training=1;
					startgame();
					break;
				case 4: pz_close_window(keyman_wid);
					GrDestroyTimer(keyman_timer);
					GrUnmapWindow(keyman_wid);
					GrDestroyWindow(keyman_wid);
					GrFreeImage(kmimage_id);
					GrDestroyGC(keyman_gc);
					ret = 1;
					break;
				}
			break;
			case 'r': /* CCW spin */
			if (wmenukey.BA<4){ipod_beep();wmenukey.BA++;}		
			break;

			case 'l': /* CW spin */
			if (wmenukey.BA>0){ipod_beep();wmenukey.BA--;}
			break;
			
			case 'm': /* menu */
					pz_close_window(keyman_wid);
					GrDestroyTimer(keyman_timer);
					GrUnmapWindow(keyman_wid);
					GrDestroyWindow(keyman_wid);
					GrFreeImage(kmimage_id);
					GrDestroyGC(keyman_gc);
					ret = 1;		
			break;
			}
			break;
			
					
		case PAUSE:
			if (event->keystroke.ch==wsetkey.KLEFT && dialogkey == 1){ipod_beep();dialogkey=0;}
			if (event->keystroke.ch==wsetkey.KRIGHT && dialogkey == 0){ipod_beep();dialogkey=1;}
			if (event->keystroke.ch==wsetkey.KJUMP && dialogkey == 0){GAMEN=INGAME;}
			else if (event->keystroke.ch==wsetkey.KJUMP && dialogkey == 1){GAMEN=MENU;}
			
			break;
		case END:break;
		case NODATA:
			if (event->keystroke.ch=='\r'){
			GrDestroyTimer(keyman_timer);
			GrUnmapWindow(keyman_wid);
			GrDestroyWindow(keyman_wid);
			GrFreeImage(kmimage_id);
			GrDestroyGC(keyman_gc);
			ret = 1;
			}
			break;
		}
	
	
	
	break;
    }

    return ret;
}