diff --git a/Aquaria/DSQ.cpp b/Aquaria/DSQ.cpp index 57c5b75..3dcbdab 100644 --- a/Aquaria/DSQ.cpp +++ b/Aquaria/DSQ.cpp @@ -1728,19 +1728,6 @@ void DSQ::toggleVersionLabel(bool on) versionLabel->alpha.interpolateTo(a, 1); } -void DSQ::toggleInputMode() -{ - switch(inputMode) - { - case INPUT_MOUSE: - setInputMode(INPUT_JOYSTICK); - break; - case INPUT_JOYSTICK: - setInputMode(INPUT_MOUSE); - break; - } -} - void DSQ::setInputMode(InputMode mode) { inputMode = mode; @@ -1840,11 +1827,6 @@ int DSQ::getEntityTypeIndexByName(std::string s) return -1; } -void DSQ::toggleMuffleSound(bool toggle) -{ - -} - void DSQ::loadModsCallback(const std::string &filename, intptr_t param) { @@ -2797,17 +2779,13 @@ void DSQ::createSaveSlotPage() addRenderObject(saveSlots[i], LR_FILEMENU); } - - if (inputMode == INPUT_JOYSTICK) - { - saveSlots[0]->setDirMove(DIR_RIGHT, arrowUp); - saveSlots[1]->setDirMove(DIR_RIGHT, arrowUp); - saveSlots[2]->setDirMove(DIR_RIGHT, arrowDown); - saveSlots[3]->setDirMove(DIR_RIGHT, cancel); - arrowDown->setDirMove(DIR_DOWN, cancel); - cancel->setDirMove(DIR_UP, arrowDown); - cancel->setDirMove(DIR_LEFT, saveSlots[3]); - } + saveSlots[0]->setDirMove(DIR_RIGHT, arrowUp); + saveSlots[1]->setDirMove(DIR_RIGHT, arrowUp); + saveSlots[2]->setDirMove(DIR_RIGHT, arrowDown); + saveSlots[3]->setDirMove(DIR_RIGHT, cancel); + arrowDown->setDirMove(DIR_DOWN, cancel); + cancel->setDirMove(DIR_UP, arrowDown); + cancel->setDirMove(DIR_LEFT, saveSlots[3]); } void DSQ::nextSaveSlotPage() diff --git a/Aquaria/DSQ.h b/Aquaria/DSQ.h index 7a4e857..243709b 100644 --- a/Aquaria/DSQ.h +++ b/Aquaria/DSQ.h @@ -283,8 +283,6 @@ public: bool modIsSelected; - void toggleMuffleSound(bool toggle); - void toggleInputMode(); void shakeCamera(float mag, float time); Vector avStart; Entity *getEntityByName(const std::string &name); diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index fb7a1b1..c126064 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -8230,17 +8230,28 @@ luaFunc(getInputMode) luaReturnInt(dsq->inputMode); } +static Joystick *_getJoystick(lua_State *L, int idx = 1) +{ + int source = lua_tointeger(L, idx) - 1; + if(source < 0) + return core->getJoystick(0); // HACK: FIXME: do something sensible instead + + return core->getJoystickForSourceID(source); +} + luaFunc(getJoystickAxisLeft) { - Vector v;// = core->joystick.position; - assert(false); // FIXME + Vector v; + if(Joystick *j = _getJoystick(L)) + v = j->position; luaReturnVec2(v.x, v.y); } luaFunc(getJoystickAxisRight) { - Vector v;// = core->joystick.rightStick; - assert(false); // FIXME + Vector v; + if(Joystick *j = _getJoystick(L)) + v = j->rightStick; luaReturnVec2(v.x, v.y); } diff --git a/BBGE/Core.cpp b/BBGE/Core.cpp index 15c5afb..1011acd 100644 --- a/BBGE/Core.cpp +++ b/BBGE/Core.cpp @@ -3059,9 +3059,9 @@ void Core::clearActionButtons() actionStatus.clear(); } -Joystick *Core::getJoystickForSourceID(unsigned sourceID) +Joystick *Core::getJoystickForSourceID(int sourceID) { - if(sourceID < (unsigned)actionStatus.size()) - return getJoystick(actionStatus[sourceID]->getJoystickID()); + if(unsigned(sourceID+1) < (unsigned)actionStatus.size()) + return getJoystick(actionStatus[sourceID+1]->getJoystickID()); return NULL; } diff --git a/BBGE/Core.h b/BBGE/Core.h index 54c5197..930c80e 100644 --- a/BBGE/Core.h +++ b/BBGE/Core.h @@ -564,7 +564,7 @@ public: Joystick *getJoystick(int idx); // warning: may return NULL/contain holes // not the actual number of joysticks! size_t getNumJoysticks() const { return joysticks.size(); } - Joystick *getJoystickForSourceID(unsigned sourceID); + Joystick *getJoystickForSourceID(int sourceID); private: std::vector joysticks; }; diff --git a/BBGE/GameKeys.h b/BBGE/GameKeys.h index 37e9a2f..27f44d4 100644 --- a/BBGE/GameKeys.h +++ b/BBGE/GameKeys.h @@ -64,7 +64,7 @@ #define KEY_G SDL_SCANCODE_G #define KEY_H SDL_SCANCODE_H #define KEY_I SDL_SCANCODE_I -#define KEY_J SDL_SCANCODE_K +#define KEY_J SDL_SCANCODE_J #define KEY_K SDL_SCANCODE_K #define KEY_L SDL_SCANCODE_L #define KEY_M SDL_SCANCODE_M