Пример #1
0
 void WindowEventListener::fireWindowEvent(Event::ConstType type, Ogre::RenderWindow* window)
 {
   size_t handle;
   window->getCustomAttribute("WINDOW", &handle);
   unsigned int width, height, depth;
   int left, top;
   window->getMetrics(width, height, depth, left, top);
   mEngine->fireEvent(WindowEvent(type, handle, width, height));
 }
Пример #2
0
/*****************************************************************
関数名 : InputKey
機能	: キー入力の受付
引数	: なし
出力	: なし
*****************************************************************/
void InputKey()
{
	SDL_Event event;
	if(SDL_PollEvent(&event)){
		switch(event.type){
        	case SDL_QUIT:
        		gState = GAME_END;
        		break;
        	case SDL_KEYDOWN:
        	//case SDL_KEYUP:
        		WindowEvent(event.key.keysym.sym);
        		break;
        	/* ジョイスティックはボタンをキーボード入力に変換して適用 */
        	case SDL_JOYAXISMOTION:
        		if(event.jaxis.axis && event.jaxis.value < 0)
        			WindowEvent(SDLK_UP);
        		else if(event.jaxis.axis && event.jaxis.value > 0)
        			WindowEvent(SDLK_DOWN);
        		else if(!event.jaxis.axis && event.jaxis.value < 0)
        			WindowEvent(SDLK_LEFT);
        		else if(!event.jaxis.axis && event.jaxis.value > 0)
        			WindowEvent(SDLK_RIGHT);
      			break;
        	case SDL_JOYBUTTONDOWN:
    			if(event.jbutton.button == 0 || event.jbutton.button == 3)
    				WindowEvent(SDLK_x); //■or○ボタン
    			else if(event.jbutton.button == 2)
    				WindowEvent(SDLK_z); //×ボタン
    			else if(event.jbutton.button == 4)
    				WindowEvent(SDLK_s); //Lボタン
    			else if(event.jbutton.button == 5)
    				WindowEvent(SDLK_d); //Rボタン
    			break;
        }
	 }
}
Пример #3
0
BOOL
consoleDoWindow (
    void
    )

/*++

Routine Description:

    Responds to a window event

Arguments:

    None.

Return Value:

    TRUE if window changed
    FALSE otherwise

--*/

{

    PINPUT_RECORD   pEvent;

    pEvent = NextEvent( NOADVANCE, NOWAIT );

    if (( EVENT_TYPE(pEvent) ) == WINDOW_BUFFER_SIZE_EVENT) {

	pEvent = NextEvent( ADVANCE, WAIT );
	WindowEvent(PWINDOW_EVT(pEvent));
    }

    return FALSE;

}
Пример #4
0
BOOL
consoleGetKey (
    PKBDKEY        Key,
     BOOL           fWait
    )
