예제 #1
0
파일: input.c 프로젝트: BruceJawn/FlashNES
static void KeyboardCommands(void)
{
  int is_shift, is_alt;

  keys=GetKeyboard(); 

  if(InputType[2]==SIFC_FKB)	// Family Keyboard (FKB)
  {
   if(keyonly(SCROLLLOCK)) 
   {
    cidisabled^=1;
    FCEUI_DispMessage("Family Keyboard %sabled.",cidisabled?"en":"dis");
   }
   #ifdef SDL
   	SDL_WM_GrabInput( cidisabled? SDL_GRAB_ON: SDL_GRAB_OFF );
   #endif
   if(cidisabled) return;
  }

  is_shift = KEY(LEFTSHIFT) | KEY(RIGHTSHIFT);
  is_alt = KEY(LEFTALT) | KEY(RIGHTALT);

   #ifdef SDL
	if(keyonly(F4))
	{
		if(is_shift)
			FCEUI_SetRenderDisable(-1, 2);
		else
			FCEUI_SetRenderDisable(2, -1);
	}
	#endif
	
	#if defined(SDL) && !defined(FLASH)
		if(keyonly(ENTER) && is_alt) ToggleFS();
	#endif


// Disable most keyboard shortcuts in Flash
#ifndef FLASH

	NoWaiting &=~ 1;
	
	if(KEY(GRAVE))
	{
		NoWaiting|=1;
	}
	
	if(gametype==GIT_FDS)
	{
		if(keyonly(F6)) FCEUI_FDSSelect();
		if(keyonly(F8)) FCEUI_FDSInsert(0);
	}
	
	if(keyonly(F9))
	{
		FCEUI_SaveSnapshot();
	}

	if(gametype!=GIT_NSF)
	{
		#ifndef EXTGUI
		if(keyonly(F2))
		{
			DoCheatSeq();
		}
		#endif
		
		if(keyonly(F5)) 
		{
			if(is_shift)
				FCEUI_SaveMovie(NULL);
			else
				FCEUI_SaveState(NULL);
		}
		
		if(keyonly(F7)) 
		{
			if(is_shift)
				FCEUI_LoadMovie(NULL);
			else
				FCEUI_LoadState(NULL);
		}
	}

  if(keyonly(F1)) FCEUI_ToggleTileView();

  if(keyonly(F10)) FCEUI_ResetNES();
  if(keyonly(F11)) FCEUI_PowerNES();

  #ifdef EXTGUI
  if(keyonly(F3)) GUI_Hide(-1);
  if(KEY(F12)) GUI_RequestExit();
  if(KEY(ESCAPE)) CloseGame();
  #else
  if(KEY(F12) || KEY(ESCAPE)) CloseGame();
  #endif

  if(gametype==GIT_VSUNI)
  {
	if(keyonly(F8)) FCEUI_VSUniCoin();
	if(keyonly(F6))
        {
	 DIPS^=1;
	 FCEUI_VSUniToggleDIPView();
	}
	if(!(DIPS&1)) goto DIPSless;
	if(keyonly(1)) FCEUI_VSUniToggleDIP(0);
	if(keyonly(2)) FCEUI_VSUniToggleDIP(1);
	if(keyonly(3)) FCEUI_VSUniToggleDIP(2);
	if(keyonly(4)) FCEUI_VSUniToggleDIP(3);
	if(keyonly(5)) FCEUI_VSUniToggleDIP(4);
	if(keyonly(6)) FCEUI_VSUniToggleDIP(5);
	if(keyonly(7)) FCEUI_VSUniToggleDIP(6);
	if(keyonly(8)) FCEUI_VSUniToggleDIP(7);
  }
  else
  {
   static uint8 bbuf[32];
   static int bbuft;
   static int barcoder = 0;

   if(keyonly(H)) FCEUI_NTSCSELHUE();
   if(keyonly(T)) FCEUI_NTSCSELTINT();
   if(KEY(KP_MINUS) || KEY(MINUS)) FCEUI_NTSCDEC();
   if(KEY(KP_PLUS) || KEY(EQUAL)) FCEUI_NTSCINC();

   if((InputType[2] == SIFC_BWORLD) || (cspec == SIS_DATACH))
   {
    if(keyonly(F8)) 
    {
     barcoder ^= 1;
     if(!barcoder)
     {
      if(InputType[2] == SIFC_BWORLD)
      {
       strcpy(&BWorldData[1],bbuf);
       BWorldData[0]=1;
      }
      else
       FCEUI_DatachSet(bbuf);
      FCEUI_DispMessage("Barcode Entered");
     } 
     else { bbuft = 0; FCEUI_DispMessage("Enter Barcode");}
    }
   } else barcoder = 0;

	#define SSM(x)		\
	{ if(barcoder) { if(bbuft < 13) {bbuf[bbuft++] = '0' + x; bbuf[bbuft] = 0;} FCEUI_DispMessage("Barcode: %s",bbuf);}	\
	else { 			\
	 if(is_shift) FCEUI_SelectMovie(x); 	\
	 else FCEUI_SelectState(x); 	\
	} }

   DIPSless:
   if(keyonly(0)) SSM(0);
   if(keyonly(1)) SSM(1);
   if(keyonly(2)) SSM(2);
   if(keyonly(3)) SSM(3);
   if(keyonly(4)) SSM(4);
   if(keyonly(5)) SSM(5);
   if(keyonly(6)) SSM(6);
   if(keyonly(7)) SSM(7);
   if(keyonly(8)) SSM(8);
   if(keyonly(9)) SSM(9);
   #undef SSM
 }
#endif
}
예제 #2
0
static unsigned char DecodeJoy(unsigned short chan)
{
	s8 pad_x = userInput[chan].pad.stickX;
	s8 pad_y = userInput[chan].pad.stickY;
	u32 jp = userInput[chan].pad.btns_h;
	unsigned char J = 0;

	#ifdef HW_RVL
	s8 wm_ax = userInput[chan].WPAD_StickX(0);
	s8 wm_ay = userInput[chan].WPAD_StickY(0);
	u32 wp = userInput[chan].wpad->btns_h;

	u32 exp_type;
	if ( WPAD_Probe(chan, &exp_type) != 0 ) exp_type = WPAD_EXP_NONE;
	#endif

	/***
	Gamecube Joystick input
	***/
	// Is XY inside the "zone"?
	if (pad_x * pad_x + pad_y * pad_y > PADCAL * PADCAL)
	{
		if (pad_x > 0 && pad_y == 0) J |= JOY_RIGHT;
		if (pad_x < 0 && pad_y == 0) J |= JOY_LEFT;
		if (pad_x == 0 && pad_y > 0) J |= JOY_UP;
		if (pad_x == 0 && pad_y < 0) J |= JOY_DOWN;

		if (pad_x != 0 && pad_y != 0)
		{
			if ((float)pad_y / pad_x >= -2.41421356237 && (float)pad_y / pad_x < 2.41421356237)
			{
				if (pad_x >= 0)
					J |= JOY_RIGHT;
				else
					J |= JOY_LEFT;
			}

			if ((float)pad_x / pad_y >= -2.41421356237 && (float)pad_x / pad_y < 2.41421356237)
			{
				if (pad_y >= 0)
					J |= JOY_UP;
				else
					J |= JOY_DOWN;
			}
		}
	}
#ifdef HW_RVL
	/***
	Wii Joystick (classic, nunchuk) input
	***/
	// Is XY inside the "zone"?
	if (wm_ax * wm_ax + wm_ay * wm_ay > PADCAL * PADCAL)
	{
		/*** we don't want division by zero ***/
		if (wm_ax > 0 && wm_ay == 0)
			J |= JOY_RIGHT;
		if (wm_ax < 0 && wm_ay == 0)
			J |= JOY_LEFT;
		if (wm_ax == 0 && wm_ay > 0)
			J |= JOY_UP;
		if (wm_ax == 0 && wm_ay < 0)
			J |= JOY_DOWN;

		if (wm_ax != 0 && wm_ay != 0)
		{

			/*** Recalc left / right ***/
			float t;

			t = (float) wm_ay / wm_ax;
			if (t >= -2.41421356237 && t < 2.41421356237)
			{
				if (wm_ax >= 0)
					J |= JOY_RIGHT;
				else
					J |= JOY_LEFT;
			}

			/*** Recalc up / down ***/
			t = (float) wm_ax / wm_ay;
			if (t >= -2.41421356237 && t < 2.41421356237)
			{
				if (wm_ay >= 0)
					J |= JOY_UP;
				else
					J |= JOY_DOWN;
			}
		}
	}
#endif

	// Report pressed buttons (gamepads)
	int i;
	for (i = 0; i < MAXJP; i++)
	{
		if ( (jp & btnmap[CTRL_PAD][CTRLR_GCPAD][i])											// gamecube controller
		#ifdef HW_RVL
		|| ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_PAD][CTRLR_WIIMOTE][i]) )	// wiimote
		|| ( (exp_type == WPAD_EXP_CLASSIC) && (wp & btnmap[CTRL_PAD][CTRLR_CLASSIC][i]) )	// classic controller
		|| ( (exp_type == WPAD_EXP_NUNCHUK) && (wp & btnmap[CTRL_PAD][CTRLR_NUNCHUK][i]) )	// nunchuk + wiimote
		#endif
		)
		{
			// if zapper is on, ignore all buttons except START and SELECT
			if(GCSettings.Controller != CTRL_ZAPPER || nespadmap[i] == JOY_START || nespadmap[i] == JOY_SELECT)
			{
				if(rapidAlternator && nespadmap[i] == RAPID_A)
				{
					// activate rapid fire for A button
					J |= JOY_A;
				}
				else if(rapidAlternator && nespadmap[i] == RAPID_B)
				{
					// activate rapid fire for B button
					J |= JOY_B;
				}
				else if(nespadmap[i] > 0)
				{
					J |= nespadmap[i];
				}
				else
				{
					if(GameInfo->type == GIT_FDS) // FDS
					{
						/* the commands shouldn't be issued in parallel so
						 * we'll delay them so the virtual FDS has a chance
						 * to process them
						 */
						if(FDSSwitchRequested == 0)
							FDSSwitchRequested = 1;
					}
					else
						FCEUI_VSUniCoin(); // insert coin for VS Games
				}
			}
		}
	}

	// zapper enabled
	if(GCSettings.Controller == CTRL_ZAPPER)
	{
		int z; // NES port # (0 or 1)

		if(GameInfo->type == GIT_VSUNI)
			z = 0;
		else
			z = 1;

		myzappers[z][2] = 0; // reset trigger to not pressed

		// is trigger pressed?
		if ( (jp & btnmap[CTRL_ZAPPER][CTRLR_GCPAD][0])	// gamecube controller
		#ifdef HW_RVL
		|| ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE][0]) )	// wiimote
		#endif
		)
		{
			// report trigger press
			myzappers[z][2] |= 2;
		}

		// VS zapper games
		if ( (jp & btnmap[CTRL_ZAPPER][CTRLR_GCPAD][1])	// gamecube controller
		#ifdef HW_RVL
		|| ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE][1]) )	// wiimote
		#endif
		)
		{
			FCEUI_VSUniCoin(); // insert coin for VS zapper games
		}

		// cursor position
		UpdateCursorPosition(0); // update cursor for wiimote 1
		myzappers[z][0] = pos_x;
		myzappers[z][1] = pos_y;

		// Report changes to FCE Ultra
		zapperdata[z]->Update(z,myzappers[z],0);
	}

	return J;
}
예제 #3
0
static void KeyboardCommands(void) {
    int is_shift, is_alt;

    keys = GetKeyboard();

    if ((InputType[2] == SIFC_FKB) || (InputType[2] == SIFC_SUBORKB) || (InputType[2] == SIFC_PEC586KB)) {
        if (cidisabled) return;
    }

    is_shift = KEY(LEFTSHIFT) | KEY(RIGHTSHIFT);
    is_alt = KEY(LEFTALT) | KEY(RIGHTALT);

    if (keyonly(F4)) {
        if (is_shift) FCEUI_SetRenderDisable(-1, 2);
        else FCEUI_SetRenderDisable(2, -1);
    }

    {
        static int nocount = 0;

        NoWaiting &= ~1;
        if (KEY(GRAVE))	//&& nocount)
            NoWaiting |= 1;
        nocount = (nocount + 1) & 3;
    }

    if (gametype == GIT_FDS) {
        if (keyonly(F6)) FCEUI_FDSSelect();
        if (keyonly(F8)) FCEUI_FDSInsert(0);
    }

    if (keyonly(F9)) FCEUI_SaveSnapshot();
    if (gametype != GIT_NSF) {
        if (keyonly(F5)) {
            if (is_shift)
                FCEUI_SaveMovie(NULL);
            else
                FCEUI_SaveState(NULL);
        }
        if (keyonly(F7)) {
            if (is_shift)
                FCEUI_LoadMovie(NULL);
            else
                FCEUI_LoadState(NULL);
        }
    }

//  if(keyonly(F1)) FCEUI_ToggleTileView();

    if (gametype == GIT_VSUNI) {
        if (keyonly(F8)) FCEUI_VSUniCoin();
        if (keyonly(F6)) {
            DIPS ^= 1;
            FCEUI_VSUniToggleDIPView();
        }
        if (!(DIPS & 1)) goto DIPSless;
        if (keyonly(1)) FCEUI_VSUniToggleDIP(0);
        if (keyonly(2)) FCEUI_VSUniToggleDIP(1);
        if (keyonly(3)) FCEUI_VSUniToggleDIP(2);
        if (keyonly(4)) FCEUI_VSUniToggleDIP(3);
        if (keyonly(5)) FCEUI_VSUniToggleDIP(4);
        if (keyonly(6)) FCEUI_VSUniToggleDIP(5);
        if (keyonly(7)) FCEUI_VSUniToggleDIP(6);
        if (keyonly(8)) FCEUI_VSUniToggleDIP(7);
    } else {
        static uint8 bbuf[32];
        static int bbuft;
        static int barcoder = 0;

        if (keyonly(H)) FCEUI_NTSCSELHUE();
        if (keyonly(T)) FCEUI_NTSCSELTINT();
        if (KEY(KP_MINUS) || KEY(MINUS)) FCEUI_NTSCDEC();
        if (KEY(KP_PLUS) || KEY(EQUAL)) FCEUI_NTSCINC();

        if ((InputType[2] == SIFC_BWORLD) || (cspec == SIS_DATACH)) {
            if (keyonly(F8)) {
                barcoder ^= 1;
                if (!barcoder) {
                    if (InputType[2] == SIFC_BWORLD) {
                        strcpy(&BWorldData[1], bbuf);
                        BWorldData[0] = 1;
                    } else
                        FCEUI_DatachSet(bbuf);
                    FCEUI_DispMessage("Barcode Entered");
                } else {
                    bbuft = 0;
                    FCEUI_DispMessage("Enter Barcode");
                }
            }
        } else barcoder = 0;

#define SSM(x)				  \
	{ if (barcoder) { if (bbuft < 13) { bbuf[bbuft++] = '0' + x; bbuf[bbuft] = 0; } FCEUI_DispMessage("Barcode: %s", bbuf); }		 \
	  else {						 \
		  if (is_shift) FCEUI_SelectMovie(x);		  \
		  else FCEUI_SelectState(x);		 \
	  }	\
	}

DIPSless:
        if (keyonly(0)) SSM(0);
        if (keyonly(1)) SSM(1);
        if (keyonly(2)) SSM(2);
        if (keyonly(3)) SSM(3);
        if (keyonly(4)) SSM(4);
        if (keyonly(5)) SSM(5);
        if (keyonly(6)) SSM(6);
        if (keyonly(7)) SSM(7);
        if (keyonly(8)) SSM(8);
        if (keyonly(9)) SSM(9);
#undef SSM
    }
}
예제 #4
0
파일: pad.cpp 프로젝트: dborth/fceugx
static unsigned char DecodeJoy(unsigned short chan)
{
	s8 pad_x = userInput[chan].pad.stickX;
	s8 pad_y = userInput[chan].pad.stickY;
	u32 jp = userInput[chan].pad.btns_h;
	unsigned char J = 0;

	#ifdef HW_RVL
	s8 wm_ax = userInput[chan].WPAD_StickX(0);
	s8 wm_ay = userInput[chan].WPAD_StickY(0);
	u32 wp = userInput[chan].wpad->btns_h;
	bool isWUPC = userInput[chan].wpad->exp.classic.type == 2;

	u32 exp_type;
	if ( WPAD_Probe(chan, &exp_type) != 0 )
		exp_type = WPAD_EXP_NONE;

	s16 wiidrc_ax = userInput[chan].wiidrcdata.stickX;
	s16 wiidrc_ay = userInput[chan].wiidrcdata.stickY;
	u32 wiidrcp = userInput[chan].wiidrcdata.btns_h;
	#endif

	/***
	Gamecube Joystick input
	***/
	if (pad_y > ANALOG_SENSITIVITY)
		J |= JOY_UP;
	else if (pad_y < -ANALOG_SENSITIVITY)
		J |= JOY_DOWN;
	if (pad_x < -ANALOG_SENSITIVITY)
		J |= JOY_LEFT;
	else if (pad_x > ANALOG_SENSITIVITY)
		J |= JOY_RIGHT;
#ifdef HW_RVL
	/***
	Wii Joystick (classic, nunchuk) input
	***/
	if (wm_ay > ANALOG_SENSITIVITY)
		J |= JOY_UP;
	else if (wm_ay < -ANALOG_SENSITIVITY)
		J |= JOY_DOWN;
	if (wm_ax < -ANALOG_SENSITIVITY)
		J |= JOY_LEFT;
	else if (wm_ax > ANALOG_SENSITIVITY)
		J |= JOY_RIGHT;

	/* WiiU Gamepad */
	if (wiidrc_ay > ANALOG_SENSITIVITY)
		J |= JOY_UP;
	else if (wiidrc_ay < -ANALOG_SENSITIVITY)
		J |= JOY_DOWN;
	if (wiidrc_ax < -ANALOG_SENSITIVITY)
		J |= JOY_LEFT;
	else if (wiidrc_ax > ANALOG_SENSITIVITY)
		J |= JOY_RIGHT;
#endif

	bool zapper_triggered = false;
	// zapper enabled
	if(GCSettings.Controller == CTRL_ZAPPER)
	{
		int z; // NES port # (0 or 1)

		if(GameInfo->type == GIT_VSUNI)
			z = 0;
		else
			z = 1;

		myzappers[z][2] = 0; // reset trigger to not pressed

		// is trigger pressed?
		if ( (jp & btnmap[CTRL_ZAPPER][CTRLR_GCPAD][0])	// gamecube controller
		#ifdef HW_RVL
		|| ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE][0]) )	// wiimote
		|| (wiidrcp & btnmap[CTRL_ZAPPER][CTRLR_WIIDRC][0]) // Wii U Gamepad
		#endif
		)
		{
			// report trigger press
			myzappers[z][2] |= 2;
			zapper_triggered = true;
		}

		// VS zapper games
		if ( (jp & btnmap[CTRL_ZAPPER][CTRLR_GCPAD][1])	// gamecube controller
		#ifdef HW_RVL
		|| ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE][1]) )	// wiimote
		|| (wiidrcp & btnmap[CTRL_ZAPPER][CTRLR_WIIDRC][1]) // Wii U Gamepad
		#endif
		)
		{
			FCEUI_VSUniCoin(); // insert coin for VS zapper games
			zapper_triggered = true;
		}

		// cursor position
		int channel = 0;	// by default, use wiimote 1
		#ifdef HW_RVL
		if (userInput[1].wpad->ir.valid)
		{
			channel = 1;	// if wiimote 2 is connected, use wiimote 2 as zapper
		}
		#endif
		UpdateCursorPosition(channel); // update cursor for wiimote
		myzappers[z][0] = pos_x;
		myzappers[z][1] = pos_y;

		// Report changes to FCE Ultra
		zapperdata[z]->Update(z,myzappers[z],0);
	}

	// Report pressed buttons (gamepads)
	int i;
	for (i = 0; i < MAXJP; i++)
	{
		if ( (jp & btnmap[CTRL_PAD][CTRLR_GCPAD][i])										// gamecube controller
		#ifdef HW_RVL
		|| ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_PAD][CTRLR_WIIMOTE][i]) )		// wiimote
		|| ( (exp_type == WPAD_EXP_CLASSIC && !isWUPC) && (wp & btnmap[CTRL_PAD][CTRLR_CLASSIC][i]) )	// classic controller
		|| ( (exp_type == WPAD_EXP_CLASSIC && isWUPC) && (wp & btnmap[CTRL_PAD][CTRLR_WUPC][i]) )		// wii u pro controller
		|| ( (exp_type == WPAD_EXP_NUNCHUK) && (wp & btnmap[CTRL_PAD][CTRLR_NUNCHUK][i]) )	// nunchuk + wiimote
		|| ( (wiidrcp & btnmap[CTRL_PAD][CTRLR_WIIDRC][i]) ) // Wii U Gamepad
		#endif
		)
		{
			// if zapper is on, ignore all buttons except START and SELECT
			if (!zapper_triggered)
			{
				if(rapidAlternator && nespadmap[i] == RAPID_A)
				{
					// activate rapid fire for A button
					J |= JOY_A;
				}
				else if(rapidAlternator && nespadmap[i] == RAPID_B)
				{
					// activate rapid fire for B button
					J |= JOY_B;
				}
				else if(nespadmap[i] > 0)
				{
					J |= nespadmap[i];
				}
				else
				{
					if(GameInfo->type == GIT_FDS) // FDS
					{
						/* the commands shouldn't be issued in parallel so
						 * we'll delay them so the virtual FDS has a chance
						 * to process them
						 */
						if(FDSSwitchRequested == 0)
							FDSSwitchRequested = 1;
					}
					else
						FCEUI_VSUniCoin(); // insert coin for VS Games
				}
			}
		}
	}

	return J;
}