Fix a nasty dualcore hang in EFB read (see r3658 comment...)

Also fix an issue reported by baby.lueshi (issue 1074) in nJoy related to half press button being always pressed when unset.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3661 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
sl1nk3.s 2009-07-03 15:35:31 +00:00
parent 06b65ea425
commit 936225eee4
4 changed files with 34 additions and 32 deletions

View File

@ -161,6 +161,7 @@ void GetJoyState(CONTROLLER_STATE &_PadState, CONTROLLER_MAPPING _PadMapping, in
}
else
{
// XInput triggers for Xbox360 pads
_PadState.axis[CTL_L_SHOULDER] = XInput::GetXI(0, _PadMapping.buttons[CTL_L_SHOULDER] - 1000);
_PadState.axis[CTL_R_SHOULDER] = XInput::GetXI(0, _PadMapping.buttons[CTL_R_SHOULDER] - 1000);
}
@ -176,9 +177,12 @@ void GetJoyState(CONTROLLER_STATE &_PadState, CONTROLLER_MAPPING _PadMapping, in
ReadButton(_PadState, _PadMapping, CTL_Z_TRIGGER, NumButtons);
ReadButton(_PadState, _PadMapping, CTL_START, NumButtons);
//
if (_PadMapping.halfpress < NumButtons)
// Update Halfpress state, this one is not in the standard _PadState.buttons array
if (_PadMapping.halfpress < NumButtons && _PadMapping.halfpress >= 0)
_PadState.halfpress = SDL_JoystickGetButton(_PadState.joy, _PadMapping.halfpress);
else
_PadState.halfpress = 0;
// Check if we have an analog or digital joypad
if (_PadMapping.controllertype == CTL_DPAD_HAT)
@ -187,8 +191,8 @@ void GetJoyState(CONTROLLER_STATE &_PadState, CONTROLLER_MAPPING _PadMapping, in
}
else
{
/* Only do this if the assigned button is in range (to allow for the current way of saving keyboard
keys in the same array) */
// Only do this if the assigned button is in range (to allow for the current way of saving keyboard
// keys in the same array)
if(_PadMapping.dpad2[CTL_D_PAD_UP] <= NumButtons)
_PadState.dpad2[CTL_D_PAD_UP] = SDL_JoystickGetButton(_PadState.joy, _PadMapping.dpad2[CTL_D_PAD_UP]);
if(_PadMapping.dpad2[CTL_D_PAD_DOWN] <= NumButtons)
@ -199,7 +203,7 @@ void GetJoyState(CONTROLLER_STATE &_PadState, CONTROLLER_MAPPING _PadMapping, in
_PadState.dpad2[CTL_D_PAD_RIGHT] = SDL_JoystickGetButton(_PadState.joy, _PadMapping.dpad2[CTL_D_PAD_RIGHT]);
}
#ifdef SHOW_PAD_STATUS
#ifdef SHOW_PAD_STATUS
// Show the status of all connected pads
//if ((g_LastPad == 0 && Controller == 0) || Controller < g_LastPad) Console::ClearScreen();
g_LastPad = Controller;
@ -228,7 +232,7 @@ void GetJoyState(CONTROLLER_STATE &_PadState, CONTROLLER_MAPPING _PadMapping, in
_PadState.dpad,
_PadState.dpad2[InputCommon::CTL_D_PAD_UP], _PadState.dpad2[InputCommon::CTL_D_PAD_DOWN]
);
#endif
#endif
}
//////////////////////////////////////////////////////////////////////////////////////////

View File

@ -146,19 +146,19 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
video_initialize.pPeekMessages();
#endif
if (g_EFBAccessRequested)
{
Video_OnThreadAccessEFB();
g_EFBAccessRequested = false;
}
// Draw XFB if CP/GPfifo isn't used
if (g_XFBUpdateRequested)
{
Video_UpdateXFB(NULL, 0, 0, 0, FALSE);
}
if (g_EFBAccessRequested)
{
Video_OnThreadAccessEFB();
}
s_criticalFifo.Enter();
// check if we are able to run this buffer
if ((_fifo.bFF_GPReadEnable) && _fifo.CPReadWriteDistance && !(_fifo.bFF_BPEnable && _fifo.bFF_Breakpoint))
{

View File

@ -102,7 +102,7 @@ static bool s_PluginInitialized = false;
static volatile u32 s_AccessEFBResult = 0, s_EFBx, s_EFBy;
static volatile EFBAccessType s_AccessEFBType;
static Common::Event s_AccessEFBDone;
static Common::CriticalSection s_criticalEFB, s_criticalAccess;
static Common::CriticalSection s_criticalEFB;
void GetDllInfo (PLUGIN_INFO* _PluginInfo)
@ -519,7 +519,8 @@ void Video_OnThreadAccessEFB()
default:
break;
}
g_EFBAccessRequested = false;
s_AccessEFBDone.Set();
s_criticalEFB.Leave();
@ -529,8 +530,6 @@ u32 Video_AccessEFB(EFBAccessType type, u32 x, u32 y)
{
u32 result;
s_criticalAccess.Enter();
s_criticalEFB.Enter();
s_AccessEFBType = type;
@ -540,7 +539,7 @@ u32 Video_AccessEFB(EFBAccessType type, u32 x, u32 y)
if (g_VideoInitialize.bUseDualCore)
{
s_AccessEFBDone.Init();
g_EFBAccessRequested = true;
g_EFBAccessRequested = true;
}
s_criticalEFB.Leave();
@ -556,9 +555,8 @@ u32 Video_AccessEFB(EFBAccessType type, u32 x, u32 y)
s_AccessEFBDone.Shutdown();
result = s_AccessEFBResult;
s_criticalEFB.Leave();
s_criticalAccess.Leave();
s_criticalEFB.Leave();
return result;
}

View File

@ -76,24 +76,24 @@
// Use PAD rumble
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯
void Pad_Use_Rumble(u8 _numPAD)//, SPADStatus* _pPADStatus)
void Pad_Use_Rumble(u8 _numPAD)
{
#ifdef _WIN32
if (PadMapping[_numPAD].rumble) {
if (!g_Rumble) {
#ifdef _WIN32
if (PadMapping[_numPAD].rumble)
{
if (!g_Rumble)
{
// GetForegroundWindow() always sends the good HWND
if (FAILED(InitRumble(GetForegroundWindow())))
PanicAlert("Could not initialize Rumble!");
} else {
} else
{
// Acquire gamepad
if (pRumble[_numPAD].g_pDevice != NULL)
pRumble[_numPAD].g_pDevice->Acquire();
}
}
#elif defined(__linux__)
#elif defined(__linux__)
if (!fd)
{
sprintf(device_file_name, "/dev/input/event%d", PadMapping[_numPAD].eventnum); //TODO: Make dynamic //
@ -125,7 +125,7 @@ void Pad_Use_Rumble(u8 _numPAD)//, SPADStatus* _pPADStatus)
CanRumble = false; //We have effects but it doesn't support the rumble we are using. This is basic rumble, should work for most
}
}
#endif
#endif
}
////////////////////////////////////////////////////
@ -138,7 +138,7 @@ void PAD_Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength)
Pad_Use_Rumble(_numPAD);
// SDL can't rumble the gamepad so we need to use platform specific code
#ifdef _WIN32
#ifdef _WIN32
int a = 0;
if (_uType == 1)
@ -158,7 +158,7 @@ void PAD_Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength)
SetDeviceForcesXY(_numPAD, a);
}
#elif defined(__linux__)
#elif defined(__linux__)
struct input_event event;
if (CanRumble)
{
@ -183,7 +183,7 @@ void PAD_Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength)
}
}
}
#endif
#endif
}
#ifdef _WIN32