diff options
Diffstat (limited to 'src/core/Pad.cpp')
-rw-r--r-- | src/core/Pad.cpp | 169 |
1 files changed, 105 insertions, 64 deletions
diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index 0a626570..da86d15e 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -55,6 +55,10 @@ CMouseControllerState CPad::OldMouseControllerState; CMouseControllerState CPad::NewMouseControllerState; CMouseControllerState CPad::PCTempMouseControllerState; +#ifdef DETECT_PAD_INPUT_SWITCH +bool CPad::IsAffectedByController = false; +#endif + _TODO("gbFastTime"); extern bool gbFastTime; @@ -102,12 +106,12 @@ void TankCheat() CAutomobile *tank = new CAutomobile(MI_RHINO, MISSION_VEHICLE); #endif if (tank != nil) { - CVector pos = ThePaths.m_pathNodes[node].pos; + CVector pos = ThePaths.m_pathNodes[node].GetPosition(); pos.z += 4.0f; - tank->GetPosition() = pos; + tank->SetPosition(pos); tank->SetOrientation(0.0f, 0.0f, DEGTORAD(200.0f)); - tank->m_status = STATUS_ABANDONED; + tank->SetStatus(STATUS_ABANDONED); tank->m_nDoorLock = CARLOCK_UNLOCKED; CWorld::Add(tank); } @@ -325,6 +329,16 @@ void AltDodoCheat(void) } #endif +#ifdef DETECT_PAD_INPUT_SWITCH +bool +CControllerState::IsAnyButtonPressed(void) +{ + return !!LeftStickX || !!LeftStickY || !!RightStickX || !!RightStickY || !!LeftShoulder1 || !!LeftShoulder2 || !!RightShoulder1 || !!RightShoulder2 || + !!DPadUp || !!DPadDown || !!DPadLeft || !!DPadRight || !!Start || !!Select || !!Square || !!Triangle || !!Cross || !!Circle || !!LeftShock || + !!RightShock || !!NetworkTalk; +} +#endif + void CControllerState::Clear(void) { @@ -575,14 +589,15 @@ void CPad::UpdateMouse() PCTempMouseControllerState.MXB1 = glfwGetMouseButton(PSGLOBAL(window), GLFW_MOUSE_BUTTON_4); PCTempMouseControllerState.MXB2 = glfwGetMouseButton(PSGLOBAL(window), GLFW_MOUSE_BUTTON_5); - PSGLOBAL(lastMousePos.x) = xpos; - PSGLOBAL(lastMousePos.y) = ypos; - if (PSGLOBAL(mouseWheel) > 0) PCTempMouseControllerState.WHEELUP = 1; else if (PSGLOBAL(mouseWheel) < 0) PCTempMouseControllerState.WHEELDN = 1; + PSGLOBAL(lastMousePos.x) = xpos; + PSGLOBAL(lastMousePos.y) = ypos; + PSGLOBAL(mouseWheel) = 0.0f; + OldMouseControllerState = NewMouseControllerState; NewMouseControllerState = PCTempMouseControllerState; #endif @@ -1001,7 +1016,7 @@ void CPad::AffectFromXinput(uint32 pad) if (Abs(rx) > 0.3f || Abs(ry) > 0.3f) { PCTempJoyState.RightStickX = (int32)(rx * 128.0f); - PCTempJoyState.RightStickY = (int32)(ry * 128.0f); + PCTempJoyState.RightStickY = (int32)(-ry * 128.0f); } XINPUT_VIBRATION VibrationState; @@ -1036,11 +1051,20 @@ void CPad::UpdatePads(void) #else CapturePad(0); #endif - +#ifdef DETECT_PAD_INPUT_SWITCH + if (GetPad(0)->PCTempJoyState.IsAnyButtonPressed()) + IsAffectedByController = true; + else { +#endif + ControlsManager.ClearSimButtonPressCheckers(); + ControlsManager.AffectPadFromKeyBoard(); + ControlsManager.AffectPadFromMouse(); - ControlsManager.ClearSimButtonPressCheckers(); - ControlsManager.AffectPadFromKeyBoard(); - ControlsManager.AffectPadFromMouse(); +#ifdef DETECT_PAD_INPUT_SWITCH + } + if (IsAffectedByController && (GetPad(0)->PCTempKeyState.IsAnyButtonPressed() || GetPad(0)->PCTempMouseState.IsAnyButtonPressed())) + IsAffectedByController = false; +#endif if ( CReplay::IsPlayingBackFromFile() ) bUpdate = false; @@ -1095,7 +1119,10 @@ void CPad::Update(int16 unk) void CPad::DoCheats(void) { - GetPad(0)->DoCheats(0); +#ifdef DETECT_PAD_INPUT_SWITCH + if (IsAffectedByController) +#endif + GetPad(0)->DoCheats(0); } void CPad::DoCheats(int16 unk) @@ -1153,13 +1180,19 @@ CPad *CPad::GetPad(int32 pad) { return &Pads[pad]; } +#ifdef DETECT_PAD_INPUT_SWITCH +#define CURMODE (IsAffectedByController ? Mode : 0) +#else +#define CURMODE (Mode) +#endif + int16 CPad::GetSteeringLeftRight(void) { if ( ArePlayerControlsDisabled() ) return 0; - - switch ( Mode ) + + switch (CURMODE) { case 0: case 2: @@ -1191,8 +1224,8 @@ int16 CPad::GetSteeringUpDown(void) { if ( ArePlayerControlsDisabled() ) return 0; - - switch ( Mode ) + + switch (CURMODE) { case 0: case 2: @@ -1224,8 +1257,8 @@ int16 CPad::GetCarGunUpDown(void) { if ( ArePlayerControlsDisabled() ) return 0; - - switch ( Mode ) + + switch (CURMODE) { case 0: case 1: @@ -1251,8 +1284,8 @@ int16 CPad::GetCarGunLeftRight(void) { if ( ArePlayerControlsDisabled() ) return 0; - - switch ( Mode ) + + switch (CURMODE) { case 0: case 1: @@ -1278,8 +1311,8 @@ int16 CPad::GetPedWalkLeftRight(void) { if ( ArePlayerControlsDisabled() ) return 0; - - switch ( Mode ) + + switch (CURMODE) { case 0: case 2: @@ -1312,8 +1345,8 @@ int16 CPad::GetPedWalkUpDown(void) { if ( ArePlayerControlsDisabled() ) return 0; - - switch ( Mode ) + + switch (CURMODE) { case 0: case 2: @@ -1343,7 +1376,7 @@ int16 CPad::GetPedWalkUpDown(void) int16 CPad::GetAnalogueUpDown(void) { - switch ( Mode ) + switch (CURMODE) { case 0: case 2: @@ -1408,8 +1441,8 @@ bool CPad::GetHorn(void) { if ( ArePlayerControlsDisabled() ) return false; - - switch ( Mode ) + + switch (CURMODE) { case 0: { @@ -1447,8 +1480,8 @@ bool CPad::HornJustDown(void) { if ( ArePlayerControlsDisabled() ) return false; - - switch ( Mode ) + + switch (CURMODE) { case 0: { @@ -1487,8 +1520,8 @@ bool CPad::GetCarGunFired(void) { if ( ArePlayerControlsDisabled() ) return false; - - switch ( Mode ) + + switch (CURMODE) { case 0: case 1: @@ -1514,8 +1547,8 @@ bool CPad::CarGunJustDown(void) { if ( ArePlayerControlsDisabled() ) return false; - - switch ( Mode ) + + switch (CURMODE) { case 0: case 1: @@ -1541,8 +1574,8 @@ int16 CPad::GetHandBrake(void) { if ( ArePlayerControlsDisabled() ) return 0; - - switch ( Mode ) + + switch (CURMODE) { case 0: case 1: @@ -1574,8 +1607,8 @@ int16 CPad::GetBrake(void) { if ( ArePlayerControlsDisabled() ) return 0; - - switch ( Mode ) + + switch (CURMODE) { case 0: case 2: @@ -1612,8 +1645,8 @@ bool CPad::GetExitVehicle(void) { if ( ArePlayerControlsDisabled() ) return false; - - switch ( Mode ) + + switch (CURMODE) { case 0: case 1: @@ -1639,8 +1672,8 @@ bool CPad::ExitVehicleJustDown(void) { if ( ArePlayerControlsDisabled() ) return false; - - switch ( Mode ) + + switch (CURMODE) { case 0: case 1: @@ -1666,8 +1699,8 @@ int32 CPad::GetWeapon(void) { if ( ArePlayerControlsDisabled() ) return false; - - switch ( Mode ) + + switch (CURMODE) { case 0: case 1: @@ -1699,8 +1732,8 @@ bool CPad::WeaponJustDown(void) { if ( ArePlayerControlsDisabled() ) return false; - - switch ( Mode ) + + switch (CURMODE) { case 0: case 1: @@ -1732,8 +1765,8 @@ int16 CPad::GetAccelerate(void) { if ( ArePlayerControlsDisabled() ) return 0; - - switch ( Mode ) + + switch (CURMODE) { case 0: case 2: @@ -1768,7 +1801,7 @@ int16 CPad::GetAccelerate(void) bool CPad::CycleCameraModeUpJustDown(void) { - switch ( Mode ) + switch (CURMODE) { case 0: case 2: @@ -1792,7 +1825,7 @@ bool CPad::CycleCameraModeUpJustDown(void) bool CPad::CycleCameraModeDownJustDown(void) { - switch ( Mode ) + switch (CURMODE) { case 0: case 2: @@ -1818,8 +1851,8 @@ bool CPad::ChangeStationJustDown(void) { if ( ArePlayerControlsDisabled() ) return false; - - switch ( Mode ) + + switch (CURMODE) { case 0: { @@ -1874,8 +1907,8 @@ bool CPad::GetTarget(void) { if ( ArePlayerControlsDisabled() ) return false; - - switch ( Mode ) + + switch (CURMODE) { case 0: case 1: @@ -1901,8 +1934,8 @@ bool CPad::TargetJustDown(void) { if ( ArePlayerControlsDisabled() ) return false; - - switch ( Mode ) + + switch (CURMODE) { case 0: case 1: @@ -1936,8 +1969,8 @@ bool CPad::GetSprint(void) { if ( ArePlayerControlsDisabled() ) return false; - - switch ( Mode ) + + switch (CURMODE) { case 0: case 1: @@ -2091,8 +2124,8 @@ bool CPad::ForceCameraBehindPlayer(void) { if ( ArePlayerControlsDisabled() ) return false; - - switch ( Mode ) + + switch (CURMODE) { case 0: case 1: @@ -2124,8 +2157,8 @@ bool CPad::SniperZoomIn(void) { if ( ArePlayerControlsDisabled() ) return false; - - switch ( Mode ) + + switch (CURMODE) { case 0: case 1: @@ -2151,8 +2184,8 @@ bool CPad::SniperZoomOut(void) { if ( ArePlayerControlsDisabled() ) return false; - - switch ( Mode ) + + switch (CURMODE) { case 0: case 1: @@ -2174,6 +2207,7 @@ bool CPad::SniperZoomOut(void) return false; } +#undef CURMODE int16 CPad::SniperModeLookLeftRight(void) { @@ -2189,6 +2223,9 @@ int16 CPad::SniperModeLookLeftRight(void) int16 CPad::SniperModeLookUpDown(void) { int16 axis = NewState.LeftStickY; +#ifdef FIX_BUGS + axis = -axis; +#endif int16 dpad = (NewState.DPadUp - NewState.DPadDown) / 2; if ( Abs(axis) > Abs(dpad) ) @@ -2215,7 +2252,11 @@ int16 CPad::LookAroundLeftRight(void) int16 CPad::LookAroundUpDown(void) { int16 axis = GetPad(0)->NewState.RightStickY; - + +#ifdef FIX_BUGS + axis = -axis; +#endif + if ( Abs(axis) > 85 && !GetLookBehindForPed() ) return (int16) ( (axis + ( ( axis > 0 ) ? -85 : 85) ) * (127.0f / 32.0f) ); // 3.96875f |