mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2024-11-25 09:44:02 +00:00
Reject joystick axes for Swim[Up|Down|Left|Right] actions.
This avoids confusion since the axes are always used, analog, and allow nice control. If the axes were additionally mapped to Sim* actions, the movement would no longer be analog as soon as the (digital) action state is enabled.
This commit is contained in:
parent
844ee748e6
commit
812dc7dd7f
4 changed files with 30 additions and 10 deletions
|
@ -484,7 +484,13 @@ AquariaKeyConfig *AquariaKeyConfig::waitingForInput = 0;
|
|||
|
||||
|
||||
AquariaKeyConfig::AquariaKeyConfig(const std::string &actionInputName, InputSetType inputSetType, int inputIdx)
|
||||
: AquariaGuiElement(), RenderObject(), actionInputName(actionInputName), inputSetType(inputSetType), inputIdx(inputIdx)
|
||||
: AquariaGuiElement(), RenderObject()
|
||||
, actionInputName(actionInputName)
|
||||
, inputSetType(inputSetType)
|
||||
, inputIdx(inputIdx)
|
||||
, actionSetIndex(0)
|
||||
, acceptEsc(false)
|
||||
, rejectJoyAxis(false)
|
||||
{
|
||||
bg = new Quad();
|
||||
if (inputSetType == INPUTSET_OTHER)
|
||||
|
@ -504,10 +510,7 @@ AquariaKeyConfig::AquariaKeyConfig(const std::string &actionInputName, InputSetT
|
|||
|
||||
addChild(keyConfigFont, PM_POINTER);
|
||||
|
||||
|
||||
keyDown = false;
|
||||
acceptEsc = false;
|
||||
actionSetIndex = 0;
|
||||
|
||||
toggleEnterKey(false);
|
||||
}
|
||||
|
@ -862,6 +865,15 @@ void AquariaKeyConfig::onUpdate(float dt)
|
|||
waitingForInput = 0;
|
||||
AquariaGuiElement::canDirMoveGlobal = true;
|
||||
|
||||
if(rejectJoyAxis && (
|
||||
(ac >= JOY_AXIS_0_POS && ac < JOY_AXIS_END_POS)
|
||||
|| (ac >= JOY_AXIS_0_NEG && ac < JOY_AXIS_END_NEG)
|
||||
))
|
||||
{
|
||||
dsq->sound->playSfx("denied");
|
||||
abort = true;
|
||||
}
|
||||
|
||||
if(!abort)
|
||||
{
|
||||
if(clear || *k == ac) // clear key if pressed again
|
||||
|
@ -929,6 +941,11 @@ void AquariaKeyConfig::setAcceptEsc(bool a)
|
|||
acceptEsc = a;
|
||||
}
|
||||
|
||||
void AquariaKeyConfig::setRejectJoyAxis(bool b)
|
||||
{
|
||||
rejectJoyAxis = b;
|
||||
}
|
||||
|
||||
AquariaMenuItem::AquariaMenuItem() : Quad(), ActionMapper(), AquariaGuiElement()
|
||||
{
|
||||
quad = glow = 0;
|
||||
|
|
|
@ -176,6 +176,7 @@ public:
|
|||
|
||||
void setAcceptEsc(bool a);
|
||||
void setActionSetIndex(int idx);
|
||||
void setRejectJoyAxis(bool b);
|
||||
|
||||
protected:
|
||||
void toggleEnterKey(int on);
|
||||
|
@ -192,6 +193,7 @@ protected:
|
|||
Quad *bg;
|
||||
int actionSetIndex;
|
||||
bool acceptEsc;
|
||||
bool rejectJoyAxis;
|
||||
};
|
||||
|
||||
class AquariaComboBox;
|
||||
|
|
|
@ -1513,7 +1513,7 @@ void InGameMenu::hide(bool effects, bool cancel)
|
|||
}
|
||||
|
||||
|
||||
void InGameMenu::addKeyConfigLine(RenderObject *group, const std::string &label, const std::string &actionInputName, int x, int y, bool acceptEsc)
|
||||
void InGameMenu::addKeyConfigLine(RenderObject *group, const std::string &label, const std::string &actionInputName, int x, int y, bool acceptEsc, bool rejectJoyAxis)
|
||||
{
|
||||
TTFText *lb = new TTFText(&dsq->fontArialSmallest);
|
||||
lb->setText(label);
|
||||
|
@ -1545,6 +1545,7 @@ void InGameMenu::addKeyConfigLine(RenderObject *group, const std::string &label,
|
|||
j1->position = Vector(x,y);
|
||||
group->addChild(j1, PM_POINTER);
|
||||
keyConfigs.push_back(j1);
|
||||
j1->setRejectJoyAxis(rejectJoyAxis);
|
||||
x += KEYCONFIG_COL_DISTANCE;
|
||||
|
||||
m->setDirMove(DIR_RIGHT, k1);
|
||||
|
@ -2097,10 +2098,10 @@ void InGameMenu::create()
|
|||
|
||||
addKeyConfigLine(kk, SB(2107), "PrimaryAction", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2108), "SecondaryAction", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2109), "SwimUp", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2110), "SwimDown", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2111), "SwimLeft", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2112), "SwimRight", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2109), "SwimUp", offx, y+=yi, false, true);
|
||||
addKeyConfigLine(kk, SB(2110), "SwimDown", offx, y+=yi, false, true);
|
||||
addKeyConfigLine(kk, SB(2111), "SwimLeft", offx, y+=yi, false, true);
|
||||
addKeyConfigLine(kk, SB(2112), "SwimRight", offx, y+=yi, false, true);
|
||||
addKeyConfigLine(kk, SB(2113), "Roll", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2114), "Revert", offx, y+=yi);
|
||||
addKeyConfigLine(kk, SB(2115), "WorldMap", offx, y+=yi);
|
||||
|
|
|
@ -194,7 +194,7 @@ private:
|
|||
|
||||
void onKeyConfig();
|
||||
|
||||
void addKeyConfigLine(RenderObject *group, const std::string &label, const std::string &actionInputName, int x, int y, bool acceptEsc = false);
|
||||
void addKeyConfigLine(RenderObject *group, const std::string &label, const std::string &actionInputName, int x, int y, bool acceptEsc = false, bool rejectJoyAxis = false);
|
||||
|
||||
AquariaKeyConfig *addAxesConfigLine(RenderObject *group, const std::string &label, const std::string &actionInputName, int offx, int y);
|
||||
|
||||
|
|
Loading…
Reference in a new issue