From 5f59626eef9bc9e7792dcac36d899bd54242080a Mon Sep 17 00:00:00 2001 From: RhythmLunatic Date: Tue, 26 Mar 2019 13:36:07 -0500 Subject: [PATCH 1/5] Add More OptionsList functionality --- Themes/_fallback/metrics.ini | 54 ++++++++++++++++++++++++++++++++++++ src/OptionRowHandler.cpp | 2 +- src/OptionRowHandler.h | 2 +- src/OptionsList.cpp | 34 ++++++++++++++++++----- src/OptionsList.h | 4 ++- 5 files changed, 86 insertions(+), 10 deletions(-) diff --git a/Themes/_fallback/metrics.ini b/Themes/_fallback/metrics.ini index 882a70f748..896781eb62 100644 --- a/Themes/_fallback/metrics.ini +++ b/Themes/_fallback/metrics.ini @@ -2875,6 +2875,60 @@ ExplanationTogetherOffCommand=stoptweening [ScreenOptionsServiceExtendedChild] Fallback="ScreenOptionsServiceChild" +[OptionsList] +Fallback="ScreenWithMenuElements" + +#If true, holding left and pressing right will go to the next menu, and holding right and pressing left will go to the previous menu. +LeftAndRightSwitchesMenu=true +CodeNames="" + +#It takes from ScreenOptionsMaster. +#This is the equivalent to LineNames +TopMenus="" +TopMenu="" + +DirectLines="" +ItemsSpacingY= +MaxItemsBeforeSplit= +ItemsSplitWidth= + +TextOnCommand= +TextOffCommand= +TextTweenOffCommand= +TextTweenOnCommand= +TextResetCommand= + +UnderlineOnCommand= +UnderlineOffCommand= +UnderlineSetTwoRowsCommand= +UnderlineSetOneRowCommand= +UnderlineShowCommand= +UnderlineHideCommand= +UnderlineTweenOnCommand= +UnderlineTweenOffCommand= +UnderlineResetCommand= + +CursorOnCommand= +CursorPositionTwoRowsCommand= +CursorPositionOneRowCommand= +CursorTweenOnCommand= +CursorTweenOffCommand= +CursorResetCommand= + +OptionsListOnCommand= +OptionsListOffCommand= +OptionsListTweenOffCommand= +OptionsListTweenOnCommand= +OptionsListResetCommand= + +OptionsListTweenOutForwardCommand= +OptionsListTweenOutBackwardCommand= +OptionsListTweenInForwardCommand= +OptionsListTweenInBackwardCommand= + +OptionsListFadeOffCommand= +OptionsListFadeOnCommand= + [ScreenMiniMenu] Class="ScreenMiniMenu" Fallback="ScreenOptions" diff --git a/src/OptionRowHandler.cpp b/src/OptionRowHandler.cpp index cb92d6a4cc..1810e0d04d 100644 --- a/src/OptionRowHandler.cpp +++ b/src/OptionRowHandler.cpp @@ -1326,7 +1326,7 @@ public: LUA->Release(L); return changed; } - virtual bool GoToFirstOnStart() + virtual bool GoToFirstOnStart() const { return m_GoToFirstOnStart; } diff --git a/src/OptionRowHandler.h b/src/OptionRowHandler.h index d115ca8676..b126634114 100644 --- a/src/OptionRowHandler.h +++ b/src/OptionRowHandler.h @@ -186,7 +186,7 @@ public: virtual RString GetScreen( int /* iChoice */ ) const { return RString(); } // Exists so that a lua function can act on the selection. Returns true if the choices should be reloaded. virtual bool NotifyOfSelection(PlayerNumber pn, int choice) { return false; } - virtual bool GoToFirstOnStart() { return true; } + virtual bool GoToFirstOnStart() const { return true; } }; /** @brief Utilities for the OptionRowHandlers. */ diff --git a/src/OptionsList.cpp b/src/OptionsList.cpp index 80f2410217..914b0c7587 100644 --- a/src/OptionsList.cpp +++ b/src/OptionsList.cpp @@ -181,12 +181,14 @@ OptionsList::~OptionsList() delete hand->second; } +//This is the initialization function. void OptionsList::Load( RString sType, PlayerNumber pn ) { TOP_MENU.Load( sType, "TopMenu" ); m_pn = pn; m_bStartIsDown = false; + m_bLeftAndRightSwitchesMenu = THEME->GetMetricB( m_sName,"LeftAndRightSwitchesMenu" ); m_Codes.Load( sType ); @@ -290,7 +292,8 @@ RString OptionsList::GetCurrentRow() const return m_asMenuStack.back(); } -const OptionRowHandler *OptionsList::GetCurrentHandler() +//This can't be const because OptionRowHandler->NotifyOfSelection() will modify the OptionRow. +OptionRowHandler *OptionsList::GetCurrentHandler() { RString sCurrentRow = GetCurrentRow(); return m_Rows[sCurrentRow]; @@ -419,7 +422,7 @@ bool OptionsList::Input( const InputEventPlus &input ) if( input.type == IET_RELEASE ) return false; - if( INPUTMAPPER->IsBeingPressed(GAME_BUTTON_RIGHT, pn) ) + if(m_bLeftAndRightSwitchesMenu and INPUTMAPPER->IsBeingPressed(GAME_BUTTON_RIGHT, pn) ) { if( input.type == IET_FIRST_PRESS ) SwitchMenu( -1 ); @@ -441,7 +444,7 @@ bool OptionsList::Input( const InputEventPlus &input ) if( input.type == IET_RELEASE ) return false; - if( INPUTMAPPER->IsBeingPressed(GAME_BUTTON_LEFT, pn) ) + if(m_bLeftAndRightSwitchesMenu and INPUTMAPPER->IsBeingPressed(GAME_BUTTON_LEFT, pn) ) { if( input.type == IET_FIRST_PRESS ) SwitchMenu( +1 ); @@ -501,6 +504,9 @@ void OptionsList::SwitchToCurrentRow() Message msg("OptionsMenuChanged"); msg.SetParam( "Player", m_pn ); msg.SetParam( "Menu", m_asMenuStack.back() ); + /* This is here because if we want to adjust the size of a graphic + * behind the list or do other lua things, we'd need to know the size. */ + msg.SetParam( "Size", (int)m_asMenuStack.size()); MESSAGEMAN->Broadcast( msg ); } @@ -662,7 +668,7 @@ void OptionsList::UpdateMenuFromSelections() bool OptionsList::Start() { - const OptionRowHandler *pHandler = GetCurrentHandler(); + OptionRowHandler *pHandler = GetCurrentHandler(); const RString &sCurrentRow = m_asMenuStack.back(); vector &bSelections = m_bSelections[sCurrentRow]; if( m_iMenuStackSelection == (int)bSelections.size() ) @@ -717,12 +723,26 @@ bool OptionsList::Start() SelectItem( GetCurrentRow(), m_iMenuStackSelection ); - /* Move to the exit row. */ - m_iMenuStackSelection = (int)bSelections.size(); - PositionCursor(); + /* Move to the exit row, but only if it's SelectOne. */ + if (pHandler->m_Def.m_selectType == SELECT_ONE) + { + m_iMenuStackSelection = (int)bSelections.size(); + PositionCursor(); + } + if (pHandler->NotifyOfSelection(m_pn, m_iMenuStackSelection)) + { + /* The current selections are irrelevant when we're getting them + * from NotifyOfSelection. Re import them from the OptionRow. */ + ImportRow(sCurrentRow); + UpdateMenuFromSelections(); + } + /* Better to include Selection as a parameter since + * the index may or may not change depending on if SelectType + * is SELECT_ONE or SELECT_MULTIPLE. */ Message msg("OptionsListStart"); msg.SetParam( "Player", m_pn ); + msg.SetParam( "Selection", m_iMenuStackSelection ); MESSAGEMAN->Broadcast( msg ); return false; diff --git a/src/OptionsList.h b/src/OptionsList.h index 6a03f166fb..2291244626 100644 --- a/src/OptionsList.h +++ b/src/OptionsList.h @@ -70,7 +70,7 @@ private: void SelectionsChanged( const RString &sRowName ); void UpdateMenuFromSelections(); RString GetCurrentRow() const; - const OptionRowHandler *GetCurrentHandler(); + OptionRowHandler *GetCurrentHandler(); int GetOneSelection( RString sRow, bool bAllowFail=false ) const; void SwitchToCurrentRow(); void TweenOnCurrentRow( bool bForward ); @@ -101,6 +101,8 @@ private: vector m_asMenuStack; int m_iMenuStackSelection; +protected: + bool m_bLeftAndRightSwitchesMenu; }; From 60af9e315312c9376e8f4ed145c0e3413735fe18 Mon Sep 17 00:00:00 2001 From: RhythmLunatic Date: Tue, 26 Mar 2019 14:07:30 -0500 Subject: [PATCH 2/5] Remove Size parameter because it's broken --- src/OptionsList.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/OptionsList.cpp b/src/OptionsList.cpp index 914b0c7587..5f68e87b95 100644 --- a/src/OptionsList.cpp +++ b/src/OptionsList.cpp @@ -504,9 +504,6 @@ void OptionsList::SwitchToCurrentRow() Message msg("OptionsMenuChanged"); msg.SetParam( "Player", m_pn ); msg.SetParam( "Menu", m_asMenuStack.back() ); - /* This is here because if we want to adjust the size of a graphic - * behind the list or do other lua things, we'd need to know the size. */ - msg.SetParam( "Size", (int)m_asMenuStack.size()); MESSAGEMAN->Broadcast( msg ); } From 4eecbcf9339981070767988c9454998850363a6b Mon Sep 17 00:00:00 2001 From: RhythmLunatic Date: Tue, 26 Mar 2019 20:29:37 -0500 Subject: [PATCH 3/5] Make OptionsList inputs remappable --- Themes/_fallback/Scripts/03 Gameplay.lua | 26 +++++++++++++++++ Themes/_fallback/metrics.ini | 6 ++-- src/OptionsList.cpp | 37 ++++++++++++------------ src/OptionsList.h | 5 +++- 4 files changed, 53 insertions(+), 21 deletions(-) diff --git a/Themes/_fallback/Scripts/03 Gameplay.lua b/Themes/_fallback/Scripts/03 Gameplay.lua index fb284cb076..dc29180ecd 100644 --- a/Themes/_fallback/Scripts/03 Gameplay.lua +++ b/Themes/_fallback/Scripts/03 Gameplay.lua @@ -461,6 +461,32 @@ function GetCodeForGame(codeName) return inputCode[gameName] or inputCode["default"] end +local OptionsListKeys = { + PrevMenu = { + pump="MenuUp", + default="MenuLeft" + }, + NextMenu = { + pump="MenuDown", + default="MenuRight" + }, + PrevItem = { + pump="MenuLeft", + default="MenuUp" + }, + NextItem = { + pump="MenuRight", + default="MenuDown" + } +}; + +function GetOptionsListMapping(name) + local sGame = string.lower(GAMESTATE:GetCurrentGame():GetName()) + local map = OptionsListKeys[name] + return map[sGame] or map["default"] +end + + function oitg_zoom_mode_actor() return Def.Actor{ OnCommand= function(self) diff --git a/Themes/_fallback/metrics.ini b/Themes/_fallback/metrics.ini index 896781eb62..805d6907d1 100644 --- a/Themes/_fallback/metrics.ini +++ b/Themes/_fallback/metrics.ini @@ -2878,8 +2878,10 @@ Fallback="ScreenOptionsServiceChild" [OptionsList] Fallback="ScreenWithMenuElements" -#If true, holding left and pressing right will go to the next menu, and holding right and pressing left will go to the previous menu. -LeftAndRightSwitchesMenu=true +PrevMenuButton=GetOptionsListMapping("PrevMenu") +NextMenuButton=GetOptionsListMapping("NextMenu") +PrevItemButton=GetOptionsListMapping("PrevItem") +NextItemButton=GetOptionsListMapping("NextItem") CodeNames="" #It takes from ScreenOptionsMaster. diff --git a/src/OptionsList.cpp b/src/OptionsList.cpp index 5f68e87b95..4ebde8728b 100644 --- a/src/OptionsList.cpp +++ b/src/OptionsList.cpp @@ -188,8 +188,11 @@ void OptionsList::Load( RString sType, PlayerNumber pn ) m_pn = pn; m_bStartIsDown = false; - m_bLeftAndRightSwitchesMenu = THEME->GetMetricB( m_sName,"LeftAndRightSwitchesMenu" ); - + m_GameButtonPreviousMenu = INPUTMAPPER->GetInputScheme()->ButtonNameToIndex( THEME->GetMetric( m_sName,"PrevMenuButton" ) ); + m_GameButtonNextMenu = INPUTMAPPER->GetInputScheme()->ButtonNameToIndex( THEME->GetMetric( m_sName,"NextMenuButton" ) ); + m_GameButtonPreviousItem = INPUTMAPPER->GetInputScheme()->ButtonNameToIndex( THEME->GetMetric( m_sName,"PrevItemButton" ) ); + m_GameButtonNextItem = INPUTMAPPER->GetInputScheme()->ButtonNameToIndex( THEME->GetMetric( m_sName,"NextItemButton" ) ); + m_Codes.Load( sType ); m_Cursor.Load( THEME->GetPathG(sType, "cursor") ); @@ -417,18 +420,11 @@ bool OptionsList::Input( const InputEventPlus &input ) } } - if( input.MenuI == GAME_BUTTON_LEFT ) + if( input.MenuI == m_GameButtonPreviousItem ) { if( input.type == IET_RELEASE ) return false; - if(m_bLeftAndRightSwitchesMenu and INPUTMAPPER->IsBeingPressed(GAME_BUTTON_RIGHT, pn) ) - { - if( input.type == IET_FIRST_PRESS ) - SwitchMenu( -1 ); - return true; - } - --m_iMenuStackSelection; wrap( m_iMenuStackSelection, pHandler->m_Def.m_vsChoices.size()+1 ); // +1 for exit row PositionCursor(); @@ -439,18 +435,11 @@ bool OptionsList::Input( const InputEventPlus &input ) MESSAGEMAN->Broadcast( lMsg ); return true; } - else if( input.MenuI == GAME_BUTTON_RIGHT ) + else if( input.MenuI == m_GameButtonNextItem ) { if( input.type == IET_RELEASE ) return false; - if(m_bLeftAndRightSwitchesMenu and INPUTMAPPER->IsBeingPressed(GAME_BUTTON_LEFT, pn) ) - { - if( input.type == IET_FIRST_PRESS ) - SwitchMenu( +1 ); - return true; - } - ++m_iMenuStackSelection; wrap( m_iMenuStackSelection, pHandler->m_Def.m_vsChoices.size()+1 ); // +1 for exit row PositionCursor(); @@ -461,6 +450,18 @@ bool OptionsList::Input( const InputEventPlus &input ) MESSAGEMAN->Broadcast( lMsg ); return true; } + else if ( input.MenuI == m_GameButtonPreviousMenu ) + { + if( input.type == IET_FIRST_PRESS ) + SwitchMenu( -1 ); + return true; + } + else if ( input.MenuI == m_GameButtonNextMenu ) + { + if( input.type == IET_FIRST_PRESS ) + SwitchMenu( +1 ); + return true; + } else if( input.MenuI == GAME_BUTTON_START ) { if( input.type == IET_FIRST_PRESS ) diff --git a/src/OptionsList.h b/src/OptionsList.h index 2291244626..017caba714 100644 --- a/src/OptionsList.h +++ b/src/OptionsList.h @@ -102,7 +102,10 @@ private: vector m_asMenuStack; int m_iMenuStackSelection; protected: - bool m_bLeftAndRightSwitchesMenu; + GameButton m_GameButtonPreviousMenu; + GameButton m_GameButtonNextMenu; + GameButton m_GameButtonPreviousItem; + GameButton m_GameButtonNextItem; }; From 2648c65c222237dfed7a22f047587bf84908b27d Mon Sep 17 00:00:00 2001 From: RhythmLunatic Date: Thu, 28 Mar 2019 16:11:36 -0500 Subject: [PATCH 4/5] Change Next/Prev OptionsList to CodeDetector --- Themes/_fallback/Scripts/03 Gameplay.lua | 15 +++++++-------- Themes/_fallback/metrics.ini | 4 ++++ src/CodeDetector.cpp | 11 +++++++++++ src/CodeDetector.h | 4 ++++ src/OptionsList.cpp | 6 ++---- src/OptionsList.h | 2 -- 6 files changed, 28 insertions(+), 14 deletions(-) diff --git a/Themes/_fallback/Scripts/03 Gameplay.lua b/Themes/_fallback/Scripts/03 Gameplay.lua index dc29180ecd..84a1ef1218 100644 --- a/Themes/_fallback/Scripts/03 Gameplay.lua +++ b/Themes/_fallback/Scripts/03 Gameplay.lua @@ -331,6 +331,13 @@ local CodeDetectorCodes = { CloseCurrentFolder = { default = "MenuUp-MenuDown", }, + -- OptionsList + PrevOptionsList = { + default = "@MenuUp-MenuDown", + }, + NextOptionsList = { + default = "@MenuDown-MenuUp", + }, -- sorts NextSort1 = { default = "@MenuLeft-@MenuRight-Start", @@ -462,14 +469,6 @@ function GetCodeForGame(codeName) end local OptionsListKeys = { - PrevMenu = { - pump="MenuUp", - default="MenuLeft" - }, - NextMenu = { - pump="MenuDown", - default="MenuRight" - }, PrevItem = { pump="MenuLeft", default="MenuUp" diff --git a/Themes/_fallback/metrics.ini b/Themes/_fallback/metrics.ini index 805d6907d1..0eb954bbaa 100644 --- a/Themes/_fallback/metrics.ini +++ b/Themes/_fallback/metrics.ini @@ -368,6 +368,10 @@ PrevGroup=GetCodeForGame("PrevGroup") CloseCurrentFolder=GetCodeForGame("CloseCurrentFolder") Hidden=GetCodeForGame("Hidden") RandomVanish=GetCodeForGame("RandomVanish") +# OptionsList (if enabled) +PrevOptionsList=GetCodeForGame("PrevOptionsList") +NextOptionsList=GetCodeForGame("NextOptionsList") +# Evaluation screen SaveScreenshot1=GetCodeForGame("SaveScreenshot1") SaveScreenshot2=GetCodeForGame("SaveScreenshot2") # on the player options menu. diff --git a/src/CodeDetector.cpp b/src/CodeDetector.cpp index d35a3a00c2..42780e0805 100644 --- a/src/CodeDetector.cpp +++ b/src/CodeDetector.cpp @@ -53,6 +53,8 @@ const char *CodeNames[] = { "CancelAllPlayerOptions", "BackInEventMode", "CloseCurrentFolder", + "PrevOptionsList", + "NextOptionsList" }; XToString( Code ); @@ -116,6 +118,15 @@ bool CodeDetector::EnteredModeMenu( GameController controller ) return EnteredCode(controller,CODE_MODE_MENU1) || EnteredCode(controller,CODE_MODE_MENU2); } +bool CodeDetector::EnteredPrevOpList( GameController controller ) +{ + return EnteredCode(controller,CODE_PREV_OPLIST); +} +bool CodeDetector::EnteredNextOpList( GameController controller ) +{ + return EnteredCode(controller,CODE_NEXT_OPLIST); +} + #define TOGGLE(v,a,b) if(v!=a) v=a; else v=b; #define FLOAT_TOGGLE(v) if(v!=1.f) v=1.f; else v=0.f; // XXX: Read the metrics file instead! diff --git a/src/CodeDetector.h b/src/CodeDetector.h index d9b6089fbb..f54616af8c 100644 --- a/src/CodeDetector.h +++ b/src/CodeDetector.h @@ -47,6 +47,8 @@ enum Code { CODE_CANCEL_ALL_PLAYER_OPTIONS, CODE_BACK_IN_EVENT_MODE, CODE_CLOSE_CURRENT_FOLDER, + CODE_NEXT_OPLIST, + CODE_PREV_OPLIST, NUM_Code // leave this at the end }; @@ -63,6 +65,8 @@ public: static bool EnteredPrevGroup( GameController controller ); static bool EnteredNextGroup( GameController controller ); static bool EnteredCloseFolder( GameController controller ); + static bool EnteredPrevOpList( GameController controller ); + static bool EnteredNextOpList( GameController controller ); // todo: move to PlayerOptions.h -aj void ChangeScrollSpeed( GameController controller, bool bIncrement ); diff --git a/src/OptionsList.cpp b/src/OptionsList.cpp index 4ebde8728b..109cfecbad 100644 --- a/src/OptionsList.cpp +++ b/src/OptionsList.cpp @@ -188,8 +188,6 @@ void OptionsList::Load( RString sType, PlayerNumber pn ) m_pn = pn; m_bStartIsDown = false; - m_GameButtonPreviousMenu = INPUTMAPPER->GetInputScheme()->ButtonNameToIndex( THEME->GetMetric( m_sName,"PrevMenuButton" ) ); - m_GameButtonNextMenu = INPUTMAPPER->GetInputScheme()->ButtonNameToIndex( THEME->GetMetric( m_sName,"NextMenuButton" ) ); m_GameButtonPreviousItem = INPUTMAPPER->GetInputScheme()->ButtonNameToIndex( THEME->GetMetric( m_sName,"PrevItemButton" ) ); m_GameButtonNextItem = INPUTMAPPER->GetInputScheme()->ButtonNameToIndex( THEME->GetMetric( m_sName,"NextItemButton" ) ); @@ -450,13 +448,13 @@ bool OptionsList::Input( const InputEventPlus &input ) MESSAGEMAN->Broadcast( lMsg ); return true; } - else if ( input.MenuI == m_GameButtonPreviousMenu ) + else if ( CodeDetector::EnteredPrevOpList(input.GameI.controller) ) { if( input.type == IET_FIRST_PRESS ) SwitchMenu( -1 ); return true; } - else if ( input.MenuI == m_GameButtonNextMenu ) + else if ( CodeDetector::EnteredNextOpList(input.GameI.controller) ) { if( input.type == IET_FIRST_PRESS ) SwitchMenu( +1 ); diff --git a/src/OptionsList.h b/src/OptionsList.h index 017caba714..783e1d77c2 100644 --- a/src/OptionsList.h +++ b/src/OptionsList.h @@ -102,8 +102,6 @@ private: vector m_asMenuStack; int m_iMenuStackSelection; protected: - GameButton m_GameButtonPreviousMenu; - GameButton m_GameButtonNextMenu; GameButton m_GameButtonPreviousItem; GameButton m_GameButtonNextItem; }; From 8b8cb969d15730dc63f46f8bfcad19a5b678dab2 Mon Sep 17 00:00:00 2001 From: RhythmLunatic Date: Thu, 18 Apr 2019 09:14:41 -0500 Subject: [PATCH 5/5] Add missing PacDrive Win32 driver --- src/CMakeData-arch.cmake | 6 +- src/arch/Lights/LightsDriver_PacDrive.cpp | 106 ++++++++++++++++++++++ src/arch/Lights/LightsDriver_PacDrive.h | 28 ++++++ 3 files changed, 138 insertions(+), 2 deletions(-) create mode 100644 src/arch/Lights/LightsDriver_PacDrive.cpp create mode 100644 src/arch/Lights/LightsDriver_PacDrive.h diff --git a/src/CMakeData-arch.cmake b/src/CMakeData-arch.cmake index 2f1cb5b9bc..50faf5b817 100644 --- a/src/CMakeData-arch.cmake +++ b/src/CMakeData-arch.cmake @@ -214,9 +214,11 @@ if(NOT APPLE) if(WIN32) list(APPEND SMDATA_ARCH_LIGHTS_SRC - "arch/Lights/LightsDriver_Win32Parallel.cpp") + "arch/Lights/LightsDriver_Win32Parallel.cpp" + "arch/Lights/LightsDriver_PacDrive.cpp") list(APPEND SMDATA_ARCH_LIGHTS_HPP - "arch/Lights/LightsDriver_Win32Parallel.h") + "arch/Lights/LightsDriver_Win32Parallel.h" + "arch/Lights/LightsDriver_PacDrive.cpp") if(WITH_MINIMAID) list(APPEND SMDATA_ARCH_LIGHTS_SRC "arch/Lights/LightsDriver_Win32Minimaid.cpp") diff --git a/src/arch/Lights/LightsDriver_PacDrive.cpp b/src/arch/Lights/LightsDriver_PacDrive.cpp new file mode 100644 index 0000000000..daeb5c0499 --- /dev/null +++ b/src/arch/Lights/LightsDriver_PacDrive.cpp @@ -0,0 +1,106 @@ +// LightsDriver_PacDrive for use with a PacDrive hooked up with LEDs +// You need PacDrive32.dll in the StepMania directory to use this. + +#include "global.h" +#include "LightsDriver_PacDrive.h" +#include "windows.h" +#include "RageUtil.h" + +REGISTER_LIGHTS_DRIVER_CLASS(PacDrive); + +HINSTANCE PachDLL = NULL; + +bool PacDriveConnected = false; +typedef int (WINAPI PacInitialize)(void); +PacInitialize* m_pacinit = NULL; +typedef void (WINAPI PacShutdown)(void); +PacShutdown* m_pacdone = NULL; +typedef bool (WINAPI PacSetLEDStates)(int, short int); +PacSetLEDStates* m_pacset = NULL; + + +LightsDriver_PacDrive::LightsDriver_PacDrive() +{ + // init io.dll + PachDLL = LoadLibrary("pacdrive32.dll"); + if(PachDLL == NULL) + { + MessageBox(NULL, "Could not LoadLibrary( pacdrive32.dll ).", "ERROR", MB_OK ); + return; + } + + //Get the function pointers + m_pacinit = (PacInitialize*) GetProcAddress(PachDLL, "PacInitialize"); + m_pacset = (PacSetLEDStates*) GetProcAddress(PachDLL, "PacSetLEDStates"); + m_pacdone = (PacShutdown*) GetProcAddress(PachDLL, "PacShutdown"); + + int NumPacDrives = m_pacinit(); //initialize the pac drive + + if( NumPacDrives == 0 ) + { + PacDriveConnected = false; // set not connected + MessageBox(NULL, "Could not find connected PacDrive.", "ERROR", MB_OK); + return; + } + else + { + PacDriveConnected = true; // set connected + m_pacset(0, 0x0); // clear all lights for device i + } +} + +LightsDriver_PacDrive::~LightsDriver_PacDrive() +{ + if( PacDriveConnected ) + m_pacset(0, 0x0); // clear all lights for device i + m_pacdone(); + FreeLibrary( PachDLL ); +} + +void LightsDriver_PacDrive::Set( const LightsState *ls ) +{ + // Set the cabinet light values + short int outb=0; + + if (ls->m_bCabinetLights[LIGHT_MARQUEE_UP_LEFT]) outb|=BIT(0); + if (ls->m_bCabinetLights[LIGHT_MARQUEE_UP_RIGHT]) outb|=BIT(1); + if (ls->m_bCabinetLights[LIGHT_MARQUEE_LR_LEFT]) outb|=BIT(2); + if (ls->m_bCabinetLights[LIGHT_MARQUEE_LR_RIGHT]) outb|=BIT(3); + if (ls->m_bCabinetLights[LIGHT_BASS_LEFT] || ls->m_bCabinetLights[LIGHT_BASS_RIGHT]) outb|=BIT(4); + if (ls->m_bGameButtonLights[GameController_1][DANCE_BUTTON_LEFT]) outb|=BIT(5); + if (ls->m_bGameButtonLights[GameController_1][DANCE_BUTTON_RIGHT]) outb|=BIT(6); + if (ls->m_bGameButtonLights[GameController_1][DANCE_BUTTON_UP]) outb|=BIT(7); + if (ls->m_bGameButtonLights[GameController_1][DANCE_BUTTON_DOWN]) outb|=BIT(8); + if (ls->m_bGameButtonLights[GameController_1][GAME_BUTTON_START]) outb|=BIT(9); + if (ls->m_bGameButtonLights[GameController_2][DANCE_BUTTON_LEFT]) outb|=BIT(10); + if (ls->m_bGameButtonLights[GameController_2][DANCE_BUTTON_RIGHT]) outb|=BIT(11); + if (ls->m_bGameButtonLights[GameController_2][DANCE_BUTTON_UP]) outb|=BIT(12); + if (ls->m_bGameButtonLights[GameController_2][DANCE_BUTTON_DOWN]) outb|=BIT(13); + if (ls->m_bGameButtonLights[GameController_2][GAME_BUTTON_START]) outb|=BIT(14); + m_pacset(0,outb); +} + +/* Modified 2015 Dave Barribeau for StepMania 5.09 + * (c) 2003-2004 Chris Danford + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons to + * whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT + * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ diff --git a/src/arch/Lights/LightsDriver_PacDrive.h b/src/arch/Lights/LightsDriver_PacDrive.h new file mode 100644 index 0000000000..3ddf290200 --- /dev/null +++ b/src/arch/Lights/LightsDriver_PacDrive.h @@ -0,0 +1,28 @@ +/* + * LightsDriver_PacDrive + */ + +#ifndef LightsDriver_PacDrive_H +#define LightsDriver_PacDrive_H + +#include "arch/Lights/LightsDriver.h" + +#define BIT(i) (1<<(i)) + + +class LightsDriver_PacDrive : public LightsDriver +{ + public: + LightsDriver_PacDrive(); + virtual ~LightsDriver_PacDrive(); + + virtual void Set( const LightsState *ls ); +}; + +#endif + +/* Modified 2015 - Dave Barribeau for StepMania 5.09 +* 2014 - twistedsymphony +* Created for use with Beware's StepMania 3.9 DDR Extreme Simulation +* feel free to reuse and distribute this code +*/ \ No newline at end of file