diff options
| author | John Peterson <jpeterson57@gmail.com> | 2009-01-22 00:31:12 +0000 |
|---|---|---|
| committer | John Peterson <jpeterson57@gmail.com> | 2009-01-22 00:31:12 +0000 |
| commit | bb06dfb823009e6941e6bf355af37bb8193a69d8 (patch) | |
| tree | 6ec74158a6b8cf7df939b9f5e419d800341082b0 /Source | |
| parent | 7f9dc55fbc1ebb9b2819e896d39a426bdbe74b93 (diff) | |
nJoy and SerialInterface: Fixed the nJoy crashes
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1978 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/Core/Core/Src/HW/SI.cpp | 7 | ||||
| -rw-r--r-- | Source/Core/Core/Src/HW/SI_DeviceGCController.cpp | 4 | ||||
| -rw-r--r-- | Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp | 8 |
3 files changed, 8 insertions, 11 deletions
diff --git a/Source/Core/Core/Src/HW/SI.cpp b/Source/Core/Core/Src/HW/SI.cpp index 00779dbbbe..fc98f65c59 100644 --- a/Source/Core/Core/Src/HW/SI.cpp +++ b/Source/Core/Core/Src/HW/SI.cpp @@ -254,11 +254,8 @@ void Init() g_Channel[i].m_InHi.Hex = 0;
g_Channel[i].m_InLo.Hex = 0;
- // Check the maxpads limit
- int j = i; if(i >= MAXPADS) j = MAXPADS - 1;
-
- // Get pad
- Common::PluginPAD* pad = CPluginManager::GetInstance().GetPAD(j);
+ // Access the pad and check the MAXPADS limit
+ Common::PluginPAD* pad = CPluginManager::GetInstance().GetPAD((i >= MAXPADS) ? (MAXPADS - 1): i);
// Check if this pad is attached for the current plugin
if (pad != NULL && (pad->PAD_GetAttachedPads() & (1 << i)))
diff --git a/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp b/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp index e74eeb2f46..9d42bffe18 100644 --- a/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp +++ b/Source/Core/Core/Src/HW/SI_DeviceGCController.cpp @@ -112,7 +112,7 @@ int CSIDevice_GCController::RunBuffer(u8* _pBuffer, int _iLength) // __________________________________________________________________________________________________
// GetData
//
-// return true on new data (max 7 Bytes and 6 bits ;)
+// Return true on new data (max 7 Bytes and 6 bits ;)
//
bool
CSIDevice_GCController::GetData(u32& _Hi, u32& _Low)
@@ -120,7 +120,7 @@ CSIDevice_GCController::GetData(u32& _Hi, u32& _Low) SPADStatus PadStatus;
memset(&PadStatus, 0 ,sizeof(PadStatus));
Common::PluginPAD* pad =
- CPluginManager::GetInstance().GetPAD(ISIDevice::m_iDeviceNumber);
+ CPluginManager::GetInstance().GetPAD((ISIDevice::m_iDeviceNumber >= MAXPADS) ? (MAXPADS - 1): ISIDevice::m_iDeviceNumber);
pad->PAD_GetStatus(ISIDevice::m_iDeviceNumber, &PadStatus);
_Hi = (u32)((u8)PadStatus.stickY);
diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp index 558b2f01b5..85d2cd8fd4 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp @@ -249,7 +249,7 @@ void Initialize(void *init) /* SDL 1.3 use DirectInput instead of the old Microsoft Multimeda API, and with this we need the SDL_INIT_VIDEO flag to */ - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) + if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) { #ifdef _WIN32 MessageBox(NULL, SDL_GetError(), "Could not initialize SDL!", MB_ICONERROR); @@ -309,8 +309,8 @@ int Search_Devices() } #ifdef _DEBUG - fprintf(pFile, "Scanning for devices\n"); - fprintf(pFile, "ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ\n"); + fprintf(pFile, "Scanning for devices\n"); + fprintf(pFile, "ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ\n"); #endif for(int i = 0; i < numjoy; i++ ) @@ -409,7 +409,7 @@ void DoState(unsigned char **ptr, int mode) {} // Set PAD status // ŻŻŻŻŻŻŻŻŻŻŻŻŻŻ -// Called from: SerialInterface_Devices.cpp +// Called from: SI_DeviceGCController.cpp // Function: Gives the current pad status to the Core void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus) { |
