mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-26 16:15:39 +00:00
Merge pull request #499 from raelgc/all-directionals
Work with dpad and analogs
This commit is contained in:
commit
6576dd7ba4
|
@ -251,13 +251,13 @@ bool TextListComponent<T>::input(InputConfig* config, Input input)
|
||||||
{
|
{
|
||||||
if(input.value != 0)
|
if(input.value != 0)
|
||||||
{
|
{
|
||||||
if(config->isMappedTo("down", input))
|
if(config->isMappedLike("down", input))
|
||||||
{
|
{
|
||||||
listInput(1);
|
listInput(1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(config->isMappedTo("up", input))
|
if(config->isMappedLike("up", input))
|
||||||
{
|
{
|
||||||
listInput(-1);
|
listInput(-1);
|
||||||
return true;
|
return true;
|
||||||
|
@ -274,7 +274,7 @@ bool TextListComponent<T>::input(InputConfig* config, Input input)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}else{
|
}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))
|
config->isMappedTo("pagedown", input) || config->isMappedTo("pageup", input))
|
||||||
{
|
{
|
||||||
stopScrolling();
|
stopScrolling();
|
||||||
|
|
|
@ -55,7 +55,7 @@ bool GuiFastSelect::input(InputConfig* config, Input input)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(config->isMappedTo("up", input))
|
if(config->isMappedLike("up", input))
|
||||||
{
|
{
|
||||||
if(input.value != 0)
|
if(input.value != 0)
|
||||||
setScrollDir(-1);
|
setScrollDir(-1);
|
||||||
|
@ -63,7 +63,7 @@ bool GuiFastSelect::input(InputConfig* config, Input input)
|
||||||
setScrollDir(0);
|
setScrollDir(0);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}else if(config->isMappedTo("down", input))
|
}else if(config->isMappedLike("down", input))
|
||||||
{
|
{
|
||||||
if(input.value != 0)
|
if(input.value != 0)
|
||||||
setScrollDir(1);
|
setScrollDir(1);
|
||||||
|
@ -71,12 +71,12 @@ bool GuiFastSelect::input(InputConfig* config, Input input)
|
||||||
setScrollDir(0);
|
setScrollDir(0);
|
||||||
|
|
||||||
return true;
|
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();
|
mSortId = (mSortId + 1) % FileSorts::SortTypes.size();
|
||||||
updateSortText();
|
updateSortText();
|
||||||
return true;
|
return true;
|
||||||
}else if(config->isMappedTo("right", input) && input.value != 0)
|
}else if(config->isMappedLike("right", input) && input.value != 0)
|
||||||
{
|
{
|
||||||
mSortId--;
|
mSortId--;
|
||||||
if(mSortId < 0)
|
if(mSortId < 0)
|
||||||
|
|
|
@ -150,12 +150,12 @@ bool SystemView::input(InputConfig* config, Input input)
|
||||||
{
|
{
|
||||||
case VERTICAL:
|
case VERTICAL:
|
||||||
case VERTICAL_WHEEL:
|
case VERTICAL_WHEEL:
|
||||||
if (config->isMappedTo("up", input))
|
if (config->isMappedLike("up", input))
|
||||||
{
|
{
|
||||||
listInput(-1);
|
listInput(-1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (config->isMappedTo("down", input))
|
if (config->isMappedLike("down", input))
|
||||||
{
|
{
|
||||||
listInput(1);
|
listInput(1);
|
||||||
return true;
|
return true;
|
||||||
|
@ -164,12 +164,12 @@ bool SystemView::input(InputConfig* config, Input input)
|
||||||
case HORIZONTAL:
|
case HORIZONTAL:
|
||||||
case HORIZONTAL_WHEEL:
|
case HORIZONTAL_WHEEL:
|
||||||
default:
|
default:
|
||||||
if (config->isMappedTo("left", input))
|
if (config->isMappedLike("left", input))
|
||||||
{
|
{
|
||||||
listInput(-1);
|
listInput(-1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (config->isMappedTo("right", input))
|
if (config->isMappedLike("right", input))
|
||||||
{
|
{
|
||||||
listInput(1);
|
listInput(1);
|
||||||
return true;
|
return true;
|
||||||
|
@ -191,10 +191,10 @@ bool SystemView::input(InputConfig* config, Input input)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if(config->isMappedTo("left", input) ||
|
if(config->isMappedLike("left", input) ||
|
||||||
config->isMappedTo("right", input) ||
|
config->isMappedLike("right", input) ||
|
||||||
config->isMappedTo("up", input) ||
|
config->isMappedLike("up", input) ||
|
||||||
config->isMappedTo("down", input))
|
config->isMappedLike("down", input))
|
||||||
listInput(0);
|
listInput(0);
|
||||||
if(!UIModeController::getInstance()->isUIModeKid() && config->isMappedTo("select", input) && Settings::getInstance()->getBool("ScreenSaverControls"))
|
if(!UIModeController::getInstance()->isUIModeKid() && config->isMappedTo("select", input) && Settings::getInstance()->getBool("ScreenSaverControls"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -64,7 +64,7 @@ bool UIModeController::inputIsMatch(InputConfig * config, Input input)
|
||||||
{
|
{
|
||||||
for (auto valstring : mInputVals)
|
for (auto valstring : mInputVals)
|
||||||
{
|
{
|
||||||
if (config->isMappedTo(valstring, input) &&
|
if (config->isMappedLike(valstring, input) &&
|
||||||
(mPassKeySequence[mPassKeyCounter] == valstring[0]))
|
(mPassKeySequence[mPassKeyCounter] == valstring[0]))
|
||||||
{
|
{
|
||||||
mPassKeyCounter++;
|
mPassKeyCounter++;
|
||||||
|
|
|
@ -104,7 +104,7 @@ std::string GridGameListView::getQuickSystemSelectLeftButton()
|
||||||
|
|
||||||
bool GridGameListView::input(InputConfig* config, Input input)
|
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 GuiComponent::input(config, input);
|
||||||
|
|
||||||
return ISimpleGameListView::input(config, input);
|
return ISimpleGameListView::input(config, input);
|
||||||
|
|
|
@ -118,7 +118,7 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}else if(config->isMappedTo(getQuickSystemSelectRightButton(), input))
|
}else if(config->isMappedLike(getQuickSystemSelectRightButton(), input))
|
||||||
{
|
{
|
||||||
if(Settings::getInstance()->getBool("QuickSystemSelect"))
|
if(Settings::getInstance()->getBool("QuickSystemSelect"))
|
||||||
{
|
{
|
||||||
|
@ -126,7 +126,7 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
|
||||||
ViewController::get()->goToNextGameList();
|
ViewController::get()->goToNextGameList();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}else if(config->isMappedTo(getQuickSystemSelectLeftButton(), input))
|
}else if(config->isMappedLike(getQuickSystemSelectLeftButton(), input))
|
||||||
{
|
{
|
||||||
if(Settings::getInstance()->getBool("QuickSystemSelect"))
|
if(Settings::getInstance()->getBool("QuickSystemSelect"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -111,6 +111,21 @@ bool InputConfig::isMappedTo(const std::string& name, Input input)
|
||||||
return false;
|
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<std::string> InputConfig::getMappedTo(Input input)
|
std::vector<std::string> InputConfig::getMappedTo(Input input)
|
||||||
{
|
{
|
||||||
std::vector<std::string> maps;
|
std::vector<std::string> maps;
|
||||||
|
|
|
@ -108,6 +108,7 @@ public:
|
||||||
|
|
||||||
//Returns true if Input is mapped to this name, false otherwise.
|
//Returns true if Input is mapped to this name, false otherwise.
|
||||||
bool isMappedTo(const std::string& name, Input input);
|
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.
|
//Returns a list of names this input is mapped to.
|
||||||
std::vector<std::string> getMappedTo(Input input);
|
std::vector<std::string> getMappedTo(Input input);
|
||||||
|
|
|
@ -120,9 +120,9 @@ void Window::input(InputConfig* config, Input input)
|
||||||
if(mScreenSaver->isScreenSaverActive() && Settings::getInstance()->getBool("ScreenSaverControls") &&
|
if(mScreenSaver->isScreenSaverActive() && Settings::getInstance()->getBool("ScreenSaverControls") &&
|
||||||
(Settings::getInstance()->getString("ScreenSaverBehavior") == "random video"))
|
(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) {
|
if (input.value != 0) {
|
||||||
// handle screensaver control
|
// handle screensaver control
|
||||||
|
|
|
@ -233,19 +233,19 @@ bool ComponentGrid::input(InputConfig* config, Input input)
|
||||||
if(!input.value)
|
if(!input.value)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(config->isMappedTo("down", input))
|
if(config->isMappedLike("down", input))
|
||||||
{
|
{
|
||||||
return moveCursor(Vector2i(0, 1));
|
return moveCursor(Vector2i(0, 1));
|
||||||
}
|
}
|
||||||
if(config->isMappedTo("up", input))
|
if(config->isMappedLike("up", input))
|
||||||
{
|
{
|
||||||
return moveCursor(Vector2i(0, -1));
|
return moveCursor(Vector2i(0, -1));
|
||||||
}
|
}
|
||||||
if(config->isMappedTo("left", input))
|
if(config->isMappedLike("left", input))
|
||||||
{
|
{
|
||||||
return moveCursor(Vector2i(-1, 0));
|
return moveCursor(Vector2i(-1, 0));
|
||||||
}
|
}
|
||||||
if(config->isMappedTo("right", input))
|
if(config->isMappedLike("right", input))
|
||||||
{
|
{
|
||||||
return moveCursor(Vector2i(1, 0));
|
return moveCursor(Vector2i(1, 0));
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,10 +75,10 @@ bool ComponentList::input(InputConfig* config, Input input)
|
||||||
}
|
}
|
||||||
|
|
||||||
// input handler didn't consume the input - try to scroll
|
// 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);
|
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);
|
return listInput(input.value != 0 ? 1 : 0);
|
||||||
|
|
||||||
|
|
|
@ -54,9 +54,9 @@ bool DateTimeEditComponent::input(InputConfig* config, Input input)
|
||||||
}
|
}
|
||||||
|
|
||||||
int incDir = 0;
|
int incDir = 0;
|
||||||
if(config->isMappedTo("up", input) || config->isMappedTo("pageup", input))
|
if(config->isMappedLike("up", input) || config->isMappedTo("pageup", input))
|
||||||
incDir = 1;
|
incDir = 1;
|
||||||
else if(config->isMappedTo("down", input) || config->isMappedTo("pagedown", input))
|
else if(config->isMappedLike("down", input) || config->isMappedTo("pagedown", input))
|
||||||
incDir = -1;
|
incDir = -1;
|
||||||
|
|
||||||
if(incDir != 0)
|
if(incDir != 0)
|
||||||
|
@ -103,7 +103,7 @@ bool DateTimeEditComponent::input(InputConfig* config, Input input)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(config->isMappedTo("right", input))
|
if(config->isMappedLike("right", input))
|
||||||
{
|
{
|
||||||
mEditIndex++;
|
mEditIndex++;
|
||||||
if(mEditIndex >= (int)mCursorBoxes.size())
|
if(mEditIndex >= (int)mCursorBoxes.size())
|
||||||
|
@ -111,7 +111,7 @@ bool DateTimeEditComponent::input(InputConfig* config, Input input)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(config->isMappedTo("left", input))
|
if(config->isMappedLike("left", input))
|
||||||
{
|
{
|
||||||
mEditIndex--;
|
mEditIndex--;
|
||||||
if(mEditIndex < 0)
|
if(mEditIndex < 0)
|
||||||
|
|
|
@ -117,13 +117,13 @@ bool ImageGridComponent<T>::input(InputConfig* config, Input input)
|
||||||
if(input.value != 0)
|
if(input.value != 0)
|
||||||
{
|
{
|
||||||
Vector2i dir = Vector2i::Zero();
|
Vector2i dir = Vector2i::Zero();
|
||||||
if(config->isMappedTo("up", input))
|
if(config->isMappedLike("up", input))
|
||||||
dir[1 ^ mScrollDirection] = -1;
|
dir[1 ^ mScrollDirection] = -1;
|
||||||
else if(config->isMappedTo("down", input))
|
else if(config->isMappedLike("down", input))
|
||||||
dir[1 ^ mScrollDirection] = 1;
|
dir[1 ^ mScrollDirection] = 1;
|
||||||
else if(config->isMappedTo("left", input))
|
else if(config->isMappedLike("left", input))
|
||||||
dir[0 ^ mScrollDirection] = -1;
|
dir[0 ^ mScrollDirection] = -1;
|
||||||
else if(config->isMappedTo("right", input))
|
else if(config->isMappedLike("right", input))
|
||||||
dir[0 ^ mScrollDirection] = 1;
|
dir[0 ^ mScrollDirection] = 1;
|
||||||
|
|
||||||
if(dir != Vector2i::Zero())
|
if(dir != Vector2i::Zero())
|
||||||
|
@ -132,7 +132,7 @@ bool ImageGridComponent<T>::input(InputConfig* config, Input input)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}else{
|
}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();
|
stopScrolling();
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,7 +190,7 @@ public:
|
||||||
}
|
}
|
||||||
if(!mMultiSelect)
|
if(!mMultiSelect)
|
||||||
{
|
{
|
||||||
if(config->isMappedTo("left", input))
|
if(config->isMappedLike("left", input))
|
||||||
{
|
{
|
||||||
// move selection to previous
|
// move selection to previous
|
||||||
unsigned int i = getSelectedId();
|
unsigned int i = getSelectedId();
|
||||||
|
@ -203,7 +203,7 @@ public:
|
||||||
onSelectedChanged();
|
onSelectedChanged();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}else if(config->isMappedTo("right", input))
|
}else if(config->isMappedLike("right", input))
|
||||||
{
|
{
|
||||||
// move selection to next
|
// move selection to next
|
||||||
unsigned int i = getSelectedId();
|
unsigned int i = getSelectedId();
|
||||||
|
|
|
@ -22,7 +22,7 @@ SliderComponent::SliderComponent(Window* window, float min, float max, float inc
|
||||||
|
|
||||||
bool SliderComponent::input(InputConfig* config, Input input)
|
bool SliderComponent::input(InputConfig* config, Input input)
|
||||||
{
|
{
|
||||||
if(config->isMappedTo("left", input))
|
if(config->isMappedLike("left", input))
|
||||||
{
|
{
|
||||||
if(input.value)
|
if(input.value)
|
||||||
setValue(mValue - mSingleIncrement);
|
setValue(mValue - mSingleIncrement);
|
||||||
|
@ -31,7 +31,7 @@ bool SliderComponent::input(InputConfig* config, Input input)
|
||||||
mMoveAccumulator = -MOVE_REPEAT_DELAY;
|
mMoveAccumulator = -MOVE_REPEAT_DELAY;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(config->isMappedTo("right", input))
|
if(config->isMappedLike("right", input))
|
||||||
{
|
{
|
||||||
if(input.value)
|
if(input.value)
|
||||||
setValue(mValue + mSingleIncrement);
|
setValue(mValue + mSingleIncrement);
|
||||||
|
|
|
@ -90,9 +90,9 @@ void TextEditComponent::stopEditing()
|
||||||
|
|
||||||
bool TextEditComponent::input(InputConfig* config, Input input)
|
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);
|
(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);
|
(config->getDeviceId() == DEVICE_KEYBOARD && input.id == SDLK_RIGHT);
|
||||||
|
|
||||||
if(input.value == 0)
|
if(input.value == 0)
|
||||||
|
@ -129,10 +129,10 @@ bool TextEditComponent::input(InputConfig* config, Input input)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(config->getDeviceId() != DEVICE_KEYBOARD && config->isMappedTo("up", input))
|
if(config->getDeviceId() != DEVICE_KEYBOARD && config->isMappedLike("up", input))
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
}else if(config->getDeviceId() != DEVICE_KEYBOARD && config->isMappedTo("down", input))
|
}else if(config->getDeviceId() != DEVICE_KEYBOARD && config->isMappedLike("down", input))
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
}else if(cursor_left || cursor_right)
|
}else if(cursor_left || cursor_right)
|
||||||
|
|
Loading…
Reference in a new issue