mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-06-06 19:06:48 +02:00
Merge with 2 axis navigation
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
previousItem = Up
|
up = Up
|
||||||
nextItem = Down
|
down = Down
|
||||||
pageUp = Left
|
left = Left
|
||||||
pageDown = Right
|
right = Right
|
||||||
|
pageUp = A
|
||||||
|
pageDown = B
|
||||||
select = Space
|
select = Space
|
||||||
back = Escape
|
back = Escape
|
||||||
quit = Q
|
quit = Q
|
||||||
|
|||||||
@@ -31,8 +31,23 @@ bool UserInput::Initialize()
|
|||||||
{
|
{
|
||||||
bool retVal = true;
|
bool retVal = true;
|
||||||
|
|
||||||
retVal = MapKey("nextItem", KeyCodeNextItem) && retVal;
|
if(!MapKey("up", KeyCodeUp))
|
||||||
retVal = MapKey("previousItem", KeyCodePreviousItem) && retVal;
|
{
|
||||||
|
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("pageDown", KeyCodePageDown) && retVal;
|
||||||
retVal = MapKey("pageUp", KeyCodePageUp) && retVal;
|
retVal = MapKey("pageUp", KeyCodePageUp) && retVal;
|
||||||
retVal = MapKey("select", KeyCodeSelect) && 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 UserInput::MapKey(std::string keyDescription, KeyCode_E key)
|
||||||
{
|
{
|
||||||
bool retVal = false;
|
|
||||||
SDL_Scancode scanCode;
|
SDL_Scancode scanCode;
|
||||||
std::string description;
|
std::string description;
|
||||||
|
|
||||||
@@ -70,22 +84,18 @@ bool UserInput::MapKey(std::string keyDescription, KeyCode_E key)
|
|||||||
if(!Config.GetProperty(configKey, description))
|
if(!Config.GetProperty(configKey, description))
|
||||||
{
|
{
|
||||||
Logger::Write(Logger::ZONE_ERROR, "Configuration", "Missing property " + configKey);
|
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());
|
Logger::Write(Logger::ZONE_ERROR, "Configuration", "Unsupported property value for " + configKey + "(" + description + "). See Documentation/Keycodes.txt for valid inputs");
|
||||||
|
return false;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return retVal;
|
KeyMap[key] = scanCode;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,10 @@ class UserInput
|
|||||||
public:
|
public:
|
||||||
enum KeyCode_E
|
enum KeyCode_E
|
||||||
{
|
{
|
||||||
KeyCodeNextItem,
|
KeyCodeUp,
|
||||||
KeyCodePreviousItem,
|
KeyCodeDown,
|
||||||
|
KeyCodeLeft,
|
||||||
|
KeyCodeRight,
|
||||||
KeyCodeSelect,
|
KeyCodeSelect,
|
||||||
KeyCodeBack,
|
KeyCodeBack,
|
||||||
KeyCodePageDown,
|
KeyCodePageDown,
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ ScrollingList::ScrollingList(Configuration &c,
|
|||||||
, FontInst(font)
|
, FontInst(font)
|
||||||
, LayoutKey(layoutKey)
|
, LayoutKey(layoutKey)
|
||||||
, ImageType(imageType)
|
, ImageType(imageType)
|
||||||
|
, HorizontalScroll(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,6 +156,16 @@ void ScrollingList::SetItems(std::vector<ComponentItemBinding *> *spriteList)
|
|||||||
AllocateSpritePoints();
|
AllocateSpritePoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ScrollingList::IsHorizontalScroll()
|
||||||
|
{
|
||||||
|
return HorizontalScroll;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScrollingList::SetScrollOrientation(bool horizontal)
|
||||||
|
{
|
||||||
|
HorizontalScroll = horizontal;
|
||||||
|
}
|
||||||
|
|
||||||
void ScrollingList::SetScrollAcceleration(float value)
|
void ScrollingList::SetScrollAcceleration(float value)
|
||||||
{
|
{
|
||||||
ScrollAcceleration = value;
|
ScrollAcceleration = value;
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ public:
|
|||||||
void DestroyItems();
|
void DestroyItems();
|
||||||
void SetPoints(std::vector<ViewInfo *> *scrollPoints, std::vector<AnimationEvents *> *tweenPoints);
|
void SetPoints(std::vector<ViewInfo *> *scrollPoints, std::vector<AnimationEvents *> *tweenPoints);
|
||||||
void SetScrollDirection(ScrollDirection direction);
|
void SetScrollDirection(ScrollDirection direction);
|
||||||
|
void SetScrollOrientation(bool horizontal);
|
||||||
|
bool IsHorizontalScroll();
|
||||||
void PageUp();
|
void PageUp();
|
||||||
void PageDown();
|
void PageDown();
|
||||||
bool IsIdle();
|
bool IsIdle();
|
||||||
@@ -127,5 +129,6 @@ private:
|
|||||||
Font *FontInst;
|
Font *FontInst;
|
||||||
std::string LayoutKey;
|
std::string LayoutKey;
|
||||||
std::string ImageType;
|
std::string ImageType;
|
||||||
|
bool HorizontalScroll;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -335,6 +335,13 @@ void Page::SetScrolling(ScrollDirection direction)
|
|||||||
ActiveMenu->SetScrollDirection(menuDirection);
|
ActiveMenu->SetScrollDirection(menuDirection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Page::IsHorizontalScroll()
|
||||||
|
{
|
||||||
|
if(!ActiveMenu) { return false; }
|
||||||
|
|
||||||
|
return ActiveMenu->IsHorizontalScroll();
|
||||||
|
}
|
||||||
|
|
||||||
void Page::PageScroll(ScrollDirection direction)
|
void Page::PageScroll(ScrollDirection direction)
|
||||||
{
|
{
|
||||||
if(ActiveMenu)
|
if(ActiveMenu)
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ public:
|
|||||||
void StartComponents();
|
void StartComponents();
|
||||||
void Stop();
|
void Stop();
|
||||||
void SetScrolling(ScrollDirection direction);
|
void SetScrolling(ScrollDirection direction);
|
||||||
|
bool IsHorizontalScroll();
|
||||||
unsigned int GetMenuDepth();
|
unsigned int GetMenuDepth();
|
||||||
Item *GetSelectedItem();
|
Item *GetSelectedItem();
|
||||||
Item *GetPendingSelectedItem();
|
Item *GetPendingSelectedItem();
|
||||||
|
|||||||
@@ -580,6 +580,7 @@ ScrollingList * PageBuilder::BuildMenu(xml_node<> *menuXml)
|
|||||||
xml_attribute<> *menuTypeXml = menuXml->first_attribute("type");
|
xml_attribute<> *menuTypeXml = menuXml->first_attribute("type");
|
||||||
xml_attribute<> *scrollTimeXml = menuXml->first_attribute("scrollTime");
|
xml_attribute<> *scrollTimeXml = menuXml->first_attribute("scrollTime");
|
||||||
xml_attribute<> *scrollAccelerationXml = menuXml->first_attribute("scrollAcceleration");
|
xml_attribute<> *scrollAccelerationXml = menuXml->first_attribute("scrollAcceleration");
|
||||||
|
xml_attribute<> *scrollOrientationXml = menuXml->first_attribute("orientation");
|
||||||
|
|
||||||
if(menuTypeXml)
|
if(menuTypeXml)
|
||||||
{
|
{
|
||||||
@@ -612,6 +613,15 @@ ScrollingList * PageBuilder::BuildMenu(xml_node<> *menuXml)
|
|||||||
menu->SetScrollAcceleration(Utils::ConvertFloat(scrollAccelerationXml->value()));
|
menu->SetScrollAcceleration(Utils::ConvertFloat(scrollAccelerationXml->value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(scrollOrientationXml)
|
||||||
|
{
|
||||||
|
std::string scrollOrientation = scrollOrientationXml->value();
|
||||||
|
if(scrollOrientation == "horizontal")
|
||||||
|
{
|
||||||
|
menu->SetScrollOrientation(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ViewInfo *v = menu->GetBaseViewInfo();
|
ViewInfo *v = menu->GetBaseViewInfo();
|
||||||
BuildViewInfo(menuXml, v);
|
BuildViewInfo(menuXml, v);
|
||||||
|
|
||||||
|
|||||||
@@ -378,13 +378,27 @@ RetroFE::RETROFE_STATE RetroFE::ProcessUserInput(Page *page)
|
|||||||
|
|
||||||
Attract.Reset();
|
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)])
|
else
|
||||||
{
|
{
|
||||||
page->SetScrolling(Page::ScrollDirectionForward);
|
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)])
|
if (keys[Input.GetScancode(UserInput::KeyCodePageUp)])
|
||||||
{
|
{
|
||||||
@@ -432,8 +446,10 @@ RetroFE::RETROFE_STATE RetroFE::ProcessUserInput(Page *page)
|
|||||||
state = RETROFE_QUIT_REQUEST;
|
state = RETROFE_QUIT_REQUEST;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!keys[Input.GetScancode(UserInput::KeyCodePreviousItem)] &&
|
if(!keys[Input.GetScancode(UserInput::KeyCodeUp)] &&
|
||||||
!keys[Input.GetScancode(UserInput::KeyCodeNextItem)] &&
|
!keys[Input.GetScancode(UserInput::KeyCodeLeft)] &&
|
||||||
|
!keys[Input.GetScancode(UserInput::KeyCodeDown)] &&
|
||||||
|
!keys[Input.GetScancode(UserInput::KeyCodeRight)] &&
|
||||||
!keys[Input.GetScancode(UserInput::KeyCodePageUp)] &&
|
!keys[Input.GetScancode(UserInput::KeyCodePageUp)] &&
|
||||||
!keys[Input.GetScancode(UserInput::KeyCodePageDown)])
|
!keys[Input.GetScancode(UserInput::KeyCodePageDown)])
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user