2008-09-16 07:42:21 +02:00
|
|
|
/****************************************************************************
|
2008-09-17 04:27:55 +02:00
|
|
|
* Visual Boy Advance GX
|
2008-09-16 07:42:21 +02:00
|
|
|
*
|
2021-01-06 21:13:12 +01:00
|
|
|
* Tantric 2008-2021
|
2008-09-16 07:42:21 +02:00
|
|
|
*
|
|
|
|
* input.cpp
|
|
|
|
*
|
|
|
|
* Wii/Gamecube controller management
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#include <gccore.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ogcsys.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <wiiuse/wpad.h>
|
2010-03-31 04:45:09 +02:00
|
|
|
#include <ogc/lwp_watchdog.h>
|
2008-09-16 07:42:21 +02:00
|
|
|
|
2010-03-22 00:49:59 +01:00
|
|
|
#include "vbagx.h"
|
2008-09-16 07:42:21 +02:00
|
|
|
#include "button_mapping.h"
|
2008-10-19 21:10:55 +02:00
|
|
|
#include "audio.h"
|
2008-09-16 07:42:21 +02:00
|
|
|
#include "video.h"
|
|
|
|
#include "input.h"
|
2009-03-04 08:01:04 +01:00
|
|
|
#include "gameinput.h"
|
|
|
|
#include "vbasupport.h"
|
2010-01-25 08:36:48 +01:00
|
|
|
#include "fastmath.h"
|
2010-03-22 00:49:59 +01:00
|
|
|
#include "gui/gui.h"
|
|
|
|
|
|
|
|
#include "vba/gba/GBA.h"
|
|
|
|
#include "vba/gba/bios.h"
|
|
|
|
#include "vba/gba/GBAinline.h"
|
2008-09-16 07:42:21 +02:00
|
|
|
|
2018-08-31 00:09:31 +02:00
|
|
|
#define ANALOG_SENSITIVITY 30
|
|
|
|
|
2009-03-04 08:01:04 +01:00
|
|
|
int rumbleRequest[4] = {0,0,0,0};
|
2020-09-29 00:57:20 +02:00
|
|
|
int playerMapping[4] = {0,1,2,3};
|
2009-04-08 09:08:12 +02:00
|
|
|
GuiTrigger userInput[4];
|
|
|
|
|
|
|
|
#ifdef HW_RVL
|
2009-03-04 08:01:04 +01:00
|
|
|
static int rumbleCount[4] = {0,0,0,0};
|
2009-04-08 09:08:12 +02:00
|
|
|
#endif
|
|
|
|
|
2009-10-15 09:43:25 +02:00
|
|
|
static bool cartridgeRumble = false, possibleCartridgeRumble = false;
|
|
|
|
static int gameRumbleCount = 0, menuRumbleCount = 0, rumbleCountAlready = 0;
|
2008-12-19 23:01:15 +01:00
|
|
|
|
2009-10-15 09:43:25 +02:00
|
|
|
static unsigned int vbapadmap[10]; // VBA controller buttons
|
2018-09-06 04:00:21 +02:00
|
|
|
u32 btnmap[6][10]; // button mapping
|
2008-12-19 23:01:15 +01:00
|
|
|
|
2009-06-27 22:06:26 +02:00
|
|
|
void ResetControls(int wiiCtrl)
|
2008-12-19 23:01:15 +01:00
|
|
|
{
|
2009-04-08 09:08:12 +02:00
|
|
|
int i;
|
2008-12-19 23:01:15 +01:00
|
|
|
|
|
|
|
// VBA controller buttons
|
|
|
|
// All other pads are mapped to this
|
|
|
|
i=0;
|
|
|
|
vbapadmap[i++] = VBA_BUTTON_B;
|
|
|
|
vbapadmap[i++] = VBA_BUTTON_A;
|
|
|
|
vbapadmap[i++] = VBA_BUTTON_SELECT;
|
|
|
|
vbapadmap[i++] = VBA_BUTTON_START;
|
|
|
|
vbapadmap[i++] = VBA_UP;
|
|
|
|
vbapadmap[i++] = VBA_DOWN;
|
|
|
|
vbapadmap[i++] = VBA_LEFT;
|
|
|
|
vbapadmap[i++] = VBA_RIGHT;
|
|
|
|
vbapadmap[i++] = VBA_BUTTON_L;
|
|
|
|
vbapadmap[i++] = VBA_BUTTON_R;
|
|
|
|
|
|
|
|
/*** Gamecube controller Padmap ***/
|
2009-07-01 19:15:21 +02:00
|
|
|
if(wiiCtrl == CTRLR_GCPAD || wiiCtrl == -1)
|
2009-06-27 22:06:26 +02:00
|
|
|
{
|
|
|
|
i=0;
|
|
|
|
btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_B;
|
|
|
|
btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_A;
|
|
|
|
btnmap[CTRLR_GCPAD][i++] = PAD_TRIGGER_Z;
|
|
|
|
btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_START;
|
|
|
|
btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_UP;
|
|
|
|
btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_DOWN;
|
|
|
|
btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_LEFT;
|
|
|
|
btnmap[CTRLR_GCPAD][i++] = PAD_BUTTON_RIGHT;
|
|
|
|
btnmap[CTRLR_GCPAD][i++] = PAD_TRIGGER_L;
|
|
|
|
btnmap[CTRLR_GCPAD][i++] = PAD_TRIGGER_R;
|
|
|
|
}
|
2008-12-19 23:01:15 +01:00
|
|
|
|
|
|
|
/*** Wiimote Padmap ***/
|
2009-07-01 19:15:21 +02:00
|
|
|
if(wiiCtrl == CTRLR_WIIMOTE || wiiCtrl == -1)
|
2009-06-27 22:06:26 +02:00
|
|
|
{
|
|
|
|
i=0;
|
|
|
|
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_1;
|
|
|
|
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_2;
|
|
|
|
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_MINUS;
|
|
|
|
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_PLUS;
|
|
|
|
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_RIGHT;
|
|
|
|
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_LEFT;
|
|
|
|
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_UP;
|
|
|
|
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_DOWN;
|
|
|
|
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_B;
|
|
|
|
btnmap[CTRLR_WIIMOTE][i++] = WPAD_BUTTON_A;
|
|
|
|
}
|
2008-12-19 23:01:15 +01:00
|
|
|
|
|
|
|
/*** Classic Controller Padmap ***/
|
2009-07-01 19:15:21 +02:00
|
|
|
if(wiiCtrl == CTRLR_CLASSIC || wiiCtrl == -1)
|
2009-06-27 22:06:26 +02:00
|
|
|
{
|
|
|
|
i=0;
|
|
|
|
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_Y;
|
|
|
|
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_B;
|
|
|
|
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_MINUS;
|
|
|
|
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_PLUS;
|
|
|
|
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_UP;
|
|
|
|
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_DOWN;
|
|
|
|
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_LEFT;
|
|
|
|
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_RIGHT;
|
|
|
|
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_FULL_L;
|
|
|
|
btnmap[CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_FULL_R;
|
|
|
|
}
|
2008-12-19 23:01:15 +01:00
|
|
|
|
|
|
|
/*** Nunchuk + wiimote Padmap ***/
|
2009-07-01 19:15:21 +02:00
|
|
|
if(wiiCtrl == CTRLR_NUNCHUK || wiiCtrl == -1)
|
2009-06-27 22:06:26 +02:00
|
|
|
{
|
|
|
|
i=0;
|
|
|
|
btnmap[CTRLR_NUNCHUK][i++] = WPAD_NUNCHUK_BUTTON_C;
|
|
|
|
btnmap[CTRLR_NUNCHUK][i++] = WPAD_NUNCHUK_BUTTON_Z;
|
|
|
|
btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_MINUS;
|
|
|
|
btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_PLUS;
|
|
|
|
btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_UP;
|
|
|
|
btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_DOWN;
|
|
|
|
btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_LEFT;
|
|
|
|
btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_RIGHT;
|
|
|
|
btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_2;
|
|
|
|
btnmap[CTRLR_NUNCHUK][i++] = WPAD_BUTTON_1;
|
|
|
|
}
|
2018-09-06 04:00:21 +02:00
|
|
|
|
2018-08-14 23:20:22 +02:00
|
|
|
/*** Wii U Pro Padmap ***/
|
|
|
|
if(wiiCtrl == CTRLR_WUPC || wiiCtrl == -1)
|
|
|
|
{
|
|
|
|
i=0;
|
|
|
|
btnmap[CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_Y;
|
|
|
|
btnmap[CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_B;
|
|
|
|
btnmap[CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_MINUS;
|
|
|
|
btnmap[CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_PLUS;
|
|
|
|
btnmap[CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_UP;
|
|
|
|
btnmap[CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_DOWN;
|
|
|
|
btnmap[CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_LEFT;
|
|
|
|
btnmap[CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_RIGHT;
|
|
|
|
btnmap[CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_FULL_L;
|
|
|
|
btnmap[CTRLR_WUPC][i++] = WPAD_CLASSIC_BUTTON_FULL_R;
|
|
|
|
}
|
2018-09-06 04:00:21 +02:00
|
|
|
|
|
|
|
/*** Wii U Gamepad Padmap ***/
|
|
|
|
if(wiiCtrl == CTRLR_WIIDRC || wiiCtrl == -1)
|
|
|
|
{
|
|
|
|
i=0;
|
|
|
|
btnmap[CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_Y;
|
|
|
|
btnmap[CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_B;
|
|
|
|
btnmap[CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_MINUS;
|
|
|
|
btnmap[CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_PLUS;
|
|
|
|
btnmap[CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_UP;
|
|
|
|
btnmap[CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_DOWN;
|
|
|
|
btnmap[CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_LEFT;
|
|
|
|
btnmap[CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_RIGHT;
|
|
|
|
btnmap[CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_L;
|
|
|
|
btnmap[CTRLR_WIIDRC][i++] = WIIDRC_BUTTON_R;
|
|
|
|
}
|
2009-06-27 22:06:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* UpdatePads
|
|
|
|
*
|
2009-10-13 02:49:08 +02:00
|
|
|
* Scans pad and wpad
|
2009-06-27 22:06:26 +02:00
|
|
|
***************************************************************************/
|
2010-03-31 04:45:09 +02:00
|
|
|
|
2009-06-27 22:06:26 +02:00
|
|
|
void
|
|
|
|
UpdatePads()
|
|
|
|
{
|
|
|
|
#ifdef HW_RVL
|
2018-09-06 04:00:21 +02:00
|
|
|
WiiDRC_ScanPads();
|
2009-06-27 22:06:26 +02:00
|
|
|
WPAD_ScanPads();
|
|
|
|
#endif
|
2010-03-31 04:45:09 +02:00
|
|
|
|
2012-07-29 23:08:21 +02:00
|
|
|
PAD_ScanPads();
|
2009-06-27 22:06:26 +02:00
|
|
|
|
2019-01-05 21:33:54 +01:00
|
|
|
for(int i=3; i >= 0; i--)
|
|
|
|
{
|
2009-06-27 22:06:26 +02:00
|
|
|
userInput[i].pad.btns_d = PAD_ButtonsDown(i);
|
|
|
|
userInput[i].pad.btns_u = PAD_ButtonsUp(i);
|
|
|
|
userInput[i].pad.btns_h = PAD_ButtonsHeld(i);
|
|
|
|
userInput[i].pad.stickX = PAD_StickX(i);
|
|
|
|
userInput[i].pad.stickY = PAD_StickY(i);
|
|
|
|
userInput[i].pad.substickX = PAD_SubStickX(i);
|
|
|
|
userInput[i].pad.substickY = PAD_SubStickY(i);
|
|
|
|
userInput[i].pad.triggerL = PAD_TriggerL(i);
|
|
|
|
userInput[i].pad.triggerR = PAD_TriggerR(i);
|
2019-01-05 21:33:54 +01:00
|
|
|
}
|
|
|
|
#ifdef HW_RVL
|
2018-09-06 04:00:21 +02:00
|
|
|
if(WiiDRC_Inited() && WiiDRC_Connected())
|
|
|
|
{
|
|
|
|
userInput[0].wiidrcdata.btns_d = WiiDRC_ButtonsDown();
|
|
|
|
userInput[0].wiidrcdata.btns_u = WiiDRC_ButtonsUp();
|
|
|
|
userInput[0].wiidrcdata.btns_h = WiiDRC_ButtonsHeld();
|
|
|
|
userInput[0].wiidrcdata.stickX = WiiDRC_lStickX();
|
|
|
|
userInput[0].wiidrcdata.stickY = WiiDRC_lStickY();
|
|
|
|
userInput[0].wiidrcdata.substickX = WiiDRC_rStickX();
|
|
|
|
userInput[0].wiidrcdata.substickY = WiiDRC_rStickY();
|
|
|
|
}
|
2019-01-05 21:33:54 +01:00
|
|
|
#endif
|
2009-03-04 08:01:04 +01:00
|
|
|
}
|
|
|
|
|
2009-10-13 02:49:08 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* SetupPads
|
|
|
|
*
|
|
|
|
* Sets up userInput triggers for use
|
|
|
|
***************************************************************************/
|
|
|
|
void
|
|
|
|
SetupPads()
|
|
|
|
{
|
|
|
|
PAD_Init();
|
|
|
|
|
|
|
|
#ifdef HW_RVL
|
|
|
|
// read wiimote accelerometer and IR data
|
|
|
|
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
|
|
|
|
WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for(int i=0; i < 4; i++)
|
|
|
|
{
|
|
|
|
userInput[i].chan = i;
|
|
|
|
#ifdef HW_RVL
|
|
|
|
userInput[i].wpad = WPAD_Data(i);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-04 08:01:04 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* ShutoffRumble
|
|
|
|
***************************************************************************/
|
|
|
|
void ShutoffRumble()
|
|
|
|
{
|
|
|
|
#ifdef HW_RVL
|
2010-04-17 05:06:12 +02:00
|
|
|
if(CONF_GetPadMotorMode() == 0)
|
|
|
|
return;
|
2009-03-04 08:01:04 +01:00
|
|
|
for(int i=0;i<4;i++)
|
|
|
|
{
|
|
|
|
WPAD_Rumble(i, 0);
|
2009-04-08 09:08:12 +02:00
|
|
|
rumbleCount[i] = 0;
|
2009-10-27 22:51:17 +01:00
|
|
|
rumbleRequest[i] = 0;
|
2009-03-04 08:01:04 +01:00
|
|
|
}
|
|
|
|
#endif
|
2009-04-07 16:23:18 +02:00
|
|
|
PAD_ControlMotor(PAD_CHAN0, PAD_MOTOR_STOP);
|
2009-03-04 08:01:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* DoRumble
|
|
|
|
***************************************************************************/
|
|
|
|
void DoRumble(int i)
|
|
|
|
{
|
2010-04-17 05:06:12 +02:00
|
|
|
#ifdef HW_RVL
|
|
|
|
if(CONF_GetPadMotorMode() == 0 || !GCSettings.Rumble) return;
|
|
|
|
|
|
|
|
if(rumbleRequest[i] && rumbleCount[i] < 3)
|
|
|
|
{
|
|
|
|
WPAD_Rumble(i, 1); // rumble on
|
|
|
|
rumbleCount[i]++;
|
|
|
|
}
|
|
|
|
else if(rumbleRequest[i])
|
2009-03-04 08:01:04 +01:00
|
|
|
{
|
2010-04-17 05:06:12 +02:00
|
|
|
rumbleCount[i] = 12;
|
|
|
|
rumbleRequest[i] = 0;
|
2009-03-04 08:01:04 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(rumbleCount[i])
|
2010-04-17 05:06:12 +02:00
|
|
|
rumbleCount[i]--;
|
2009-03-04 08:01:04 +01:00
|
|
|
WPAD_Rumble(i, 0); // rumble off
|
|
|
|
}
|
2009-04-08 09:08:12 +02:00
|
|
|
#endif
|
2010-04-17 05:06:12 +02:00
|
|
|
}
|
2008-09-16 07:42:21 +02:00
|
|
|
|
2009-05-28 16:15:56 +02:00
|
|
|
static int SilenceNeeded = 0;
|
|
|
|
|
2009-04-08 09:08:12 +02:00
|
|
|
static void updateRumble()
|
|
|
|
{
|
2010-03-16 00:44:32 +01:00
|
|
|
if(!GCSettings.Rumble) return;
|
|
|
|
|
Rumble for all GBC rumble games and Drill Dozer. Rumble should work on Gamecube controller too. The following games have native rumble support: WarioWare Twisted, Drill Dozer, 10 Pin Bowling, 3-D Ultra Pinball Thrillride, Disney's The Little Mermaid II: Pinball Frenzy, Hole in One Golf, Missile Command, NASCAR Challenge, Perfect Dark, Pokémon Pinball, Polaris SnoCross, Ready 2 Rumble Boxing, Star Wars Episode I: Racer, Test Drive Off-Road 3, Tonka Raceway, Top Gear Pocket\Top Gear Rally, Vigilante 8, Zebco Fishing, and maybe some other games.
Also, rumble and wii-control code has been cleaned up a bit.
2009-03-20 21:22:22 +01:00
|
|
|
bool r = false;
|
2009-04-08 09:08:12 +02:00
|
|
|
if (ConfigRequested) r = (menuRumbleCount > 0);
|
2009-05-28 16:15:56 +02:00
|
|
|
else r = cartridgeRumble || possibleCartridgeRumble || (gameRumbleCount > 0) || (menuRumbleCount > 0);
|
2009-06-27 22:06:26 +02:00
|
|
|
|
2010-01-25 08:36:48 +01:00
|
|
|
if (SilenceNeeded > 0)
|
|
|
|
{
|
|
|
|
if (r)
|
|
|
|
{
|
|
|
|
SilenceNeeded = 5;
|
|
|
|
// It will always be greater than 0 after that!
|
|
|
|
r = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (--SilenceNeeded > 0) r = false;
|
|
|
|
}
|
2009-05-28 16:15:56 +02:00
|
|
|
}
|
Rumble for all GBC rumble games and Drill Dozer. Rumble should work on Gamecube controller too. The following games have native rumble support: WarioWare Twisted, Drill Dozer, 10 Pin Bowling, 3-D Ultra Pinball Thrillride, Disney's The Little Mermaid II: Pinball Frenzy, Hole in One Golf, Missile Command, NASCAR Challenge, Perfect Dark, Pokémon Pinball, Polaris SnoCross, Ready 2 Rumble Boxing, Star Wars Episode I: Racer, Test Drive Off-Road 3, Tonka Raceway, Top Gear Pocket\Top Gear Rally, Vigilante 8, Zebco Fishing, and maybe some other games.
Also, rumble and wii-control code has been cleaned up a bit.
2009-03-20 21:22:22 +01:00
|
|
|
|
|
|
|
#ifdef HW_RVL
|
|
|
|
// Rumble wii remote 0
|
|
|
|
WPAD_Rumble(0, r);
|
|
|
|
#endif
|
2009-04-07 16:23:18 +02:00
|
|
|
PAD_ControlMotor(PAD_CHAN0, r?PAD_MOTOR_RUMBLE:PAD_MOTOR_STOP);
|
Rumble for all GBC rumble games and Drill Dozer. Rumble should work on Gamecube controller too. The following games have native rumble support: WarioWare Twisted, Drill Dozer, 10 Pin Bowling, 3-D Ultra Pinball Thrillride, Disney's The Little Mermaid II: Pinball Frenzy, Hole in One Golf, Missile Command, NASCAR Challenge, Perfect Dark, Pokémon Pinball, Polaris SnoCross, Ready 2 Rumble Boxing, Star Wars Episode I: Racer, Test Drive Off-Road 3, Tonka Raceway, Top Gear Pocket\Top Gear Rally, Vigilante 8, Zebco Fishing, and maybe some other games.
Also, rumble and wii-control code has been cleaned up a bit.
2009-03-20 21:22:22 +01:00
|
|
|
}
|
|
|
|
|
2010-03-16 00:44:32 +01:00
|
|
|
void updateRumbleFrame()
|
|
|
|
{
|
|
|
|
if(!GCSettings.Rumble) return;
|
|
|
|
|
2009-04-08 09:08:12 +02:00
|
|
|
// If we already rumbled continuously for more than 50 frames,
|
Rumble for all GBC rumble games and Drill Dozer. Rumble should work on Gamecube controller too. The following games have native rumble support: WarioWare Twisted, Drill Dozer, 10 Pin Bowling, 3-D Ultra Pinball Thrillride, Disney's The Little Mermaid II: Pinball Frenzy, Hole in One Golf, Missile Command, NASCAR Challenge, Perfect Dark, Pokémon Pinball, Polaris SnoCross, Ready 2 Rumble Boxing, Star Wars Episode I: Racer, Test Drive Off-Road 3, Tonka Raceway, Top Gear Pocket\Top Gear Rally, Vigilante 8, Zebco Fishing, and maybe some other games.
Also, rumble and wii-control code has been cleaned up a bit.
2009-03-20 21:22:22 +01:00
|
|
|
// then disable rumbling for a while.
|
2009-05-28 16:15:56 +02:00
|
|
|
if (rumbleCountAlready > 70) {
|
|
|
|
SilenceNeeded = 5;
|
|
|
|
rumbleCountAlready = 0;
|
2009-04-08 09:08:12 +02:00
|
|
|
} else if (ConfigRequested) {
|
2010-01-25 08:36:48 +01:00
|
|
|
if (menuRumbleCount>0) ++rumbleCountAlready;
|
2009-05-28 16:15:56 +02:00
|
|
|
else rumbleCountAlready=0;
|
Rumble for all GBC rumble games and Drill Dozer. Rumble should work on Gamecube controller too. The following games have native rumble support: WarioWare Twisted, Drill Dozer, 10 Pin Bowling, 3-D Ultra Pinball Thrillride, Disney's The Little Mermaid II: Pinball Frenzy, Hole in One Golf, Missile Command, NASCAR Challenge, Perfect Dark, Pokémon Pinball, Polaris SnoCross, Ready 2 Rumble Boxing, Star Wars Episode I: Racer, Test Drive Off-Road 3, Tonka Raceway, Top Gear Pocket\Top Gear Rally, Vigilante 8, Zebco Fishing, and maybe some other games.
Also, rumble and wii-control code has been cleaned up a bit.
2009-03-20 21:22:22 +01:00
|
|
|
} else {
|
2009-05-28 16:15:56 +02:00
|
|
|
if (gameRumbleCount>0 || menuRumbleCount>0 || possibleCartridgeRumble)
|
2010-01-25 08:36:48 +01:00
|
|
|
++rumbleCountAlready;
|
2009-05-28 16:15:56 +02:00
|
|
|
else rumbleCountAlready=0;
|
Rumble for all GBC rumble games and Drill Dozer. Rumble should work on Gamecube controller too. The following games have native rumble support: WarioWare Twisted, Drill Dozer, 10 Pin Bowling, 3-D Ultra Pinball Thrillride, Disney's The Little Mermaid II: Pinball Frenzy, Hole in One Golf, Missile Command, NASCAR Challenge, Perfect Dark, Pokémon Pinball, Polaris SnoCross, Ready 2 Rumble Boxing, Star Wars Episode I: Racer, Test Drive Off-Road 3, Tonka Raceway, Top Gear Pocket\Top Gear Rally, Vigilante 8, Zebco Fishing, and maybe some other games.
Also, rumble and wii-control code has been cleaned up a bit.
2009-03-20 21:22:22 +01:00
|
|
|
}
|
|
|
|
updateRumble();
|
2010-01-25 08:36:48 +01:00
|
|
|
if (gameRumbleCount>0 && !ConfigRequested) --gameRumbleCount;
|
|
|
|
if (menuRumbleCount>0) --menuRumbleCount;
|
Rumble for all GBC rumble games and Drill Dozer. Rumble should work on Gamecube controller too. The following games have native rumble support: WarioWare Twisted, Drill Dozer, 10 Pin Bowling, 3-D Ultra Pinball Thrillride, Disney's The Little Mermaid II: Pinball Frenzy, Hole in One Golf, Missile Command, NASCAR Challenge, Perfect Dark, Pokémon Pinball, Polaris SnoCross, Ready 2 Rumble Boxing, Star Wars Episode I: Racer, Test Drive Off-Road 3, Tonka Raceway, Top Gear Pocket\Top Gear Rally, Vigilante 8, Zebco Fishing, and maybe some other games.
Also, rumble and wii-control code has been cleaned up a bit.
2009-03-20 21:22:22 +01:00
|
|
|
}
|
|
|
|
|
2009-05-28 16:15:56 +02:00
|
|
|
void systemPossibleCartridgeRumble(bool RumbleOn) {
|
|
|
|
possibleCartridgeRumble = RumbleOn;
|
|
|
|
updateRumble();
|
|
|
|
}
|
|
|
|
|
Rumble for all GBC rumble games and Drill Dozer. Rumble should work on Gamecube controller too. The following games have native rumble support: WarioWare Twisted, Drill Dozer, 10 Pin Bowling, 3-D Ultra Pinball Thrillride, Disney's The Little Mermaid II: Pinball Frenzy, Hole in One Golf, Missile Command, NASCAR Challenge, Perfect Dark, Pokémon Pinball, Polaris SnoCross, Ready 2 Rumble Boxing, Star Wars Episode I: Racer, Test Drive Off-Road 3, Tonka Raceway, Top Gear Pocket\Top Gear Rally, Vigilante 8, Zebco Fishing, and maybe some other games.
Also, rumble and wii-control code has been cleaned up a bit.
2009-03-20 21:22:22 +01:00
|
|
|
void systemCartridgeRumble(bool RumbleOn) {
|
|
|
|
cartridgeRumble = RumbleOn;
|
2009-05-28 16:15:56 +02:00
|
|
|
possibleCartridgeRumble = false;
|
Rumble for all GBC rumble games and Drill Dozer. Rumble should work on Gamecube controller too. The following games have native rumble support: WarioWare Twisted, Drill Dozer, 10 Pin Bowling, 3-D Ultra Pinball Thrillride, Disney's The Little Mermaid II: Pinball Frenzy, Hole in One Golf, Missile Command, NASCAR Challenge, Perfect Dark, Pokémon Pinball, Polaris SnoCross, Ready 2 Rumble Boxing, Star Wars Episode I: Racer, Test Drive Off-Road 3, Tonka Raceway, Top Gear Pocket\Top Gear Rally, Vigilante 8, Zebco Fishing, and maybe some other games.
Also, rumble and wii-control code has been cleaned up a bit.
2009-03-20 21:22:22 +01:00
|
|
|
updateRumble();
|
|
|
|
}
|
|
|
|
|
|
|
|
void systemGameRumble(int RumbleForFrames) {
|
|
|
|
if (RumbleForFrames > gameRumbleCount) gameRumbleCount = RumbleForFrames;
|
|
|
|
}
|
|
|
|
|
|
|
|
void systemGameRumbleOnlyFor(int OnlyRumbleForFrames) {
|
|
|
|
gameRumbleCount = OnlyRumbleForFrames;
|
|
|
|
}
|
|
|
|
|
2009-10-15 09:43:25 +02:00
|
|
|
u32 StandardMovement(unsigned short chan)
|
2008-09-16 07:42:21 +02:00
|
|
|
{
|
2009-03-04 08:01:04 +01:00
|
|
|
u32 J = 0;
|
2012-01-27 03:34:38 +01:00
|
|
|
|
2009-10-15 09:43:25 +02:00
|
|
|
s8 pad_x = userInput[chan].pad.stickX;
|
|
|
|
s8 pad_y = userInput[chan].pad.stickY;
|
2008-09-16 07:42:21 +02:00
|
|
|
#ifdef HW_RVL
|
2009-10-15 09:43:25 +02:00
|
|
|
s8 wm_ax = userInput[0].WPAD_StickX(0);
|
|
|
|
s8 wm_ay = userInput[0].WPAD_StickY(0);
|
2018-09-06 04:00:21 +02:00
|
|
|
s16 wiidrc_ax = userInput[chan].wiidrcdata.stickX;
|
|
|
|
s16 wiidrc_ay = userInput[chan].wiidrcdata.stickY;
|
2008-09-16 07:42:21 +02:00
|
|
|
#endif
|
2012-01-27 03:34:38 +01:00
|
|
|
|
2008-09-16 07:42:21 +02:00
|
|
|
/***
|
2009-03-04 08:01:04 +01:00
|
|
|
Gamecube Joystick input, same as normal
|
2008-09-16 07:42:21 +02:00
|
|
|
***/
|
2018-08-31 00:09:31 +02:00
|
|
|
if (pad_y > ANALOG_SENSITIVITY)
|
|
|
|
J |= VBA_UP;
|
|
|
|
else if (pad_y < -ANALOG_SENSITIVITY)
|
|
|
|
J |= VBA_DOWN;
|
|
|
|
if (pad_x < -ANALOG_SENSITIVITY)
|
|
|
|
J |= VBA_LEFT;
|
|
|
|
else if (pad_x > ANALOG_SENSITIVITY)
|
|
|
|
J |= VBA_RIGHT;
|
2008-09-16 07:42:21 +02:00
|
|
|
#ifdef HW_RVL
|
|
|
|
/***
|
|
|
|
Wii Joystick (classic, nunchuk) input
|
|
|
|
***/
|
2018-08-31 00:09:31 +02:00
|
|
|
if (wm_ay > ANALOG_SENSITIVITY)
|
|
|
|
J |= VBA_UP;
|
|
|
|
else if (wm_ay < -ANALOG_SENSITIVITY)
|
|
|
|
J |= VBA_DOWN;
|
|
|
|
if (wm_ax < -ANALOG_SENSITIVITY)
|
|
|
|
J |= VBA_LEFT;
|
|
|
|
else if (wm_ax > ANALOG_SENSITIVITY)
|
|
|
|
J |= VBA_RIGHT;
|
2018-09-06 04:00:21 +02:00
|
|
|
|
|
|
|
/* Wii U Gamepad */
|
|
|
|
if (wiidrc_ay > ANALOG_SENSITIVITY)
|
|
|
|
J |= VBA_UP;
|
|
|
|
else if (wiidrc_ay < -ANALOG_SENSITIVITY)
|
|
|
|
J |= VBA_DOWN;
|
|
|
|
if (wiidrc_ax < -ANALOG_SENSITIVITY)
|
|
|
|
J |= VBA_LEFT;
|
|
|
|
else if (wiidrc_ax > ANALOG_SENSITIVITY)
|
|
|
|
J |= VBA_RIGHT;
|
2009-03-04 08:01:04 +01:00
|
|
|
#endif
|
|
|
|
return J;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 StandardDPad(unsigned short pad)
|
|
|
|
{
|
|
|
|
u32 J = 0;
|
2012-07-29 23:08:21 +02:00
|
|
|
u32 jp = userInput[pad].pad.btns_h;
|
2009-03-04 08:01:04 +01:00
|
|
|
#ifdef HW_RVL
|
|
|
|
u32 exp_type;
|
|
|
|
if ( WPAD_Probe(pad, &exp_type) != 0 )
|
|
|
|
exp_type = WPAD_EXP_NONE;
|
2012-07-29 23:08:21 +02:00
|
|
|
u32 wp = userInput[pad].wpad->btns_h;
|
2009-03-04 08:01:04 +01:00
|
|
|
if (wp & WPAD_BUTTON_RIGHT)
|
|
|
|
J |= VBA_RIGHT;
|
2018-09-06 04:00:21 +02:00
|
|
|
else if (wp & WPAD_BUTTON_LEFT)
|
2009-03-04 08:01:04 +01:00
|
|
|
J |= VBA_LEFT;
|
|
|
|
if (wp & WPAD_BUTTON_UP)
|
|
|
|
J |= VBA_UP;
|
2018-09-06 04:00:21 +02:00
|
|
|
else if (wp & WPAD_BUTTON_DOWN)
|
2009-03-04 08:01:04 +01:00
|
|
|
J |= VBA_DOWN;
|
|
|
|
if (exp_type == WPAD_EXP_CLASSIC)
|
|
|
|
{
|
|
|
|
if (wp & WPAD_CLASSIC_BUTTON_UP)
|
|
|
|
J |= VBA_UP;
|
2018-09-06 04:00:21 +02:00
|
|
|
else if (wp & WPAD_CLASSIC_BUTTON_DOWN)
|
2009-03-04 08:01:04 +01:00
|
|
|
J |= VBA_DOWN;
|
|
|
|
if (wp & WPAD_CLASSIC_BUTTON_LEFT)
|
|
|
|
J |= VBA_LEFT;
|
2018-09-06 04:00:21 +02:00
|
|
|
else if (wp & WPAD_CLASSIC_BUTTON_RIGHT)
|
2009-03-04 08:01:04 +01:00
|
|
|
J |= VBA_RIGHT;
|
|
|
|
}
|
2018-09-06 04:00:21 +02:00
|
|
|
/* Wii U Gamepad */
|
|
|
|
u32 wiidrcp = userInput[pad].wiidrcdata.btns_h;
|
|
|
|
if (wiidrcp & WIIDRC_BUTTON_UP)
|
|
|
|
J |= VBA_UP;
|
|
|
|
else if (wiidrcp & WIIDRC_BUTTON_DOWN)
|
|
|
|
J |= VBA_DOWN;
|
|
|
|
if (wiidrcp & WIIDRC_BUTTON_LEFT)
|
|
|
|
J |= VBA_LEFT;
|
|
|
|
else if (wiidrcp & WIIDRC_BUTTON_RIGHT)
|
|
|
|
J |= VBA_RIGHT;
|
2009-03-04 08:01:04 +01:00
|
|
|
#endif
|
|
|
|
if (jp & PAD_BUTTON_UP)
|
|
|
|
J |= VBA_UP;
|
2018-09-06 04:00:21 +02:00
|
|
|
else if (jp & PAD_BUTTON_DOWN)
|
2009-03-04 08:01:04 +01:00
|
|
|
J |= VBA_DOWN;
|
|
|
|
if (jp & PAD_BUTTON_LEFT)
|
|
|
|
J |= VBA_LEFT;
|
2018-09-06 04:00:21 +02:00
|
|
|
else if (jp & PAD_BUTTON_RIGHT)
|
2009-03-04 08:01:04 +01:00
|
|
|
J |= VBA_RIGHT;
|
|
|
|
return J;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 StandardSideways(unsigned short pad)
|
|
|
|
{
|
|
|
|
u32 J = 0;
|
|
|
|
#ifdef HW_RVL
|
2012-07-29 23:08:21 +02:00
|
|
|
u32 wp = userInput[pad].wpad->btns_h;
|
2009-03-04 08:01:04 +01:00
|
|
|
|
|
|
|
if (wp & WPAD_BUTTON_RIGHT)
|
|
|
|
J |= VBA_UP;
|
2018-09-06 04:00:21 +02:00
|
|
|
else if (wp & WPAD_BUTTON_LEFT)
|
2009-03-04 08:01:04 +01:00
|
|
|
J |= VBA_DOWN;
|
|
|
|
if (wp & WPAD_BUTTON_UP)
|
|
|
|
J |= VBA_LEFT;
|
2018-09-06 04:00:21 +02:00
|
|
|
else if (wp & WPAD_BUTTON_DOWN)
|
2009-03-04 08:01:04 +01:00
|
|
|
J |= VBA_RIGHT;
|
|
|
|
|
|
|
|
if (wp & WPAD_BUTTON_PLUS)
|
|
|
|
J |= VBA_BUTTON_START;
|
|
|
|
if (wp & WPAD_BUTTON_MINUS)
|
|
|
|
J |= VBA_BUTTON_SELECT;
|
|
|
|
|
|
|
|
if (wp & WPAD_BUTTON_1)
|
|
|
|
J |= VBA_BUTTON_B;
|
|
|
|
if (wp & WPAD_BUTTON_2)
|
|
|
|
J |= VBA_BUTTON_A;
|
|
|
|
if (cartridgeType == 2)
|
|
|
|
{
|
|
|
|
if (wp & WPAD_BUTTON_A)
|
|
|
|
J |= VBA_BUTTON_R;
|
|
|
|
if (wp & WPAD_BUTTON_B)
|
|
|
|
J |= VBA_BUTTON_L;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (wp & WPAD_BUTTON_B || wp & WPAD_BUTTON_A)
|
|
|
|
J |= VBA_SPEED;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return J;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 StandardClassic(unsigned short pad)
|
|
|
|
{
|
|
|
|
u32 J = 0;
|
|
|
|
#ifdef HW_RVL
|
2018-08-01 20:41:41 +02:00
|
|
|
u32 wp = userInput[pad].wpad->btns_h;
|
2009-03-04 08:01:04 +01:00
|
|
|
|
|
|
|
if (wp & WPAD_CLASSIC_BUTTON_RIGHT)
|
|
|
|
J |= VBA_RIGHT;
|
2018-09-06 04:00:21 +02:00
|
|
|
else if (wp & WPAD_CLASSIC_BUTTON_LEFT)
|
2009-03-04 08:01:04 +01:00
|
|
|
J |= VBA_LEFT;
|
|
|
|
if (wp & WPAD_CLASSIC_BUTTON_UP)
|
|
|
|
J |= VBA_UP;
|
2018-09-06 04:00:21 +02:00
|
|
|
else if (wp & WPAD_CLASSIC_BUTTON_DOWN)
|
2009-03-04 08:01:04 +01:00
|
|
|
J |= VBA_DOWN;
|
|
|
|
|
|
|
|
if (wp & WPAD_CLASSIC_BUTTON_PLUS)
|
|
|
|
J |= VBA_BUTTON_START;
|
|
|
|
if (wp & WPAD_CLASSIC_BUTTON_MINUS)
|
|
|
|
J |= VBA_BUTTON_SELECT;
|
|
|
|
|
|
|
|
if (wp & WPAD_CLASSIC_BUTTON_FULL_L || wp & WPAD_CLASSIC_BUTTON_ZL)
|
|
|
|
J |= VBA_BUTTON_L;
|
|
|
|
if (wp & WPAD_CLASSIC_BUTTON_FULL_R || wp & WPAD_CLASSIC_BUTTON_ZR)
|
|
|
|
J |= VBA_BUTTON_R;
|
|
|
|
|
|
|
|
if (wp & WPAD_CLASSIC_BUTTON_A)
|
|
|
|
J |= VBA_BUTTON_A;
|
|
|
|
if (wp & WPAD_CLASSIC_BUTTON_B)
|
|
|
|
J |= VBA_BUTTON_B;
|
|
|
|
if (wp & WPAD_CLASSIC_BUTTON_Y || wp & WPAD_CLASSIC_BUTTON_X)
|
|
|
|
J |= VBA_SPEED;
|
|
|
|
#endif
|
|
|
|
return J;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 StandardGamecube(unsigned short pad)
|
|
|
|
{
|
|
|
|
u32 J = 0;
|
2012-07-29 23:08:21 +02:00
|
|
|
u32 jp = userInput[pad].pad.btns_h;
|
2009-03-04 08:01:04 +01:00
|
|
|
if (jp & PAD_BUTTON_UP)
|
|
|
|
J |= VBA_UP;
|
2018-09-06 04:00:21 +02:00
|
|
|
else if (jp & PAD_BUTTON_DOWN)
|
2009-03-04 08:01:04 +01:00
|
|
|
J |= VBA_DOWN;
|
|
|
|
if (jp & PAD_BUTTON_LEFT)
|
|
|
|
J |= VBA_LEFT;
|
2018-09-06 04:00:21 +02:00
|
|
|
else if (jp & PAD_BUTTON_RIGHT)
|
2009-03-04 08:01:04 +01:00
|
|
|
J |= VBA_RIGHT;
|
|
|
|
if (jp & PAD_BUTTON_A)
|
|
|
|
J |= VBA_BUTTON_A;
|
|
|
|
if (jp & PAD_BUTTON_B)
|
|
|
|
J |= VBA_BUTTON_B;
|
|
|
|
if (jp & PAD_BUTTON_START)
|
|
|
|
J |= VBA_BUTTON_START;
|
|
|
|
if (jp & PAD_BUTTON_X)
|
|
|
|
J |= VBA_BUTTON_SELECT;
|
|
|
|
if (jp & PAD_TRIGGER_L)
|
|
|
|
J |= VBA_BUTTON_L;
|
|
|
|
if (jp & PAD_TRIGGER_R)
|
|
|
|
J |= VBA_BUTTON_R;
|
|
|
|
if (jp & PAD_TRIGGER_Z || jp & PAD_BUTTON_Y)
|
|
|
|
J |= VBA_SPEED;
|
|
|
|
return J;
|
|
|
|
}
|
|
|
|
|
2009-04-03 01:41:09 +02:00
|
|
|
u32 DecodeGamecube(unsigned short pad)
|
|
|
|
{
|
|
|
|
u32 J = 0;
|
2012-07-29 23:08:21 +02:00
|
|
|
u32 jp = userInput[pad].pad.btns_h;
|
2010-01-25 08:36:48 +01:00
|
|
|
for (u32 i = 0; i < MAXJP; ++i)
|
2009-04-03 01:41:09 +02:00
|
|
|
{
|
2009-04-08 09:08:12 +02:00
|
|
|
if (jp & btnmap[CTRLR_GCPAD][i])
|
2009-04-03 01:41:09 +02:00
|
|
|
J |= vbapadmap[i];
|
|
|
|
}
|
|
|
|
return J;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 DecodeWiimote(unsigned short pad)
|
|
|
|
{
|
|
|
|
u32 J = 0;
|
|
|
|
#ifdef HW_RVL
|
|
|
|
WPADData * wp = WPAD_Data(pad);
|
2010-01-25 08:36:48 +01:00
|
|
|
|
|
|
|
u32 wpad_btns_h = wp->btns_h;
|
|
|
|
|
|
|
|
if(wp->exp.type == WPAD_EXP_NONE)
|
2009-04-03 01:41:09 +02:00
|
|
|
{
|
2010-01-25 08:36:48 +01:00
|
|
|
for (u32 i = 0; i < MAXJP; ++i)
|
|
|
|
{
|
|
|
|
if (wpad_btns_h & btnmap[CTRLR_WIIMOTE][i] )
|
|
|
|
J |= vbapadmap[i];
|
|
|
|
}
|
2009-04-03 01:41:09 +02:00
|
|
|
}
|
2010-01-25 08:36:48 +01:00
|
|
|
|
2009-04-03 01:41:09 +02:00
|
|
|
#endif
|
|
|
|
return J;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 DecodeClassic(unsigned short pad)
|
|
|
|
{
|
|
|
|
u32 J = 0;
|
|
|
|
#ifdef HW_RVL
|
|
|
|
WPADData * wp = WPAD_Data(pad);
|
2010-01-25 08:36:48 +01:00
|
|
|
u32 wpad_btns_h = wp->btns_h;
|
|
|
|
|
|
|
|
if(wp->exp.type == WPAD_EXP_CLASSIC){
|
2018-08-14 23:20:22 +02:00
|
|
|
if (wp->exp.classic.type == 2) {
|
|
|
|
for (u32 i = 0; i < MAXJP; ++i){
|
|
|
|
if (wpad_btns_h & btnmap[CTRLR_WUPC][i] )
|
|
|
|
J |= vbapadmap[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (u32 i = 0; i < MAXJP; ++i){
|
|
|
|
if (wpad_btns_h & btnmap[CTRLR_CLASSIC][i] )
|
|
|
|
J |= vbapadmap[i];
|
|
|
|
}
|
2010-01-25 08:36:48 +01:00
|
|
|
}
|
2009-04-03 01:41:09 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return J;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 DecodeNunchuk(unsigned short pad)
|
|
|
|
{
|
|
|
|
u32 J = 0;
|
|
|
|
#ifdef HW_RVL
|
2018-08-14 23:20:22 +02:00
|
|
|
WPADData * wp = WPAD_Data(pad);
|
|
|
|
u32 wpad_btns_h = wp->btns_h;
|
2010-01-25 08:36:48 +01:00
|
|
|
|
2018-08-14 23:20:22 +02:00
|
|
|
if(wp->exp.type == WPAD_EXP_NUNCHUK){
|
2010-01-25 08:36:48 +01:00
|
|
|
for (u32 i = 0; i < MAXJP; ++i){
|
2018-08-14 23:27:10 +02:00
|
|
|
if (wpad_btns_h & btnmap[CTRLR_NUNCHUK][i] )
|
2010-01-25 08:36:48 +01:00
|
|
|
J |= vbapadmap[i];
|
|
|
|
}
|
2009-04-03 01:41:09 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return J;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HW_RVL
|
|
|
|
static u32 CCToGC(u32 w) {
|
|
|
|
u32 gc = 0;
|
|
|
|
if (w & WPAD_CLASSIC_BUTTON_A) gc |= PAD_BUTTON_A;
|
|
|
|
if (w & WPAD_CLASSIC_BUTTON_B) gc |= PAD_BUTTON_B;
|
|
|
|
if (w & WPAD_CLASSIC_BUTTON_X) gc |= PAD_BUTTON_X;
|
|
|
|
if (w & WPAD_CLASSIC_BUTTON_Y) gc |= PAD_BUTTON_Y;
|
|
|
|
if (w & WPAD_CLASSIC_BUTTON_PLUS) gc |= PAD_BUTTON_START;
|
|
|
|
if (w & WPAD_CLASSIC_BUTTON_MINUS) gc |= 0;
|
|
|
|
if (w & (WPAD_CLASSIC_BUTTON_ZL | WPAD_CLASSIC_BUTTON_ZR)) gc |= PAD_TRIGGER_Z;
|
|
|
|
if (w & WPAD_CLASSIC_BUTTON_FULL_L) gc |= PAD_TRIGGER_L;
|
|
|
|
if (w & WPAD_CLASSIC_BUTTON_FULL_R) gc |= PAD_TRIGGER_R;
|
|
|
|
if (w & WPAD_CLASSIC_BUTTON_UP) gc |= PAD_BUTTON_UP;
|
2018-09-06 04:00:21 +02:00
|
|
|
else if (w & WPAD_CLASSIC_BUTTON_DOWN) gc |= PAD_BUTTON_DOWN;
|
2009-04-03 01:41:09 +02:00
|
|
|
if (w & WPAD_CLASSIC_BUTTON_LEFT) gc |= PAD_BUTTON_LEFT;
|
2018-09-06 04:00:21 +02:00
|
|
|
else if (w & WPAD_CLASSIC_BUTTON_RIGHT) gc |= PAD_BUTTON_RIGHT;
|
2009-04-03 01:41:09 +02:00
|
|
|
return gc;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// For developers who don't have gamecube pads but need to test gamecube input
|
|
|
|
u32 PAD_ButtonsHeldFake(unsigned short pad)
|
|
|
|
{
|
|
|
|
u32 gc = 0;
|
|
|
|
#ifdef HW_RVL
|
2009-10-15 09:43:25 +02:00
|
|
|
if (userInput[pad].wpad->exp.type == WPAD_EXP_CLASSIC) {
|
|
|
|
gc = CCToGC(userInput[pad].wpad->btns_h);
|
2009-04-03 01:41:09 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return gc;
|
|
|
|
}
|
|
|
|
u32 PAD_ButtonsDownFake(unsigned short pad)
|
|
|
|
{
|
|
|
|
u32 gc = 0;
|
|
|
|
#ifdef HW_RVL
|
2009-10-15 09:43:25 +02:00
|
|
|
if (userInput[pad].wpad->exp.type == WPAD_EXP_CLASSIC) {
|
|
|
|
gc = CCToGC(userInput[pad].wpad->btns_d);
|
2009-04-03 01:41:09 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return gc;
|
|
|
|
}
|
|
|
|
u32 PAD_ButtonsUpFake(unsigned short pad)
|
|
|
|
{
|
|
|
|
u32 gc = 0;
|
|
|
|
#ifdef HW_RVL
|
2009-10-15 09:43:25 +02:00
|
|
|
if (userInput[pad].wpad->exp.type == WPAD_EXP_CLASSIC) {
|
|
|
|
gc = CCToGC(userInput[pad].wpad->btns_u);
|
2009-04-03 01:41:09 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return gc;
|
|
|
|
}
|
|
|
|
|
2009-03-04 08:01:04 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* DecodeJoy
|
|
|
|
*
|
|
|
|
* Reads the STATE (not changes) from a controller and reports
|
|
|
|
* this STATE (not changes) to VBA
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static u32 DecodeJoy(unsigned short pad)
|
|
|
|
{
|
|
|
|
#ifdef HW_RVL
|
2009-10-13 02:49:08 +02:00
|
|
|
CursorX = userInput[pad].wpad->ir.x;
|
|
|
|
CursorY = userInput[pad].wpad->ir.y;
|
|
|
|
CursorValid = userInput[pad].wpad->ir.valid;
|
2009-04-03 01:41:09 +02:00
|
|
|
#else
|
|
|
|
CursorX = CursorY = CursorValid = 0;
|
|
|
|
#endif
|
2009-03-04 08:01:04 +01:00
|
|
|
|
2009-04-03 01:41:09 +02:00
|
|
|
// check for games that should have special Wii controls
|
2009-04-08 09:08:12 +02:00
|
|
|
if (GCSettings.WiiControls)
|
2009-04-03 01:41:09 +02:00
|
|
|
switch (RomIdCode & 0xFFFFFF)
|
2009-03-04 08:01:04 +01:00
|
|
|
{
|
2009-04-03 01:41:09 +02:00
|
|
|
// Zelda
|
|
|
|
case ZELDA1:
|
|
|
|
return Zelda1Input(pad);
|
|
|
|
case ZELDA2:
|
|
|
|
return Zelda2Input(pad);
|
|
|
|
case ALINKTOTHEPAST:
|
|
|
|
return ALinkToThePastInput(pad);
|
|
|
|
case LINKSAWAKENING:
|
|
|
|
return LinksAwakeningInput(pad);
|
|
|
|
case ORACLEOFAGES:
|
|
|
|
return OracleOfAgesInput(pad);
|
|
|
|
case ORACLEOFSEASONS:
|
|
|
|
return OracleOfSeasonsInput(pad);
|
|
|
|
case MINISHCAP:
|
|
|
|
return MinishCapInput(pad);
|
|
|
|
|
|
|
|
// Metroid
|
|
|
|
case METROID0:
|
|
|
|
return MetroidZeroInput(pad);
|
|
|
|
case METROID1:
|
|
|
|
return Metroid1Input(pad);
|
|
|
|
case METROID2:
|
|
|
|
return Metroid2Input(pad);
|
|
|
|
case METROID4:
|
|
|
|
return MetroidFusionInput(pad);
|
|
|
|
|
|
|
|
// TMNT
|
2009-04-25 14:09:13 +02:00
|
|
|
case TMNT1:
|
|
|
|
return TMNT1Input(pad);
|
|
|
|
case TMNT2:
|
|
|
|
return TMNT2Input(pad);
|
|
|
|
case TMNT3:
|
|
|
|
return TMNT3Input(pad);
|
|
|
|
case TMNTGBA:
|
|
|
|
return TMNTGBAInput(pad);
|
2009-05-27 19:31:18 +02:00
|
|
|
case TMNTGBA2:
|
|
|
|
return TMNTGBA2Input(pad);
|
2009-04-03 01:41:09 +02:00
|
|
|
case TMNT:
|
|
|
|
return TMNTInput(pad);
|
|
|
|
|
|
|
|
// Medal Of Honor
|
|
|
|
case MOHUNDERGROUND:
|
|
|
|
return MohUndergroundInput(pad);
|
|
|
|
case MOHINFILTRATOR:
|
|
|
|
return MohInfiltratorInput(pad);
|
|
|
|
|
|
|
|
// Harry Potter
|
|
|
|
case HARRYPOTTER1GBC:
|
|
|
|
return HarryPotter1GBCInput(pad);
|
|
|
|
case HARRYPOTTER2GBC:
|
|
|
|
return HarryPotter2GBCInput(pad);
|
|
|
|
case HARRYPOTTER1:
|
|
|
|
return HarryPotter1Input(pad);
|
|
|
|
case HARRYPOTTER2:
|
|
|
|
return HarryPotter2Input(pad);
|
|
|
|
case HARRYPOTTER3:
|
|
|
|
return HarryPotter3Input(pad);
|
|
|
|
case HARRYPOTTER4:
|
|
|
|
return HarryPotter4Input(pad);
|
|
|
|
case HARRYPOTTER5:
|
|
|
|
return HarryPotter5Input(pad);
|
|
|
|
|
|
|
|
// Mario
|
|
|
|
case MARIO1CLASSIC:
|
|
|
|
case MARIO2CLASSIC:
|
|
|
|
return Mario1ClassicInput(pad);
|
|
|
|
case MARIO1DX:
|
|
|
|
return Mario1DXInput(pad);
|
|
|
|
case MARIO2ADV:
|
|
|
|
return Mario2Input(pad);
|
|
|
|
case MARIO3ADV:
|
|
|
|
return Mario3Input(pad);
|
|
|
|
case MARIOWORLD:
|
|
|
|
return MarioWorldInput(pad);
|
|
|
|
case YOSHIISLAND:
|
|
|
|
return YoshiIslandInput(pad);
|
|
|
|
case MARIOLAND1:
|
|
|
|
return MarioLand1Input(pad);
|
|
|
|
case MARIOLAND2:
|
|
|
|
return MarioLand2Input(pad);
|
|
|
|
case YOSHIUG:
|
|
|
|
return UniversalGravitationInput(pad);
|
|
|
|
|
|
|
|
// Mario Kart
|
|
|
|
case MARIOKART:
|
|
|
|
return MarioKartInput(pad);
|
|
|
|
|
|
|
|
// Lego Star Wars
|
|
|
|
case LSW1:
|
|
|
|
return LegoStarWars1Input(pad);
|
|
|
|
case LSW2:
|
|
|
|
return LegoStarWars2Input(pad);
|
|
|
|
|
2009-05-27 19:31:18 +02:00
|
|
|
// Star Wars
|
|
|
|
case SWOBIWAN:
|
|
|
|
return SWObiWanInput(pad);
|
2009-05-29 19:04:50 +02:00
|
|
|
case SWJPB:
|
|
|
|
return SWJediPowerBattlesInput(pad);
|
2009-05-27 19:31:18 +02:00
|
|
|
case SWEP2:
|
|
|
|
return SWEpisode2Input(pad);
|
2009-05-29 19:04:50 +02:00
|
|
|
case SWEP3:
|
|
|
|
return SWEpisode3Input(pad);
|
|
|
|
case SWEP4:
|
|
|
|
return SWEpisode4Input(pad);
|
|
|
|
case SWEP5:
|
|
|
|
return SWEpisode5Input(pad);
|
|
|
|
case SWEP6:
|
|
|
|
return SWEpisode6Input(pad);
|
|
|
|
case SWTRILOGY:
|
|
|
|
return SWTrilogyInput(pad);
|
|
|
|
case SWNDA:
|
|
|
|
return SWNDAInput(pad);
|
|
|
|
case SWYODA:
|
|
|
|
return SWYodaStoriesInput(pad);
|
2009-05-27 19:31:18 +02:00
|
|
|
|
2009-04-03 01:41:09 +02:00
|
|
|
// Mortal Kombat
|
|
|
|
case MK1:
|
|
|
|
return MK1Input(pad);
|
2009-04-25 14:09:13 +02:00
|
|
|
case MK12:
|
|
|
|
return MK12Input(pad);
|
2009-04-03 01:41:09 +02:00
|
|
|
case MK2:
|
2009-04-25 14:09:13 +02:00
|
|
|
return MK2Input(pad);
|
2009-04-03 01:41:09 +02:00
|
|
|
case MK3:
|
2009-04-25 14:09:13 +02:00
|
|
|
return MK3Input(pad);
|
2009-04-03 01:41:09 +02:00
|
|
|
case MK4:
|
|
|
|
return MK4Input(pad);
|
|
|
|
case MKA:
|
|
|
|
return MKAInput(pad);
|
|
|
|
case MKDA:
|
2009-04-26 21:23:12 +02:00
|
|
|
return MKDAInput(pad);
|
2009-04-03 01:41:09 +02:00
|
|
|
case MKTE:
|
|
|
|
return MKTEInput(pad);
|
|
|
|
|
|
|
|
// WarioWare
|
|
|
|
case TWISTED:
|
|
|
|
return TwistedInput(pad);
|
|
|
|
|
|
|
|
// Kirby
|
|
|
|
case KIRBYTNT:
|
|
|
|
case KIRBYTNTJ:
|
|
|
|
return KirbyTntInput(pad);
|
|
|
|
|
|
|
|
// Boktai
|
|
|
|
case BOKTAI1:
|
|
|
|
return BoktaiInput(pad);
|
|
|
|
case BOKTAI2:
|
|
|
|
case BOKTAI3:
|
|
|
|
return Boktai2Input(pad);
|
2009-04-08 09:08:12 +02:00
|
|
|
|
2009-04-03 01:41:09 +02:00
|
|
|
// One Piece
|
|
|
|
case ONEPIECE:
|
|
|
|
return OnePieceInput(pad);
|
2009-06-27 22:06:26 +02:00
|
|
|
|
2009-05-27 19:31:18 +02:00
|
|
|
// Lord of the Rings
|
|
|
|
case HOBBIT:
|
|
|
|
return HobbitInput(pad);
|
|
|
|
case LOTR1:
|
|
|
|
return FellowshipOfTheRingInput(pad);
|
|
|
|
case LOTR2:
|
|
|
|
case LOTR3:
|
|
|
|
return ReturnOfTheKingInput(pad);
|
2009-06-27 22:06:26 +02:00
|
|
|
|
2009-05-28 00:20:21 +02:00
|
|
|
// Castlevania
|
|
|
|
case CVADVENTURE:
|
|
|
|
return CastlevaniaAdventureInput(pad);
|
|
|
|
case CVBELMONT:
|
|
|
|
return CastlevaniaBelmontInput(pad);
|
|
|
|
case CVLEGENDS:
|
|
|
|
return CastlevaniaLegendsInput(pad);
|
2009-05-28 01:05:14 +02:00
|
|
|
case CVCIRCLEMOON:
|
|
|
|
case CVHARMONY:
|
|
|
|
case CVARIA:
|
|
|
|
return CastlevaniaCircleMoonInput(pad);
|
2016-06-05 00:59:43 +02:00
|
|
|
|
|
|
|
case KIDDRACULA:
|
|
|
|
return KidDraculaInput(pad);
|
2009-03-04 08:01:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// the function result, J, is a combination of flags for all the VBA buttons that are down
|
|
|
|
u32 J = StandardMovement(pad);
|
|
|
|
|
2008-10-09 08:48:46 +02:00
|
|
|
// Turbo feature
|
2018-09-06 04:00:21 +02:00
|
|
|
if(userInput[0].pad.substickX > 70 ||
|
|
|
|
userInput[0].WPAD_Stick(1,0) > 70 ||
|
|
|
|
userInput[0].wiidrcdata.substickX > 45)
|
2008-09-22 07:01:57 +02:00
|
|
|
J |= VBA_SPEED;
|
|
|
|
|
2009-04-14 07:24:01 +02:00
|
|
|
// Report pressed buttons (gamepads)
|
2010-01-25 08:36:48 +01:00
|
|
|
u32 pad_btns_h = userInput[pad].pad.btns_h; // GCN
|
2018-09-06 04:00:21 +02:00
|
|
|
u32 wiidrcp_btns_h = userInput[pad].wiidrcdata.btns_h;
|
2010-01-25 08:36:48 +01:00
|
|
|
#ifdef HW_RVL
|
|
|
|
u32 wpad_btns_h = userInput[pad].wpad->btns_h;
|
|
|
|
int wpad_exp_type = userInput[pad].wpad->exp.type;
|
2018-08-14 23:20:22 +02:00
|
|
|
bool isWUPC = userInput[pad].wpad->exp.classic.type == 2;
|
2010-01-25 08:36:48 +01:00
|
|
|
|
|
|
|
if(wpad_exp_type == WPAD_EXP_NONE)
|
|
|
|
{ // wiimote
|
|
|
|
|
|
|
|
for (u32 i =0; i < MAXJP; ++i)
|
|
|
|
{
|
|
|
|
if ((pad_btns_h & btnmap[CTRLR_GCPAD][i]) // gamecube controller
|
2018-09-06 04:00:21 +02:00
|
|
|
|| ( wiidrcp_btns_h & btnmap[CTRLR_WIIDRC][i] ) //wii u gamepad
|
2010-03-11 07:04:53 +01:00
|
|
|
|| ( (wpad_btns_h & btnmap[CTRLR_WIIMOTE][i]) ))
|
2010-01-25 08:36:48 +01:00
|
|
|
J |= vbapadmap[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else if(wpad_exp_type == WPAD_EXP_CLASSIC)
|
|
|
|
{ // classic controller
|
2020-03-20 22:23:38 +01:00
|
|
|
if (isWUPC) {
|
2020-03-01 18:06:08 +01:00
|
|
|
for (u32 i = 0; i < MAXJP; ++i)
|
|
|
|
{
|
|
|
|
if (wpad_btns_h & btnmap[CTRLR_WUPC][i] )
|
|
|
|
J |= vbapadmap[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (u32 i = 0; i < MAXJP; ++i)
|
|
|
|
{
|
|
|
|
if ((pad_btns_h & btnmap[CTRLR_GCPAD][i]) // gamecube controller
|
|
|
|
|| ( wiidrcp_btns_h & btnmap[CTRLR_WIIDRC][i] ) //wiiu gamepad
|
|
|
|
|| ( (wpad_btns_h & btnmap[CTRLR_CLASSIC][i]) ))
|
|
|
|
J |= vbapadmap[i];
|
|
|
|
}
|
2018-08-14 23:20:22 +02:00
|
|
|
}
|
|
|
|
}
|
2010-01-25 08:36:48 +01:00
|
|
|
else if(wpad_exp_type == WPAD_EXP_NUNCHUK)
|
|
|
|
{ // nunchuk + wiimote
|
|
|
|
|
|
|
|
for (u32 i =0; i < MAXJP; ++i)
|
|
|
|
{
|
|
|
|
if ((pad_btns_h & btnmap[CTRLR_GCPAD][i]) // gamecube controller
|
2010-03-11 07:04:53 +01:00
|
|
|
|| ( (wpad_btns_h & btnmap[CTRLR_NUNCHUK][i]) ))
|
2010-01-25 08:36:48 +01:00
|
|
|
J |= vbapadmap[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
// Check out this trickery!
|
|
|
|
// If all else fails OR if HW_RVL is undefined, the result is the same
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
for (u32 i = 0; i < MAXJP; ++i)
|
|
|
|
{
|
2018-09-06 04:00:21 +02:00
|
|
|
if ((pad_btns_h & btnmap[CTRLR_GCPAD][i]) || (wiidrcp_btns_h & btnmap[CTRLR_WIIDRC][i]))
|
2010-01-25 08:36:48 +01:00
|
|
|
J |= vbapadmap[i];
|
|
|
|
}
|
|
|
|
}
|
2008-09-16 07:42:21 +02:00
|
|
|
return J;
|
|
|
|
}
|
Rumble for all GBC rumble games and Drill Dozer. Rumble should work on Gamecube controller too. The following games have native rumble support: WarioWare Twisted, Drill Dozer, 10 Pin Bowling, 3-D Ultra Pinball Thrillride, Disney's The Little Mermaid II: Pinball Frenzy, Hole in One Golf, Missile Command, NASCAR Challenge, Perfect Dark, Pokémon Pinball, Polaris SnoCross, Ready 2 Rumble Boxing, Star Wars Episode I: Racer, Test Drive Off-Road 3, Tonka Raceway, Top Gear Pocket\Top Gear Rally, Vigilante 8, Zebco Fishing, and maybe some other games.
Also, rumble and wii-control code has been cleaned up a bit.
2009-03-20 21:22:22 +01:00
|
|
|
|
2009-05-28 06:20:04 +02:00
|
|
|
bool MenuRequested()
|
|
|
|
{
|
2018-08-01 20:41:41 +02:00
|
|
|
for(int i=0; i<4; i++) {
|
2016-06-05 00:59:43 +02:00
|
|
|
if (
|
|
|
|
(userInput[i].pad.substickX < -70)
|
|
|
|
#ifdef HW_RVL
|
|
|
|
|| (userInput[i].wpad->btns_h & WPAD_BUTTON_HOME) ||
|
2018-09-06 04:00:21 +02:00
|
|
|
(userInput[i].wpad->btns_h & WPAD_CLASSIC_BUTTON_HOME) ||
|
|
|
|
(userInput[i].wiidrcdata.btns_h & WIIDRC_BUTTON_HOME)
|
2016-06-05 00:59:43 +02:00
|
|
|
#endif
|
2009-05-28 06:20:04 +02:00
|
|
|
)
|
2016-06-05 00:59:43 +02:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2018-08-01 20:41:41 +02:00
|
|
|
}
|
|
|
|
return false;
|
2009-05-28 06:20:04 +02:00
|
|
|
}
|
|
|
|
|
2020-09-29 00:57:20 +02:00
|
|
|
static int GetPlayerChan(int pad)
|
|
|
|
{
|
|
|
|
for(int i=3; i >= 0; i--) {
|
|
|
|
if(playerMapping[i] == pad) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pad;
|
|
|
|
}
|
|
|
|
|
2008-10-18 22:40:48 +02:00
|
|
|
u32 GetJoy(int pad)
|
2008-09-16 07:42:21 +02:00
|
|
|
{
|
2009-03-04 08:01:04 +01:00
|
|
|
// request to go back to menu
|
2009-05-28 06:20:04 +02:00
|
|
|
if (MenuRequested())
|
2008-09-16 07:42:21 +02:00
|
|
|
{
|
2009-05-25 08:45:42 +02:00
|
|
|
ScreenshotRequested = 1;
|
Rumble for all GBC rumble games and Drill Dozer. Rumble should work on Gamecube controller too. The following games have native rumble support: WarioWare Twisted, Drill Dozer, 10 Pin Bowling, 3-D Ultra Pinball Thrillride, Disney's The Little Mermaid II: Pinball Frenzy, Hole in One Golf, Missile Command, NASCAR Challenge, Perfect Dark, Pokémon Pinball, Polaris SnoCross, Ready 2 Rumble Boxing, Star Wars Episode I: Racer, Test Drive Off-Road 3, Tonka Raceway, Top Gear Pocket\Top Gear Rally, Vigilante 8, Zebco Fishing, and maybe some other games.
Also, rumble and wii-control code has been cleaned up a bit.
2009-03-20 21:22:22 +01:00
|
|
|
updateRumbleFrame();
|
2008-10-21 09:17:07 +02:00
|
|
|
return 0;
|
2008-09-16 07:42:21 +02:00
|
|
|
}
|
2009-04-14 07:24:01 +02:00
|
|
|
|
2020-09-29 00:57:20 +02:00
|
|
|
int chan = GetPlayerChan(pad);
|
|
|
|
|
|
|
|
u32 J = DecodeJoy(chan);
|
2009-04-14 07:24:01 +02:00
|
|
|
// don't allow up+down or left+right
|
|
|
|
if ((J & 48) == 48)
|
|
|
|
J &= ~16;
|
|
|
|
if ((J & 192) == 192)
|
|
|
|
J &= ~128;
|
|
|
|
updateRumbleFrame();
|
2016-06-05 00:59:43 +02:00
|
|
|
|
2009-04-14 07:24:01 +02:00
|
|
|
return J;
|
2008-09-16 07:42:21 +02:00
|
|
|
}
|