mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-07-03 06:24:32 +00:00
More WIP towards multiple input sets
This commit is contained in:
parent
b438064517
commit
bf94d541cd
21 changed files with 449 additions and 232 deletions
|
@ -24,9 +24,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
JoystickConfig::JoystickConfig()
|
||||
{
|
||||
s1ax = 0;
|
||||
s1ay = 0;
|
||||
s2ax = 0;
|
||||
s2ay = 0;
|
||||
s1ay = 1;
|
||||
s2ax = 2;
|
||||
s2ay = 3;
|
||||
s1dead = 0.3f;
|
||||
s2dead = 0.3f;
|
||||
}
|
||||
|
@ -92,6 +92,13 @@ int ActionSet::_whichJoystickForName()
|
|||
return -1;
|
||||
}
|
||||
|
||||
void ActionSet::updateJoystick()
|
||||
{
|
||||
Joystick *j = core->getJoystick(joystickID);
|
||||
if(j)
|
||||
j->setEnabled(enabled);
|
||||
}
|
||||
|
||||
ActionInput *ActionSet::getActionInputByName(const std::string &name)
|
||||
{
|
||||
for (ActionInputSet::iterator i = inputSet.begin(); i != inputSet.end(); i++)
|
||||
|
|
|
@ -50,6 +50,7 @@ public:
|
|||
void clearActions();
|
||||
int assignJoystickByName(); // -1 if no such joystick found
|
||||
void assignJoystickIdx(int idx);
|
||||
void updateJoystick();
|
||||
|
||||
ActionInput *addActionInput(const std::string &name);
|
||||
ActionInput *getActionInputByName(const std::string &name);
|
||||
|
@ -67,7 +68,7 @@ public:
|
|||
|
||||
//std::string insertInputIntoString(const std::string &string);
|
||||
private:
|
||||
int _whichJoystickForName(); // -1 if no souch joystick found
|
||||
int _whichJoystickForName(); // -1 if no such joystick found
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -34,12 +34,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "FrameBuffer.h"
|
||||
#include "Shader.h"
|
||||
#include "Joystick.h"
|
||||
|
||||
#include "GameKeys.h"
|
||||
|
||||
|
||||
class ParticleEffect;
|
||||
class Joystick;
|
||||
|
||||
class ParticleManager;
|
||||
|
||||
|
|
|
@ -163,8 +163,8 @@ void DebugFont::setAlign(Align align)
|
|||
|
||||
#include "../BBGE/Quad.h"
|
||||
|
||||
DebugButton::DebugButton(int buttonID, DebugButtonReceiver *receiver, int bgWidth, int fsize, bool quitMain)
|
||||
: RenderObject(), label(0), highlight(0), quitMain(quitMain), receiver(receiver), buttonID(buttonID)
|
||||
DebugButton::DebugButton(int buttonID, DebugButtonReceiver *receiver, int bgWidth, int fsize)
|
||||
: RenderObject(), label(0), highlight(0), receiver(receiver), buttonID(buttonID)
|
||||
, activeAlpha(0.5f), activeColor(1,1,1), inactiveAlpha(0.5f), inactiveColor(0,0,0)
|
||||
{
|
||||
if (bgWidth == 0)
|
||||
|
@ -214,8 +214,6 @@ void DebugButton::onUpdate(float dt)
|
|||
|
||||
if (doit)
|
||||
{
|
||||
if (quitMain)
|
||||
core->quitNestedMain();
|
||||
event.call();
|
||||
if (receiver)
|
||||
receiver->buttonPress(this);
|
||||
|
|
|
@ -53,10 +53,9 @@ class DebugButtonReceiver;
|
|||
class DebugButton : public RenderObject
|
||||
{
|
||||
public:
|
||||
DebugButton(int buttonID=-1, DebugButtonReceiver *receiver=0, int bgWidth=0, int fsize=0, bool quitMain=false);
|
||||
DebugButton(int buttonID=-1, DebugButtonReceiver *receiver=0, int bgWidth=0, int fsize=0);
|
||||
DebugFont *label;
|
||||
EventPtr event;
|
||||
bool quitMain;
|
||||
int buttonID;
|
||||
float activeAlpha;
|
||||
Vector activeColor;
|
||||
|
|
|
@ -193,7 +193,6 @@ void Joystick::rumble(float leftMotor, float rightMotor, float time)
|
|||
|
||||
void Joystick::calibrate(Vector &calvec, float deadZone)
|
||||
{
|
||||
|
||||
if (calvec.isLength2DIn(deadZone))
|
||||
{
|
||||
calvec = Vector(0,0,0);
|
||||
|
@ -232,7 +231,6 @@ void Joystick::update(float dt)
|
|||
shutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
if (sdl_controller)
|
||||
{
|
||||
for(int i = 0; i < numJoyAxes; ++i)
|
||||
|
@ -262,10 +260,10 @@ void Joystick::update(float dt)
|
|||
Sint16 ax = SDL_JoystickGetAxis(sdl_joy, i);
|
||||
axisRaw[i] = float(ax)/32768.0f;
|
||||
}
|
||||
position.x = axisRaw[s1ax];
|
||||
position.y = axisRaw[s1ay];
|
||||
rightStick.x = axisRaw[s2ax];
|
||||
rightStick.y = axisRaw[s2ay];
|
||||
position.x = s1ax >= 0 ? axisRaw[s1ax] : 0.0f;
|
||||
position.y = s1ay >= 0 ? axisRaw[s1ay] : 0.0f;
|
||||
rightStick.x = s2ax >= 0 ? axisRaw[s2ax] : 0.0f;
|
||||
rightStick.y = s2ay >= 0 ? axisRaw[s2ay] : 0.0f;
|
||||
}
|
||||
|
||||
calibrate(position, deadZone1);
|
||||
|
|
|
@ -39,6 +39,7 @@ public:
|
|||
int getIndex() const { return stickIndex; }
|
||||
int getInstanceID() const { return instanceID; }
|
||||
inline bool isEnabled() const { return enabled; }
|
||||
inline void setEnabled(bool on) { enabled = on; }
|
||||
|
||||
const char *getAxisName(int axis) const;
|
||||
const char *getButtonName(int btn) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue