mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 06:35:30 +00:00
Merge remote-tracking branch 'scrawl/joystick'
This commit is contained in:
commit
babac842f6
@ -375,6 +375,9 @@ configure_file(${OpenMW_SOURCE_DIR}/files/opencs.ini
|
||||
configure_file(${OpenMW_SOURCE_DIR}/files/opencs/defaultfilters
|
||||
"${OpenMW_BINARY_DIR}/resources/defaultfilters" COPYONLY)
|
||||
|
||||
configure_file(${OpenMW_SOURCE_DIR}/files/gamecontrollerdb.txt
|
||||
"${OpenMW_BINARY_DIR}/gamecontrollerdb.txt")
|
||||
|
||||
if (NOT WIN32 AND NOT APPLE)
|
||||
configure_file(${OpenMW_SOURCE_DIR}/files/openmw.desktop
|
||||
"${OpenMW_BINARY_DIR}/openmw.desktop")
|
||||
@ -462,6 +465,8 @@ IF(NOT WIN32 AND NOT APPLE)
|
||||
INSTALL(FILES "${OpenMW_BINARY_DIR}/settings-default.cfg" DESTINATION "${SYSCONFDIR}" COMPONENT "openmw")
|
||||
INSTALL(FILES "${OpenMW_BINARY_DIR}/transparency-overrides.cfg" DESTINATION "${SYSCONFDIR}" COMPONENT "openmw")
|
||||
INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" DESTINATION "${SYSCONFDIR}" RENAME "openmw.cfg" COMPONENT "openmw")
|
||||
INSTALL(FILES "${OpenMW_BINARY_DIR}/gamecontrollerdb.txt" DESTINATION "${SYSCONFDIR}" COMPONENT "openmw")
|
||||
|
||||
IF(BUILD_OPENCS)
|
||||
INSTALL(FILES "${OpenMW_BINARY_DIR}/opencs.ini" DESTINATION "${SYSCONFDIR}" COMPONENT "opencs")
|
||||
ENDIF(BUILD_OPENCS)
|
||||
@ -482,6 +487,7 @@ if(WIN32)
|
||||
"${OpenMW_SOURCE_DIR}/Docs/license/DejaVu Font License.txt"
|
||||
"${OpenMW_BINARY_DIR}/settings-default.cfg"
|
||||
"${OpenMW_BINARY_DIR}/transparency-overrides.cfg"
|
||||
"${OpenMW_BINARY_DIR}/gamecontrollerdb.txt"
|
||||
"${OpenMW_BINARY_DIR}/Release/openmw.exe"
|
||||
DESTINATION ".")
|
||||
|
||||
@ -767,6 +773,7 @@ if (APPLE)
|
||||
install(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
|
||||
install(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" RENAME "openmw.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
|
||||
install(FILES "${OpenMW_BINARY_DIR}/settings-default.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
|
||||
install(FILES "${OpenMW_BINARY_DIR}/gamecontrollerdb.txt" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
|
||||
install(FILES "${OpenMW_BINARY_DIR}/transparency-overrides.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
|
||||
install(FILES "${OpenMW_BINARY_DIR}/opencs.ini" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime)
|
||||
|
||||
|
@ -194,7 +194,7 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
|
||||
std::srand ( std::time(NULL) );
|
||||
MWClass::registerClasses();
|
||||
|
||||
Uint32 flags = SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE;
|
||||
Uint32 flags = SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE|SDL_INIT_GAMECONTROLLER|SDL_INIT_JOYSTICK;
|
||||
if(SDL_WasInit(flags) == 0)
|
||||
{
|
||||
//kindly ask SDL not to trash our OGL context
|
||||
@ -368,9 +368,29 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
|
||||
// Create input and UI first to set up a bootstrapping environment for
|
||||
// showing a loading screen and keeping the window responsive while doing so
|
||||
|
||||
std::string keybinderUser = (mCfgMgr.getUserConfigPath() / "input_v2.xml").string();
|
||||
std::string keybinderUser = (mCfgMgr.getUserConfigPath() / "input_v3.xml").string();
|
||||
bool keybinderUserExists = boost::filesystem::exists(keybinderUser);
|
||||
MWInput::InputManager* input = new MWInput::InputManager (*mOgre, *this, keybinderUser, keybinderUserExists, mGrab);
|
||||
if(!keybinderUserExists)
|
||||
{
|
||||
std::string input2 = (mCfgMgr.getUserConfigPath() / "input_v2.xml").string();
|
||||
if(boost::filesystem::exists(input2)) {
|
||||
boost::filesystem::copy_file(input2, keybinderUser);
|
||||
keybinderUserExists = boost::filesystem::exists(keybinderUser);
|
||||
}
|
||||
}
|
||||
|
||||
// find correct path to the game controller bindings
|
||||
const std::string localdefault = mCfgMgr.getLocalPath().string() + "/gamecontrollerdb.cfg";
|
||||
const std::string globaldefault = mCfgMgr.getGlobalPath().string() + "/gamecontrollerdb.cfg";
|
||||
std::string gameControllerdb;
|
||||
if (boost::filesystem::exists(localdefault))
|
||||
gameControllerdb = localdefault;
|
||||
else if (boost::filesystem::exists(globaldefault))
|
||||
gameControllerdb = globaldefault;
|
||||
else
|
||||
gameControllerdb = ""; //if it doesn't exist, pass in an empty string
|
||||
|
||||
MWInput::InputManager* input = new MWInput::InputManager (*mOgre, *this, keybinderUser, keybinderUserExists, gameControllerdb, mGrab);
|
||||
mEnvironment.setInputManager (input);
|
||||
|
||||
MWGui::WindowManager* window = new MWGui::WindowManager(
|
||||
|
@ -37,11 +37,23 @@ namespace MWBase
|
||||
virtual bool getControlSwitch (const std::string& sw) = 0;
|
||||
|
||||
virtual std::string getActionDescription (int action) = 0;
|
||||
virtual std::string getActionBindingName (int action) = 0;
|
||||
virtual std::vector<int> getActionSorting () = 0;
|
||||
virtual std::string getActionKeyBindingName (int action) = 0;
|
||||
virtual std::string getActionControllerBindingName (int action) = 0;
|
||||
virtual std::string sdlControllerAxisToString(int axis) = 0;
|
||||
virtual std::string sdlControllerButtonToString(int button) = 0;
|
||||
///Actions available for binding to keyboard buttons
|
||||
virtual std::vector<int> getActionKeySorting() = 0;
|
||||
///Actions available for binding to controller buttons
|
||||
virtual std::vector<int> getActionControllerSorting() = 0;
|
||||
virtual int getNumActions() = 0;
|
||||
virtual void enableDetectingBindingMode (int action) = 0;
|
||||
virtual void resetToDefaultBindings() = 0;
|
||||
///If keyboard is true, only pay attention to keyboard events. If false, only pay attention to controller events (excluding esc)
|
||||
virtual void enableDetectingBindingMode (int action, bool keyboard) = 0;
|
||||
virtual void resetToDefaultKeyBindings() = 0;
|
||||
virtual void resetToDefaultControllerBindings() = 0;
|
||||
|
||||
/// Returns if the last used input device was a joystick or a keyboard
|
||||
/// @return true if joystick, false otherwise
|
||||
virtual bool joystickLastUsed() = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,8 @@ namespace MWGui
|
||||
}
|
||||
|
||||
SettingsWindow::SettingsWindow() :
|
||||
WindowBase("openmw_settings_window.layout")
|
||||
WindowBase("openmw_settings_window.layout"),
|
||||
mKeyboardMode(true)
|
||||
{
|
||||
configureWidgets(mMainWidget);
|
||||
|
||||
@ -188,6 +189,8 @@ namespace MWGui
|
||||
getWidget(mResetControlsButton, "ResetControlsButton");
|
||||
getWidget(mRefractionButton, "RefractionButton");
|
||||
getWidget(mDifficultySlider, "DifficultySlider");
|
||||
getWidget(mKeyboardSwitch, "KeyboardButton");
|
||||
getWidget(mControllerSwitch, "ControllerButton");
|
||||
|
||||
#ifndef WIN32
|
||||
// hide gamma controls since it currently does not work under Linux
|
||||
@ -213,6 +216,9 @@ namespace MWGui
|
||||
|
||||
mShadowsTextureSize->eventComboChangePosition += MyGUI::newDelegate(this, &SettingsWindow::onShadowTextureSizeChanged);
|
||||
|
||||
mKeyboardSwitch->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onKeyboardSwitchClicked);
|
||||
mControllerSwitch->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onControllerSwitchClicked);
|
||||
|
||||
center();
|
||||
|
||||
mResetControlsButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onResetDefaultBindings);
|
||||
@ -260,9 +266,13 @@ namespace MWGui
|
||||
|
||||
MyGUI::TextBox* diffText;
|
||||
getWidget(diffText, "DifficultyText");
|
||||
|
||||
diffText->setCaptionWithReplacing("#{sDifficulty} (" + MyGUI::utility::toString(int(Settings::Manager::getInt("difficulty", "Game"))) + ")");
|
||||
|
||||
mWindowBorderButton->setEnabled(!Settings::Manager::getBool("fullscreen", "Video"));
|
||||
|
||||
mKeyboardSwitch->setStateSelected(true);
|
||||
mControllerSwitch->setStateSelected(false);
|
||||
}
|
||||
|
||||
void SettingsWindow::onOkButtonClicked(MyGUI::Widget* _sender)
|
||||
@ -462,14 +472,37 @@ namespace MWGui
|
||||
MWBase::Environment::get().getInputManager()->processChangedSettings(changed);
|
||||
}
|
||||
|
||||
void SettingsWindow::onKeyboardSwitchClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
if(mKeyboardMode)
|
||||
return;
|
||||
mKeyboardMode = true;
|
||||
mKeyboardSwitch->setStateSelected(true);
|
||||
mControllerSwitch->setStateSelected(false);
|
||||
updateControlsBox();
|
||||
}
|
||||
|
||||
void SettingsWindow::onControllerSwitchClicked(MyGUI::Widget* _sender)
|
||||
{
|
||||
if(!mKeyboardMode)
|
||||
return;
|
||||
mKeyboardMode = false;
|
||||
mKeyboardSwitch->setStateSelected(false);
|
||||
mControllerSwitch->setStateSelected(true);
|
||||
updateControlsBox();
|
||||
}
|
||||
|
||||
void SettingsWindow::updateControlsBox()
|
||||
{
|
||||
while (mControlsBox->getChildCount())
|
||||
MyGUI::Gui::getInstance().destroyWidget(mControlsBox->getChildAt(0));
|
||||
|
||||
MWBase::Environment::get().getWindowManager ()->removeStaticMessageBox();
|
||||
|
||||
std::vector<int> actions = MWBase::Environment::get().getInputManager()->getActionSorting ();
|
||||
MWBase::Environment::get().getWindowManager()->removeStaticMessageBox();
|
||||
std::vector<int> actions;
|
||||
if(mKeyboardMode)
|
||||
actions = MWBase::Environment::get().getInputManager()->getActionKeySorting();
|
||||
else
|
||||
actions = MWBase::Environment::get().getInputManager()->getActionControllerSorting();
|
||||
|
||||
const int h = 18;
|
||||
const int w = mControlsBox->getWidth() - 28;
|
||||
@ -480,7 +513,11 @@ namespace MWGui
|
||||
if (desc == "")
|
||||
continue;
|
||||
|
||||
std::string binding = MWBase::Environment::get().getInputManager()->getActionBindingName (*it);
|
||||
std::string binding;
|
||||
if(mKeyboardMode)
|
||||
binding = MWBase::Environment::get().getInputManager()->getActionKeyBindingName(*it);
|
||||
else
|
||||
binding = MWBase::Environment::get().getInputManager()->getActionControllerBindingName(*it);
|
||||
|
||||
Gui::SharedStateButton* leftText = mControlsBox->createWidget<Gui::SharedStateButton>("SandTextButton", MyGUI::IntCoord(0,curH,w,h), MyGUI::Align::Default);
|
||||
leftText->setCaptionWithReplacing(desc);
|
||||
@ -514,7 +551,7 @@ namespace MWGui
|
||||
MWBase::Environment::get().getWindowManager ()->staticMessageBox ("#{sControlsMenu3}");
|
||||
MWBase::Environment::get().getWindowManager ()->disallowMouse();
|
||||
|
||||
MWBase::Environment::get().getInputManager ()->enableDetectingBindingMode (actionId);
|
||||
MWBase::Environment::get().getInputManager ()->enableDetectingBindingMode (actionId, mKeyboardMode);
|
||||
|
||||
}
|
||||
|
||||
@ -537,7 +574,10 @@ namespace MWGui
|
||||
|
||||
void SettingsWindow::onResetDefaultBindingsAccept()
|
||||
{
|
||||
MWBase::Environment::get().getInputManager ()->resetToDefaultBindings ();
|
||||
if(mKeyboardMode)
|
||||
MWBase::Environment::get().getInputManager ()->resetToDefaultKeyBindings ();
|
||||
else
|
||||
MWBase::Environment::get().getInputManager()->resetToDefaultControllerBindings();
|
||||
updateControlsBox ();
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,9 @@ namespace MWGui
|
||||
// controls
|
||||
MyGUI::ScrollView* mControlsBox;
|
||||
MyGUI::Button* mResetControlsButton;
|
||||
MyGUI::Button* mKeyboardSwitch;
|
||||
MyGUI::Button* mControllerSwitch;
|
||||
bool mKeyboardMode; //if true, setting up the keyboard. Otherwise, it's controller
|
||||
|
||||
void onOkButtonClicked(MyGUI::Widget* _sender);
|
||||
void onFpsToggled(MyGUI::Widget* _sender);
|
||||
@ -63,6 +66,8 @@ namespace MWGui
|
||||
void onInputTabMouseWheel(MyGUI::Widget* _sender, int _rel);
|
||||
void onResetDefaultBindings(MyGUI::Widget* _sender);
|
||||
void onResetDefaultBindingsAccept ();
|
||||
void onKeyboardSwitchClicked(MyGUI::Widget* _sender);
|
||||
void onControllerSwitchClicked(MyGUI::Widget* _sender);
|
||||
|
||||
void onWindowResize(MyGUI::Window* _sender);
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <OgreRoot.h>
|
||||
#include <OgreRenderWindow.h>
|
||||
#include <cmath>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
@ -11,6 +12,8 @@
|
||||
#include <MyGUI_Button.h>
|
||||
#include <MyGUI_EditBox.h>
|
||||
|
||||
#include <SDL_version.h>
|
||||
|
||||
#include <openengine/ogre/renderer.hpp>
|
||||
|
||||
#include "../engine.hpp"
|
||||
@ -32,6 +35,8 @@
|
||||
|
||||
#include "../mwgui/windowbase.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace ICS;
|
||||
|
||||
namespace
|
||||
@ -97,7 +102,8 @@ namespace MWInput
|
||||
{
|
||||
InputManager::InputManager(OEngine::Render::OgreRenderer &ogre,
|
||||
OMW::Engine& engine,
|
||||
const std::string& userFile, bool userFileExists, bool grab)
|
||||
const std::string& userFile, bool userFileExists,
|
||||
const std::string& controllerBindingsFile, bool grab)
|
||||
: mOgre(ogre)
|
||||
, mPlayer(NULL)
|
||||
, mEngine(engine)
|
||||
@ -120,6 +126,9 @@ namespace MWInput
|
||||
, mAlwaysRunActive(Settings::Manager::getBool("always run", "Input"))
|
||||
, mAttemptJump(false)
|
||||
, mControlsDisabled(false)
|
||||
, mJoystickLastUsed(false)
|
||||
, mDetectingKeyboard(false)
|
||||
, mFakeDeviceID(1)
|
||||
{
|
||||
|
||||
Ogre::RenderWindow* window = ogre.getWindow ();
|
||||
@ -128,13 +137,14 @@ namespace MWInput
|
||||
mInputManager->setMouseEventCallback (this);
|
||||
mInputManager->setKeyboardEventCallback (this);
|
||||
mInputManager->setWindowEventCallback(this);
|
||||
mInputManager->setControllerEventCallback(this);
|
||||
|
||||
std::string file = userFileExists ? userFile : "";
|
||||
mInputBinder = new ICS::InputControlSystem(file, true, this, NULL, A_Last);
|
||||
|
||||
adjustMouseRegion (window->getWidth(), window->getHeight());
|
||||
|
||||
loadKeyDefaults();
|
||||
loadControllerDefaults();
|
||||
|
||||
for (int i = 0; i < A_Last; ++i)
|
||||
{
|
||||
@ -148,6 +158,32 @@ namespace MWInput
|
||||
mControlSwitch["playermagic"] = true;
|
||||
mControlSwitch["playerviewswitch"] = true;
|
||||
mControlSwitch["vanitymode"] = true;
|
||||
|
||||
/* Joystick Init */
|
||||
|
||||
//Load controller mappings
|
||||
#if SDL_VERSION_ATLEAST(2,0,2)
|
||||
if(controllerBindingsFile!="")
|
||||
{
|
||||
SDL_GameControllerAddMappingsFromFile(controllerBindingsFile.c_str());
|
||||
}
|
||||
#endif
|
||||
|
||||
//Open all presently connected sticks
|
||||
int numSticks = SDL_NumJoysticks();
|
||||
for(int i = 0; i < numSticks; i++)
|
||||
{
|
||||
if(SDL_IsGameController(i))
|
||||
{
|
||||
SDL_ControllerDeviceEvent evt;
|
||||
evt.which = i;
|
||||
controllerAdded(mFakeDeviceID, evt);
|
||||
}
|
||||
else
|
||||
{
|
||||
//ICS_LOG(std::string("Unusable controller plugged in: ")+SDL_JoystickNameForIndex(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InputManager::clear()
|
||||
@ -190,6 +226,27 @@ namespace MWInput
|
||||
|
||||
int action = channel->getNumber();
|
||||
|
||||
if((previousValue == 1 || previousValue == 0) && (currentValue==1 || currentValue==0))
|
||||
{
|
||||
//Is a normal button press, so don't change it at all
|
||||
}
|
||||
//Otherwise only trigger button presses as they go through specific points
|
||||
else if(previousValue >= .8 && currentValue < .8)
|
||||
{
|
||||
currentValue = 0.0;
|
||||
previousValue = 1.0;
|
||||
}
|
||||
else if(previousValue <= .6 && currentValue > .6)
|
||||
{
|
||||
currentValue = 1.0;
|
||||
previousValue = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//If it's not switching between those values, ignore the channel change.
|
||||
return;
|
||||
}
|
||||
|
||||
if (mControlSwitch["playercontrols"])
|
||||
{
|
||||
if (action == A_Use)
|
||||
@ -219,7 +276,6 @@ namespace MWInput
|
||||
break;
|
||||
case A_Activate:
|
||||
resetIdleTime();
|
||||
|
||||
if (!MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||
activate();
|
||||
break;
|
||||
@ -346,6 +402,47 @@ namespace MWInput
|
||||
|
||||
updateCursorMode();
|
||||
|
||||
if(mJoystickLastUsed)
|
||||
{
|
||||
if (mGuiCursorEnabled)
|
||||
{
|
||||
float xAxis = mInputBinder->getChannel(A_MoveLeftRight)->getValue()*2.0f-1.0f;
|
||||
float yAxis = mInputBinder->getChannel(A_MoveForwardBackward)->getValue()*2.0f-1.0f;
|
||||
float zAxis = mInputBinder->getChannel(A_LookUpDown)->getValue()*2.0f-1.0f;
|
||||
const MyGUI::IntSize& viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||
|
||||
// We keep track of our own mouse position, so that moving the mouse while in
|
||||
// game mode does not move the position of the GUI cursor
|
||||
mMouseX += xAxis * dt * 1500.0f;
|
||||
mMouseY += yAxis * dt * 1500.0f;
|
||||
mMouseWheel -= zAxis * dt * 1500.0f;
|
||||
|
||||
mMouseX = std::max(0.f, std::min(mMouseX, float(viewSize.width)));
|
||||
mMouseY = std::max(0.f, std::min(mMouseY, float(viewSize.height)));
|
||||
|
||||
MyGUI::InputManager::getInstance().injectMouseMove( mMouseX, mMouseY, mMouseWheel);
|
||||
mInputManager->warpMouse(mMouseX, mMouseY);
|
||||
}
|
||||
if (mMouseLookEnabled)
|
||||
{
|
||||
float xAxis = mInputBinder->getChannel(A_LookLeftRight)->getValue()*2.0f-1.0f;
|
||||
float yAxis = mInputBinder->getChannel(A_LookUpDown)->getValue()*2.0f-1.0f;
|
||||
resetIdleTime();
|
||||
|
||||
float rot[3];
|
||||
rot[0] = yAxis * (dt * 100.0f) * 10.0f * mCameraSensitivity * (1.0f/256.f) * (mInvertY ? -1 : 1) * mCameraYMultiplier;
|
||||
rot[1] = 0.0f;
|
||||
rot[2] = xAxis * (dt * 100.0f) * 10.0f * mCameraSensitivity * (1.0f/256.f);
|
||||
|
||||
// Only actually turn player when we're not in vanity mode
|
||||
if(!MWBase::Environment::get().getWorld()->vanityRotateCamera(rot))
|
||||
{
|
||||
mPlayer->yaw(rot[2]);
|
||||
mPlayer->pitch(rot[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Disable movement in Gui mode
|
||||
if (!(MWBase::Environment::get().getWindowManager()->isGuiMode()
|
||||
|| MWBase::Environment::get().getStateManager()->getState() != MWBase::StateManager::State_Running))
|
||||
@ -355,34 +452,74 @@ namespace MWInput
|
||||
if (mControlSwitch["playercontrols"])
|
||||
{
|
||||
bool triedToMove = false;
|
||||
if (actionIsActive(A_MoveLeft))
|
||||
bool isRunning = false;
|
||||
if(mJoystickLastUsed)
|
||||
{
|
||||
triedToMove = true;
|
||||
mPlayer->setLeftRight (-1);
|
||||
}
|
||||
else if (actionIsActive(A_MoveRight))
|
||||
{
|
||||
triedToMove = true;
|
||||
mPlayer->setLeftRight (1);
|
||||
}
|
||||
float xAxis = mInputBinder->getChannel(A_MoveLeftRight)->getValue();
|
||||
float yAxis = mInputBinder->getChannel(A_MoveForwardBackward)->getValue();
|
||||
if (xAxis < .5)
|
||||
{
|
||||
triedToMove = true;
|
||||
mPlayer->setLeftRight (-1);
|
||||
}
|
||||
else if (xAxis > .5)
|
||||
{
|
||||
triedToMove = true;
|
||||
mPlayer->setLeftRight (1);
|
||||
}
|
||||
|
||||
if (actionIsActive(A_MoveForward))
|
||||
{
|
||||
triedToMove = true;
|
||||
mPlayer->setAutoMove (false);
|
||||
mPlayer->setForwardBackward (1);
|
||||
}
|
||||
else if (actionIsActive(A_MoveBackward))
|
||||
{
|
||||
triedToMove = true;
|
||||
mPlayer->setAutoMove (false);
|
||||
mPlayer->setForwardBackward (-1);
|
||||
}
|
||||
if (yAxis < .5)
|
||||
{
|
||||
triedToMove = true;
|
||||
mPlayer->setAutoMove (false);
|
||||
mPlayer->setForwardBackward (1);
|
||||
}
|
||||
else if (yAxis > .5)
|
||||
{
|
||||
triedToMove = true;
|
||||
mPlayer->setAutoMove (false);
|
||||
mPlayer->setForwardBackward (-1);
|
||||
}
|
||||
|
||||
else if(mPlayer->getAutoMove())
|
||||
else if(mPlayer->getAutoMove())
|
||||
{
|
||||
triedToMove = true;
|
||||
mPlayer->setForwardBackward (1);
|
||||
}
|
||||
isRunning = xAxis > .75 || xAxis < .25 || yAxis > .75 || yAxis < .25;
|
||||
if(triedToMove) resetIdleTime();
|
||||
}
|
||||
else
|
||||
{
|
||||
triedToMove = true;
|
||||
mPlayer->setForwardBackward (1);
|
||||
if (actionIsActive(A_MoveLeft))
|
||||
{
|
||||
triedToMove = true;
|
||||
mPlayer->setLeftRight (-1);
|
||||
}
|
||||
else if (actionIsActive(A_MoveRight))
|
||||
{
|
||||
triedToMove = true;
|
||||
mPlayer->setLeftRight (1);
|
||||
}
|
||||
|
||||
if (actionIsActive(A_MoveForward))
|
||||
{
|
||||
triedToMove = true;
|
||||
mPlayer->setAutoMove (false);
|
||||
mPlayer->setForwardBackward (1);
|
||||
}
|
||||
else if (actionIsActive(A_MoveBackward))
|
||||
{
|
||||
triedToMove = true;
|
||||
mPlayer->setAutoMove (false);
|
||||
mPlayer->setForwardBackward (-1);
|
||||
}
|
||||
|
||||
else if(mPlayer->getAutoMove())
|
||||
{
|
||||
triedToMove = true;
|
||||
mPlayer->setForwardBackward (1);
|
||||
}
|
||||
}
|
||||
|
||||
mPlayer->setSneak(actionIsActive(A_Sneak));
|
||||
@ -394,7 +531,7 @@ namespace MWInput
|
||||
mOverencumberedMessageDelay = 0.f;
|
||||
}
|
||||
|
||||
if (mAlwaysRunActive)
|
||||
if (mAlwaysRunActive || isRunning)
|
||||
mPlayer->setRunState(!actionIsActive(A_Run));
|
||||
else
|
||||
mPlayer->setRunState(actionIsActive(A_Run));
|
||||
@ -538,6 +675,7 @@ namespace MWInput
|
||||
}
|
||||
if (!mControlsDisabled && !consumed)
|
||||
mInputBinder->keyPressed (arg);
|
||||
mJoystickLastUsed = false;
|
||||
}
|
||||
|
||||
void InputManager::textInput(const SDL_TextInputEvent &arg)
|
||||
@ -550,6 +688,7 @@ namespace MWInput
|
||||
|
||||
void InputManager::keyReleased(const SDL_KeyboardEvent &arg )
|
||||
{
|
||||
mJoystickLastUsed = false;
|
||||
OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(arg.keysym.sym);
|
||||
|
||||
setPlayerControlsEnabled(!MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::Enum(kc)));
|
||||
@ -558,6 +697,7 @@ namespace MWInput
|
||||
|
||||
void InputManager::mousePressed( const SDL_MouseButtonEvent &arg, Uint8 id )
|
||||
{
|
||||
mJoystickLastUsed = false;
|
||||
bool guiMode = false;
|
||||
|
||||
if (id == SDL_BUTTON_LEFT || id == SDL_BUTTON_RIGHT) // MyGUI only uses these mouse events
|
||||
@ -582,7 +722,8 @@ namespace MWInput
|
||||
}
|
||||
|
||||
void InputManager::mouseReleased( const SDL_MouseButtonEvent &arg, Uint8 id )
|
||||
{
|
||||
{
|
||||
mJoystickLastUsed = false;
|
||||
|
||||
if(mInputBinder->detectingBindingState())
|
||||
{
|
||||
@ -602,6 +743,7 @@ namespace MWInput
|
||||
{
|
||||
mInputBinder->mouseMoved (arg);
|
||||
|
||||
mJoystickLastUsed = false;
|
||||
resetIdleTime ();
|
||||
|
||||
if (mGuiCursorEnabled)
|
||||
@ -650,6 +792,78 @@ namespace MWInput
|
||||
}
|
||||
}
|
||||
|
||||
void InputManager::buttonPressed(int deviceID, const SDL_ControllerButtonEvent &arg )
|
||||
{
|
||||
mJoystickLastUsed = true;
|
||||
bool guiMode = false;
|
||||
|
||||
if (arg.button == SDL_CONTROLLER_BUTTON_A || arg.button == SDL_CONTROLLER_BUTTON_B) // We'll pretend that A is left click and B is right click
|
||||
{
|
||||
guiMode = MWBase::Environment::get().getWindowManager()->isGuiMode();
|
||||
if(!mInputBinder->detectingBindingState())
|
||||
{
|
||||
guiMode = MyGUI::InputManager::getInstance().injectMousePress(mMouseX, mMouseY, sdlButtonToMyGUI((arg.button == SDL_CONTROLLER_BUTTON_B) ? SDL_BUTTON_RIGHT : SDL_BUTTON_LEFT)) && guiMode;
|
||||
if (MyGUI::InputManager::getInstance ().getMouseFocusWidget () != 0)
|
||||
{
|
||||
MyGUI::Button* b = MyGUI::InputManager::getInstance ().getMouseFocusWidget ()->castType<MyGUI::Button>(false);
|
||||
if (b && b->getEnabled())
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager ()->playSound ("Menu Click", 1.f, 1.f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setPlayerControlsEnabled(!guiMode);
|
||||
|
||||
//esc, to leave inital movie screen
|
||||
OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(SDLK_ESCAPE);
|
||||
bool guiFocus = MyGUI::InputManager::getInstance().injectKeyPress(MyGUI::KeyCode::Enum(kc), 0);
|
||||
setPlayerControlsEnabled(!guiFocus);
|
||||
|
||||
if (!mControlsDisabled)
|
||||
mInputBinder->buttonPressed(deviceID, arg);
|
||||
}
|
||||
|
||||
void InputManager::buttonReleased(int deviceID, const SDL_ControllerButtonEvent &arg )
|
||||
{
|
||||
mJoystickLastUsed = true;
|
||||
if(mInputBinder->detectingBindingState())
|
||||
mInputBinder->buttonReleased(deviceID, arg);
|
||||
else if(arg.button == SDL_CONTROLLER_BUTTON_A || arg.button == SDL_CONTROLLER_BUTTON_B)
|
||||
{
|
||||
bool guiMode = MWBase::Environment::get().getWindowManager()->isGuiMode();
|
||||
guiMode = MyGUI::InputManager::getInstance().injectMouseRelease(mMouseX, mMouseY, sdlButtonToMyGUI((arg.button == SDL_CONTROLLER_BUTTON_B) ? SDL_BUTTON_RIGHT : SDL_BUTTON_LEFT)) && guiMode;
|
||||
|
||||
if(mInputBinder->detectingBindingState()) return; // don't allow same mouseup to bind as initiated bind
|
||||
|
||||
setPlayerControlsEnabled(!guiMode);
|
||||
mInputBinder->buttonReleased(deviceID, arg);
|
||||
}
|
||||
else
|
||||
mInputBinder->buttonReleased(deviceID, arg);
|
||||
|
||||
//to escape inital movie
|
||||
OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(SDLK_ESCAPE);
|
||||
setPlayerControlsEnabled(!MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::Enum(kc)));
|
||||
}
|
||||
|
||||
void InputManager::axisMoved(int deviceID, const SDL_ControllerAxisEvent &arg )
|
||||
{
|
||||
mJoystickLastUsed = true;
|
||||
if (!mControlsDisabled)
|
||||
mInputBinder->axisMoved(deviceID, arg);
|
||||
}
|
||||
|
||||
void InputManager::controllerAdded(int deviceID, const SDL_ControllerDeviceEvent &arg)
|
||||
{
|
||||
mInputBinder->controllerAdded(deviceID, arg);
|
||||
}
|
||||
void InputManager::controllerRemoved(const SDL_ControllerDeviceEvent &arg)
|
||||
{
|
||||
mInputBinder->controllerRemoved(arg);
|
||||
}
|
||||
|
||||
void InputManager::windowFocusChange(bool have_focus)
|
||||
{
|
||||
}
|
||||
@ -895,7 +1109,7 @@ namespace MWInput
|
||||
|
||||
bool InputManager::actionIsActive (int id)
|
||||
{
|
||||
return mInputBinder->getChannel (id)->getValue () == 1;
|
||||
return (mInputBinder->getChannel (id)->getValue ()==1.0);
|
||||
}
|
||||
|
||||
void InputManager::loadKeyDefaults (bool force)
|
||||
@ -968,14 +1182,88 @@ namespace MWInput
|
||||
&& mInputBinder->getMouseButtonBinding (control, ICS::Control::INCREASE) == ICS_MAX_DEVICE_BUTTONS
|
||||
))
|
||||
{
|
||||
clearAllBindings (control);
|
||||
clearAllKeyBindings(control);
|
||||
|
||||
if (defaultKeyBindings.find(i) != defaultKeyBindings.end()
|
||||
&& !mInputBinder->isKeyBound(defaultKeyBindings[i]))
|
||||
{
|
||||
control->setInitialValue(0.0f);
|
||||
mInputBinder->addKeyBinding(control, defaultKeyBindings[i], ICS::Control::INCREASE);
|
||||
}
|
||||
else if (defaultMouseButtonBindings.find(i) != defaultMouseButtonBindings.end()
|
||||
&& !mInputBinder->isMouseButtonBound(defaultMouseButtonBindings[i]))
|
||||
{
|
||||
control->setInitialValue(0.0f);
|
||||
mInputBinder->addMouseButtonBinding (control, defaultMouseButtonBindings[i], ICS::Control::INCREASE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InputManager::loadControllerDefaults(bool force)
|
||||
{
|
||||
// using hardcoded key defaults is inevitable, if we want the configuration files to stay valid
|
||||
// across different versions of OpenMW (in the case where another input action is added)
|
||||
std::map<int, int> defaultButtonBindings;
|
||||
|
||||
defaultButtonBindings[A_Activate] = SDL_CONTROLLER_BUTTON_A;
|
||||
defaultButtonBindings[A_ToggleWeapon] = SDL_CONTROLLER_BUTTON_X;
|
||||
defaultButtonBindings[A_ToggleSpell] = SDL_CONTROLLER_BUTTON_LEFTSHOULDER;
|
||||
//defaultButtonBindings[A_QuickButtonsMenu] = SDL_GetButtonFromScancode(SDL_SCANCODE_F1); // Need to implement, should be ToggleSpell(5) AND Wait(9)
|
||||
defaultButtonBindings[A_Sneak] = SDL_CONTROLLER_BUTTON_RIGHTSTICK;
|
||||
defaultButtonBindings[A_Jump] = SDL_CONTROLLER_BUTTON_Y;
|
||||
defaultButtonBindings[A_Journal] = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER;
|
||||
defaultButtonBindings[A_Rest] = SDL_CONTROLLER_BUTTON_BACK;
|
||||
defaultButtonBindings[A_TogglePOV] = SDL_CONTROLLER_BUTTON_LEFTSTICK;
|
||||
defaultButtonBindings[A_Inventory] = SDL_CONTROLLER_BUTTON_B;
|
||||
defaultButtonBindings[A_GameMenu] = SDL_CONTROLLER_BUTTON_START;
|
||||
defaultButtonBindings[A_QuickSave] = SDL_CONTROLLER_BUTTON_GUIDE;
|
||||
defaultButtonBindings[A_QuickKey1] = SDL_CONTROLLER_BUTTON_DPAD_UP;
|
||||
defaultButtonBindings[A_QuickKey2] = SDL_CONTROLLER_BUTTON_DPAD_LEFT;
|
||||
defaultButtonBindings[A_QuickKey3] = SDL_CONTROLLER_BUTTON_DPAD_DOWN;
|
||||
defaultButtonBindings[A_QuickKey4] = SDL_CONTROLLER_BUTTON_DPAD_RIGHT;
|
||||
|
||||
std::map<int, int> defaultAxisBindings;
|
||||
defaultAxisBindings[A_MoveForwardBackward] = SDL_CONTROLLER_AXIS_LEFTY;
|
||||
defaultAxisBindings[A_MoveLeftRight] = SDL_CONTROLLER_AXIS_LEFTX;
|
||||
defaultAxisBindings[A_LookUpDown] = SDL_CONTROLLER_AXIS_RIGHTY;
|
||||
defaultAxisBindings[A_LookLeftRight] = SDL_CONTROLLER_AXIS_RIGHTX;
|
||||
defaultAxisBindings[A_Use] = SDL_CONTROLLER_AXIS_TRIGGERRIGHT;
|
||||
|
||||
for (int i = 0; i < A_Last; i++)
|
||||
{
|
||||
ICS::Control* control;
|
||||
bool controlExists = mInputBinder->getChannel(i)->getControlsCount () != 0;
|
||||
if (!controlExists)
|
||||
{
|
||||
int inital;
|
||||
if (defaultButtonBindings.find(i) != defaultButtonBindings.end())
|
||||
inital = 0.0f;
|
||||
else inital = 0.5f;
|
||||
control = new ICS::Control(boost::lexical_cast<std::string>(i), false, true, inital, ICS::ICS_MAX, ICS::ICS_MAX);
|
||||
mInputBinder->addControl(control);
|
||||
control->attachChannel(mInputBinder->getChannel(i), ICS::Channel::DIRECT);
|
||||
}
|
||||
else
|
||||
{
|
||||
control = mInputBinder->getChannel(i)->getAttachedControls ().front().control;
|
||||
}
|
||||
|
||||
if (!controlExists || force || ( mInputBinder->getJoystickAxisBinding (control, mFakeDeviceID, ICS::Control::INCREASE) == ICS::InputControlSystem::UNASSIGNED && mInputBinder->getJoystickButtonBinding (control, mFakeDeviceID, ICS::Control::INCREASE) == ICS_MAX_DEVICE_BUTTONS ))
|
||||
{
|
||||
clearAllControllerBindings(control);
|
||||
|
||||
if (defaultButtonBindings.find(i) != defaultButtonBindings.end())
|
||||
{
|
||||
control->setInitialValue(0.0f);
|
||||
mInputBinder->addJoystickButtonBinding(control, mFakeDeviceID, defaultButtonBindings[i], ICS::Control::INCREASE);
|
||||
}
|
||||
else if (defaultAxisBindings.find(i) != defaultAxisBindings.end())
|
||||
{
|
||||
control->setValue(0.5f);
|
||||
control->setInitialValue(0.5f);
|
||||
mInputBinder->addJoystickAxisBinding(control, mFakeDeviceID, defaultAxisBindings[i], ICS::Control::INCREASE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1029,7 +1317,7 @@ namespace MWInput
|
||||
return "#{" + descriptions[action] + "}";
|
||||
}
|
||||
|
||||
std::string InputManager::getActionBindingName (int action)
|
||||
std::string InputManager::getActionKeyBindingName (int action)
|
||||
{
|
||||
if (mInputBinder->getChannel (action)->getControlsCount () == 0)
|
||||
return "#{sNone}";
|
||||
@ -1044,7 +1332,81 @@ namespace MWInput
|
||||
return "#{sNone}";
|
||||
}
|
||||
|
||||
std::vector<int> InputManager::getActionSorting()
|
||||
std::string InputManager::getActionControllerBindingName (int action)
|
||||
{
|
||||
if (mInputBinder->getChannel (action)->getControlsCount () == 0)
|
||||
return "#{sNone}";
|
||||
|
||||
ICS::Control* c = mInputBinder->getChannel (action)->getAttachedControls ().front().control;
|
||||
|
||||
if (mInputBinder->getJoystickAxisBinding (c, mFakeDeviceID, ICS::Control::INCREASE) != ICS::InputControlSystem::UNASSIGNED)
|
||||
return sdlControllerAxisToString(mInputBinder->getJoystickAxisBinding (c, mFakeDeviceID, ICS::Control::INCREASE));
|
||||
else if (mInputBinder->getJoystickButtonBinding (c, mFakeDeviceID, ICS::Control::INCREASE) != ICS_MAX_DEVICE_BUTTONS )
|
||||
return sdlControllerButtonToString(mInputBinder->getJoystickButtonBinding (c, mFakeDeviceID, ICS::Control::INCREASE));
|
||||
else
|
||||
return "#{sNone}";
|
||||
}
|
||||
|
||||
std::string InputManager::sdlControllerButtonToString(int button)
|
||||
{
|
||||
switch(button)
|
||||
{
|
||||
case SDL_CONTROLLER_BUTTON_A:
|
||||
return "A Button";
|
||||
case SDL_CONTROLLER_BUTTON_B:
|
||||
return "B Button";
|
||||
case SDL_CONTROLLER_BUTTON_BACK:
|
||||
return "Back Button";
|
||||
case SDL_CONTROLLER_BUTTON_DPAD_DOWN:
|
||||
return "DPad Down";
|
||||
case SDL_CONTROLLER_BUTTON_DPAD_LEFT:
|
||||
return "DPad Left";
|
||||
case SDL_CONTROLLER_BUTTON_DPAD_RIGHT:
|
||||
return "DPad Right";
|
||||
case SDL_CONTROLLER_BUTTON_DPAD_UP:
|
||||
return "DPad Up";
|
||||
case SDL_CONTROLLER_BUTTON_GUIDE:
|
||||
return "Guide Button";
|
||||
case SDL_CONTROLLER_BUTTON_LEFTSHOULDER:
|
||||
return "Left Shoulder";
|
||||
case SDL_CONTROLLER_BUTTON_LEFTSTICK:
|
||||
return "Left Stick Button";
|
||||
case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER:
|
||||
return "Right Shoulder";
|
||||
case SDL_CONTROLLER_BUTTON_RIGHTSTICK:
|
||||
return "Right Stick Button";
|
||||
case SDL_CONTROLLER_BUTTON_START:
|
||||
return "Start Button";
|
||||
case SDL_CONTROLLER_BUTTON_X:
|
||||
return "X Button";
|
||||
case SDL_CONTROLLER_BUTTON_Y:
|
||||
return "Y Button";
|
||||
default:
|
||||
return "Button " + boost::lexical_cast<std::string>(button);
|
||||
}
|
||||
}
|
||||
std::string InputManager::sdlControllerAxisToString(int axis)
|
||||
{
|
||||
switch(axis)
|
||||
{
|
||||
case SDL_CONTROLLER_AXIS_LEFTX:
|
||||
return "Left Stick X";
|
||||
case SDL_CONTROLLER_AXIS_LEFTY:
|
||||
return "Left Stick Y";
|
||||
case SDL_CONTROLLER_AXIS_RIGHTX:
|
||||
return "Right Stick X";
|
||||
case SDL_CONTROLLER_AXIS_RIGHTY:
|
||||
return "Right Stick Y";
|
||||
case SDL_CONTROLLER_AXIS_TRIGGERLEFT:
|
||||
return "Left Trigger";
|
||||
case SDL_CONTROLLER_AXIS_TRIGGERRIGHT:
|
||||
return "Right Trigger";
|
||||
default:
|
||||
return "Axis " + boost::lexical_cast<std::string>(axis);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<int> InputManager::getActionKeySorting()
|
||||
{
|
||||
std::vector<int> ret;
|
||||
ret.push_back(A_MoveForward);
|
||||
@ -1086,11 +1448,42 @@ namespace MWInput
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void InputManager::enableDetectingBindingMode (int action)
|
||||
std::vector<int> InputManager::getActionControllerSorting()
|
||||
{
|
||||
ICS::Control* c = mInputBinder->getChannel (action)->getAttachedControls ().front().control;
|
||||
std::vector<int> ret;
|
||||
ret.push_back(A_TogglePOV);
|
||||
ret.push_back(A_Sneak);
|
||||
ret.push_back(A_Activate);
|
||||
ret.push_back(A_Use);
|
||||
ret.push_back(A_ToggleWeapon);
|
||||
ret.push_back(A_ToggleSpell);
|
||||
ret.push_back(A_AutoMove);
|
||||
ret.push_back(A_Jump);
|
||||
ret.push_back(A_Inventory);
|
||||
ret.push_back(A_Journal);
|
||||
ret.push_back(A_Rest);
|
||||
ret.push_back(A_QuickSave);
|
||||
ret.push_back(A_QuickLoad);
|
||||
ret.push_back(A_Screenshot);
|
||||
ret.push_back(A_QuickKeysMenu);
|
||||
ret.push_back(A_QuickKey1);
|
||||
ret.push_back(A_QuickKey2);
|
||||
ret.push_back(A_QuickKey3);
|
||||
ret.push_back(A_QuickKey4);
|
||||
ret.push_back(A_QuickKey5);
|
||||
ret.push_back(A_QuickKey6);
|
||||
ret.push_back(A_QuickKey7);
|
||||
ret.push_back(A_QuickKey8);
|
||||
ret.push_back(A_QuickKey9);
|
||||
ret.push_back(A_QuickKey10);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void InputManager::enableDetectingBindingMode (int action, bool keyboard)
|
||||
{
|
||||
mDetectingKeyboard = keyboard;
|
||||
ICS::Control* c = mInputBinder->getChannel (action)->getAttachedControls ().front().control;
|
||||
mInputBinder->enableDetectingBindingState (c, ICS::Control::INCREASE);
|
||||
}
|
||||
|
||||
@ -1106,9 +1499,17 @@ namespace MWInput
|
||||
{
|
||||
//Disallow binding escape key
|
||||
if(key==SDL_SCANCODE_ESCAPE)
|
||||
{
|
||||
//Stop binding if esc pressed
|
||||
mInputBinder->cancelDetectingBindingState();
|
||||
MWBase::Environment::get().getWindowManager ()->notifyInputActionBound ();
|
||||
return;
|
||||
}
|
||||
if(!mDetectingKeyboard)
|
||||
return;
|
||||
|
||||
clearAllBindings(control);
|
||||
clearAllKeyBindings(control);
|
||||
control->setInitialValue(0.0f);
|
||||
ICS::DetectingBindingListener::keyBindingDetected (ICS, control, key, direction);
|
||||
MWBase::Environment::get().getWindowManager ()->notifyInputActionBound ();
|
||||
}
|
||||
@ -1116,59 +1517,69 @@ namespace MWInput
|
||||
void InputManager::mouseButtonBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
|
||||
, unsigned int button, ICS::Control::ControlChangingDirection direction)
|
||||
{
|
||||
clearAllBindings(control);
|
||||
if(!mDetectingKeyboard)
|
||||
return;
|
||||
clearAllKeyBindings(control);
|
||||
control->setInitialValue(0.0f);
|
||||
ICS::DetectingBindingListener::mouseButtonBindingDetected (ICS, control, button, direction);
|
||||
MWBase::Environment::get().getWindowManager ()->notifyInputActionBound ();
|
||||
}
|
||||
|
||||
void InputManager::joystickAxisBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
|
||||
, int deviceId, int axis, ICS::Control::ControlChangingDirection direction)
|
||||
void InputManager::joystickAxisBindingDetected(ICS::InputControlSystem* ICS, int deviceID, ICS::Control* control
|
||||
, int axis, ICS::Control::ControlChangingDirection direction)
|
||||
{
|
||||
clearAllBindings(control);
|
||||
ICS::DetectingBindingListener::joystickAxisBindingDetected (ICS, control, deviceId, axis, direction);
|
||||
//only allow binding to the trigers
|
||||
if(axis != SDL_CONTROLLER_AXIS_TRIGGERLEFT && axis != SDL_CONTROLLER_AXIS_TRIGGERRIGHT)
|
||||
return;
|
||||
if(mDetectingKeyboard)
|
||||
return;
|
||||
|
||||
clearAllControllerBindings(control);
|
||||
control->setValue(0.5f); //axis bindings must start at 0.5
|
||||
control->setInitialValue(0.5f);
|
||||
ICS::DetectingBindingListener::joystickAxisBindingDetected (ICS, deviceID, control, axis, direction);
|
||||
MWBase::Environment::get().getWindowManager ()->notifyInputActionBound ();
|
||||
}
|
||||
|
||||
void InputManager::joystickButtonBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
|
||||
, int deviceId, unsigned int button, ICS::Control::ControlChangingDirection direction)
|
||||
void InputManager::joystickButtonBindingDetected(ICS::InputControlSystem* ICS, int deviceID, ICS::Control* control
|
||||
, unsigned int button, ICS::Control::ControlChangingDirection direction)
|
||||
{
|
||||
clearAllBindings(control);
|
||||
ICS::DetectingBindingListener::joystickButtonBindingDetected (ICS, control, deviceId, button, direction);
|
||||
if(mDetectingKeyboard)
|
||||
return;
|
||||
clearAllControllerBindings(control);
|
||||
control->setInitialValue(0.0f);
|
||||
ICS::DetectingBindingListener::joystickButtonBindingDetected (ICS, deviceID, control, button, direction);
|
||||
MWBase::Environment::get().getWindowManager ()->notifyInputActionBound ();
|
||||
}
|
||||
|
||||
void InputManager::joystickPOVBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
|
||||
, int deviceId, int pov,ICS:: InputControlSystem::POVAxis axis, ICS::Control::ControlChangingDirection direction)
|
||||
{
|
||||
clearAllBindings(control);
|
||||
ICS::DetectingBindingListener::joystickPOVBindingDetected (ICS, control, deviceId, pov, axis, direction);
|
||||
MWBase::Environment::get().getWindowManager ()->notifyInputActionBound ();
|
||||
}
|
||||
|
||||
void InputManager::joystickSliderBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
|
||||
, int deviceId, int slider, ICS::Control::ControlChangingDirection direction)
|
||||
{
|
||||
clearAllBindings(control);
|
||||
ICS::DetectingBindingListener::joystickSliderBindingDetected (ICS, control, deviceId, slider, direction);
|
||||
MWBase::Environment::get().getWindowManager ()->notifyInputActionBound ();
|
||||
}
|
||||
|
||||
void InputManager::clearAllBindings (ICS::Control* control)
|
||||
void InputManager::clearAllKeyBindings (ICS::Control* control)
|
||||
{
|
||||
// right now we don't really need multiple bindings for the same action, so remove all others first
|
||||
if (mInputBinder->getKeyBinding (control, ICS::Control::INCREASE) != SDL_SCANCODE_UNKNOWN)
|
||||
mInputBinder->removeKeyBinding (mInputBinder->getKeyBinding (control, ICS::Control::INCREASE));
|
||||
if (mInputBinder->getMouseButtonBinding (control, ICS::Control::INCREASE) != ICS_MAX_DEVICE_BUTTONS)
|
||||
mInputBinder->removeMouseButtonBinding (mInputBinder->getMouseButtonBinding (control, ICS::Control::INCREASE));
|
||||
|
||||
/// \todo add joysticks here once they are added
|
||||
}
|
||||
|
||||
void InputManager::resetToDefaultBindings()
|
||||
void InputManager::clearAllControllerBindings (ICS::Control* control)
|
||||
{
|
||||
// right now we don't really need multiple bindings for the same action, so remove all others first
|
||||
if (mInputBinder->getJoystickAxisBinding (control, mFakeDeviceID, ICS::Control::INCREASE) != SDL_SCANCODE_UNKNOWN)
|
||||
mInputBinder->removeJoystickAxisBinding (mFakeDeviceID, mInputBinder->getJoystickAxisBinding (control, mFakeDeviceID, ICS::Control::INCREASE));
|
||||
if (mInputBinder->getJoystickButtonBinding (control, mFakeDeviceID, ICS::Control::INCREASE) != ICS_MAX_DEVICE_BUTTONS)
|
||||
mInputBinder->removeJoystickButtonBinding (mFakeDeviceID, mInputBinder->getJoystickButtonBinding (control, mFakeDeviceID, ICS::Control::INCREASE));
|
||||
}
|
||||
|
||||
void InputManager::resetToDefaultKeyBindings()
|
||||
{
|
||||
loadKeyDefaults(true);
|
||||
}
|
||||
|
||||
void InputManager::resetToDefaultControllerBindings()
|
||||
{
|
||||
loadControllerDefaults(true);
|
||||
}
|
||||
|
||||
MyGUI::MouseButton InputManager::sdlButtonToMyGUI(Uint8 button)
|
||||
{
|
||||
//The right button is the second button, according to MyGUI
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "../mwgui/mode.hpp"
|
||||
|
||||
#include <components/settings/settings.hpp>
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
|
||||
#include "../mwbase/inputmanager.hpp"
|
||||
#include <extern/sdl4ogre/sdlinputwrapper.hpp>
|
||||
@ -41,6 +42,11 @@ namespace MyGUI
|
||||
class MouseButton;
|
||||
}
|
||||
|
||||
namespace Files
|
||||
{
|
||||
struct ConfigurationManager;
|
||||
}
|
||||
|
||||
#include <extern/oics/ICSChannelListener.h>
|
||||
#include <extern/oics/ICSInputControlSystem.h>
|
||||
|
||||
@ -55,13 +61,15 @@ namespace MWInput
|
||||
public SFO::KeyListener,
|
||||
public SFO::MouseListener,
|
||||
public SFO::WindowListener,
|
||||
public SFO::ControllerListener,
|
||||
public ICS::ChannelListener,
|
||||
public ICS::DetectingBindingListener
|
||||
{
|
||||
public:
|
||||
InputManager(OEngine::Render::OgreRenderer &_ogre,
|
||||
OMW::Engine& engine,
|
||||
const std::string& userFile, bool userFileExists, bool grab);
|
||||
const std::string& userFile, bool userFileExists,
|
||||
const std::string& controllerBindingsFile, bool grab);
|
||||
|
||||
virtual ~InputManager();
|
||||
|
||||
@ -82,11 +90,16 @@ namespace MWInput
|
||||
virtual bool getControlSwitch (const std::string& sw);
|
||||
|
||||
virtual std::string getActionDescription (int action);
|
||||
virtual std::string getActionBindingName (int action);
|
||||
virtual std::string getActionKeyBindingName (int action);
|
||||
virtual std::string getActionControllerBindingName (int action);
|
||||
virtual int getNumActions() { return A_Last; }
|
||||
virtual std::vector<int> getActionSorting ();
|
||||
virtual void enableDetectingBindingMode (int action);
|
||||
virtual void resetToDefaultBindings();
|
||||
virtual std::vector<int> getActionKeySorting();
|
||||
virtual std::vector<int> getActionControllerSorting();
|
||||
virtual void enableDetectingBindingMode (int action, bool keyboard);
|
||||
virtual void resetToDefaultKeyBindings();
|
||||
virtual void resetToDefaultControllerBindings();
|
||||
|
||||
virtual bool joystickLastUsed() {return mJoystickLastUsed;}
|
||||
|
||||
public:
|
||||
virtual void keyPressed(const SDL_KeyboardEvent &arg );
|
||||
@ -97,6 +110,12 @@ namespace MWInput
|
||||
virtual void mouseReleased( const SDL_MouseButtonEvent &arg, Uint8 id );
|
||||
virtual void mouseMoved( const SFO::MouseMotionEvent &arg );
|
||||
|
||||
virtual void buttonPressed(int deviceID, const SDL_ControllerButtonEvent &arg);
|
||||
virtual void buttonReleased(int deviceID, const SDL_ControllerButtonEvent &arg);
|
||||
virtual void axisMoved(int deviceID, const SDL_ControllerAxisEvent &arg);
|
||||
virtual void controllerAdded(int deviceID, const SDL_ControllerDeviceEvent &arg);
|
||||
virtual void controllerRemoved(const SDL_ControllerDeviceEvent &arg);
|
||||
|
||||
virtual void windowVisibilityChange( bool visible );
|
||||
virtual void windowFocusChange( bool have_focus );
|
||||
virtual void windowResized (int x, int y);
|
||||
@ -113,21 +132,17 @@ namespace MWInput
|
||||
virtual void mouseButtonBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
|
||||
, unsigned int button, ICS::Control::ControlChangingDirection direction);
|
||||
|
||||
virtual void joystickAxisBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
|
||||
, int deviceId, int axis, ICS::Control::ControlChangingDirection direction);
|
||||
virtual void joystickAxisBindingDetected(ICS::InputControlSystem* ICS, int deviceID, ICS::Control* control
|
||||
, int axis, ICS::Control::ControlChangingDirection direction);
|
||||
|
||||
virtual void joystickButtonBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
|
||||
, int deviceId, unsigned int button, ICS::Control::ControlChangingDirection direction);
|
||||
virtual void joystickButtonBindingDetected(ICS::InputControlSystem* ICS, int deviceID, ICS::Control* control
|
||||
, unsigned int button, ICS::Control::ControlChangingDirection direction);
|
||||
|
||||
virtual void joystickPOVBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
|
||||
, int deviceId, int pov,ICS:: InputControlSystem::POVAxis axis, ICS::Control::ControlChangingDirection direction);
|
||||
|
||||
virtual void joystickSliderBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
|
||||
, int deviceId, int slider, ICS::Control::ControlChangingDirection direction);
|
||||
|
||||
void clearAllBindings (ICS::Control* control);
|
||||
void clearAllKeyBindings (ICS::Control* control);
|
||||
void clearAllControllerBindings (ICS::Control* control);
|
||||
|
||||
private:
|
||||
bool mJoystickLastUsed;
|
||||
OEngine::Render::OgreRenderer &mOgre;
|
||||
MWWorld::Player* mPlayer;
|
||||
OMW::Engine& mEngine;
|
||||
@ -156,6 +171,8 @@ namespace MWInput
|
||||
bool mMouseLookEnabled;
|
||||
bool mGuiCursorEnabled;
|
||||
|
||||
bool mDetectingKeyboard;
|
||||
|
||||
float mOverencumberedMessageDelay;
|
||||
|
||||
float mMouseX;
|
||||
@ -171,6 +188,9 @@ namespace MWInput
|
||||
void adjustMouseRegion(int width, int height);
|
||||
MyGUI::MouseButton sdlButtonToMyGUI(Uint8 button);
|
||||
|
||||
virtual std::string sdlControllerAxisToString(int axis);
|
||||
virtual std::string sdlControllerButtonToString(int button);
|
||||
|
||||
void resetIdleTime();
|
||||
void updateIdleTime(float dt);
|
||||
|
||||
@ -199,6 +219,9 @@ namespace MWInput
|
||||
bool actionIsActive (int id);
|
||||
|
||||
void loadKeyDefaults(bool force = false);
|
||||
void loadControllerDefaults(bool force = false);
|
||||
|
||||
int mFakeDeviceID; //As we only support one controller at a time, use a fake deviceID so we don't lose bindings when switching controllers
|
||||
|
||||
private:
|
||||
enum Actions
|
||||
@ -263,6 +286,11 @@ namespace MWInput
|
||||
|
||||
A_ToggleDebug,
|
||||
|
||||
A_LookUpDown, //Joystick look
|
||||
A_LookLeftRight,
|
||||
A_MoveForwardBackward,
|
||||
A_MoveLeftRight,
|
||||
|
||||
A_Last // Marker for the last item
|
||||
};
|
||||
};
|
||||
|
@ -270,15 +270,21 @@ namespace MWScript
|
||||
|
||||
std::string InterpreterContext::getActionBinding(const std::string& action) const
|
||||
{
|
||||
std::vector<int> actions = MWBase::Environment::get().getInputManager()->getActionSorting ();
|
||||
MWBase::InputManager* input = MWBase::Environment::get().getInputManager();
|
||||
std::vector<int> actions = input->getActionKeySorting ();
|
||||
for (std::vector<int>::const_iterator it = actions.begin(); it != actions.end(); ++it)
|
||||
{
|
||||
std::string desc = MWBase::Environment::get().getInputManager()->getActionDescription (*it);
|
||||
std::string desc = input->getActionDescription (*it);
|
||||
if(desc == "")
|
||||
continue;
|
||||
|
||||
if(desc == action)
|
||||
return MWBase::Environment::get().getInputManager()->getActionBindingName (*it);
|
||||
{
|
||||
if(input->joystickLastUsed())
|
||||
return input->getActionControllerBindingName(*it);
|
||||
else
|
||||
return input->getActionKeyBindingName (*it);
|
||||
}
|
||||
}
|
||||
|
||||
return "None";
|
||||
|
18
extern/oics/ICSControl.cpp
vendored
18
extern/oics/ICSControl.cpp
vendored
@ -43,10 +43,10 @@ namespace ICS
|
||||
, mAxisBindable(axisBindable)
|
||||
, currentChangingDirection(STOP)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
Control::~Control()
|
||||
Control::~Control()
|
||||
{
|
||||
mAttachedChannels.clear();
|
||||
}
|
||||
@ -92,7 +92,7 @@ namespace ICS
|
||||
}
|
||||
|
||||
void Control::setChangingDirection(ControlChangingDirection direction)
|
||||
{
|
||||
{
|
||||
currentChangingDirection = direction;
|
||||
mPendingActions.push_back(direction);
|
||||
}
|
||||
@ -102,9 +102,9 @@ namespace ICS
|
||||
if(!mPendingActions.empty())
|
||||
{
|
||||
size_t timedActionsCount = 0;
|
||||
|
||||
|
||||
std::list<Control::ControlChangingDirection>::iterator cached_end = mPendingActions.end();
|
||||
for(std::list<Control::ControlChangingDirection>::iterator it = mPendingActions.begin() ;
|
||||
for(std::list<Control::ControlChangingDirection>::iterator it = mPendingActions.begin() ;
|
||||
it != cached_end ; ++it)
|
||||
{
|
||||
if( (*it) != Control::STOP )
|
||||
@ -112,14 +112,14 @@ namespace ICS
|
||||
timedActionsCount++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
float timeSinceLastFramePart = timeSinceLastFrame / std::max<size_t>(1, timedActionsCount);
|
||||
for(std::list<Control::ControlChangingDirection>::iterator it = mPendingActions.begin() ;
|
||||
for(std::list<Control::ControlChangingDirection>::iterator it = mPendingActions.begin() ;
|
||||
it != cached_end ; ++it)
|
||||
{
|
||||
if( (*it) != Control::STOP )
|
||||
{
|
||||
this->setValue(mValue +
|
||||
this->setValue(mValue +
|
||||
(((int)(*it)) * mStepSize * mStepsPerSeconds * (timeSinceLastFramePart)));
|
||||
}
|
||||
else if(mAutoReverseToInitialValue && !mIgnoreAutoReverse && mValue != mInitialValue )
|
||||
@ -141,7 +141,7 @@ namespace ICS
|
||||
}
|
||||
else if( currentChangingDirection != Control::STOP )
|
||||
{
|
||||
this->setValue(mValue +
|
||||
this->setValue(mValue +
|
||||
(((int)currentChangingDirection) * mStepSize * mStepsPerSeconds * (timeSinceLastFrame)));
|
||||
}
|
||||
else if(mAutoReverseToInitialValue && !mIgnoreAutoReverse && mValue != mInitialValue )
|
||||
|
7
extern/oics/ICSControl.h
vendored
7
extern/oics/ICSControl.h
vendored
@ -34,7 +34,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
namespace ICS
|
||||
{
|
||||
|
||||
|
||||
class DllExport Control
|
||||
{
|
||||
public:
|
||||
@ -52,9 +52,10 @@ namespace ICS
|
||||
|
||||
void setValue(float value);
|
||||
inline float getValue(){ return mValue; };
|
||||
inline float getInitialValue(){ return mInitialValue; };
|
||||
inline float getInitialValue(){ return mInitialValue; };
|
||||
inline void setInitialValue(float i) {mInitialValue = i;};
|
||||
|
||||
void attachChannel(Channel* channel, Channel::ChannelDirection direction, float percentage = 1.0);
|
||||
void attachChannel(Channel* channel, Channel::ChannelDirection direction, float percentage = 1.0);
|
||||
std::list<Channel*> getAttachedChannels(){ return mAttachedChannels; };
|
||||
|
||||
inline float getStepSize(){ return mStepSize; };
|
||||
|
273
extern/oics/ICSInputControlSystem.cpp
vendored
273
extern/oics/ICSInputControlSystem.cpp
vendored
@ -60,10 +60,10 @@ namespace ICS
|
||||
xmlDoc = new TiXmlDocument(file.c_str());
|
||||
xmlDoc->LoadFile();
|
||||
|
||||
if(xmlDoc->Error())
|
||||
if(xmlDoc->Error())
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "TinyXml reported an error reading \""+ file + "\". Row " <<
|
||||
std::ostringstream message;
|
||||
message << "TinyXml reported an error reading \""+ file + "\". Row " <<
|
||||
(int)xmlDoc->ErrorRow() << ", Col " << (int)xmlDoc->ErrorCol() << ": " <<
|
||||
xmlDoc->ErrorDesc() ;
|
||||
ICS_LOG(message.str());
|
||||
@ -81,10 +81,10 @@ namespace ICS
|
||||
|
||||
TiXmlElement* xmlControl = xmlRoot->FirstChildElement("Control");
|
||||
|
||||
size_t controlChannelCount = 0;
|
||||
while(xmlControl)
|
||||
size_t controlChannelCount = 0;
|
||||
while(xmlControl)
|
||||
{
|
||||
TiXmlElement* xmlChannel = xmlControl->FirstChildElement("Channel");
|
||||
TiXmlElement* xmlChannel = xmlControl->FirstChildElement("Channel");
|
||||
while(xmlChannel)
|
||||
{
|
||||
controlChannelCount = std::max(channelCount, FromString<size_t>(xmlChannel->Attribute("number"))+1);
|
||||
@ -111,7 +111,7 @@ namespace ICS
|
||||
// <interval type="bezier" startX="0.5" startY="0.5" midX="0.75" midY="0.5" endX="1.0" endY="1.0" step="0.1" />
|
||||
//</ChannelFilter>
|
||||
|
||||
TiXmlElement* xmlChannelFilter = xmlRoot->FirstChildElement("ChannelFilter");
|
||||
TiXmlElement* xmlChannelFilter = xmlRoot->FirstChildElement("ChannelFilter");
|
||||
while(xmlChannelFilter)
|
||||
{
|
||||
int ch = FromString<int>(xmlChannelFilter->Attribute("number"));
|
||||
@ -133,12 +133,12 @@ namespace ICS
|
||||
float step = FromString<float>(xmlInterval->Attribute("step"));
|
||||
|
||||
ICS_LOG("Applying Bezier filter to channel [number="
|
||||
+ ToString<int>(ch) + ", startX="
|
||||
+ ToString<float>(startX) + ", startY="
|
||||
+ ToString<float>(startY) + ", midX="
|
||||
+ ToString<float>(midX) + ", midY="
|
||||
+ ToString<float>(midY) + ", endX="
|
||||
+ ToString<float>(endX) + ", endY="
|
||||
+ ToString<int>(ch) + ", startX="
|
||||
+ ToString<float>(startX) + ", startY="
|
||||
+ ToString<float>(startY) + ", midX="
|
||||
+ ToString<float>(midX) + ", midY="
|
||||
+ ToString<float>(midY) + ", endX="
|
||||
+ ToString<float>(endX) + ", endY="
|
||||
+ ToString<float>(endY) + ", step="
|
||||
+ ToString<float>(step) + "]");
|
||||
|
||||
@ -152,8 +152,8 @@ namespace ICS
|
||||
xmlChannelFilter = xmlChannelFilter->NextSiblingElement("ChannelFilter");
|
||||
}
|
||||
|
||||
xmlControl = xmlRoot->FirstChildElement("Control");
|
||||
while(xmlControl)
|
||||
xmlControl = xmlRoot->FirstChildElement("Control");
|
||||
while(xmlControl)
|
||||
{
|
||||
bool axisBindable = true;
|
||||
if(xmlControl->Attribute("axisBindable"))
|
||||
@ -176,11 +176,11 @@ namespace ICS
|
||||
std::string value(xmlControl->Attribute("stepSize"));
|
||||
if(value == "MAX")
|
||||
{
|
||||
_stepSize = ICS_MAX;
|
||||
_stepSize = ICS_MAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
_stepSize = FromString<float>(value.c_str());
|
||||
_stepSize = FromString<float>(value.c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -194,7 +194,7 @@ namespace ICS
|
||||
std::string value(xmlControl->Attribute("stepsPerSeconds"));
|
||||
if(value == "MAX")
|
||||
{
|
||||
_stepsPerSeconds = ICS_MAX;
|
||||
_stepsPerSeconds = ICS_MAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -224,12 +224,8 @@ namespace ICS
|
||||
|
||||
loadJoystickButtonBinders(xmlControl);
|
||||
|
||||
loadJoystickPOVBinders(xmlControl);
|
||||
|
||||
loadJoystickSliderBinders(xmlControl);
|
||||
|
||||
// Attach controls to channels
|
||||
TiXmlElement* xmlChannel = xmlControl->FirstChildElement("Channel");
|
||||
TiXmlElement* xmlChannel = xmlControl->FirstChildElement("Channel");
|
||||
while(xmlChannel)
|
||||
{
|
||||
ICS_LOG("\tAttaching control to channel [number="
|
||||
@ -250,7 +246,7 @@ namespace ICS
|
||||
{
|
||||
percentage = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ICS_LOG("ERROR: attaching percentage value range is [0,1]");
|
||||
@ -338,7 +334,7 @@ namespace ICS
|
||||
for(std::vector<Channel*>::const_iterator o = mChannels.begin() ; o != mChannels.end(); ++o)
|
||||
{
|
||||
ICS::IntervalList intervals = (*o)->getIntervals();
|
||||
|
||||
|
||||
if(intervals.size() > 1) // all channels have a default linear filter
|
||||
{
|
||||
TiXmlElement ChannelFilter( "ChannelFilter" );
|
||||
@ -371,7 +367,7 @@ namespace ICS
|
||||
|
||||
ChannelFilter.InsertEndChild(XMLInterval);
|
||||
}
|
||||
|
||||
|
||||
++interval;
|
||||
}
|
||||
|
||||
@ -401,7 +397,7 @@ namespace ICS
|
||||
control.SetAttribute( "autoReverseToInitialValue", "false" );
|
||||
}
|
||||
control.SetAttribute( "initialValue", ToString<float>((*o)->getInitialValue()).c_str() );
|
||||
|
||||
|
||||
if((*o)->getStepSize() == ICS_MAX)
|
||||
{
|
||||
control.SetAttribute( "stepSize", "MAX" );
|
||||
@ -445,12 +441,12 @@ namespace ICS
|
||||
control.InsertEndChild(keyBinder);
|
||||
}
|
||||
|
||||
if(getMouseAxisBinding(*o, Control/*::ControlChangingDirection*/::INCREASE)
|
||||
if(getMouseAxisBinding(*o, Control/*::ControlChangingDirection*/::INCREASE)
|
||||
!= InputControlSystem/*::NamedAxis*/::UNASSIGNED)
|
||||
{
|
||||
TiXmlElement binder( "MouseBinder" );
|
||||
|
||||
InputControlSystem::NamedAxis axis =
|
||||
InputControlSystem::NamedAxis axis =
|
||||
getMouseAxisBinding(*o, Control/*::ControlChangingDirection*/::INCREASE);
|
||||
if(axis == InputControlSystem/*::NamedAxis*/::X)
|
||||
{
|
||||
@ -469,12 +465,12 @@ namespace ICS
|
||||
control.InsertEndChild(binder);
|
||||
}
|
||||
|
||||
if(getMouseAxisBinding(*o, Control/*::ControlChangingDirection*/::DECREASE)
|
||||
if(getMouseAxisBinding(*o, Control/*::ControlChangingDirection*/::DECREASE)
|
||||
!= InputControlSystem/*::NamedAxis*/::UNASSIGNED)
|
||||
{
|
||||
TiXmlElement binder( "MouseBinder" );
|
||||
|
||||
InputControlSystem::NamedAxis axis =
|
||||
InputControlSystem::NamedAxis axis =
|
||||
getMouseAxisBinding(*o, Control/*::ControlChangingDirection*/::DECREASE);
|
||||
if(axis == InputControlSystem/*::NamedAxis*/::X)
|
||||
{
|
||||
@ -493,7 +489,7 @@ namespace ICS
|
||||
control.InsertEndChild(binder);
|
||||
}
|
||||
|
||||
if(getMouseButtonBinding(*o, Control/*::ControlChangingDirection*/::INCREASE)
|
||||
if(getMouseButtonBinding(*o, Control/*::ControlChangingDirection*/::INCREASE)
|
||||
!= ICS_MAX_DEVICE_BUTTONS)
|
||||
{
|
||||
TiXmlElement binder( "MouseButtonBinder" );
|
||||
@ -519,7 +515,7 @@ namespace ICS
|
||||
control.InsertEndChild(binder);
|
||||
}
|
||||
|
||||
if(getMouseButtonBinding(*o, Control/*::ControlChangingDirection*/::DECREASE)
|
||||
if(getMouseButtonBinding(*o, Control/*::ControlChangingDirection*/::DECREASE)
|
||||
!= ICS_MAX_DEVICE_BUTTONS)
|
||||
{
|
||||
TiXmlElement binder( "MouseButtonBinder" );
|
||||
@ -543,153 +539,72 @@ namespace ICS
|
||||
}
|
||||
binder.SetAttribute( "direction", "DECREASE" );
|
||||
control.InsertEndChild(binder);
|
||||
}
|
||||
}
|
||||
JoystickIDList::const_iterator it = mJoystickIDList.begin();
|
||||
while(it!=mJoystickIDList.end())
|
||||
{
|
||||
int deviceID = *it;
|
||||
if(getJoystickAxisBinding(*o, deviceID, Control/*::ControlChangingDirection*/::INCREASE)
|
||||
!= /*NamedAxis::*/UNASSIGNED)
|
||||
{
|
||||
TiXmlElement binder( "JoystickAxisBinder" );
|
||||
|
||||
JoystickIDList::const_iterator it = mJoystickIDList.begin();
|
||||
while(it != mJoystickIDList.end())
|
||||
{
|
||||
int deviceId = *it;
|
||||
binder.SetAttribute( "axis", ToString<int>(
|
||||
getJoystickAxisBinding(*o, deviceID, Control/*::ControlChangingDirection*/::INCREASE)).c_str() );
|
||||
|
||||
if(getJoystickAxisBinding(*o, deviceId, Control/*::ControlChangingDirection*/::INCREASE)
|
||||
!= /*NamedAxis::*/UNASSIGNED)
|
||||
{
|
||||
TiXmlElement binder( "JoystickAxisBinder" );
|
||||
binder.SetAttribute( "direction", "INCREASE" );
|
||||
|
||||
binder.SetAttribute( "deviceId", deviceID ); //completely useless, but required for backwards compatability
|
||||
|
||||
binder.SetAttribute( "axis", ToString<int>(
|
||||
getJoystickAxisBinding(*o, deviceId, Control/*::ControlChangingDirection*/::INCREASE)).c_str() );
|
||||
control.InsertEndChild(binder);
|
||||
}
|
||||
|
||||
binder.SetAttribute( "direction", "INCREASE" );
|
||||
if(getJoystickAxisBinding(*o, deviceID, Control/*::ControlChangingDirection*/::DECREASE)
|
||||
!= /*NamedAxis::*/UNASSIGNED)
|
||||
{
|
||||
TiXmlElement binder( "JoystickAxisBinder" );
|
||||
|
||||
binder.SetAttribute( "deviceId", ToString<int>(deviceId).c_str() );
|
||||
|
||||
control.InsertEndChild(binder);
|
||||
}
|
||||
binder.SetAttribute( "axis", ToString<int>(
|
||||
getJoystickAxisBinding(*o, deviceID, Control/*::ControlChangingDirection*/::DECREASE)).c_str() );
|
||||
|
||||
if(getJoystickAxisBinding(*o, deviceId, Control/*::ControlChangingDirection*/::DECREASE)
|
||||
!= /*NamedAxis::*/UNASSIGNED)
|
||||
{
|
||||
TiXmlElement binder( "JoystickAxisBinder" );
|
||||
binder.SetAttribute( "direction", "DECREASE" );
|
||||
|
||||
binder.SetAttribute( "deviceId", deviceID ); //completely useless, but required for backwards compatability
|
||||
|
||||
binder.SetAttribute( "axis", ToString<int>(
|
||||
getJoystickAxisBinding(*o, deviceId, Control/*::ControlChangingDirection*/::DECREASE)).c_str() );
|
||||
control.InsertEndChild(binder);
|
||||
}
|
||||
|
||||
binder.SetAttribute( "direction", "DECREASE" );
|
||||
if(getJoystickButtonBinding(*o, deviceID, Control/*::ControlChangingDirection*/::INCREASE)
|
||||
!= ICS_MAX_DEVICE_BUTTONS)
|
||||
{
|
||||
TiXmlElement binder( "JoystickButtonBinder" );
|
||||
|
||||
binder.SetAttribute( "deviceId", ToString<int>(deviceId).c_str() );
|
||||
|
||||
control.InsertEndChild(binder);
|
||||
}
|
||||
binder.SetAttribute( "button", ToString<unsigned int>(
|
||||
getJoystickButtonBinding(*o, deviceID, Control/*::ControlChangingDirection*/::INCREASE)).c_str() );
|
||||
|
||||
if(getJoystickButtonBinding(*o, deviceId, Control/*::ControlChangingDirection*/::INCREASE)
|
||||
!= ICS_MAX_DEVICE_BUTTONS)
|
||||
{
|
||||
TiXmlElement binder( "JoystickButtonBinder" );
|
||||
binder.SetAttribute( "direction", "INCREASE" );
|
||||
|
||||
binder.SetAttribute( "deviceId", deviceID ); //completely useless, but required for backwards compatability
|
||||
|
||||
binder.SetAttribute( "button", ToString<unsigned int>(
|
||||
getJoystickButtonBinding(*o, deviceId, Control/*::ControlChangingDirection*/::INCREASE)).c_str() );
|
||||
control.InsertEndChild(binder);
|
||||
}
|
||||
|
||||
binder.SetAttribute( "direction", "INCREASE" );
|
||||
if(getJoystickButtonBinding(*o, deviceID, Control/*::ControlChangingDirection*/::DECREASE)
|
||||
!= ICS_MAX_DEVICE_BUTTONS)
|
||||
{
|
||||
TiXmlElement binder( "JoystickButtonBinder" );
|
||||
|
||||
binder.SetAttribute( "deviceId", ToString<int>(deviceId).c_str() );
|
||||
|
||||
control.InsertEndChild(binder);
|
||||
}
|
||||
binder.SetAttribute( "button", ToString<unsigned int>(
|
||||
getJoystickButtonBinding(*o, deviceID, Control/*::ControlChangingDirection*/::DECREASE)).c_str() );
|
||||
|
||||
if(getJoystickButtonBinding(*o, deviceId, Control/*::ControlChangingDirection*/::DECREASE)
|
||||
!= ICS_MAX_DEVICE_BUTTONS)
|
||||
{
|
||||
TiXmlElement binder( "JoystickButtonBinder" );
|
||||
binder.SetAttribute( "direction", "DECREASE" );
|
||||
|
||||
binder.SetAttribute( "deviceId", deviceID ); //completely useless, but required for backwards compatability
|
||||
|
||||
binder.SetAttribute( "button", ToString<unsigned int>(
|
||||
getJoystickButtonBinding(*o, *it, Control/*::ControlChangingDirection*/::DECREASE)).c_str() );
|
||||
|
||||
binder.SetAttribute( "direction", "DECREASE" );
|
||||
|
||||
binder.SetAttribute( "deviceId", ToString<int>(deviceId).c_str() );
|
||||
|
||||
control.InsertEndChild(binder);
|
||||
}
|
||||
|
||||
if(getJoystickPOVBinding(*o, deviceId, Control/*::ControlChangingDirection*/::INCREASE).index >= 0)
|
||||
{
|
||||
TiXmlElement binder( "JoystickPOVBinder" );
|
||||
|
||||
POVBindingPair POVPair = getJoystickPOVBinding(*o, deviceId, Control/*::ControlChangingDirection*/::INCREASE);
|
||||
|
||||
binder.SetAttribute( "pov", ToString<int>(POVPair.index).c_str() );
|
||||
|
||||
binder.SetAttribute( "direction", "INCREASE" );
|
||||
|
||||
binder.SetAttribute( "deviceId", ToString<int>(deviceId).c_str() );
|
||||
|
||||
if(POVPair.axis == ICS::InputControlSystem::EastWest)
|
||||
{
|
||||
binder.SetAttribute( "axis", "EastWest" );
|
||||
}
|
||||
else
|
||||
{
|
||||
binder.SetAttribute( "axis", "NorthSouth" );
|
||||
}
|
||||
|
||||
control.InsertEndChild(binder);
|
||||
}
|
||||
|
||||
if(getJoystickPOVBinding(*o, deviceId, Control/*::ControlChangingDirection*/::DECREASE).index >= 0)
|
||||
{
|
||||
TiXmlElement binder( "JoystickPOVBinder" );
|
||||
|
||||
POVBindingPair POVPair = getJoystickPOVBinding(*o, deviceId, Control/*::ControlChangingDirection*/::DECREASE);
|
||||
|
||||
binder.SetAttribute( "pov", ToString<int>(POVPair.index).c_str() );
|
||||
|
||||
binder.SetAttribute( "direction", "DECREASE" );
|
||||
|
||||
binder.SetAttribute( "deviceId", ToString<int>(deviceId).c_str() );
|
||||
|
||||
if(POVPair.axis == ICS::InputControlSystem::EastWest)
|
||||
{
|
||||
binder.SetAttribute( "axis", "EastWest" );
|
||||
}
|
||||
else
|
||||
{
|
||||
binder.SetAttribute( "axis", "NorthSouth" );
|
||||
}
|
||||
|
||||
control.InsertEndChild(binder);
|
||||
}
|
||||
|
||||
if(getJoystickSliderBinding(*o, deviceId, Control/*::ControlChangingDirection*/::INCREASE)
|
||||
!= /*NamedAxis::*/UNASSIGNED)
|
||||
{
|
||||
TiXmlElement binder( "JoystickSliderBinder" );
|
||||
|
||||
binder.SetAttribute( "slider", ToString<int>(
|
||||
getJoystickSliderBinding(*o, deviceId, Control/*::ControlChangingDirection*/::INCREASE)).c_str() );
|
||||
|
||||
binder.SetAttribute( "direction", "INCREASE" );
|
||||
|
||||
binder.SetAttribute( "deviceId", ToString<int>(deviceId).c_str() );
|
||||
|
||||
control.InsertEndChild(binder);
|
||||
}
|
||||
|
||||
if(getJoystickSliderBinding(*o, deviceId, Control/*::ControlChangingDirection*/::DECREASE)
|
||||
!= /*NamedAxis::*/UNASSIGNED)
|
||||
{
|
||||
TiXmlElement binder( "JoystickSliderBinder" );
|
||||
|
||||
binder.SetAttribute( "slider", ToString<int>(
|
||||
getJoystickSliderBinding(*o, deviceId, Control/*::ControlChangingDirection*/::DECREASE)).c_str() );
|
||||
|
||||
binder.SetAttribute( "direction", "DECREASE" );
|
||||
|
||||
binder.SetAttribute( "deviceId", ToString<int>(deviceId).c_str() );
|
||||
|
||||
control.InsertEndChild(binder);
|
||||
}
|
||||
|
||||
++it;
|
||||
}
|
||||
control.InsertEndChild(binder);
|
||||
}
|
||||
it++;
|
||||
}
|
||||
|
||||
|
||||
std::list<Channel*> channels = (*o)->getAttachedChannels();
|
||||
@ -700,19 +615,19 @@ namespace ICS
|
||||
|
||||
binder.SetAttribute( "number", ToString<int>((*it)->getNumber()).c_str() );
|
||||
|
||||
Channel::ChannelDirection direction = (*it)->getAttachedControlBinding(*o).direction;
|
||||
Channel::ChannelDirection direction = (*it)->getAttachedControlBinding(*o).direction;
|
||||
if(direction == Channel/*::ChannelDirection*/::DIRECT)
|
||||
{
|
||||
binder.SetAttribute( "direction", "DIRECT" );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
binder.SetAttribute( "direction", "INVERSE" );
|
||||
}
|
||||
|
||||
|
||||
float percentage = (*it)->getAttachedControlBinding(*o).percentage;
|
||||
binder.SetAttribute( "percentage", ToString<float>(percentage).c_str() );
|
||||
|
||||
|
||||
control.InsertEndChild(binder);
|
||||
}
|
||||
|
||||
@ -734,7 +649,7 @@ namespace ICS
|
||||
}
|
||||
}
|
||||
|
||||
//! @todo Future versions should consider channel exponentials and mixtures, so
|
||||
//! @todo Future versions should consider channel exponentials and mixtures, so
|
||||
// after updating Controls, Channels should be updated according to their values
|
||||
}
|
||||
|
||||
@ -748,24 +663,6 @@ namespace ICS
|
||||
return mControls[i]->getValue();
|
||||
}
|
||||
|
||||
void InputControlSystem::addJoystick(int deviceId)
|
||||
{
|
||||
ICS_LOG("Adding joystick (device id: " + ToString<int>(deviceId) + ")");
|
||||
|
||||
for(int j = 0 ; j < ICS_MAX_JOYSTICK_AXIS ; j++)
|
||||
{
|
||||
if(mControlsJoystickAxisBinderMap[deviceId].find(j) == mControlsJoystickAxisBinderMap[deviceId].end())
|
||||
{
|
||||
ControlAxisBinderItem controlJoystickBinderItem;
|
||||
controlJoystickBinderItem.direction = Control::STOP;
|
||||
controlJoystickBinderItem.control = NULL;
|
||||
mControlsJoystickAxisBinderMap[deviceId][j] = controlJoystickBinderItem;
|
||||
}
|
||||
}
|
||||
|
||||
mJoystickIDList.push_back(deviceId);
|
||||
}
|
||||
|
||||
Control* InputControlSystem::findControl(std::string name)
|
||||
{
|
||||
if(mActive)
|
||||
|
90
extern/oics/ICSInputControlSystem.h
vendored
90
extern/oics/ICSInputControlSystem.h
vendored
@ -32,7 +32,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#include "ICSControl.h"
|
||||
#include "ICSChannel.h"
|
||||
|
||||
#include "../sdl4ogre/events.h"
|
||||
#include "../sdl4ogre/events.h"
|
||||
|
||||
#include "boost/lexical_cast.hpp"
|
||||
|
||||
#define ICS_LOG(text) if(mLog) mLog->logMessage( ("ICS: " + std::string(text)).c_str() );
|
||||
#define ICS_MAX_JOYSTICK_AXIS 16
|
||||
@ -43,16 +45,16 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
namespace ICS
|
||||
{
|
||||
class DllExport InputControlSystemLog
|
||||
class DllExport InputControlSystemLog
|
||||
{
|
||||
public:
|
||||
virtual void logMessage(const char* text) = 0;
|
||||
};
|
||||
|
||||
class DllExport InputControlSystem :
|
||||
class DllExport InputControlSystem :
|
||||
public SFO::MouseListener,
|
||||
public SFO::KeyListener,
|
||||
public SFO::JoyListener
|
||||
public SFO::ControllerListener
|
||||
{
|
||||
|
||||
public:
|
||||
@ -62,6 +64,7 @@ namespace ICS
|
||||
|
||||
typedef NamedAxis MouseAxis; // MouseAxis is deprecated. It will be removed in future versions
|
||||
|
||||
typedef std::map<int, SDL_GameController*> JoystickInstanceMap;
|
||||
typedef std::list<int> JoystickIDList;
|
||||
|
||||
typedef struct
|
||||
@ -72,7 +75,7 @@ namespace ICS
|
||||
|
||||
InputControlSystem(std::string file = "", bool active = true
|
||||
, DetectingBindingListener* detectingBindingListener = NULL
|
||||
, InputControlSystemLog* log = NULL, size_t channelCount = 16);
|
||||
, InputControlSystemLog* log = NULL, size_t channelCount = 16);
|
||||
~InputControlSystem();
|
||||
|
||||
std::string getFileName(){ return mFileName; };
|
||||
@ -98,50 +101,43 @@ namespace ICS
|
||||
inline void activate(){ this->mActive = true; };
|
||||
inline void deactivate(){ this->mActive = false; };
|
||||
|
||||
void addJoystick(int deviceId);
|
||||
JoystickIDList& getJoystickIdList(){ return mJoystickIDList; };
|
||||
|
||||
void controllerAdded (int deviceID, const SDL_ControllerDeviceEvent &args);
|
||||
void controllerRemoved(const SDL_ControllerDeviceEvent &args);
|
||||
JoystickIDList& getJoystickIdList(){ return mJoystickIDList; };
|
||||
JoystickInstanceMap& getJoystickInstanceMap(){ return mJoystickInstanceMap; };
|
||||
|
||||
// MouseListener
|
||||
void mouseMoved(const SFO::MouseMotionEvent &evt);
|
||||
void mousePressed(const SDL_MouseButtonEvent &evt, Uint8);
|
||||
void mouseReleased(const SDL_MouseButtonEvent &evt, Uint8);
|
||||
|
||||
|
||||
// KeyListener
|
||||
void keyPressed(const SDL_KeyboardEvent &evt);
|
||||
void keyReleased(const SDL_KeyboardEvent &evt);
|
||||
|
||||
// JoyStickListener
|
||||
void buttonPressed(const SDL_JoyButtonEvent &evt, int button);
|
||||
void buttonReleased(const SDL_JoyButtonEvent &evt, int button);
|
||||
void axisMoved(const SDL_JoyAxisEvent &evt, int axis);
|
||||
void povMoved(const SDL_JoyHatEvent &evt, int index);
|
||||
//TODO: does this have an SDL equivalent?
|
||||
//bool sliderMoved(const OIS::JoyStickEvent &evt, int index);
|
||||
|
||||
// ControllerListener
|
||||
void buttonPressed(int deviceID, const SDL_ControllerButtonEvent &evt);
|
||||
void buttonReleased(int deviceID, const SDL_ControllerButtonEvent &evt);
|
||||
void axisMoved(int deviceID, const SDL_ControllerAxisEvent &evt);
|
||||
|
||||
void addKeyBinding(Control* control, SDL_Scancode key, Control::ControlChangingDirection direction);
|
||||
bool isKeyBound(SDL_Scancode key) const;
|
||||
void addMouseAxisBinding(Control* control, NamedAxis axis, Control::ControlChangingDirection direction);
|
||||
void addMouseButtonBinding(Control* control, unsigned int button, Control::ControlChangingDirection direction);
|
||||
bool isMouseButtonBound(unsigned int button) const;
|
||||
void addJoystickAxisBinding(Control* control, int deviceId, int axis, Control::ControlChangingDirection direction);
|
||||
void addJoystickButtonBinding(Control* control, int deviceId, unsigned int button, Control::ControlChangingDirection direction);
|
||||
void addJoystickPOVBinding(Control* control, int deviceId, int index, POVAxis axis, Control::ControlChangingDirection direction);
|
||||
void addJoystickSliderBinding(Control* control, int deviceId, int index, Control::ControlChangingDirection direction);
|
||||
void addJoystickAxisBinding(Control* control, int deviceID, int axis, Control::ControlChangingDirection direction);
|
||||
void addJoystickButtonBinding(Control* control, int deviceID, unsigned int button, Control::ControlChangingDirection direction);
|
||||
void removeKeyBinding(SDL_Scancode key);
|
||||
void removeMouseAxisBinding(NamedAxis axis);
|
||||
void removeMouseButtonBinding(unsigned int button);
|
||||
void removeJoystickAxisBinding(int deviceId, int axis);
|
||||
void removeJoystickButtonBinding(int deviceId, unsigned int button);
|
||||
void removeJoystickPOVBinding(int deviceId, int index, POVAxis axis);
|
||||
void removeJoystickSliderBinding(int deviceId, int index);
|
||||
void removeJoystickAxisBinding(int deviceID, int axis);
|
||||
void removeJoystickButtonBinding(int deviceID, unsigned int button);
|
||||
|
||||
SDL_Scancode getKeyBinding(Control* control, ICS::Control::ControlChangingDirection direction);
|
||||
NamedAxis getMouseAxisBinding(Control* control, ICS::Control::ControlChangingDirection direction);
|
||||
unsigned int getMouseButtonBinding(Control* control, ICS::Control::ControlChangingDirection direction);
|
||||
int getJoystickAxisBinding(Control* control, int deviceId, ICS::Control::ControlChangingDirection direction);
|
||||
unsigned int getJoystickButtonBinding(Control* control, int deviceId, ICS::Control::ControlChangingDirection direction);
|
||||
POVBindingPair getJoystickPOVBinding(Control* control, int deviceId, ICS::Control::ControlChangingDirection direction);
|
||||
int getJoystickSliderBinding(Control* control, int deviceId, ICS::Control::ControlChangingDirection direction);
|
||||
int getJoystickAxisBinding(Control* control, int deviceID, ICS::Control::ControlChangingDirection direction);
|
||||
unsigned int getJoystickButtonBinding(Control* control, int deviceID, ICS::Control::ControlChangingDirection direction);
|
||||
|
||||
std::string scancodeToString(SDL_Scancode key);
|
||||
|
||||
@ -189,21 +185,15 @@ namespace ICS
|
||||
|
||||
typedef std::map<SDL_Scancode, ControlKeyBinderItem> ControlsKeyBinderMapType; // <Scancode, [direction, control]>
|
||||
typedef std::map<int, ControlAxisBinderItem> ControlsAxisBinderMapType; // <axis, [direction, control]>
|
||||
typedef std::map<int, ControlButtonBinderItem> ControlsButtonBinderMapType; // <button, [direction, control]>
|
||||
typedef std::map<int, ControlPOVBinderItem> ControlsPOVBinderMapType; // <index, [direction, control]>
|
||||
typedef std::map<int, ControlSliderBinderItem> ControlsSliderBinderMapType; // <index, [direction, control]>
|
||||
|
||||
typedef std::map<int, ControlsAxisBinderMapType> JoystickAxisBinderMapType; // <joystick_id, <axis, [direction, control]> >
|
||||
typedef std::map<int, ControlsButtonBinderMapType> JoystickButtonBinderMapType; // <joystick_id, <button, [direction, control]> >
|
||||
typedef std::map<int, std::map<int, ControlsPOVBinderMapType> > JoystickPOVBinderMapType; // <joystick_id, <index, <axis, [direction, control]> > >
|
||||
typedef std::map<int, ControlsSliderBinderMapType> JoystickSliderBinderMapType; // <joystick_id, <index, [direction, control]> >
|
||||
typedef std::map<int, ControlButtonBinderItem> ControlsButtonBinderMapType; // <button, [direction, control]>
|
||||
|
||||
typedef std::map<int, ControlsAxisBinderMapType> JoystickAxisBinderMapType; // <joystick_id, <axis, [direction, control]> >
|
||||
typedef std::map<int, ControlsButtonBinderMapType> JoystickButtonBinderMapType; // <joystick_id, <button, [direction, control]> >
|
||||
|
||||
ControlsAxisBinderMapType mControlsMouseAxisBinderMap; // <axis, [direction, control]>
|
||||
ControlsButtonBinderMapType mControlsMouseButtonBinderMap; // <int, [direction, control]>
|
||||
JoystickAxisBinderMapType mControlsJoystickAxisBinderMap; // <joystick_id, <axis, [direction, control]> >
|
||||
JoystickButtonBinderMapType mControlsJoystickButtonBinderMap; // <joystick_id, <button, [direction, control]> >
|
||||
JoystickPOVBinderMapType mControlsJoystickPOVBinderMap; // <joystick_id, <index, <axis, [direction, control]> > >
|
||||
JoystickSliderBinderMapType mControlsJoystickSliderBinderMap; // <joystick_id, <index, [direction, control]> >
|
||||
JoystickAxisBinderMapType mControlsJoystickAxisBinderMap; // <axis, [direction, control]>
|
||||
JoystickButtonBinderMapType mControlsJoystickButtonBinderMap; // <button, [direction, control]>
|
||||
|
||||
std::vector<Control *> mControls;
|
||||
std::vector<Channel *> mChannels;
|
||||
@ -212,7 +202,7 @@ namespace ICS
|
||||
|
||||
bool mActive;
|
||||
InputControlSystemLog* mLog;
|
||||
|
||||
|
||||
DetectingBindingListener* mDetectingBindingListener;
|
||||
Control* mDetectingBindingControl;
|
||||
Control::ControlChangingDirection mDetectingBindingDirection;
|
||||
@ -220,7 +210,8 @@ namespace ICS
|
||||
bool mXmouseAxisBinded;
|
||||
bool mYmouseAxisBinded;
|
||||
|
||||
JoystickIDList mJoystickIDList;
|
||||
JoystickIDList mJoystickIDList;
|
||||
JoystickInstanceMap mJoystickInstanceMap;
|
||||
|
||||
int mMouseAxisBindingInitialValues[3];
|
||||
|
||||
@ -242,17 +233,12 @@ namespace ICS
|
||||
virtual void mouseButtonBindingDetected(InputControlSystem* ICS, Control* control
|
||||
, unsigned int button, Control::ControlChangingDirection direction);
|
||||
|
||||
virtual void joystickAxisBindingDetected(InputControlSystem* ICS, Control* control
|
||||
, int deviceId, int axis, Control::ControlChangingDirection direction);
|
||||
virtual void joystickAxisBindingDetected(InputControlSystem* ICS, int deviceID, Control* control
|
||||
, int axis, Control::ControlChangingDirection direction);
|
||||
|
||||
virtual void joystickButtonBindingDetected(InputControlSystem* ICS, Control* control
|
||||
, int deviceId, unsigned int button, Control::ControlChangingDirection direction);
|
||||
virtual void joystickButtonBindingDetected(InputControlSystem* ICS, int deviceID, Control* control
|
||||
, unsigned int button, Control::ControlChangingDirection direction);
|
||||
|
||||
virtual void joystickPOVBindingDetected(InputControlSystem* ICS, Control* control
|
||||
, int deviceId, int pov, InputControlSystem::POVAxis axis, Control::ControlChangingDirection direction);
|
||||
|
||||
virtual void joystickSliderBindingDetected(InputControlSystem* ICS, Control* control
|
||||
, int deviceId, int slider, Control::ControlChangingDirection direction);
|
||||
};
|
||||
|
||||
static const float ICS_MAX = std::numeric_limits<float>::max();
|
||||
|
693
extern/oics/ICSInputControlSystem_joystick.cpp
vendored
693
extern/oics/ICSInputControlSystem_joystick.cpp
vendored
@ -27,14 +27,15 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#include "ICSInputControlSystem.h"
|
||||
|
||||
#define SDL_JOY_AXIS_MIN -32768
|
||||
#define SDL_JOY_AXIS_MAX 32767
|
||||
#define SDL_JOY_AXIS_MAX 32767
|
||||
#define DEADZONE 0.1f
|
||||
|
||||
namespace ICS
|
||||
{
|
||||
// load xml
|
||||
void InputControlSystem::loadJoystickAxisBinders(TiXmlElement* xmlControlNode)
|
||||
{
|
||||
TiXmlElement* xmlJoystickBinder = xmlControlNode->FirstChildElement("JoystickAxisBinder");
|
||||
TiXmlElement* xmlJoystickBinder = xmlControlNode->FirstChildElement("JoystickAxisBinder");
|
||||
while(xmlJoystickBinder)
|
||||
{
|
||||
Control::ControlChangingDirection dir = Control::STOP;
|
||||
@ -47,8 +48,7 @@ namespace ICS
|
||||
dir = Control::DECREASE;
|
||||
}
|
||||
|
||||
addJoystickAxisBinding(mControls.back(), FromString<int>(xmlJoystickBinder->Attribute("deviceId"))
|
||||
, FromString<int>(xmlJoystickBinder->Attribute("axis")), dir);
|
||||
addJoystickAxisBinding(mControls.back(), FromString<int>(xmlJoystickBinder->Attribute("deviceId")), FromString<int>(xmlJoystickBinder->Attribute("axis")), dir);
|
||||
|
||||
xmlJoystickBinder = xmlJoystickBinder->NextSiblingElement("JoystickAxisBinder");
|
||||
}
|
||||
@ -56,7 +56,7 @@ namespace ICS
|
||||
|
||||
void InputControlSystem::loadJoystickButtonBinders(TiXmlElement* xmlControlNode)
|
||||
{
|
||||
TiXmlElement* xmlJoystickButtonBinder = xmlControlNode->FirstChildElement("JoystickButtonBinder");
|
||||
TiXmlElement* xmlJoystickButtonBinder = xmlControlNode->FirstChildElement("JoystickButtonBinder");
|
||||
while(xmlJoystickButtonBinder)
|
||||
{
|
||||
Control::ControlChangingDirection dir = Control::STOP;
|
||||
@ -69,335 +69,194 @@ namespace ICS
|
||||
dir = Control::DECREASE;
|
||||
}
|
||||
|
||||
addJoystickButtonBinding(mControls.back(), FromString<int>(xmlJoystickButtonBinder->Attribute("deviceId"))
|
||||
, FromString<int>(xmlJoystickButtonBinder->Attribute("button")), dir);
|
||||
addJoystickButtonBinding(mControls.back(), FromString<int>(xmlJoystickButtonBinder->Attribute("deviceId")), FromString<int>(xmlJoystickButtonBinder->Attribute("button")), dir);
|
||||
|
||||
xmlJoystickButtonBinder = xmlJoystickButtonBinder->NextSiblingElement("JoystickButtonBinder");
|
||||
}
|
||||
}
|
||||
|
||||
void InputControlSystem::loadJoystickPOVBinders(TiXmlElement* xmlControlNode)
|
||||
{
|
||||
TiXmlElement* xmlJoystickPOVBinder = xmlControlNode->FirstChildElement("JoystickPOVBinder");
|
||||
while(xmlJoystickPOVBinder)
|
||||
{
|
||||
Control::ControlChangingDirection dir = Control::STOP;
|
||||
if(std::string(xmlJoystickPOVBinder->Attribute("direction")) == "INCREASE")
|
||||
{
|
||||
dir = Control::INCREASE;
|
||||
}
|
||||
else if(std::string(xmlJoystickPOVBinder->Attribute("direction")) == "DECREASE")
|
||||
{
|
||||
dir = Control::DECREASE;
|
||||
}
|
||||
|
||||
InputControlSystem::POVAxis axis = /*POVAxis::*/NorthSouth;
|
||||
if(std::string(xmlJoystickPOVBinder->Attribute("axis")) == "EastWest")
|
||||
{
|
||||
axis = /*POVAxis::*/EastWest;
|
||||
}
|
||||
|
||||
addJoystickPOVBinding(mControls.back(), FromString<int>(xmlJoystickPOVBinder->Attribute("deviceId"))
|
||||
, FromString<int>(xmlJoystickPOVBinder->Attribute("pov")), axis, dir);
|
||||
|
||||
xmlJoystickPOVBinder = xmlJoystickPOVBinder->NextSiblingElement("JoystickPOVBinder");
|
||||
}
|
||||
}
|
||||
|
||||
void InputControlSystem::loadJoystickSliderBinders(TiXmlElement* xmlControlNode)
|
||||
{
|
||||
TiXmlElement* xmlJoystickSliderBinder = xmlControlNode->FirstChildElement("JoystickSliderBinder");
|
||||
while(xmlJoystickSliderBinder)
|
||||
{
|
||||
Control::ControlChangingDirection dir = Control::STOP;
|
||||
if(std::string(xmlJoystickSliderBinder->Attribute("direction")) == "INCREASE")
|
||||
{
|
||||
dir = Control::INCREASE;
|
||||
}
|
||||
else if(std::string(xmlJoystickSliderBinder->Attribute("direction")) == "DECREASE")
|
||||
{
|
||||
dir = Control::DECREASE;
|
||||
}
|
||||
|
||||
addJoystickSliderBinding(mControls.back(), FromString<int>(xmlJoystickSliderBinder->Attribute("deviceId"))
|
||||
, FromString<int>(xmlJoystickSliderBinder->Attribute("slider")), dir);
|
||||
|
||||
xmlJoystickSliderBinder = xmlJoystickSliderBinder->NextSiblingElement("JoystickSliderBinder");
|
||||
}
|
||||
}
|
||||
|
||||
// add bindings
|
||||
void InputControlSystem::addJoystickAxisBinding(Control* control, int deviceId, int axis, Control::ControlChangingDirection direction)
|
||||
void InputControlSystem::addJoystickAxisBinding(Control* control, int deviceID, int axis, Control::ControlChangingDirection direction)
|
||||
{
|
||||
ICS_LOG("\tAdding AxisBinder [deviceid="
|
||||
+ ToString<int>(deviceId) + ", axis="
|
||||
+ ToString<int>(axis) + ", direction="
|
||||
+ ToString<int>(direction) + "]");
|
||||
ICS_LOG("\tAdding AxisBinder [axis="
|
||||
+ ToString<int>(axis) + ", deviceID="
|
||||
+ ToString<int>(deviceID) + ", direction="
|
||||
+ ToString<int>(direction) + "]");
|
||||
|
||||
control->setValue(0.5f); //all joystick axis start at .5, so do that
|
||||
|
||||
ControlAxisBinderItem controlAxisBinderItem;
|
||||
controlAxisBinderItem.control = control;
|
||||
controlAxisBinderItem.direction = direction;
|
||||
mControlsJoystickAxisBinderMap[ deviceId ][ axis ] = controlAxisBinderItem;
|
||||
mControlsJoystickAxisBinderMap[deviceID][axis] = controlAxisBinderItem;
|
||||
}
|
||||
|
||||
void InputControlSystem::addJoystickButtonBinding(Control* control, int deviceId, unsigned int button, Control::ControlChangingDirection direction)
|
||||
void InputControlSystem::addJoystickButtonBinding(Control* control, int deviceID, unsigned int button, Control::ControlChangingDirection direction)
|
||||
{
|
||||
ICS_LOG("\tAdding JoystickButtonBinder [deviceId="
|
||||
+ ToString<int>(deviceId) + ", button="
|
||||
+ ToString<int>(button) + ", direction="
|
||||
+ ToString<int>(direction) + "]");
|
||||
ICS_LOG("\tAdding JoystickButtonBinder [button="
|
||||
+ ToString<int>(button) + ", deviceID="
|
||||
+ ToString<int>(deviceID) + ", direction="
|
||||
+ ToString<int>(direction) + "]");
|
||||
|
||||
ControlButtonBinderItem controlJoystickButtonBinderItem;
|
||||
controlJoystickButtonBinderItem.direction = direction;
|
||||
controlJoystickButtonBinderItem.control = control;
|
||||
mControlsJoystickButtonBinderMap[ deviceId ][ button ] = controlJoystickButtonBinderItem;
|
||||
}
|
||||
|
||||
void InputControlSystem::addJoystickPOVBinding(Control* control, int deviceId, int index, InputControlSystem::POVAxis axis, Control::ControlChangingDirection direction)
|
||||
{
|
||||
ICS_LOG("\tAdding JoystickPOVBinder [deviceId="
|
||||
+ ToString<int>(deviceId) + ", pov="
|
||||
+ ToString<int>(index) + ", axis="
|
||||
+ ToString<int>(axis) + ", direction="
|
||||
+ ToString<int>(direction) + "]");
|
||||
|
||||
ControlPOVBinderItem ControlPOVBinderItem;
|
||||
ControlPOVBinderItem.direction = direction;
|
||||
ControlPOVBinderItem.control = control;
|
||||
mControlsJoystickPOVBinderMap[ deviceId ][ index ][ axis ] = ControlPOVBinderItem;
|
||||
}
|
||||
|
||||
void InputControlSystem::addJoystickSliderBinding(Control* control, int deviceId, int index, Control::ControlChangingDirection direction)
|
||||
{
|
||||
ICS_LOG("\tAdding JoystickSliderBinder [deviceId="
|
||||
+ ToString<int>(deviceId) + ", direction="
|
||||
+ ToString<int>(index) + ", direction="
|
||||
+ ToString<int>(direction) + "]");
|
||||
|
||||
ControlSliderBinderItem ControlSliderBinderItem;
|
||||
ControlSliderBinderItem.direction = direction;
|
||||
ControlSliderBinderItem.control = control;
|
||||
mControlsJoystickSliderBinderMap[ deviceId ][ index ] = ControlSliderBinderItem;
|
||||
mControlsJoystickButtonBinderMap[deviceID][button] = controlJoystickButtonBinderItem;
|
||||
}
|
||||
|
||||
// get bindings
|
||||
int InputControlSystem::getJoystickAxisBinding(Control* control, int deviceId, ICS::Control::ControlChangingDirection direction)
|
||||
{
|
||||
if(mControlsJoystickAxisBinderMap.find(deviceId) != mControlsJoystickAxisBinderMap.end())
|
||||
int InputControlSystem::getJoystickAxisBinding(Control* control, int deviceID, ICS::Control::ControlChangingDirection direction)
|
||||
{
|
||||
if(mControlsJoystickAxisBinderMap.find(deviceID) != mControlsJoystickAxisBinderMap.end())
|
||||
{
|
||||
ControlsAxisBinderMapType::iterator it = mControlsJoystickAxisBinderMap[deviceId].begin();
|
||||
while(it != mControlsJoystickAxisBinderMap[deviceId].end())
|
||||
{
|
||||
if(it->first >= 0 && it->second.control == control && it->second.direction == direction)
|
||||
{
|
||||
return it->first;
|
||||
}
|
||||
ControlsAxisBinderMapType::iterator it = mControlsJoystickAxisBinderMap[deviceID].begin();
|
||||
while(it != mControlsJoystickAxisBinderMap[deviceID].end())
|
||||
{
|
||||
if(it->first >= 0 && it->second.control == control && it->second.direction == direction)
|
||||
{
|
||||
return it->first;
|
||||
}
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return /*NamedAxis::*/UNASSIGNED;
|
||||
}
|
||||
|
||||
unsigned int InputControlSystem::getJoystickButtonBinding(Control* control, int deviceId, ICS::Control::ControlChangingDirection direction)
|
||||
{
|
||||
if(mControlsJoystickButtonBinderMap.find(deviceId) != mControlsJoystickButtonBinderMap.end())
|
||||
unsigned int InputControlSystem::getJoystickButtonBinding(Control* control, int deviceID, ICS::Control::ControlChangingDirection direction)
|
||||
{
|
||||
if(mControlsJoystickButtonBinderMap.find(deviceID) != mControlsJoystickButtonBinderMap.end())
|
||||
{
|
||||
ControlsButtonBinderMapType::iterator it = mControlsJoystickButtonBinderMap[deviceId].begin();
|
||||
while(it != mControlsJoystickButtonBinderMap[deviceId].end())
|
||||
{
|
||||
if(it->second.control == control && it->second.direction == direction)
|
||||
{
|
||||
return it->first;
|
||||
}
|
||||
ControlsButtonBinderMapType::iterator it = mControlsJoystickButtonBinderMap[deviceID].begin();
|
||||
while(it != mControlsJoystickButtonBinderMap[deviceID].end())
|
||||
{
|
||||
if(it->second.control == control && it->second.direction == direction)
|
||||
{
|
||||
return it->first;
|
||||
}
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ICS_MAX_DEVICE_BUTTONS;
|
||||
}
|
||||
|
||||
InputControlSystem::POVBindingPair InputControlSystem::getJoystickPOVBinding(Control* control, int deviceId, ICS::Control::ControlChangingDirection direction)
|
||||
{
|
||||
POVBindingPair result;
|
||||
result.index = -1;
|
||||
|
||||
if(mControlsJoystickPOVBinderMap.find(deviceId) != mControlsJoystickPOVBinderMap.end())
|
||||
{
|
||||
//ControlsAxisBinderMapType::iterator it = mControlsJoystickPOVBinderMap[deviceId].begin();
|
||||
std::map<int, ControlsPOVBinderMapType>::iterator it = mControlsJoystickPOVBinderMap[deviceId].begin();
|
||||
while(it != mControlsJoystickPOVBinderMap[deviceId].end())
|
||||
{
|
||||
ControlsPOVBinderMapType::const_iterator it2 = it->second.begin();
|
||||
while(it2 != it->second.end())
|
||||
{
|
||||
if(it2->second.control == control && it2->second.direction == direction)
|
||||
{
|
||||
result.index = it->first;
|
||||
result.axis = (POVAxis)it2->first;
|
||||
return result;
|
||||
}
|
||||
it2++;
|
||||
}
|
||||
|
||||
it++;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int InputControlSystem::getJoystickSliderBinding(Control* control, int deviceId, ICS::Control::ControlChangingDirection direction)
|
||||
{
|
||||
if(mControlsJoystickSliderBinderMap.find(deviceId) != mControlsJoystickSliderBinderMap.end())
|
||||
{
|
||||
ControlsButtonBinderMapType::iterator it = mControlsJoystickSliderBinderMap[deviceId].begin();
|
||||
while(it != mControlsJoystickSliderBinderMap[deviceId].end())
|
||||
{
|
||||
if(it->second.control == control && it->second.direction == direction)
|
||||
{
|
||||
return it->first;
|
||||
}
|
||||
it++;
|
||||
}
|
||||
}
|
||||
|
||||
return /*NamedAxis::*/UNASSIGNED;
|
||||
}
|
||||
|
||||
// remove bindings
|
||||
void InputControlSystem::removeJoystickAxisBinding(int deviceId, int axis)
|
||||
{
|
||||
if(mControlsJoystickAxisBinderMap.find(deviceId) != mControlsJoystickAxisBinderMap.end())
|
||||
void InputControlSystem::removeJoystickAxisBinding(int deviceID, int axis)
|
||||
{
|
||||
if(mControlsJoystickAxisBinderMap.find(deviceID) != mControlsJoystickAxisBinderMap.end())
|
||||
{
|
||||
ControlsButtonBinderMapType::iterator it = mControlsJoystickAxisBinderMap[deviceId].find(axis);
|
||||
if(it != mControlsJoystickAxisBinderMap[deviceId].end())
|
||||
{
|
||||
mControlsJoystickAxisBinderMap[deviceId].erase(it);
|
||||
}
|
||||
}
|
||||
ControlsAxisBinderMapType::iterator it = mControlsJoystickAxisBinderMap[deviceID].find(axis);
|
||||
if(it != mControlsJoystickAxisBinderMap[deviceID].end())
|
||||
{
|
||||
mControlsJoystickAxisBinderMap[deviceID].erase(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InputControlSystem::removeJoystickButtonBinding(int deviceId, unsigned int button)
|
||||
{
|
||||
if(mControlsJoystickButtonBinderMap.find(deviceId) != mControlsJoystickButtonBinderMap.end())
|
||||
void InputControlSystem::removeJoystickButtonBinding(int deviceID, unsigned int button)
|
||||
{
|
||||
if(mControlsJoystickButtonBinderMap.find(deviceID) != mControlsJoystickButtonBinderMap.end())
|
||||
{
|
||||
ControlsButtonBinderMapType::iterator it = mControlsJoystickButtonBinderMap[deviceId].find(button);
|
||||
if(it != mControlsJoystickButtonBinderMap[deviceId].end())
|
||||
{
|
||||
mControlsJoystickButtonBinderMap[deviceId].erase(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InputControlSystem::removeJoystickPOVBinding(int deviceId, int index, POVAxis axis)
|
||||
{
|
||||
if(mControlsJoystickPOVBinderMap.find(deviceId) != mControlsJoystickPOVBinderMap.end())
|
||||
{
|
||||
std::map<int, ControlsPOVBinderMapType>::iterator it = mControlsJoystickPOVBinderMap[deviceId].find(index);
|
||||
if(it != mControlsJoystickPOVBinderMap[deviceId].end())
|
||||
{
|
||||
if(it->second.find(axis) != it->second.end())
|
||||
{
|
||||
it->second.erase( it->second.find(axis) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InputControlSystem::removeJoystickSliderBinding(int deviceId, int index)
|
||||
{
|
||||
if(mControlsJoystickSliderBinderMap.find(deviceId) != mControlsJoystickSliderBinderMap.end())
|
||||
{
|
||||
ControlsButtonBinderMapType::iterator it = mControlsJoystickSliderBinderMap[deviceId].find(index);
|
||||
if(it != mControlsJoystickSliderBinderMap[deviceId].end())
|
||||
{
|
||||
mControlsJoystickSliderBinderMap[deviceId].erase(it);
|
||||
}
|
||||
}
|
||||
ControlsButtonBinderMapType::iterator it = mControlsJoystickButtonBinderMap[deviceID].find(button);
|
||||
if(it != mControlsJoystickButtonBinderMap[deviceID].end())
|
||||
{
|
||||
mControlsJoystickButtonBinderMap[deviceID].erase(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// joyStick listeners
|
||||
void InputControlSystem::buttonPressed(const SDL_JoyButtonEvent &evt, int button)
|
||||
{
|
||||
if(mActive)
|
||||
{
|
||||
if(!mDetectingBindingControl)
|
||||
{
|
||||
if(mControlsJoystickButtonBinderMap.find(evt.which) != mControlsJoystickButtonBinderMap.end())
|
||||
{
|
||||
ControlsButtonBinderMapType::const_iterator it = mControlsJoystickButtonBinderMap[evt.which].find(button);
|
||||
if(it != mControlsJoystickButtonBinderMap[evt.which].end())
|
||||
{
|
||||
it->second.control->setIgnoreAutoReverse(false);
|
||||
if(!it->second.control->getAutoChangeDirectionOnLimitsAfterStop())
|
||||
{
|
||||
it->second.control->setChangingDirection(it->second.direction);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(it->second.control->getValue() == 1)
|
||||
{
|
||||
it->second.control->setChangingDirection(Control::DECREASE);
|
||||
}
|
||||
else if(it->second.control->getValue() == 0)
|
||||
{
|
||||
it->second.control->setChangingDirection(Control::INCREASE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(mDetectingBindingListener)
|
||||
{
|
||||
mDetectingBindingListener->joystickButtonBindingDetected(this,
|
||||
mDetectingBindingControl, evt.which, button, mDetectingBindingDirection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InputControlSystem::buttonReleased(const SDL_JoyButtonEvent &evt, int button)
|
||||
{
|
||||
if(mActive)
|
||||
{
|
||||
if(mControlsJoystickButtonBinderMap.find(evt.which) != mControlsJoystickButtonBinderMap.end())
|
||||
{
|
||||
ControlsButtonBinderMapType::const_iterator it = mControlsJoystickButtonBinderMap[evt.which].find(button);
|
||||
if(it != mControlsJoystickButtonBinderMap[evt.which].end())
|
||||
{
|
||||
it->second.control->setChangingDirection(Control::STOP);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InputControlSystem::axisMoved(const SDL_JoyAxisEvent &evt, int axis)
|
||||
void InputControlSystem::buttonPressed(int deviceID, const SDL_ControllerButtonEvent &evt)
|
||||
{
|
||||
if(mActive)
|
||||
{
|
||||
if(!mDetectingBindingControl)
|
||||
{
|
||||
if(mControlsJoystickButtonBinderMap.find(deviceID) != mControlsJoystickButtonBinderMap.end())
|
||||
{
|
||||
ControlsButtonBinderMapType::const_iterator it = mControlsJoystickButtonBinderMap[deviceID].find(evt.button);
|
||||
if(it != mControlsJoystickButtonBinderMap[deviceID].end())
|
||||
{
|
||||
it->second.control->setIgnoreAutoReverse(false);
|
||||
if(!it->second.control->getAutoChangeDirectionOnLimitsAfterStop())
|
||||
{
|
||||
it->second.control->setChangingDirection(it->second.direction);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(it->second.control->getValue() == 1)
|
||||
{
|
||||
it->second.control->setChangingDirection(Control::DECREASE);
|
||||
}
|
||||
else if(it->second.control->getValue() == 0)
|
||||
{
|
||||
it->second.control->setChangingDirection(Control::INCREASE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InputControlSystem::buttonReleased(int deviceID, const SDL_ControllerButtonEvent &evt)
|
||||
{
|
||||
if(mActive)
|
||||
{
|
||||
if(!mDetectingBindingControl)
|
||||
{
|
||||
if(mControlsJoystickButtonBinderMap.find(deviceID) != mControlsJoystickButtonBinderMap.end())
|
||||
{
|
||||
ControlsButtonBinderMapType::const_iterator it = mControlsJoystickButtonBinderMap[deviceID].find(evt.button);
|
||||
if(it != mControlsJoystickButtonBinderMap[deviceID].end())
|
||||
{
|
||||
it->second.control->setChangingDirection(Control::STOP);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(mDetectingBindingListener)
|
||||
{
|
||||
if(mControlsJoystickAxisBinderMap.find(evt.which) != mControlsJoystickAxisBinderMap.end())
|
||||
{
|
||||
ControlAxisBinderItem joystickBinderItem = mControlsJoystickAxisBinderMap[ evt.which ][ axis ]; // joystic axis start at 0 index
|
||||
Control* ctrl = joystickBinderItem.control;
|
||||
if(ctrl)
|
||||
{
|
||||
ctrl->setIgnoreAutoReverse(true);
|
||||
mDetectingBindingListener->joystickButtonBindingDetected(this, deviceID,
|
||||
mDetectingBindingControl, evt.button, mDetectingBindingDirection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float axisRange = SDL_JOY_AXIS_MAX - SDL_JOY_AXIS_MIN;
|
||||
float valDisplaced = (float)(evt.value - SDL_JOY_AXIS_MIN);
|
||||
void InputControlSystem::axisMoved(int deviceID, const SDL_ControllerAxisEvent &evt)
|
||||
{
|
||||
if(mActive)
|
||||
{
|
||||
if(!mDetectingBindingControl)
|
||||
{
|
||||
if(mControlsJoystickAxisBinderMap.find(deviceID) != mControlsJoystickAxisBinderMap.end())
|
||||
{
|
||||
ControlAxisBinderItem joystickBinderItem = mControlsJoystickAxisBinderMap[deviceID][evt.axis]; // joystic axis start at 0 index
|
||||
Control* ctrl = joystickBinderItem.control;
|
||||
if(ctrl)
|
||||
{
|
||||
ctrl->setIgnoreAutoReverse(true);
|
||||
|
||||
if(joystickBinderItem.direction == Control::INCREASE)
|
||||
{
|
||||
ctrl->setValue( valDisplaced / axisRange );
|
||||
}
|
||||
else if(joystickBinderItem.direction == Control::DECREASE)
|
||||
{
|
||||
ctrl->setValue( 1 - ( valDisplaced / axisRange ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
float axisRange = SDL_JOY_AXIS_MAX - SDL_JOY_AXIS_MIN;
|
||||
float valDisplaced = (float)(evt.value - SDL_JOY_AXIS_MIN);
|
||||
float percent = valDisplaced / axisRange * (1+DEADZONE*2) - DEADZONE; //Assures all values, 0 through 1, are seen
|
||||
if(percent > .5-DEADZONE && percent < .5+DEADZONE) //close enough to center
|
||||
percent = .5;
|
||||
else if(percent > .5)
|
||||
percent -= DEADZONE;
|
||||
else
|
||||
percent += DEADZONE;
|
||||
|
||||
if(joystickBinderItem.direction == Control::INCREASE)
|
||||
{
|
||||
ctrl->setValue( percent );
|
||||
}
|
||||
else if(joystickBinderItem.direction == Control::DECREASE)
|
||||
{
|
||||
ctrl->setValue( 1 - ( percent ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(mDetectingBindingListener)
|
||||
{
|
||||
@ -408,250 +267,76 @@ namespace ICS
|
||||
{
|
||||
if( abs( evt.value ) > ICS_JOYSTICK_AXIS_BINDING_MARGIN)
|
||||
{
|
||||
mDetectingBindingListener->joystickAxisBindingDetected(this,
|
||||
mDetectingBindingControl, evt.which, axis, mDetectingBindingDirection);
|
||||
mDetectingBindingListener->joystickAxisBindingDetected(this, deviceID,
|
||||
mDetectingBindingControl, evt.axis, mDetectingBindingDirection);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Here be dragons, apparently
|
||||
void InputControlSystem::povMoved(const SDL_JoyHatEvent &evt, int index)
|
||||
}
|
||||
|
||||
void InputControlSystem::controllerAdded(int deviceID, const SDL_ControllerDeviceEvent &args)
|
||||
{
|
||||
if(mActive)
|
||||
{
|
||||
if(!mDetectingBindingControl)
|
||||
{
|
||||
if(mControlsJoystickPOVBinderMap.find(evt.which) != mControlsJoystickPOVBinderMap.end())
|
||||
{
|
||||
std::map<int, ControlsPOVBinderMapType>::const_iterator i = mControlsJoystickPOVBinderMap[ evt.which ].find(index);
|
||||
if(i != mControlsJoystickPOVBinderMap[ evt.which ].end())
|
||||
{
|
||||
if(evt.value != SDL_HAT_LEFT
|
||||
&& evt.value != SDL_HAT_RIGHT
|
||||
&& evt.value != SDL_HAT_CENTERED)
|
||||
{
|
||||
ControlsPOVBinderMapType::const_iterator it = i->second.find( /*POVAxis::*/NorthSouth );
|
||||
if(it != i->second.end())
|
||||
{
|
||||
it->second.control->setIgnoreAutoReverse(false);
|
||||
if(!it->second.control->getAutoChangeDirectionOnLimitsAfterStop())
|
||||
{
|
||||
if(evt.value == SDL_HAT_UP
|
||||
|| evt.value == SDL_HAT_LEFTUP
|
||||
|| evt.value == SDL_HAT_RIGHTUP)
|
||||
{
|
||||
it->second.control->setChangingDirection(it->second.direction);
|
||||
}
|
||||
else
|
||||
{
|
||||
it->second.control->setChangingDirection((Control::ControlChangingDirection)(-1 * it->second.direction));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(it->second.control->getValue() == 1)
|
||||
{
|
||||
it->second.control->setChangingDirection(Control::DECREASE);
|
||||
}
|
||||
else if(it->second.control->getValue() == 0)
|
||||
{
|
||||
it->second.control->setChangingDirection(Control::INCREASE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ICS_LOG("Adding joystick (index: " + ToString<int>(args.which) + ")");
|
||||
SDL_GameController* cntrl = SDL_GameControllerOpen(args.which);
|
||||
int instanceID = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(cntrl));
|
||||
if(std::find(mJoystickIDList.begin(), mJoystickIDList.end(), deviceID)==mJoystickIDList.end())
|
||||
{
|
||||
for(int j = 0 ; j < ICS_MAX_JOYSTICK_AXIS ; j++)
|
||||
{
|
||||
if(mControlsJoystickAxisBinderMap[deviceID].find(j) == mControlsJoystickAxisBinderMap[deviceID].end())
|
||||
{
|
||||
ControlAxisBinderItem controlJoystickBinderItem;
|
||||
controlJoystickBinderItem.direction = Control::STOP;
|
||||
controlJoystickBinderItem.control = NULL;
|
||||
mControlsJoystickAxisBinderMap[deviceID][j] = controlJoystickBinderItem;
|
||||
}
|
||||
}
|
||||
mJoystickIDList.push_front(deviceID);
|
||||
}
|
||||
|
||||
if(evt.value != SDL_HAT_UP
|
||||
&& evt.value != SDL_HAT_DOWN
|
||||
&& evt.value != SDL_HAT_CENTERED)
|
||||
{
|
||||
ControlsPOVBinderMapType::const_iterator it = i->second.find( /*POVAxis::*/EastWest );
|
||||
if(it != i->second.end())
|
||||
{
|
||||
it->second.control->setIgnoreAutoReverse(false);
|
||||
if(!it->second.control->getAutoChangeDirectionOnLimitsAfterStop())
|
||||
{
|
||||
if(evt.value == SDL_HAT_RIGHT
|
||||
|| evt.value == SDL_HAT_RIGHTUP
|
||||
|| evt.value == SDL_HAT_RIGHTDOWN)
|
||||
{
|
||||
it->second.control->setChangingDirection(it->second.direction);
|
||||
}
|
||||
else
|
||||
{
|
||||
it->second.control->setChangingDirection((Control::ControlChangingDirection)(-1 * it->second.direction));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(it->second.control->getValue() == 1)
|
||||
{
|
||||
it->second.control->setChangingDirection(Control::DECREASE);
|
||||
}
|
||||
else if(it->second.control->getValue() == 0)
|
||||
{
|
||||
it->second.control->setChangingDirection(Control::INCREASE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(evt.value == SDL_HAT_CENTERED)
|
||||
{
|
||||
ControlsPOVBinderMapType::const_iterator it = i->second.find( /*POVAxis::*/NorthSouth );
|
||||
if(it != i->second.end())
|
||||
{
|
||||
it->second.control->setChangingDirection(Control::STOP);
|
||||
}
|
||||
|
||||
it = i->second.find( /*POVAxis::*/EastWest );
|
||||
if(it != i->second.end())
|
||||
{
|
||||
it->second.control->setChangingDirection(Control::STOP);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(mDetectingBindingListener)
|
||||
{
|
||||
if(mDetectingBindingControl && mDetectingBindingControl->isAxisBindable())
|
||||
{
|
||||
if(evt.value == SDL_HAT_LEFT
|
||||
|| evt.value == SDL_HAT_RIGHT
|
||||
|| evt.value == SDL_HAT_UP
|
||||
|| evt.value == SDL_HAT_DOWN)
|
||||
{
|
||||
POVAxis povAxis = NorthSouth;
|
||||
if(evt.value == SDL_HAT_LEFT
|
||||
|| evt.value == SDL_HAT_RIGHT)
|
||||
{
|
||||
povAxis = EastWest;
|
||||
}
|
||||
|
||||
mDetectingBindingListener->joystickPOVBindingDetected(this,
|
||||
mDetectingBindingControl, evt.which, index, povAxis, mDetectingBindingDirection);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mJoystickInstanceMap[instanceID] = cntrl;
|
||||
}
|
||||
void InputControlSystem::controllerRemoved(const SDL_ControllerDeviceEvent &args)
|
||||
{
|
||||
ICS_LOG("Removing joystick (instance id: " + ToString<int>(args.which) + ")");
|
||||
if(mJoystickInstanceMap.count(args.which)!=0)
|
||||
{
|
||||
SDL_GameControllerClose(mJoystickInstanceMap.at(args.which));
|
||||
mJoystickInstanceMap.erase(args.which);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: does this have an SDL equivalent?
|
||||
/*
|
||||
void InputControlSystem::sliderMoved(const OIS::JoyStickEvent &evt, int index)
|
||||
{
|
||||
if(mActive)
|
||||
{
|
||||
if(!mDetectingBindingControl)
|
||||
{
|
||||
if(mControlsJoystickSliderBinderMap.find(evt.device->getID()) != mControlsJoystickSliderBinderMap.end())
|
||||
{
|
||||
ControlSliderBinderItem joystickBinderItem = mControlsJoystickSliderBinderMap[ evt.device->getID() ][ index ];
|
||||
Control* ctrl = joystickBinderItem.control;
|
||||
if(ctrl)
|
||||
{
|
||||
ctrl->setIgnoreAutoReverse(true);
|
||||
if(joystickBinderItem.direction == Control::INCREASE)
|
||||
{
|
||||
float axisRange = OIS::JoyStick::MAX_AXIS - OIS::JoyStick::MIN_AXIS;
|
||||
float valDisplaced = (float)( evt.state.mSliders[index].abX - OIS::JoyStick::MIN_AXIS);
|
||||
|
||||
ctrl->setValue( valDisplaced / axisRange );
|
||||
}
|
||||
else if(joystickBinderItem.direction == Control::DECREASE)
|
||||
{
|
||||
float axisRange = OIS::JoyStick::MAX_AXIS - OIS::JoyStick::MIN_AXIS;
|
||||
float valDisplaced = (float)(evt.state.mSliders[index].abX - OIS::JoyStick::MIN_AXIS);
|
||||
|
||||
ctrl->setValue( 1 - ( valDisplaced / axisRange ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(mDetectingBindingListener)
|
||||
{
|
||||
if(mDetectingBindingControl && mDetectingBindingControl->isAxisBindable())
|
||||
{
|
||||
if( abs( evt.state.mSliders[index].abX ) > ICS_JOYSTICK_SLIDER_BINDING_MARGIN)
|
||||
{
|
||||
mDetectingBindingListener->joystickSliderBindingDetected(this,
|
||||
mDetectingBindingControl, evt.device->getID(), index, mDetectingBindingDirection);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// joystick auto bindings
|
||||
void DetectingBindingListener::joystickAxisBindingDetected(InputControlSystem* ICS, Control* control
|
||||
, int deviceId, int axis, Control::ControlChangingDirection direction)
|
||||
void DetectingBindingListener::joystickAxisBindingDetected(InputControlSystem* ICS, int deviceID, Control* control, int axis, Control::ControlChangingDirection direction)
|
||||
{
|
||||
// if the joystick axis is used by another control, remove it
|
||||
ICS->removeJoystickAxisBinding(deviceId, axis);
|
||||
ICS->removeJoystickAxisBinding(deviceID, axis);
|
||||
|
||||
// if the control has an axis assigned, remove it
|
||||
int oldAxis = ICS->getJoystickAxisBinding(control, deviceId, direction);
|
||||
if(oldAxis != InputControlSystem::UNASSIGNED)
|
||||
int oldAxis = ICS->getJoystickAxisBinding(control, deviceID, direction);
|
||||
if(oldAxis != InputControlSystem::UNASSIGNED)
|
||||
{
|
||||
ICS->removeJoystickAxisBinding(deviceId, oldAxis);
|
||||
ICS->removeJoystickAxisBinding(deviceID, oldAxis);
|
||||
}
|
||||
|
||||
ICS->addJoystickAxisBinding(control, deviceId, axis, direction);
|
||||
ICS->addJoystickAxisBinding(control, deviceID, axis, direction);
|
||||
ICS->cancelDetectingBindingState();
|
||||
}
|
||||
void DetectingBindingListener::joystickButtonBindingDetected(InputControlSystem* ICS, Control* control
|
||||
, int deviceId, unsigned int button, Control::ControlChangingDirection direction)
|
||||
void DetectingBindingListener::joystickButtonBindingDetected(InputControlSystem* ICS, int deviceID, Control* control
|
||||
, unsigned int button, Control::ControlChangingDirection direction)
|
||||
{
|
||||
// if the joystick button is used by another control, remove it
|
||||
ICS->removeJoystickButtonBinding(deviceId, button);
|
||||
ICS->removeJoystickButtonBinding(deviceID, button);
|
||||
|
||||
// if the control has a joystick button assigned, remove it
|
||||
unsigned int oldButton = ICS->getJoystickButtonBinding(control, deviceId, direction);
|
||||
unsigned int oldButton = ICS->getJoystickButtonBinding(control, deviceID, direction);
|
||||
if(oldButton != ICS_MAX_DEVICE_BUTTONS)
|
||||
{
|
||||
ICS->removeJoystickButtonBinding(deviceId, oldButton);
|
||||
ICS->removeJoystickButtonBinding(deviceID, oldButton);
|
||||
}
|
||||
|
||||
ICS->addJoystickButtonBinding(control, deviceId, button, direction);
|
||||
ICS->cancelDetectingBindingState();
|
||||
}
|
||||
|
||||
|
||||
void DetectingBindingListener::joystickPOVBindingDetected(InputControlSystem* ICS, Control* control
|
||||
, int deviceId, int pov, InputControlSystem::POVAxis axis, Control::ControlChangingDirection direction)
|
||||
{
|
||||
// if the joystick slider is used by another control, remove it
|
||||
ICS->removeJoystickPOVBinding(deviceId, pov, axis);
|
||||
|
||||
// if the control has a joystick button assigned, remove it
|
||||
ICS::InputControlSystem::POVBindingPair oldPOV = ICS->getJoystickPOVBinding(control, deviceId, direction);
|
||||
if(oldPOV.index >= 0 && oldPOV.axis == axis)
|
||||
{
|
||||
ICS->removeJoystickPOVBinding(deviceId, oldPOV.index, oldPOV.axis);
|
||||
}
|
||||
|
||||
ICS->addJoystickPOVBinding(control, deviceId, pov, axis, direction);
|
||||
ICS->cancelDetectingBindingState();
|
||||
}
|
||||
|
||||
void DetectingBindingListener::joystickSliderBindingDetected(InputControlSystem* ICS, Control* control
|
||||
, int deviceId, int slider, Control::ControlChangingDirection direction)
|
||||
{
|
||||
// if the joystick slider is used by another control, remove it
|
||||
ICS->removeJoystickSliderBinding(deviceId, slider);
|
||||
|
||||
// if the control has a joystick slider assigned, remove it
|
||||
int oldSlider = ICS->getJoystickSliderBinding(control, deviceId, direction);
|
||||
if(oldSlider != InputControlSystem::/*NamedAxis::*/UNASSIGNED)
|
||||
{
|
||||
ICS->removeJoystickSliderBinding(deviceId, oldSlider);
|
||||
}
|
||||
|
||||
ICS->addJoystickSliderBinding(control, deviceId, slider, direction);
|
||||
ICS->addJoystickButtonBinding(control, deviceID, button, direction);
|
||||
ICS->cancelDetectingBindingState();
|
||||
}
|
||||
}
|
||||
|
18
extern/sdl4ogre/events.h
vendored
18
extern/sdl4ogre/events.h
vendored
@ -40,23 +40,25 @@ public:
|
||||
virtual void keyReleased(const SDL_KeyboardEvent &arg) = 0;
|
||||
};
|
||||
|
||||
class JoyListener
|
||||
class ControllerListener
|
||||
{
|
||||
public:
|
||||
virtual ~JoyListener() {}
|
||||
virtual ~ControllerListener() {}
|
||||
/** @remarks Joystick button down event */
|
||||
virtual void buttonPressed( const SDL_JoyButtonEvent &evt, int button ) = 0;
|
||||
virtual void buttonPressed(int deviceID, const SDL_ControllerButtonEvent &evt) = 0;
|
||||
|
||||
/** @remarks Joystick button up event */
|
||||
virtual void buttonReleased( const SDL_JoyButtonEvent &evt, int button ) = 0;
|
||||
virtual void buttonReleased(int deviceID, const SDL_ControllerButtonEvent &evt) = 0;
|
||||
|
||||
/** @remarks Joystick axis moved event */
|
||||
virtual void axisMoved( const SDL_JoyAxisEvent &arg, int axis ) = 0;
|
||||
virtual void axisMoved(int deviceID, const SDL_ControllerAxisEvent &arg) = 0;
|
||||
|
||||
//-- Not so common control events, so are not required --//
|
||||
/** @remarks Joystick Added **/
|
||||
virtual void controllerAdded(int deviceID, const SDL_ControllerDeviceEvent &arg) = 0;
|
||||
|
||||
/** @remarks Joystick Removed **/
|
||||
virtual void controllerRemoved(const SDL_ControllerDeviceEvent &arg) = 0;
|
||||
|
||||
//! Joystick Event, and povID
|
||||
virtual void povMoved( const SDL_JoyHatEvent &arg, int index) {}
|
||||
};
|
||||
|
||||
class WindowListener
|
||||
|
36
extern/sdl4ogre/sdlinputwrapper.cpp
vendored
36
extern/sdl4ogre/sdlinputwrapper.cpp
vendored
@ -20,7 +20,7 @@ namespace SFO
|
||||
mMouseY(0),
|
||||
mMouseX(0),
|
||||
mMouseInWindow(true),
|
||||
mJoyListener(NULL),
|
||||
mConListener(NULL),
|
||||
mKeyboardListener(NULL),
|
||||
mMouseListener(NULL),
|
||||
mWindowListener(NULL),
|
||||
@ -91,24 +91,32 @@ namespace SFO
|
||||
case SDL_TEXTINPUT:
|
||||
mKeyboardListener->textInput(evt.text);
|
||||
break;
|
||||
case SDL_JOYHATMOTION: //As we manage everything with GameController, don't even bother with these.
|
||||
case SDL_JOYAXISMOTION:
|
||||
if (mJoyListener)
|
||||
mJoyListener->axisMoved(evt.jaxis, evt.jaxis.axis);
|
||||
break;
|
||||
case SDL_JOYBUTTONDOWN:
|
||||
if (mJoyListener)
|
||||
mJoyListener->buttonPressed(evt.jbutton, evt.jbutton.button);
|
||||
break;
|
||||
case SDL_JOYBUTTONUP:
|
||||
if (mJoyListener)
|
||||
mJoyListener->buttonReleased(evt.jbutton, evt.jbutton.button);
|
||||
break;
|
||||
case SDL_JOYDEVICEADDED:
|
||||
//SDL_JoystickOpen(evt.jdevice.which);
|
||||
//std::cout << "Detected a new joystick: " << SDL_JoystickNameForIndex(evt.jdevice.which) << std::endl;
|
||||
break;
|
||||
case SDL_JOYDEVICEREMOVED:
|
||||
//std::cout << "A joystick has been removed" << std::endl;
|
||||
break;
|
||||
case SDL_CONTROLLERDEVICEADDED:
|
||||
if(mConListener)
|
||||
mConListener->controllerAdded(1, evt.cdevice); //We only support one joystick, so give everything a generic deviceID
|
||||
break;
|
||||
case SDL_CONTROLLERDEVICEREMOVED:
|
||||
if(mConListener)
|
||||
mConListener->controllerRemoved(evt.cdevice);
|
||||
break;
|
||||
case SDL_CONTROLLERBUTTONDOWN:
|
||||
if(mConListener)
|
||||
mConListener->buttonPressed(1, evt.cbutton);
|
||||
break;
|
||||
case SDL_CONTROLLERBUTTONUP:
|
||||
if(mConListener)
|
||||
mConListener->buttonReleased(1, evt.cbutton);
|
||||
break;
|
||||
case SDL_CONTROLLERAXISMOTION:
|
||||
if(mConListener)
|
||||
mConListener->axisMoved(1, evt.caxis);
|
||||
break;
|
||||
case SDL_WINDOWEVENT:
|
||||
handleWindowEvent(evt);
|
||||
|
4
extern/sdl4ogre/sdlinputwrapper.hpp
vendored
4
extern/sdl4ogre/sdlinputwrapper.hpp
vendored
@ -24,7 +24,7 @@ namespace SFO
|
||||
void setMouseEventCallback(MouseListener* listen) { mMouseListener = listen; }
|
||||
void setKeyboardEventCallback(KeyListener* listen) { mKeyboardListener = listen; }
|
||||
void setWindowEventCallback(WindowListener* listen) { mWindowListener = listen; }
|
||||
void setJoyEventCallback(JoyListener* listen) { mJoyListener = listen; }
|
||||
void setControllerEventCallback(ControllerListener* listen) { mConListener = listen; }
|
||||
|
||||
void capture(bool windowEventsOnly);
|
||||
bool isModifierHeld(SDL_Keymod mod);
|
||||
@ -54,7 +54,7 @@ namespace SFO
|
||||
SFO::MouseListener* mMouseListener;
|
||||
SFO::KeyListener* mKeyboardListener;
|
||||
SFO::WindowListener* mWindowListener;
|
||||
SFO::JoyListener* mJoyListener;
|
||||
SFO::ControllerListener* mConListener;
|
||||
|
||||
typedef boost::unordered_map<SDL_Keycode, OIS::KeyCode> KeyMap;
|
||||
KeyMap mKeyMap;
|
||||
|
101
files/gamecontrollerdb.txt
Normal file
101
files/gamecontrollerdb.txt
Normal file
@ -0,0 +1,101 @@
|
||||
# from https://github.com/gabomdq/SDL_GameControllerDB
|
||||
# License:
|
||||
# Simple DirectMedia Layer
|
||||
# Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
|
||||
#
|
||||
# This software is provided 'as-is', without any express or implied
|
||||
# warranty. In no event will the authors be held liable for any damages
|
||||
# arising from the use of this software.
|
||||
#
|
||||
# Permission is granted to anyone to use this software for any purpose,
|
||||
# including commercial applications, and to alter it and redistribute it
|
||||
# freely, subject to the following restrictions:
|
||||
#
|
||||
# 1. The origin of this software must not be misrepresented; you must not
|
||||
# claim that you wrote the original software. If you use this software
|
||||
# in a product, an acknowledgment in the product documentation would be
|
||||
# appreciated but is not required.
|
||||
# 2. Altered source versions must be plainly marked as such, and must not be
|
||||
# misrepresented as being the original software.
|
||||
# 3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
# Windows - DINPUT
|
||||
8f0e1200000000000000504944564944,Acme,platform:Windows,x:b2,a:b0,b:b1,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b5,rightshoulder:b6,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a3,righty:a2,
|
||||
341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||
ffff0000000000000000504944564944,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,
|
||||
6d0416c2000000000000504944564944,Generic DirectInput Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||
6d0419c2000000000000504944564944,Logitech F710 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,
|
||||
88880803000000000000504944564944,PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b9,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:b7,rightx:a3,righty:a4,start:b11,x:b0,y:b3,platform:Windows,
|
||||
4c056802000000000000504944564944,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Windows,
|
||||
25090500000000000000504944564944,PS3 DualShock,a:b2,b:b1,back:b9,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b0,y:b3,platform:Windows,
|
||||
4c05c405000000000000504944564944,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,
|
||||
6d0418c2000000000000504944564944,Logitech RumblePad 2 USB,platform:Windows,x:b0,a:b1,b:b2,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,
|
||||
36280100000000000000504944564944,OUYA Controller,platform:Windows,a:b0,b:b3,y:b2,x:b1,start:b14,guide:b15,leftstick:b6,rightstick:b7,leftshoulder:b4,rightshoulder:b5,dpup:b8,dpleft:b10,dpdown:b9,dpright:b11,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:b12,righttrigger:b13,
|
||||
4f0400b3000000000000504944564944,Thrustmaster Firestorm Dual Power,a:b0,b:b2,y:b3,x:b1,start:b10,guide:b8,back:b9,leftstick:b11,rightstick:b12,leftshoulder:b4,rightshoulder:b6,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b5,righttrigger:b7,platform:Windows,
|
||||
00f00300000000000000504944564944,RetroUSB.com RetroPad,a:b1,b:b5,x:b0,y:b4,back:b2,start:b3,leftshoulder:b6,rightshoulder:b7,leftx:a0,lefty:a1,platform:Windows,
|
||||
00f0f100000000000000504944564944,RetroUSB.com Super RetroPort,a:b1,b:b5,x:b0,y:b4,back:b2,start:b3,leftshoulder:b6,rightshoulder:b7,leftx:a0,lefty:a1,platform:Windows,
|
||||
28040140000000000000504944564944,GamePad Pro USB,platform:Windows,a:b1,b:b2,x:b0,y:b3,back:b8,start:b9,leftshoulder:b4,rightshoulder:b5,leftx:a0,lefty:a1,lefttrigger:b6,righttrigger:b7,
|
||||
ff113133000000000000504944564944,SVEN X-PAD,platform:Windows,a:b2,b:b3,y:b1,x:b0,start:b5,back:b4,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a4,lefttrigger:b8,righttrigger:b9,
|
||||
8f0e0300000000000000504944564944,Piranha xtreme,platform:Windows,x:b3,a:b2,b:b1,y:b0,back:b8,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b4,rightshoulder:b7,righttrigger:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a3,righty:a2,
|
||||
8f0e0d31000000000000504944564944,Multilaser JS071 USB,platform:Windows,a:b1,b:b2,y:b3,x:b0,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,
|
||||
10080300000000000000504944564944,PS2 USB,platform:Windows,a:b2,b:b1,y:b0,x:b3,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a4,righty:a2,lefttrigger:b4,righttrigger:b5,
|
||||
|
||||
# OS X
|
||||
0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,
|
||||
6d0400000000000016c2000000000000,Logitech F310 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||
6d0400000000000018c2000000000000,Logitech F510 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||
6d040000000000001fc2000000000000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,
|
||||
6d0400000000000019c2000000000000,Logitech Wireless Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,
|
||||
4c050000000000006802000000000000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Mac OS X,
|
||||
4c05000000000000c405000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,Platform:Mac OS X,
|
||||
5e040000000000008e02000000000000,X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,
|
||||
891600000000000000fd000000000000,Razer Onza Tournament,a:b0,b:b1,y:b3,x:b2,start:b8,guide:b10,back:b9,leftstick:b6,rightstick:b7,leftshoulder:b4,rightshoulder:b5,dpup:b11,dpleft:b13,dpdown:b12,dpright:b14,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,platform:Mac OS X,
|
||||
4f0400000000000000b3000000000000,Thrustmaster Firestorm Dual Power,a:b0,b:b2,y:b3,x:b1,start:b10,guide:b8,back:b9,leftstick:b11,rightstick:,leftshoulder:b4,rightshoulder:b6,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b5,righttrigger:b7,platform:Mac OS X,
|
||||
8f0e0000000000000300000000000000,Piranha xtreme,platform:Mac OS X,x:b3,a:b2,b:b1,y:b0,back:b8,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b4,rightshoulder:b7,righttrigger:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a3,righty:a2,
|
||||
0d0f0000000000004d00000000000000,HORI Gem Pad 3,platform:Mac OS X,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,
|
||||
|
||||
# Linux
|
||||
0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Linux,
|
||||
03000000ba2200002010000001010000,Jess Technology USB Game Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,platform:Linux,
|
||||
030000006d04000019c2000010010000,Logitech Cordless RumblePad 2,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||
030000006d0400001dc2000014400000,Logitech F310 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
030000006d0400001ec2000020200000,Logitech F510 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
030000006d04000019c2000011010000,Logitech F710 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Linux,
|
||||
030000006d0400001fc2000005030000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
030000004c0500006802000011010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Linux,
|
||||
030000004c050000c405000011010000,Sony DualShock 4,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a5,lefttrigger:b6,righttrigger:b7,platform:Linux,
|
||||
03000000de280000ff11000001000000,Valve Streaming Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
030000005e0400008e02000014010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
030000005e0400008e02000010010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
030000005e0400001907000000010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
|
||||
03000000100800000100000010010000,Twin USB PS2 Adapter,a:b2,b:b1,y:b0,x:b3,start:b9,guide:,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a2,lefttrigger:b4,righttrigger:b5,platform:Linux,
|
||||
03000000a306000023f6000011010000,Saitek Cyborg V.1 Game Pad,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a4,lefttrigger:b6,righttrigger:b7,platform:Linux,
|
||||
030000004f04000020b3000010010000,Thrustmaster 2 in 1 DT,a:b0,b:b2,y:b3,x:b1,start:b9,guide:,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b6,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b5,righttrigger:b7,platform:Linux,
|
||||
030000004f04000023b3000000010000,Thrustmaster Dual Trigger 3-in-1,platform:Linux,x:b0,a:b1,b:b2,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.0,dpdown:h0.4,dpright:h0.0,dpright:h0.2,dpup:h0.0,dpup:h0.1,leftshoulder:h0.0,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a5,
|
||||
030000008f0e00000300000010010000,GreenAsia Inc. USB Joystick ,platform:Linux,x:b3,a:b2,b:b1,y:b0,back:b8,start:b9,dpleft:h0.8,dpdown:h0.0,dpdown:h0.4,dpright:h0.0,dpright:h0.2,dpup:h0.0,dpup:h0.1,leftshoulder:h0.0,leftshoulder:b6,lefttrigger:b4,rightshoulder:b7,righttrigger:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a3,righty:a2,
|
||||
030000008f0e00001200000010010000,GreenAsia Inc. USB Joystick ,platform:Linux,x:b2,a:b0,b:b1,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b5,rightshoulder:b6,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a3,righty:a2,
|
||||
030000005e0400009102000007010000,X360 Wireless Controller,a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:b13,dpleft:b11,dpdown:b14,dpright:b12,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,platform:Linux,
|
||||
030000006d04000016c2000010010000,Logitech Logitech Dual Action,platform:Linux,x:b0,a:b1,b:b2,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.0,dpdown:h0.4,dpright:h0.0,dpright:h0.2,dpup:h0.0,dpup:h0.1,leftshoulder:h0.0,dpup:h0.1,leftshoulder:h0.0,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,
|
||||
03000000260900008888000000010000,GameCube {WiseGroup USB box},a:b0,b:b2,y:b3,x:b1,start:b7,leftshoulder:,rightshoulder:b6,dpup:h0.1,dpleft:h0.8,rightstick:,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,platform:Linux,
|
||||
030000006d04000011c2000010010000,Logitech WingMan Cordless RumblePad,a:b0,b:b1,y:b4,x:b3,start:b8,guide:b5,back:b2,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:b9,righttrigger:b10,platform:Linux,
|
||||
030000006d04000018c2000010010000,Logitech Logitech RumblePad 2 USB,platform:Linux,x:b0,a:b1,b:b2,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,
|
||||
05000000d6200000ad0d000001000000,Moga Pro,platform:Linux,a:b0,b:b1,y:b3,x:b2,start:b6,leftstick:b7,rightstick:b8,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a5,righttrigger:a4,
|
||||
030000004f04000009d0000000010000,Thrustmaster Run N Drive Wireless PS3,platform:Linux,a:b1,b:b2,x:b0,y:b3,start:b9,guide:b12,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,
|
||||
030000004f04000008d0000000010000,Thrustmaster Run N Drive Wireless,platform:Linux,a:b1,b:b2,x:b0,y:b3,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a5,lefttrigger:b6,righttrigger:b7,
|
||||
0300000000f000000300000000010000,RetroUSB.com RetroPad,a:b1,b:b5,x:b0,y:b4,back:b2,start:b3,leftshoulder:b6,rightshoulder:b7,leftx:a0,lefty:a1,platform:Linux,
|
||||
0300000000f00000f100000000010000,RetroUSB.com Super RetroPort,a:b1,b:b5,x:b0,y:b4,back:b2,start:b3,leftshoulder:b6,rightshoulder:b7,leftx:a0,lefty:a1,platform:Linux,
|
||||
030000006f0e00001f01000000010000,Generic X-Box pad,platform:Linux,x:b2,a:b0,b:b1,y:b3,back:b6,guide:b8,start:b7,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,leftstick:b9,rightstick:b10,leftx:a0,lefty:a1,rightx:a3,righty:a4,
|
||||
03000000280400000140000000010000,Gravis GamePad Pro USB ,platform:Linux,x:b0,a:b1,b:b2,y:b3,back:b8,start:b9,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftx:a0,lefty:a1,
|
||||
030000005e0400008902000021010000,Microsoft X-Box pad v2 (US),platform:Linux,x:b3,a:b0,b:b1,y:b4,back:b6,start:b7,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b5,lefttrigger:a2,rightshoulder:b2,righttrigger:a5,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a3,righty:a4,
|
||||
030000006f0e00001e01000011010000,Rock Candy Gamepad for PS3,platform:Linux,a:b1,b:b2,x:b0,y:b3,back:b8,start:b9,guide:b12,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,
|
||||
03000000250900000500000000010000,Sony PS2 pad with SmartJoy adapter,platform:Linux,a:b2,b:b1,y:b0,x:b3,start:b8,back:b9,leftstick:b10,rightstick:b11,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b4,righttrigger:b5,
|
||||
030000008916000000fd000024010000,Razer Onza Tournament,a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:b13,dpleft:b11,dpdown:b14,dpright:b12,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,platform:Linux,
|
||||
030000004f04000000b3000010010000,Thrustmaster Firestorm Dual Power,a:b0,b:b2,y:b3,x:b1,start:b10,guide:b8,back:b9,leftstick:b11,rightstick:b12,leftshoulder:b4,rightshoulder:b6,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b5,righttrigger:b7,platform:Linux,
|
||||
03000000ad1b000001f5000033050000,Hori Pad EX Turbo 2,a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,platform:Linux,
|
||||
050000004c050000c405000000010000,PS4 Controller (Bluetooth),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Linux,
|
||||
060000004c0500006802000000010000,PS3 Controller (Bluetooth),a:b14,b:b13,y:b12,x:b15,start:b3,guide:b16,back:b0,leftstick:b1,rightstick:b2,leftshoulder:b10,rightshoulder:b11,dpup:b4,dpleft:b7,dpdown:b6,dpright:b5,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b8,righttrigger:b9,platform:Linux,
|
||||
03000000790000000600000010010000,DragonRise Inc. Generic USB Joystick ,platform:Linux,x:b3,a:b2,b:b1,y:b0,back:b8,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a3,righty:a4,
|
||||
03000000666600000488000000010000,Super Joy Box 5 Pro,platform:Linux,a:b2,b:b1,x:b3,y:b0,back:b9,start:b8,leftshoulder:b6,rightshoulder:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b4,righttrigger:b5,dpup:b12,dpleft:b15,dpdown:b14,dpright:b13,
|
||||
05000000362800000100000002010000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,platform:Linux,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b1,y:b2,
|
||||
05000000362800000100000003010000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,platform:Linux,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b1,y:b2,
|
||||
030000008916000001fd000024010000,Razer Onza Classic Edition,platform:Linux,x:b2,a:b0,b:b1,y:b3,back:b6,guide:b8tart:b7,dpleft:b11,dpdown:b14,dpright:b12,dpup:b13,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,leftstick:b9,rightstick:b10,leftx:a0,lefty:a1,rightx:a3,righty:a4,
|
@ -4,7 +4,7 @@
|
||||
<Property key="MinSize" value="430 446"/>
|
||||
<Widget type="TabControl" skin="TabControl" position="8 8 368 405" align="Stretch" name="SettingsTab">
|
||||
<Property key="ButtonAutoWidth" value="true"/>
|
||||
<Widget type="TabItem" skin="" position="4 32 360 308">
|
||||
<Widget type="TabItem" skin="" position="4 32 360 358">
|
||||
<Property key="Caption" value=" #{sPrefs} "/>
|
||||
<Widget type="Widget" skin="" position="4 4 352 54" align="Left Top HStretch">
|
||||
<Widget type="TextBox" skin="NormalText" position="0 0 352 16" align="Left Top">
|
||||
@ -172,15 +172,21 @@
|
||||
</Widget>
|
||||
<Widget type="TabItem" skin="" position="4 32 360 308">
|
||||
<Property key="Caption" value=" #{sControls} "/>
|
||||
<Widget type="Widget" skin="MW_Box" position="4 4 352 154" align="Stretch">
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" position="4 4 137 24" align="Left Top" name="KeyboardButton">
|
||||
<Property key="Caption" value="Mouse/Keyboard"/>
|
||||
</Widget>
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" position="141 4 137 24" align="Lept Top" name="ControllerButton">
|
||||
<Property key="Caption" value="Controller"/>
|
||||
</Widget>
|
||||
<Widget type="Widget" skin="MW_Box" position="4 34 352 154" align="Stretch">
|
||||
<Widget type="ScrollView" skin="MW_ScrollView" position="4 4 344 146" align="Stretch" name="ControlsBox">
|
||||
<Property key="CanvasAlign" value="Left Top"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" position="4 162 137 24" align="Left Bottom" name="ResetControlsButton">
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" position="4 194 137 24" align="Left Bottom" name="ResetControlsButton">
|
||||
<Property key="Caption" value="#{sControlsMenu1}"/>
|
||||
</Widget>
|
||||
<Widget type="HBox" skin="" position="4 192 300 24" align="Left Bottom">
|
||||
<Widget type="HBox" skin="" position="4 224 300 24" align="Left Bottom">
|
||||
<Widget type="AutoSizedButton" skin="MW_Button" position="0 0 24 24" align="Left Bottom" name="InvertYButton">
|
||||
<UserString key="SettingCategory" value="Input"/>
|
||||
<UserString key="SettingName" value="invert y axis"/>
|
||||
@ -190,10 +196,10 @@
|
||||
<Property key="Caption" value="#{sMouseFlip}"/>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget type="TextBox" skin="NormalText" position="4 228 336 18" align="Left Bottom">
|
||||
<Widget type="TextBox" skin="NormalText" position="4 254 336 18" align="Left Bottom">
|
||||
<Property key="Caption" value="Camera sensitivity"/>
|
||||
</Widget>
|
||||
<Widget type="MWScrollBar" skin="MW_HScroll" position="4 252 336 18" align="HStretch Bottom" name="CameraSensitivitySlider">
|
||||
<Widget type="MWScrollBar" skin="MW_HScroll" position="4 278 336 18" align="HStretch Bottom" name="CameraSensitivitySlider">
|
||||
<Property key="Range" value="10000"/>
|
||||
<Property key="Page" value="300"/>
|
||||
<UserString key="SettingType" value="Slider"/>
|
||||
@ -203,11 +209,11 @@
|
||||
<UserString key="SettingMin" value="0.2"/>
|
||||
<UserString key="SettingMax" value="5.0"/>
|
||||
</Widget>
|
||||
<Widget type="TextBox" skin="SandText" position="4 276 336 18" align="Left Bottom">
|
||||
<Widget type="TextBox" skin="SandText" position="4 302 336 18" align="Left Bottom">
|
||||
<Property key="Caption" value="#{sLow}"/>
|
||||
<Property key="TextAlign" value="Left"/>
|
||||
</Widget>
|
||||
<Widget type="TextBox" skin="SandText" position="4 276 336 18" align="Right Bottom">
|
||||
<Widget type="TextBox" skin="SandText" position="4 302 336 18" align="Right Bottom">
|
||||
<Property key="Caption" value="#{sHigh}"/>
|
||||
<Property key="TextAlign" value="Right"/>
|
||||
</Widget>
|
||||
|
Loading…
x
Reference in New Issue
Block a user