diff --git a/Package/Environment/Common/controls.conf b/Package/Environment/Common/controls.conf index b4fd723..d42051b 100644 --- a/Package/Environment/Common/controls.conf +++ b/Package/Environment/Common/controls.conf @@ -1,7 +1,9 @@ -previousItem = Up -nextItem = Down -pageUp = Left -pageDown = Right +up = Up +down = Down +left = Left +right = Right +pageUp = A +pageDown = B select = Space back = Escape quit = Q diff --git a/RetroFE/Source/Control/UserInput.cpp b/RetroFE/Source/Control/UserInput.cpp index ea0ce4e..79c11af 100644 --- a/RetroFE/Source/Control/UserInput.cpp +++ b/RetroFE/Source/Control/UserInput.cpp @@ -31,8 +31,23 @@ bool UserInput::Initialize() { bool retVal = true; - retVal = MapKey("nextItem", KeyCodeNextItem) && retVal; - retVal = MapKey("previousItem", KeyCodePreviousItem) && retVal; + if(!MapKey("up", KeyCodeUp)) + { + retVal = MapKey("left", KeyCodeUp) && retVal; + } + if(!MapKey("left", KeyCodeLeft)) + { + retVal = MapKey("up", KeyCodeLeft) && retVal; + } + if(!MapKey("down", KeyCodeDown)) + { + retVal = MapKey("right", KeyCodeDown) && retVal; + } + if(!MapKey("right", KeyCodeRight)) + { + retVal = MapKey("down", KeyCodeRight) && retVal; + } + retVal = MapKey("pageDown", KeyCodePageDown) && retVal; retVal = MapKey("pageUp", KeyCodePageUp) && retVal; retVal = MapKey("select", KeyCodeSelect) && retVal; @@ -61,7 +76,6 @@ SDL_Scancode UserInput::GetScancode(KeyCode_E key) bool UserInput::MapKey(std::string keyDescription, KeyCode_E key) { - bool retVal = false; SDL_Scancode scanCode; std::string description; @@ -70,22 +84,18 @@ bool UserInput::MapKey(std::string keyDescription, KeyCode_E key) if(!Config.GetProperty(configKey, description)) { Logger::Write(Logger::ZONE_ERROR, "Configuration", "Missing property " + configKey); + return false; } - else + + scanCode = SDL_GetScancodeFromName(description.c_str()); + + if(scanCode == SDL_SCANCODE_UNKNOWN) { - scanCode = SDL_GetScancodeFromName(description.c_str()); - - if(scanCode == SDL_SCANCODE_UNKNOWN) - { - Logger::Write(Logger::ZONE_ERROR, "Configuration", "Unsupported property value for " + configKey + "(" + description + "). See Documentation/Keycodes.txt for valid inputs"); - } - else - { - KeyMap[key] = scanCode; - retVal = true; - } + Logger::Write(Logger::ZONE_ERROR, "Configuration", "Unsupported property value for " + configKey + "(" + description + "). See Documentation/Keycodes.txt for valid inputs"); + return false; } - return retVal; + KeyMap[key] = scanCode; + return true; } diff --git a/RetroFE/Source/Control/UserInput.h b/RetroFE/Source/Control/UserInput.h index 455a87c..07c4cf5 100644 --- a/RetroFE/Source/Control/UserInput.h +++ b/RetroFE/Source/Control/UserInput.h @@ -25,8 +25,10 @@ class UserInput public: enum KeyCode_E { - KeyCodeNextItem, - KeyCodePreviousItem, + KeyCodeUp, + KeyCodeDown, + KeyCodeLeft, + KeyCodeRight, KeyCodeSelect, KeyCodeBack, KeyCodePageDown, diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.cpp b/RetroFE/Source/Graphics/Component/ScrollingList.cpp index 6990d30..5880300 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.cpp +++ b/RetroFE/Source/Graphics/Component/ScrollingList.cpp @@ -65,6 +65,7 @@ ScrollingList::ScrollingList(Configuration &c, , FontInst(font) , LayoutKey(layoutKey) , ImageType(imageType) + , HorizontalScroll(false) { } @@ -155,6 +156,16 @@ void ScrollingList::SetItems(std::vector *spriteList) AllocateSpritePoints(); } +bool ScrollingList::IsHorizontalScroll() +{ + return HorizontalScroll; +} + +void ScrollingList::SetScrollOrientation(bool horizontal) +{ + HorizontalScroll = horizontal; +} + void ScrollingList::SetScrollAcceleration(float value) { ScrollAcceleration = value; diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.h b/RetroFE/Source/Graphics/Component/ScrollingList.h index 41d41a7..0038599 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.h +++ b/RetroFE/Source/Graphics/Component/ScrollingList.h @@ -61,6 +61,8 @@ public: void DestroyItems(); void SetPoints(std::vector *scrollPoints, std::vector *tweenPoints); void SetScrollDirection(ScrollDirection direction); + void SetScrollOrientation(bool horizontal); + bool IsHorizontalScroll(); void PageUp(); void PageDown(); bool IsIdle(); @@ -127,5 +129,6 @@ private: Font *FontInst; std::string LayoutKey; std::string ImageType; + bool HorizontalScroll; }; diff --git a/RetroFE/Source/Graphics/Page.cpp b/RetroFE/Source/Graphics/Page.cpp index 37e7eca..d408e01 100644 --- a/RetroFE/Source/Graphics/Page.cpp +++ b/RetroFE/Source/Graphics/Page.cpp @@ -335,6 +335,13 @@ void Page::SetScrolling(ScrollDirection direction) ActiveMenu->SetScrollDirection(menuDirection); } +bool Page::IsHorizontalScroll() +{ + if(!ActiveMenu) { return false; } + + return ActiveMenu->IsHorizontalScroll(); +} + void Page::PageScroll(ScrollDirection direction) { if(ActiveMenu) diff --git a/RetroFE/Source/Graphics/Page.h b/RetroFE/Source/Graphics/Page.h index d60a299..0ff8f21 100644 --- a/RetroFE/Source/Graphics/Page.h +++ b/RetroFE/Source/Graphics/Page.h @@ -58,6 +58,7 @@ public: void StartComponents(); void Stop(); void SetScrolling(ScrollDirection direction); + bool IsHorizontalScroll(); unsigned int GetMenuDepth(); Item *GetSelectedItem(); Item *GetPendingSelectedItem(); diff --git a/RetroFE/Source/Graphics/PageBuilder.cpp b/RetroFE/Source/Graphics/PageBuilder.cpp index 30a6bc1..77c4713 100644 --- a/RetroFE/Source/Graphics/PageBuilder.cpp +++ b/RetroFE/Source/Graphics/PageBuilder.cpp @@ -580,6 +580,7 @@ ScrollingList * PageBuilder::BuildMenu(xml_node<> *menuXml) xml_attribute<> *menuTypeXml = menuXml->first_attribute("type"); xml_attribute<> *scrollTimeXml = menuXml->first_attribute("scrollTime"); xml_attribute<> *scrollAccelerationXml = menuXml->first_attribute("scrollAcceleration"); + xml_attribute<> *scrollOrientationXml = menuXml->first_attribute("orientation"); if(menuTypeXml) { @@ -612,6 +613,15 @@ ScrollingList * PageBuilder::BuildMenu(xml_node<> *menuXml) menu->SetScrollAcceleration(Utils::ConvertFloat(scrollAccelerationXml->value())); } + if(scrollOrientationXml) + { + std::string scrollOrientation = scrollOrientationXml->value(); + if(scrollOrientation == "horizontal") + { + menu->SetScrollOrientation(true); + } + } + ViewInfo *v = menu->GetBaseViewInfo(); BuildViewInfo(menuXml, v); diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index 23a271c..238f656 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -378,13 +378,27 @@ RetroFE::RETROFE_STATE RetroFE::ProcessUserInput(Page *page) Attract.Reset(); - if (keys[Input.GetScancode(UserInput::KeyCodePreviousItem)]) + if(page->IsHorizontalScroll()) { - page->SetScrolling(Page::ScrollDirectionBack); + if (keys[Input.GetScancode(UserInput::KeyCodeLeft)]) + { + page->SetScrolling(Page::ScrollDirectionBack); + } + if (keys[Input.GetScancode(UserInput::KeyCodeRight)]) + { + page->SetScrolling(Page::ScrollDirectionForward); + } } - if (keys[Input.GetScancode(UserInput::KeyCodeNextItem)]) - { - page->SetScrolling(Page::ScrollDirectionForward); + else + { + if (keys[Input.GetScancode(UserInput::KeyCodeUp)]) + { + page->SetScrolling(Page::ScrollDirectionBack); + } + if (keys[Input.GetScancode(UserInput::KeyCodeDown)]) + { + page->SetScrolling(Page::ScrollDirectionForward); + } } if (keys[Input.GetScancode(UserInput::KeyCodePageUp)]) { @@ -432,8 +446,10 @@ RetroFE::RETROFE_STATE RetroFE::ProcessUserInput(Page *page) state = RETROFE_QUIT_REQUEST; } - if(!keys[Input.GetScancode(UserInput::KeyCodePreviousItem)] && - !keys[Input.GetScancode(UserInput::KeyCodeNextItem)] && + if(!keys[Input.GetScancode(UserInput::KeyCodeUp)] && + !keys[Input.GetScancode(UserInput::KeyCodeLeft)] && + !keys[Input.GetScancode(UserInput::KeyCodeDown)] && + !keys[Input.GetScancode(UserInput::KeyCodeRight)] && !keys[Input.GetScancode(UserInput::KeyCodePageUp)] && !keys[Input.GetScancode(UserInput::KeyCodePageDown)]) {