diff --git a/es-app/src/components/TextListComponent.h b/es-app/src/components/TextListComponent.h index 42ab9501b..2873b1847 100644 --- a/es-app/src/components/TextListComponent.h +++ b/es-app/src/components/TextListComponent.h @@ -251,13 +251,13 @@ bool TextListComponent::input(InputConfig* config, Input input) { if(input.value != 0) { - if(config->isMappedTo("down", input)) + if(config->isMappedLike("down", input)) { listInput(1); return true; } - if(config->isMappedTo("up", input)) + if(config->isMappedLike("up", input)) { listInput(-1); return true; @@ -274,7 +274,7 @@ bool TextListComponent::input(InputConfig* config, Input input) return true; } }else{ - if(config->isMappedTo("down", input) || config->isMappedTo("up", input) || + if(config->isMappedLike("down", input) || config->isMappedLike("up", input) || config->isMappedTo("pagedown", input) || config->isMappedTo("pageup", input)) { stopScrolling(); diff --git a/es-app/src/guis/GuiFastSelect.cpp b/es-app/src/guis/GuiFastSelect.cpp index 122762151..3bf0af8cd 100644 --- a/es-app/src/guis/GuiFastSelect.cpp +++ b/es-app/src/guis/GuiFastSelect.cpp @@ -55,7 +55,7 @@ bool GuiFastSelect::input(InputConfig* config, Input input) return true; } - if(config->isMappedTo("up", input)) + if(config->isMappedLike("up", input)) { if(input.value != 0) setScrollDir(-1); @@ -63,7 +63,7 @@ bool GuiFastSelect::input(InputConfig* config, Input input) setScrollDir(0); return true; - }else if(config->isMappedTo("down", input)) + }else if(config->isMappedLike("down", input)) { if(input.value != 0) setScrollDir(1); @@ -71,12 +71,12 @@ bool GuiFastSelect::input(InputConfig* config, Input input) setScrollDir(0); return true; - }else if(config->isMappedTo("left", input) && input.value != 0) + }else if(config->isMappedLike("left", input) && input.value != 0) { mSortId = (mSortId + 1) % FileSorts::SortTypes.size(); updateSortText(); return true; - }else if(config->isMappedTo("right", input) && input.value != 0) + }else if(config->isMappedLike("right", input) && input.value != 0) { mSortId--; if(mSortId < 0) diff --git a/es-app/src/views/SystemView.cpp b/es-app/src/views/SystemView.cpp index 871ba8724..cdd5b1ea1 100644 --- a/es-app/src/views/SystemView.cpp +++ b/es-app/src/views/SystemView.cpp @@ -150,12 +150,12 @@ bool SystemView::input(InputConfig* config, Input input) { case VERTICAL: case VERTICAL_WHEEL: - if (config->isMappedTo("up", input)) + if (config->isMappedLike("up", input)) { listInput(-1); return true; } - if (config->isMappedTo("down", input)) + if (config->isMappedLike("down", input)) { listInput(1); return true; @@ -164,12 +164,12 @@ bool SystemView::input(InputConfig* config, Input input) case HORIZONTAL: case HORIZONTAL_WHEEL: default: - if (config->isMappedTo("left", input)) + if (config->isMappedLike("left", input)) { listInput(-1); return true; } - if (config->isMappedTo("right", input)) + if (config->isMappedLike("right", input)) { listInput(1); return true; @@ -191,10 +191,10 @@ bool SystemView::input(InputConfig* config, Input input) return true; } }else{ - if(config->isMappedTo("left", input) || - config->isMappedTo("right", input) || - config->isMappedTo("up", input) || - config->isMappedTo("down", input)) + if(config->isMappedLike("left", input) || + config->isMappedLike("right", input) || + config->isMappedLike("up", input) || + config->isMappedLike("down", input)) listInput(0); if(!UIModeController::getInstance()->isUIModeKid() && config->isMappedTo("select", input) && Settings::getInstance()->getBool("ScreenSaverControls")) { diff --git a/es-app/src/views/UIModeController.cpp b/es-app/src/views/UIModeController.cpp index 812395845..1012f52eb 100644 --- a/es-app/src/views/UIModeController.cpp +++ b/es-app/src/views/UIModeController.cpp @@ -64,7 +64,7 @@ bool UIModeController::inputIsMatch(InputConfig * config, Input input) { for (auto valstring : mInputVals) { - if (config->isMappedTo(valstring, input) && + if (config->isMappedLike(valstring, input) && (mPassKeySequence[mPassKeyCounter] == valstring[0])) { mPassKeyCounter++; diff --git a/es-app/src/views/gamelist/GridGameListView.cpp b/es-app/src/views/gamelist/GridGameListView.cpp index 084c3fc49..efaaab6d8 100644 --- a/es-app/src/views/gamelist/GridGameListView.cpp +++ b/es-app/src/views/gamelist/GridGameListView.cpp @@ -104,7 +104,7 @@ std::string GridGameListView::getQuickSystemSelectLeftButton() bool GridGameListView::input(InputConfig* config, Input input) { - if(config->isMappedTo("left", input) || config->isMappedTo("right", input)) + if(config->isMappedLike("left", input) || config->isMappedLike("right", input)) return GuiComponent::input(config, input); return ISimpleGameListView::input(config, input); diff --git a/es-app/src/views/gamelist/ISimpleGameListView.cpp b/es-app/src/views/gamelist/ISimpleGameListView.cpp index 2caf26b1e..5a1a68ed3 100644 --- a/es-app/src/views/gamelist/ISimpleGameListView.cpp +++ b/es-app/src/views/gamelist/ISimpleGameListView.cpp @@ -118,7 +118,7 @@ bool ISimpleGameListView::input(InputConfig* config, Input input) } return true; - }else if(config->isMappedTo(getQuickSystemSelectRightButton(), input)) + }else if(config->isMappedLike(getQuickSystemSelectRightButton(), input)) { if(Settings::getInstance()->getBool("QuickSystemSelect")) { @@ -126,7 +126,7 @@ bool ISimpleGameListView::input(InputConfig* config, Input input) ViewController::get()->goToNextGameList(); return true; } - }else if(config->isMappedTo(getQuickSystemSelectLeftButton(), input)) + }else if(config->isMappedLike(getQuickSystemSelectLeftButton(), input)) { if(Settings::getInstance()->getBool("QuickSystemSelect")) { diff --git a/es-core/src/InputConfig.cpp b/es-core/src/InputConfig.cpp index c5c299fff..dd56dd30e 100644 --- a/es-core/src/InputConfig.cpp +++ b/es-core/src/InputConfig.cpp @@ -111,6 +111,21 @@ bool InputConfig::isMappedTo(const std::string& name, Input input) return false; } +bool InputConfig::isMappedLike(const std::string& name, Input input) +{ + if(name == "left") + { + return isMappedTo("left", input) || isMappedTo("leftanalogleft", input) || isMappedTo("rightanalogleft", input); + }else if(name == "right"){ + return isMappedTo("right", input) || isMappedTo("leftanalogright", input) || isMappedTo("rightanalogright", input); + }else if(name == "up"){ + return isMappedTo("up", input) || isMappedTo("leftanalogup", input) || isMappedTo("rightanalogup", input); + }else if(name == "down"){ + return isMappedTo("down", input) || isMappedTo("leftanalogdown", input) || isMappedTo("rightanalogdown", input); + } + return isMappedTo(name, input); +} + std::vector InputConfig::getMappedTo(Input input) { std::vector maps; diff --git a/es-core/src/InputConfig.h b/es-core/src/InputConfig.h index f3f1cbf05..4969d8ff0 100644 --- a/es-core/src/InputConfig.h +++ b/es-core/src/InputConfig.h @@ -108,6 +108,7 @@ public: //Returns true if Input is mapped to this name, false otherwise. bool isMappedTo(const std::string& name, Input input); + bool isMappedLike(const std::string& name, Input input); //Returns a list of names this input is mapped to. std::vector getMappedTo(Input input); diff --git a/es-core/src/Window.cpp b/es-core/src/Window.cpp index 76e935db1..3c0aa1d06 100644 --- a/es-core/src/Window.cpp +++ b/es-core/src/Window.cpp @@ -120,9 +120,9 @@ void Window::input(InputConfig* config, Input input) if(mScreenSaver->isScreenSaverActive() && Settings::getInstance()->getBool("ScreenSaverControls") && (Settings::getInstance()->getString("ScreenSaverBehavior") == "random video")) { - if(mScreenSaver->getCurrentGame() != NULL && (config->isMappedTo("right", input) || config->isMappedTo("start", input) || config->isMappedTo("select", input))) + if(mScreenSaver->getCurrentGame() != NULL && (config->isMappedLike("right", input) || config->isMappedTo("start", input) || config->isMappedTo("select", input))) { - if(config->isMappedTo("right", input) || config->isMappedTo("select", input)) + if(config->isMappedLike("right", input) || config->isMappedTo("select", input)) { if (input.value != 0) { // handle screensaver control diff --git a/es-core/src/components/ComponentGrid.cpp b/es-core/src/components/ComponentGrid.cpp index f4e7619f4..066f9a3f0 100644 --- a/es-core/src/components/ComponentGrid.cpp +++ b/es-core/src/components/ComponentGrid.cpp @@ -233,19 +233,19 @@ bool ComponentGrid::input(InputConfig* config, Input input) if(!input.value) return false; - if(config->isMappedTo("down", input)) + if(config->isMappedLike("down", input)) { return moveCursor(Vector2i(0, 1)); } - if(config->isMappedTo("up", input)) + if(config->isMappedLike("up", input)) { return moveCursor(Vector2i(0, -1)); } - if(config->isMappedTo("left", input)) + if(config->isMappedLike("left", input)) { return moveCursor(Vector2i(-1, 0)); } - if(config->isMappedTo("right", input)) + if(config->isMappedLike("right", input)) { return moveCursor(Vector2i(1, 0)); } diff --git a/es-core/src/components/ComponentList.cpp b/es-core/src/components/ComponentList.cpp index 28cdf0cf7..c2c42d8f3 100644 --- a/es-core/src/components/ComponentList.cpp +++ b/es-core/src/components/ComponentList.cpp @@ -75,10 +75,10 @@ bool ComponentList::input(InputConfig* config, Input input) } // input handler didn't consume the input - try to scroll - if(config->isMappedTo("up", input)) + if(config->isMappedLike("up", input)) { return listInput(input.value != 0 ? -1 : 0); - }else if(config->isMappedTo("down", input)) + }else if(config->isMappedLike("down", input)) { return listInput(input.value != 0 ? 1 : 0); diff --git a/es-core/src/components/DateTimeEditComponent.cpp b/es-core/src/components/DateTimeEditComponent.cpp index 1617934c0..d4b6636a3 100644 --- a/es-core/src/components/DateTimeEditComponent.cpp +++ b/es-core/src/components/DateTimeEditComponent.cpp @@ -54,9 +54,9 @@ bool DateTimeEditComponent::input(InputConfig* config, Input input) } int incDir = 0; - if(config->isMappedTo("up", input) || config->isMappedTo("pageup", input)) + if(config->isMappedLike("up", input) || config->isMappedTo("pageup", input)) incDir = 1; - else if(config->isMappedTo("down", input) || config->isMappedTo("pagedown", input)) + else if(config->isMappedLike("down", input) || config->isMappedTo("pagedown", input)) incDir = -1; if(incDir != 0) @@ -103,7 +103,7 @@ bool DateTimeEditComponent::input(InputConfig* config, Input input) return true; } - if(config->isMappedTo("right", input)) + if(config->isMappedLike("right", input)) { mEditIndex++; if(mEditIndex >= (int)mCursorBoxes.size()) @@ -111,7 +111,7 @@ bool DateTimeEditComponent::input(InputConfig* config, Input input) return true; } - if(config->isMappedTo("left", input)) + if(config->isMappedLike("left", input)) { mEditIndex--; if(mEditIndex < 0) diff --git a/es-core/src/components/ImageGridComponent.h b/es-core/src/components/ImageGridComponent.h index 0b30caec5..21a2558a7 100644 --- a/es-core/src/components/ImageGridComponent.h +++ b/es-core/src/components/ImageGridComponent.h @@ -117,13 +117,13 @@ bool ImageGridComponent::input(InputConfig* config, Input input) if(input.value != 0) { Vector2i dir = Vector2i::Zero(); - if(config->isMappedTo("up", input)) + if(config->isMappedLike("up", input)) dir[1 ^ mScrollDirection] = -1; - else if(config->isMappedTo("down", input)) + else if(config->isMappedLike("down", input)) dir[1 ^ mScrollDirection] = 1; - else if(config->isMappedTo("left", input)) + else if(config->isMappedLike("left", input)) dir[0 ^ mScrollDirection] = -1; - else if(config->isMappedTo("right", input)) + else if(config->isMappedLike("right", input)) dir[0 ^ mScrollDirection] = 1; if(dir != Vector2i::Zero()) @@ -132,7 +132,7 @@ bool ImageGridComponent::input(InputConfig* config, Input input) return true; } }else{ - if(config->isMappedTo("up", input) || config->isMappedTo("down", input) || config->isMappedTo("left", input) || config->isMappedTo("right", input)) + if(config->isMappedLike("up", input) || config->isMappedLike("down", input) || config->isMappedLike("left", input) || config->isMappedLike("right", input)) { stopScrolling(); } diff --git a/es-core/src/components/OptionListComponent.h b/es-core/src/components/OptionListComponent.h index dd630f5bf..bf922acdc 100644 --- a/es-core/src/components/OptionListComponent.h +++ b/es-core/src/components/OptionListComponent.h @@ -190,7 +190,7 @@ public: } if(!mMultiSelect) { - if(config->isMappedTo("left", input)) + if(config->isMappedLike("left", input)) { // move selection to previous unsigned int i = getSelectedId(); @@ -203,7 +203,7 @@ public: onSelectedChanged(); return true; - }else if(config->isMappedTo("right", input)) + }else if(config->isMappedLike("right", input)) { // move selection to next unsigned int i = getSelectedId(); diff --git a/es-core/src/components/SliderComponent.cpp b/es-core/src/components/SliderComponent.cpp index b2e9f61eb..619c79835 100644 --- a/es-core/src/components/SliderComponent.cpp +++ b/es-core/src/components/SliderComponent.cpp @@ -22,7 +22,7 @@ SliderComponent::SliderComponent(Window* window, float min, float max, float inc bool SliderComponent::input(InputConfig* config, Input input) { - if(config->isMappedTo("left", input)) + if(config->isMappedLike("left", input)) { if(input.value) setValue(mValue - mSingleIncrement); @@ -31,7 +31,7 @@ bool SliderComponent::input(InputConfig* config, Input input) mMoveAccumulator = -MOVE_REPEAT_DELAY; return true; } - if(config->isMappedTo("right", input)) + if(config->isMappedLike("right", input)) { if(input.value) setValue(mValue + mSingleIncrement); diff --git a/es-core/src/components/TextEditComponent.cpp b/es-core/src/components/TextEditComponent.cpp index d5e075803..c90ff504b 100644 --- a/es-core/src/components/TextEditComponent.cpp +++ b/es-core/src/components/TextEditComponent.cpp @@ -90,9 +90,9 @@ void TextEditComponent::stopEditing() bool TextEditComponent::input(InputConfig* config, Input input) { - bool const cursor_left = (config->getDeviceId() != DEVICE_KEYBOARD && config->isMappedTo("left", input)) || + bool const cursor_left = (config->getDeviceId() != DEVICE_KEYBOARD && config->isMappedLike("left", input)) || (config->getDeviceId() == DEVICE_KEYBOARD && input.id == SDLK_LEFT); - bool const cursor_right = (config->getDeviceId() != DEVICE_KEYBOARD && config->isMappedTo("right", input)) || + bool const cursor_right = (config->getDeviceId() != DEVICE_KEYBOARD && config->isMappedLike("right", input)) || (config->getDeviceId() == DEVICE_KEYBOARD && input.id == SDLK_RIGHT); if(input.value == 0) @@ -129,10 +129,10 @@ bool TextEditComponent::input(InputConfig* config, Input input) return true; } - if(config->getDeviceId() != DEVICE_KEYBOARD && config->isMappedTo("up", input)) + if(config->getDeviceId() != DEVICE_KEYBOARD && config->isMappedLike("up", input)) { // TODO - }else if(config->getDeviceId() != DEVICE_KEYBOARD && config->isMappedTo("down", input)) + }else if(config->getDeviceId() != DEVICE_KEYBOARD && config->isMappedLike("down", input)) { // TODO }else if(cursor_left || cursor_right)