Merge pull request #31 from invisiblek/master

Add support for PAGEUP and PAGEDOWN, contributed by invisiblek.
This commit is contained in:
Aloshi 2012-11-11 18:57:51 -08:00
commit 431958f629
4 changed files with 32 additions and 5 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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()

View file

@ -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)
mSelection += mRowVector.size();
{
if(mScrollDir == -10)
mSelection = 0;
else
mSelection += mRowVector.size();
}
if(mSelection >= (int)mRowVector.size())
mSelection -= mRowVector.size();
{
if(mScrollDir == 10)
mSelection = (int)mRowVector.size() - 1;
else
mSelection -= mRowVector.size();
}
if(mScrollSound)
mScrollSound->play();