示例#1
0
文件: joy_wii.c 项目: clobber/jzIntv
void getWiiJoyEvents()
{
   WPAD_ScanPads();
   PAD_ScanPads();
   buttonsDown[0] = WPAD_ButtonsDown(WPAD_CHAN_0);
   buttonsDown[1] = WPAD_ButtonsDown(WPAD_CHAN_1);
   buttonsHeld[0] = WPAD_ButtonsHeld(WPAD_CHAN_0);
   buttonsHeld[1] = WPAD_ButtonsHeld(WPAD_CHAN_1);
   buttonsUp[0]   = WPAD_ButtonsUp(WPAD_CHAN_0);
   buttonsUp[1]   = WPAD_ButtonsUp(WPAD_CHAN_1);
   getGamecubePadInput();
   getWiimoteAndNunchukPadInput();
   getClassicControllerPadInput();
}
示例#2
0
static void XenonInputUpdate() {
    for (int i = 0; i < MAX_INPUTS; i++) {
        old_ctrl[i] = ctrl[i];
        usb_do_poll();
        get_controller_data(&ctrl[i], i);
    }
    // update wpad
    for (int i = 0; i < MAX_INPUTS; i++) {
        wpad_xenon[i].btns_d = WPAD_ButtonsDown(i);
        wpad_xenon[i].btns_u = WPAD_ButtonsUp(i);
        wpad_xenon[i].btns_h = WPAD_ButtonsHeld(i);

        //float irx = (float)((float)PAD_StickX(i)/128.f);
        //float iry = (float)(-(float)PAD_StickY(i)/128.f)-0.5f;
        //        float iry = 0.5f-((float)PAD_StickY(i)/128.f);
        float iry = 0.5f + ((float) -PAD_StickY(i) / 128.f);
        float irx = 0.5f + ((float) PAD_StickX(i) / 128.f);

        irx *= screenwidth;
        iry *= screenheight;

        wpad_xenon[i].ir.x = irx;
        wpad_xenon[i].ir.y = iry;

        wpad_xenon[i].ir.valid = 0;
    }
}
bool UpdateManager::UpdatePackageYesOrNo()
{
	//m_pWiiManager->GetCamera()->SetCameraView(0,0) ;
	m_pWiiManager->GetMessageBox()->SetUpMessageBox( m_LatestReleaseAvailable + " Available", m_ReleaseNotes );			

	MyThread.m_Data.State = ThreadData::QUESTION;
	MyThread.m_Data.Message = "";
	MyThread.m_Data.WorkingBytesDownloaded = 0;

	// this section is logic only (a separate thread takes care of the screen updates)
	do {
		Util::SleepForMilisec(10);
		WPAD_ScanPads();
		if (WPAD_ButtonsUp(0) & WPAD_BUTTON_B)
			return false; // don't update

	} while( (WPAD_ButtonsUp(0) & WPAD_BUTTON_A ) == 0 );

	return true; // update
}
示例#4
0
void			handle_event(SDL_Surface* screen, int y)
{
  static int		i = 0;
  static int		idx = 0;
  static t_str		name("NULL");
  static const int	lim = 60;
  u32			pressed;

  WPAD_ScanPads();
  pressed = WPAD_ButtonsUp(WPAD_CHAN_0); 
  if (pressed & WPAD_BUTTON_HOME)
    {
      exit(EXIT_SUCCESS);
    }
  else if (g_choose_file && g_file.size() > 0)
    {
      if (pressed & WPAD_BUTTON_LEFT) 
	{
	  idx = (g_file.size() + idx - 1) % g_file.size();
	  name = g_file[idx];
	}
      else if (pressed & WPAD_BUTTON_RIGHT)
	{
	  idx = (g_file.size() + idx + 1) % g_file.size();
	  name = g_file[idx];
	}
      else if (strcmp(name.c_str(), "NULL") != 0 && (pressed & WPAD_BUTTON_A))
	{
	  g_fname += "/";
	  g_fname += name;
	  read_file(g_fname.c_str());
	  g_choose_file = 0;
	  g_time = 0;
	  g_score = 0;
	}
      if (i < (lim / 2))
	fontmap_printf(23, y, screen, "<%s>", name.c_str());
      else
	fontmap_printf(23, y, screen, " %s ", name.c_str());
      i = (i + 1) % lim;
    }
  else if (pressed & WPAD_BUTTON_MINUS)
    {
      g_choose_file = 1;
      g_fname = "/maps";
    }
  else if (pressed & WPAD_BUTTON_PLUS)
    {
      g_pause ^= 1;
    }
  else if (pressed & WPAD_BUTTON_UP)
    {
      g_pos_p[2] = DIR_UP;
    }
  else if (pressed & WPAD_BUTTON_LEFT)
    {
      g_pos_p[2] = DIR_LEFT;
    }
  else if (pressed & WPAD_BUTTON_RIGHT)
    {
      g_pos_p[2] = DIR_RIGHT;
    }
  else if (pressed & WPAD_BUTTON_DOWN)
    {
      g_pos_p[2] = DIR_DOWN;
    }
  else
    {
      fontmap_printf(23, y, screen,
		     "PLAYER <%02u;%02u;%u> + GHOST <%02u;%02u;%u>",
		     g_pos_p[0], g_pos_p[1], g_pos_p[2],
		     g_pos_f[0], g_pos_f[1], g_pos_f[2]);
    }
}
示例#5
0
cui_menu menu_play(cui_game* p_game)
{
	cui_menu next_state = CUI_MENU_MAIN;
	bool done=false;
	
	GRRLIB_texImg *tex_pieces = GRRLIB_LoadTexture(chess_classic_png);
	GRRLIB_texImg *tex_tile = GRRLIB_LoadTexture(keyboard_key_png);	
	GRRLIB_ttfFont* font = GRRLIB_LoadTTF(font_ttf, font_ttf_size); 
	bool is_debug = false;

	char coords[5];
	char calculated_coords[5];
	
	strcpy(coords, "d2d20");
	strcpy(calculated_coords, "d2d20");
	
	while(!done){
		WPAD_IR(0, &ir);
		WPAD_ScanPads();
		
		u32 pressed = WPAD_ButtonsDown(0);
		u32 released = WPAD_ButtonsUp(0);
		
		if(egg_check_s1_code(pressed, released)){
			is_debug = true;
			p_game->board->tile_color1 = 0xc66300FF;
			p_game->board->tile_color2 = 0x632100FF;
			p_game->board->piece_color1 = 0x4242CCFF;
			p_game->board->piece_color2 = 0x444411FF;
			cui_board_init(p_game->board);
			if(voice) AESND_PlayVoice(voice, VOICE_STEREO8, warp, warp_size, VOICE_FREQ32KHZ, 1, false);
		}

		if ( pressed & WPAD_BUTTON_HOME ){
			if(!p_game->is_mute)AESND_Pause(true);
			if(menu_home(p_game) == CUI_MENU_EXIT){done=true;next_state=CUI_MENU_EXIT;}	
			if(!p_game->is_mute)AESND_Pause(false);
		}
		
		if ( pressed & WPAD_BUTTON_MINUS){
			switch(menu_option(p_game)){
				case CUI_MENU_OPTION_GFX:menu_option_gfx(p_game);break;
				case CUI_MENU_OPTION_SND:menu_option_snd(p_game);break;
				default:break;
			}
		}
		
		int index_offset_x = (p_game->cursor->hotspot_x - 40 / 2)/ 40 - 140 / 40;
		int index_offset_y = p_game->cursor->hotspot_y / 40 - 80 / 40;
		
		if (pressed & WPAD_BUTTON_B) {
			p_game->cursor->is_grabbing = true;
			
			if(index_offset_x >= 0 && index_offset_x < 8 && index_offset_y >= 0 && index_offset_y < 8){
				coords[0] = 'a' + index_offset_x;
				coords[1] = '8' - index_offset_y;
			}
				
		}
		else if(released & WPAD_BUTTON_B){
			p_game->cursor->is_grabbing = false;

			if(index_offset_x >= 0 && index_offset_x < 8 && index_offset_y >= 0 && index_offset_y < 8){
				coords[2] = 'a' + index_offset_x;
				coords[3] = '8' - index_offset_y;
				coords[4] = 0;

				if(voice) AESND_PlayVoice(voice, VOICE_STEREO16, move_pcm, move_pcm_size, VOICE_FREQ48KHZ, 1, false);
				
				if(calculate_coords(coords, calculated_coords, p_game->engine)){
					cui_board_read_core(p_game->board, p_game->engine);
				}
				
			}
		}
		
		cui_cursor_update(p_game->cursor, ir.x, ir.y, ir.angle);
		
		
		if(p_game->tex_wallpaper)GRRLIB_DrawImg(0, -50, p_game->tex_wallpaper, 1, 1, 1, 0XFFFFFFFF);
		
		cui_board_display(p_game->board, tex_pieces, tex_tile, font, index_offset_x, index_offset_y);
		cui_cursor_display(p_game->cursor);
		
		if(is_debug){
			GRRLIB_PrintfTTF (20, 00, font, coords, 16, 0x424242FF);
			GRRLIB_PrintfTTF2 (20, 20, font, 16, 0xFFFFFFFF, "x:%.2f y:%.2f", ir.x, ir.y);
			GRRLIB_PrintfTTF2 (20, 40, font, 16, 0xFFFFFFFF, "x:%.2f y:%.2f", ir.x/40, ir.y/40);
			GRRLIB_PrintfTTF2 (20, 60, font, 16, 0xFFFFFFFF, "x:%d y:%d", index_offset_x, index_offset_y);
			GRRLIB_PrintfTTF (20, 80, font, p_game->cursor->is_grabbing?"GRAB":"POINT", 16, 0xFFFFFFFF);
			
			GRRLIB_Rectangle(p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, 4, 4, 0xFF4242FF, 1);
		}
	
		GRRLIB_Render();
	}
	
	GRRLIB_FreeTexture(tex_pieces);
	GRRLIB_FreeTexture(tex_tile);
	GRRLIB_FreeTTF(font);
		
	return next_state;
}