/*++

Routine Description:

    Gets the next key from  the input buffer.

Arguments:

    Key     -	Supplies a pointer to a key structure
    fWait   -	Supplies a flag:
		if TRUE, the function blocks until a key is ready.
		if FALSE, the function returns immediately.

Return Value:

    TRUE if keystroke read, FALSE otherwise.

--*/
{

    PINPUT_RECORD   pEvent;

    do {
	pEvent = NextEvent( ADVANCE, fWait );

	if (pEvent) {

	    switch ( EVENT_TYPE(pEvent) ) {

	    case KEY_EVENT:
		if (KeyEvent(PKEY_EVT(pEvent), Key)) {
		    return TRUE;
		}
		break;

	    case MOUSE_EVENT:
		MouseEvent(PMOUSE_EVT(pEvent));
		break;

	    case WINDOW_BUFFER_SIZE_EVENT:
		WindowEvent(PWINDOW_EVT(pEvent));
		break;

            case MENU_EVENT:
                MenuEvent(PMENU_EVT(pEvent));
            break;

            case FOCUS_EVENT:
                if (FocusEvent(PFOCUS_EVT(pEvent), Key)) {
		    return TRUE;
		}
            break;

	    default:
		break;
	    }
	}
    } while (fWait);

    return FALSE;
}
Пример #5
0
int main(int argc,char *argv[])
{


    timers timer;
    int lflag=0;
    int		num;
    int i;//cnum繰り返すため
    char	name[MAX_CLIENTS][MAX_NAME_SIZE];
    char	localHostName[]="localhost";
    char	*serverName;
    char	data[MAX_DATA];
    //int		clientID;

//    SDL_TimerID timer_id1;	// タイマ割り込みを行うためのタイマのID

    // SDL初期化
    if(SDL_Init(SDL_INIT_EVERYTHING) < 0) {
        printf("failed to initialize SDL.\n");
        exit(-1);
    }

    /* 引き数チェック */
    if(argc == 2){
    	serverName = localHostName;
        if (wiimote_connect(&wiimote, argv[1]) < 0) {	// コマンド引数に指定したWiiリモコン識別情報を渡して接続
            printf("unable to open wiimote: %s\n", wiimote_get_error());
            exit(1);
    }
    }
    else if(argc == 3){
    	serverName = argv[1];
        if (wiimote_connect(&wiimote, argv[2]) < 0) {	// コマンド引数に指定したWiiリモコン識別情報を渡して接続
            printf("unable to open wiimote: %s\n", wiimote_get_error());
            exit(1);
    }
    }
    else{
		fprintf(stderr, "Usage: %s, Cannot find a Server Name.\n", argv[0]);
		return -1;
    }

    /* サーバーとの接続 */
    if(SetUpClient(serverName,&clientID,name)==-1){
		fprintf(stderr,"setup failed : SetUpClient\n");
		return -1;
	}

    printf("clientnum=%d\n",cnum);

    /* スタート画面の初期化 */
    /*if(InitWindows()==-1){
		fprintf(stderr,"setup failed : InitWindows\n");
		return -1;
                }*/
    
   /*ゲームウィンドウの初期化*/
    /*  if(GameWindows(clientID,name,loop)==-1){
	fprintf(stderr,"setup failed : GameWindows\n");
		return -1;

                }*/

        printf("clientnum=%d\n",cnum);

        wiimote.mode.acc = 1;

        switch(clientID){
        case 0: wiimote.led.one =   1; break;
        case 1: wiimote.led.two   = 1; break; 
        case 2 :wiimote.led.three = 1; break;

        default: break;
        }

    /*wiiリモコンの入力受付開始*/

    // SDL_GetTicks関数を用いる時間管理
	Uint32 next_frame=SDL_GetTicks();	// SDLライブラリの初期化からの経過ミリ秒数を取得
        
        //dflag = 0;
        game.flag = 0;
        thr_net=SDL_CreateThread(thread_net,NULL);
        //thr_time=SDL_CreateThread(thread_time,NULL);
        timer_id1=SDL_AddTimer(100, callbackfunc, NULL);
    /* メインイベントループ */
    while(endFlag){
/*
        timer.now=SDL_GetTicks();//現在時間を取得
        timer.wit=timer.now-timer.lev;//待ち時間を計算

        if(dflag == 0)
        {
            WindowEvent(clientID);
            //timer.lev=SDL_GetTicks();//経過時間を更新
        }
        else if(timer.wit > 16){
            WindowEvent(clientID);
            dflag = 0;
            timer.lev=SDL_GetTicks();//経過時間を更新
        }
*/
        timer.wit=timer.now-timer.lev;//待ち時間を計算

        /*if(timer.wit > 1000){
            game.restTime--;
            timer.lev=SDL_GetTicks();//経過時間を更新
            }*/


        /********メイン画面ループ**************/
        if(game.flag == 0){
            loop=1;
            gametimes=3;
            TopWindow();
            printf("now==%d\n\n",game.flag);
            while(game.flag == 0){
                WindowEvent(clientID,ima);
                if(endFlag == 0)
                    break;
            }
        }
        else if(game.flag == 1){//ゲーム画面作成
            
            if(GameWindows(clientID,name,loop)==-1){
                fprintf(stderr,"setup failed : GameWindows\n");
		return -1;}
        }
        /*********ゲーム画面ループ************/
        else if(game.restTime > 0 && game.flag == 2){
            WindowEvent(clientID,ima);  
            ima=SDL_GetTicks();//現在時間を取得
            //printf("game.restTime:%d\n",game.restTime);
//>>>>>>> color
            DrawChara(clientID,cnum);
        }
        
        else if(game.flag == 3 || game.restTime <= 0)
        {
            game.flag = 3;
            if(gClients[clientID].ADsta==1 && game.restTime<=0){
                gClients[clientID].score -= gClients[clientID].Bflag;
                sprintf(data,"kabaddi,%d,%d,%d,%d,%d,%d,%d,%d\0",SCORE,clientID,gClients[clientID].score,0,0,0,0,0);
                SendData(data);
                }
            WinDisplay(clientID);
            
            printf("now==%dloop==%dcnum==%dgametimes=%d\n\n",game.flag,loop,cnum,gametimes);
            while(game.flag == 3){
                WindowEvent(clientID,ima);
                if(endFlag == 0)
                    break;
            }
        }
        else if(game.flag == 4){
            //loop=0;
            EndWindow();
            for(i=0;i<cnum;i++){
                gClients[i].score=0;
                //gClients[i].restart=0;
                // gametimes=3;
            }
            while(game.flag == 4){
                WindowEvent(clientID,ima);
                if(endFlag == 0)
                    break;
            }    
            
        }
        
        timer.lev=SDL_GetTicks();//経過時間を更新
        
        
        
        
        // timer.now=SDL_GetTicks();//現在時間を取得
        //timer.wit=timer.now-timer.lev;//待ち時間を計算
        
        // if(timer.wit<16)
            //    SDL_Delay(16-timer.wit);//16以下ならCPUを休ませる
        
        //timer.lev=SDL_GetTicks();//経過時間を更新
        
    }
    
    /* 終了処理 */
    SDL_RemoveTimer(timer_id1);
    DestroyWindow();
    CloseSoc();
    
    return 0;
}
Пример #6
0
 void WindowManager::fireWindowEvent(Event::ConstType type, unsigned long handle, unsigned int width, unsigned int height)
 {
   fireEvent(WindowEvent(type, handle, width, height));
 }