mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
Merge pull request #31 from invisiblek/master
Add support for PAGEUP and PAGEDOWN, contributed by invisiblek.
This commit is contained in:
commit
431958f629
|
@ -58,6 +58,12 @@ void InputManager::processEvent(SDL_Event* event)
|
|||
case SDLK_DOWN:
|
||||
button = DOWN;
|
||||
break;
|
||||
case SDLK_PAGEUP:
|
||||
button = PAGEUP;
|
||||
break;
|
||||
case SDLK_PAGEDOWN:
|
||||
button = PAGEDOWN;
|
||||
break;
|
||||
case SDLK_RETURN:
|
||||
button = BUTTON1;
|
||||
break;
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace InputManager {
|
|||
void loadConfig();
|
||||
|
||||
//enum for identifying input, regardless of configuration
|
||||
enum InputButton { UNKNOWN, UP, DOWN, LEFT, RIGHT, BUTTON1, BUTTON2, MENU, SELECT};
|
||||
enum InputButton { UNKNOWN, UP, DOWN, PAGEUP, PAGEDOWN, LEFT, RIGHT, BUTTON1, BUTTON2, MENU, SELECT};
|
||||
|
||||
void processEvent(SDL_Event* event);
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <fstream>
|
||||
|
||||
std::string GuiInputConfig::sConfigPath = "./input.cfg";
|
||||
std::string GuiInputConfig::sInputs[] = { "UNKNOWN", "UP", "DOWN", "LEFT", "RIGHT", "BUTTON1 (Accept)", "BUTTON2 (Back)", "START (Menu)", "SELECT (Jump-to-letter)" }; //must be same order as InputManager::InputButton enum
|
||||
std::string GuiInputConfig::sInputs[] = { "UNKNOWN", "UP", "DOWN", "PAGEUP", "PAGEDOWN", "LEFT", "RIGHT", "BUTTON1 (Accept)", "BUTTON2 (Back)", "START (Menu)", "SELECT (Jump-to-letter)" }; //must be same order as InputManager::InputButton enum
|
||||
int GuiInputConfig::sInputCount = 9;
|
||||
|
||||
GuiInputConfig::GuiInputConfig()
|
||||
|
|
|
@ -101,8 +101,19 @@ void GuiList<listType>::onInput(InputManager::InputButton button, bool keyDown)
|
|||
mScrollDir = -1;
|
||||
scroll();
|
||||
}
|
||||
if(button == InputManager::PAGEDOWN)
|
||||
{
|
||||
mScrollDir = 10;
|
||||
scroll();
|
||||
}
|
||||
|
||||
if(button == InputManager::PAGEUP)
|
||||
{
|
||||
mScrollDir = -10;
|
||||
scroll();
|
||||
}
|
||||
}else{
|
||||
if((button == InputManager::DOWN && mScrollDir > 0) || (button == InputManager::UP && mScrollDir < 0))
|
||||
if((button == InputManager::DOWN && mScrollDir > 0) || (button == InputManager::PAGEDOWN && mScrollDir > 0) || (button == InputManager::UP && mScrollDir < 0) || (button == InputManager::PAGEUP && mScrollDir < 0))
|
||||
{
|
||||
stopScrolling();
|
||||
}
|
||||
|
@ -154,9 +165,19 @@ void GuiList<listType>::scroll()
|
|||
mSelection += mScrollDir;
|
||||
|
||||
if(mSelection < 0)
|
||||
{
|
||||
if(mScrollDir == -10)
|
||||
mSelection = 0;
|
||||
else
|
||||
mSelection += mRowVector.size();
|
||||
}
|
||||
if(mSelection >= (int)mRowVector.size())
|
||||
{
|
||||
if(mScrollDir == 10)
|
||||
mSelection = (int)mRowVector.size() - 1;
|
||||
else
|
||||
mSelection -= mRowVector.size();
|
||||
}
|
||||
|
||||
if(mScrollSound)
|
||||
mScrollSound->play();
|
||||
|
|
Loading…
Reference in a new issue