diff --git a/source/frontend/options.cpp b/source/frontend/options.cpp index 3a81f93f6..ce584c3a9 100644 --- a/source/frontend/options.cpp +++ b/source/frontend/options.cpp @@ -373,10 +373,10 @@ void CFrontEndOptions::init() tb->init(fr); tb->setObjectXYWH(176+26,45,150,15); tb->setText(STR__FRONTEND__WEAPONCHANGE); - CGUIFactory::createCycleButtonFrame(m_modeMenus[MODE__CONTROL], - X_BORDER,Y_BORDER+90,OPTIONS_FRAME_W-(X_BORDER*2),25, - STR__FRONTEND__VIBRATION, - &m_vibrationStatus,s_vibrationValues,s_vibrationReadoutText); + m_vibGUIOption=CGUIFactory::createCycleButtonFrame(m_modeMenus[MODE__CONTROL], + X_BORDER,Y_BORDER+90,OPTIONS_FRAME_W-(X_BORDER*2),25, + STR__FRONTEND__VIBRATION, + &m_vibrationStatus,s_vibrationValues,s_vibrationReadoutText); // Populate SCREEN menu @@ -573,6 +573,21 @@ void CFrontEndOptions::think(int _frames) int i,j,button; + + // Hide the VIBRATION option if vibration not available + if(PadCanVibrate(0)) + { + m_vibGUIOption->unhide(); + } + else + { + if(m_vibGUIOption->isSelected()) + { + m_modeMenus[MODE__CONTROL]->selectPreviousItem(); + } + m_vibGUIOption->hide(); + } + m_background->think(_frames); if(!CFader::isFading()) diff --git a/source/frontend/options.h b/source/frontend/options.h index 2916af7df..6da876464 100644 --- a/source/frontend/options.h +++ b/source/frontend/options.h @@ -151,6 +151,7 @@ private: int m_speechVolume; int m_controlStyle; int m_vibrationStatus,m_lastVibrationStatus; + class CGUIObject *m_vibGUIOption; int m_screenXOff; int m_screenYOff; diff --git a/source/game/pause.cpp b/source/game/pause.cpp index 641da395c..b74164038 100644 --- a/source/game/pause.cpp +++ b/source/game/pause.cpp @@ -149,6 +149,7 @@ void CPauseMenu::init() CGUITextReadout *tr; fr=new ("frame") CGUIGroupFrame(); + m_vibGUIOption=fr; fr->init(m_pauseGuiFrame); fr->setObjectXYWH((FRAME_WIDTH-TEXT_BOX_WIDTH)/2,ypos,TEXT_BOX_WIDTH,TEXT_BOX_HEIGHT); tb=new ("textbox") CGUITextBox(); @@ -324,6 +325,24 @@ void CPauseMenu::think(int _frames) { if(m_active) { + if(m_pauseGuiFrame->isSelected()) + { + // Hide the VIBRATION option if vibration not available + if(PadCanVibrate(0)) + { + m_vibGUIOption->unhide(); + } + else + { + if(m_vibGUIOption->isSelected()) + { + m_pauseGuiFrame->selectPreviousItem(); + } + m_vibGUIOption->hide(); + } + } + + if(PadGetDown(0)&PAD_START) { if(!m_padDebounce) diff --git a/source/game/pause.h b/source/game/pause.h index 5e17acf80..089b19f7e 100644 --- a/source/game/pause.h +++ b/source/game/pause.h @@ -73,6 +73,7 @@ private: class CGUIControlFrame *m_pauseGuiFrame; class CGUIControlFrame *m_confirmQuitGuiFrame; + class CGUIObject *m_vibGUIOption; class FontBank *m_fontBank; diff --git a/source/pad/pads.cpp b/source/pad/pads.cpp index 39bdd8b0f..6d3895dcd 100644 --- a/source/pad/pads.cpp +++ b/source/pad/pads.cpp @@ -208,6 +208,12 @@ int PadIsDualShock(int Port) return (PadData[Port].IsAnalogue==2); } +/*****************************************************************************/ +int PadCanVibrate(int Port) +{ + return PadIsConnected(Port)&&PadData[Port].CanVibrate; +} + /*****************************************************************************/ void SetPadRescan() { @@ -293,6 +299,7 @@ int intensity; if (Pad->Status == PadStateFindPad) { Pad->Send = 0; + Pad->CanVibrate=false; } if ( Pad->Send==0 || PadRescan) { @@ -305,7 +312,11 @@ int intensity; } if (Pad->Status == PadStateStable) { - if (PadSetActAlign(PortShift,PadAlign)) Pad->Send = 1; + if (PadSetActAlign(PortShift,PadAlign)) + { + Pad->Send = 1; + Pad->CanVibrate=true; + } } } diff --git a/source/pad/pads.h b/source/pad/pads.h index 178b313f9..94513f9fa 100644 --- a/source/pad/pads.h +++ b/source/pad/pads.h @@ -64,6 +64,7 @@ typedef struct u8 Send; u8 IsAnalogue; bool Active; + bool CanVibrate; } sPadData; struct VIBE_DATA @@ -89,6 +90,7 @@ u16 PadGetRepeat(int Port); int PadIsDualShock(int Port); +int PadCanVibrate(int Port); u16 PadGetPadAngle(u16 Pad, s16 angleAdjust);