/*****************************************************************
  関数名	: InitWindows
  機能	: メインウインドウの表示,設定を行う
  引数	: int	clientID		: クライアント番号
  int	num				: 全クライアント数
  出力	: 正常に設定できたとき0,失敗したとき-1
 *****************************************************************/
int InitWindows(int clientID,int num,char name[][MAX_NAME_SIZE])
{
    int i;
    //SDL_Surface *image;
    //////////////////////////////////////////////////////////////////////////////////////
    /*変更点 画像のファイル名を変更してグー、チョキ、パーが表示できるようにした*/
    char clientButton[4][6]={"0.jpg","1.jpg","2.jpg"};
    char endButton[]="END.jpg";
    char allButton[]="ALL.jpg";


    char *s,title[10];

    /* 引き数チェック */
    assert(0<num && num<=MAX_CLIENTS);
    SDL_EnableKeyRepeat(0,1);
    /* SDLの初期化 */
    if(SDL_Init(SDL_INIT_VIDEO) < 0) {
        printf("failed to initialize SDL.\n");
        return -1;
    }

    /* メインのウインドウを作成する */
    if((gMainWindow = SDL_SetVideoMode(600,400, 32, SDL_SWSURFACE)) == NULL) {
        printf("failed to initialize videomode.\n");
        return -1;
    }
    SDL_FillRect(gMainWindow, NULL, 0x000000ff); //to blue
    stringColor(gMainWindow, 0, 0, "Press buttons 1 and 2 on the wiimote now to connect.\n", 0xffffffff);

    SDL_Flip(gMainWindow);
    /* ウインドウのタイトルをセット */
    sprintf(title,"Battle of Soft Character %d",clientID);
    SDL_WM_SetCaption(title,NULL);

    // ***** Wiiリモコン処理 *****
    wiimote_t wiimote = WIIMOTE_INIT;
    data.wiimote=wiimote;
    wiimote_report_t report = WIIMOTE_REPORT_INIT;

    // Wiiリモコンの接続(1つのみ)
    if(strcmp(wiiName,"key") !=0){
        if (wiimote_connect(&data.wiimote, wiiName) < 0) {   // コマンド引数に指定したWiiリモコン識別情報を渡して接続
            printf("unable to open wiimote: %s\n", wiimote_get_error());
            exit(1);
        }
    }
    //Wiiリモコンのレポートタイプを指定する
    if (wiimote_report(&data.wiimote, &report, sizeof(report.status)) < 0) {
        wiimote_disconnect(&data.wiimote);
    }
    data.wiimote.led.one  = 1;   
    data.wiimote.mode.acc = 1;//加速度センサをオンにする
    /* 背景を白にする */
    SDL_FillRect(gMainWindow,NULL,0xffffff);

    /* ボタンの作成 */
    ///////////////////////////////////////////////////////////////////////////////////
    /*変更点 クライアントの数だけボタンが作成されるが、ここで3つしかボタンをつくらないことにする。
      (選択用のボタン3つと終了用のボタン1つ)
     */
    //   for(i=0;i<4;i++){
    /* if (i < 3){
       /gButtonRect[i].x=20+150*i;
       gButtonRect[i].y=10;
       gButtonRect[i].w=135;
       gButtonRect[i].h=135;/
       gButtonRect[i].x=20+150*i;
       gButtonRect[i].y=10;
       gButtonRect[i].w=135;
       gButtonRect[i].h=135;
       }else{
       gButtonRect[i].x=400;
       gButtonRect[i].y=260;
       gButtonRect[i].w=70;
       gButtonRect[i].h=20;
       }*/
    /*if(i==3){
      s=endButton;
      }else{
      s=clientButton[i];
      }

      s = endButton;
      image = IMG_Load(s);
      SDL_BlitSurface(image,NULL,gMainWindow,&(gButtonRect[i]));
      SDL_FreeSurface(image);
     */
    // }
    SDL_Flip(gMainWindow);

    return 0;
}
Example #2
0
static void wiimote_reportMotionplus(t_wiimote *x, t_floatarg f)
{
   wiimote_report(x, gensym("motionplus"), f);
}
Example #3
0
static void wiimote_reportIR(t_wiimote *x, t_floatarg f)
{
   wiimote_report(x, gensym("ir"), f);
}
Example #4
0
static void wiimote_reportNunchuk(t_wiimote *x, t_floatarg f)
{
   wiimote_report(x, gensym("nunchuk"), f);
}
Example #5
0
static void wiimote_reportAcceleration(t_wiimote *x, t_floatarg f)
{
   wiimote_report(x, gensym("acceleration"), f);
}