Bind to scancodes instead of keycodes

deque
scrawl 10 years ago
parent dc1e8d4e22
commit 319f4e0547

@ -503,7 +503,7 @@ namespace MWInput
// (which is somewhat reasonable, and hopefully true for all SDL platforms) // (which is somewhat reasonable, and hopefully true for all SDL platforms)
OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(arg.keysym.sym); OIS::KeyCode kc = mInputManager->sdl2OISKeyCode(arg.keysym.sym);
if (mInputBinder->getKeyBinding(mInputBinder->getControl(A_Console), ICS::Control::INCREASE) if (mInputBinder->getKeyBinding(mInputBinder->getControl(A_Console), ICS::Control::INCREASE)
== arg.keysym.sym == arg.keysym.scancode
&& MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Console) && MWBase::Environment::get().getWindowManager()->getMode() == MWGui::GM_Console)
SDL_StopTextInput(); SDL_StopTextInput();
@ -870,41 +870,41 @@ namespace MWInput
{ {
// using hardcoded key defaults is inevitable, if we want the configuration files to stay valid // 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) // across different versions of OpenMW (in the case where another input action is added)
std::map<int, int> defaultKeyBindings; std::map<int, SDL_Scancode> defaultKeyBindings;
//Gets the Keyvalue from the Scancode; gives the button in the same place reguardless of keyboard format //Gets the Keyvalue from the Scancode; gives the button in the same place reguardless of keyboard format
defaultKeyBindings[A_Activate] = SDL_GetKeyFromScancode(SDL_SCANCODE_SPACE); defaultKeyBindings[A_Activate] = SDL_SCANCODE_SPACE;
defaultKeyBindings[A_MoveBackward] = SDL_GetKeyFromScancode(SDL_SCANCODE_S); defaultKeyBindings[A_MoveBackward] = SDL_SCANCODE_S;
defaultKeyBindings[A_MoveForward] = SDL_GetKeyFromScancode(SDL_SCANCODE_W); defaultKeyBindings[A_MoveForward] = SDL_SCANCODE_W;
defaultKeyBindings[A_MoveLeft] = SDL_GetKeyFromScancode(SDL_SCANCODE_A); defaultKeyBindings[A_MoveLeft] = SDL_SCANCODE_A;
defaultKeyBindings[A_MoveRight] = SDL_GetKeyFromScancode(SDL_SCANCODE_D); defaultKeyBindings[A_MoveRight] = SDL_SCANCODE_D;
defaultKeyBindings[A_ToggleWeapon] = SDL_GetKeyFromScancode(SDL_SCANCODE_F); defaultKeyBindings[A_ToggleWeapon] = SDL_SCANCODE_F;
defaultKeyBindings[A_ToggleSpell] = SDL_GetKeyFromScancode(SDL_SCANCODE_R); defaultKeyBindings[A_ToggleSpell] = SDL_SCANCODE_R;
defaultKeyBindings[A_QuickKeysMenu] = SDL_GetKeyFromScancode(SDL_SCANCODE_F1); defaultKeyBindings[A_QuickKeysMenu] = SDL_SCANCODE_F1;
defaultKeyBindings[A_Console] = SDL_GetKeyFromScancode(SDL_SCANCODE_GRAVE); defaultKeyBindings[A_Console] = SDL_SCANCODE_GRAVE;
defaultKeyBindings[A_Run] = SDL_GetKeyFromScancode(SDL_SCANCODE_LSHIFT); defaultKeyBindings[A_Run] = SDL_SCANCODE_LSHIFT;
defaultKeyBindings[A_Sneak] = SDL_GetKeyFromScancode(SDL_SCANCODE_LCTRL); defaultKeyBindings[A_Sneak] = SDL_SCANCODE_LCTRL;
defaultKeyBindings[A_AutoMove] = SDL_GetKeyFromScancode(SDL_SCANCODE_Q); defaultKeyBindings[A_AutoMove] = SDL_SCANCODE_Q;
defaultKeyBindings[A_Jump] = SDL_GetKeyFromScancode(SDL_SCANCODE_E); defaultKeyBindings[A_Jump] = SDL_SCANCODE_E;
defaultKeyBindings[A_Journal] = SDL_GetKeyFromScancode(SDL_SCANCODE_J); defaultKeyBindings[A_Journal] = SDL_SCANCODE_J;
defaultKeyBindings[A_Rest] = SDL_GetKeyFromScancode(SDL_SCANCODE_T); defaultKeyBindings[A_Rest] = SDL_SCANCODE_T;
defaultKeyBindings[A_GameMenu] = SDL_GetKeyFromScancode(SDL_SCANCODE_ESCAPE); defaultKeyBindings[A_GameMenu] = SDL_SCANCODE_ESCAPE;
defaultKeyBindings[A_TogglePOV] = SDL_GetKeyFromScancode(SDL_SCANCODE_TAB); defaultKeyBindings[A_TogglePOV] = SDL_SCANCODE_TAB;
defaultKeyBindings[A_QuickKey1] = SDL_GetKeyFromScancode(SDL_SCANCODE_1); defaultKeyBindings[A_QuickKey1] = SDL_SCANCODE_1;
defaultKeyBindings[A_QuickKey2] = SDL_GetKeyFromScancode(SDL_SCANCODE_2); defaultKeyBindings[A_QuickKey2] = SDL_SCANCODE_2;
defaultKeyBindings[A_QuickKey3] = SDL_GetKeyFromScancode(SDL_SCANCODE_3); defaultKeyBindings[A_QuickKey3] = SDL_SCANCODE_3;
defaultKeyBindings[A_QuickKey4] = SDL_GetKeyFromScancode(SDL_SCANCODE_4); defaultKeyBindings[A_QuickKey4] = SDL_SCANCODE_4;
defaultKeyBindings[A_QuickKey5] = SDL_GetKeyFromScancode(SDL_SCANCODE_5); defaultKeyBindings[A_QuickKey5] = SDL_SCANCODE_5;
defaultKeyBindings[A_QuickKey6] = SDL_GetKeyFromScancode(SDL_SCANCODE_6); defaultKeyBindings[A_QuickKey6] = SDL_SCANCODE_6;
defaultKeyBindings[A_QuickKey7] = SDL_GetKeyFromScancode(SDL_SCANCODE_7); defaultKeyBindings[A_QuickKey7] = SDL_SCANCODE_7;
defaultKeyBindings[A_QuickKey8] = SDL_GetKeyFromScancode(SDL_SCANCODE_8); defaultKeyBindings[A_QuickKey8] = SDL_SCANCODE_8;
defaultKeyBindings[A_QuickKey9] = SDL_GetKeyFromScancode(SDL_SCANCODE_9); defaultKeyBindings[A_QuickKey9] = SDL_SCANCODE_9;
defaultKeyBindings[A_QuickKey10] = SDL_GetKeyFromScancode(SDL_SCANCODE_0); defaultKeyBindings[A_QuickKey10] = SDL_SCANCODE_0;
defaultKeyBindings[A_Screenshot] = SDL_GetKeyFromScancode(SDL_SCANCODE_F12); defaultKeyBindings[A_Screenshot] = SDL_SCANCODE_F12;
defaultKeyBindings[A_ToggleHUD] = SDL_GetKeyFromScancode(SDL_SCANCODE_F11); defaultKeyBindings[A_ToggleHUD] = SDL_SCANCODE_F11;
defaultKeyBindings[A_AlwaysRun] = SDL_GetKeyFromScancode(SDL_SCANCODE_CAPSLOCK); defaultKeyBindings[A_AlwaysRun] = SDL_SCANCODE_CAPSLOCK;
defaultKeyBindings[A_QuickSave] = SDL_GetKeyFromScancode(SDL_SCANCODE_F5); defaultKeyBindings[A_QuickSave] = SDL_SCANCODE_F5;
defaultKeyBindings[A_QuickLoad] = SDL_GetKeyFromScancode(SDL_SCANCODE_F9); defaultKeyBindings[A_QuickLoad] = SDL_SCANCODE_F9;
std::map<int, int> defaultMouseButtonBindings; std::map<int, int> defaultMouseButtonBindings;
defaultMouseButtonBindings[A_Inventory] = SDL_BUTTON_RIGHT; defaultMouseButtonBindings[A_Inventory] = SDL_BUTTON_RIGHT;
@ -926,14 +926,14 @@ namespace MWInput
} }
if (!controlExists || force || if (!controlExists || force ||
( mInputBinder->getKeyBinding (control, ICS::Control::INCREASE) == SDLK_UNKNOWN ( mInputBinder->getKeyBinding (control, ICS::Control::INCREASE) == SDL_SCANCODE_UNKNOWN
&& mInputBinder->getMouseButtonBinding (control, ICS::Control::INCREASE) == ICS_MAX_DEVICE_BUTTONS && mInputBinder->getMouseButtonBinding (control, ICS::Control::INCREASE) == ICS_MAX_DEVICE_BUTTONS
)) ))
{ {
clearAllBindings (control); clearAllBindings (control);
if (defaultKeyBindings.find(i) != defaultKeyBindings.end()) if (defaultKeyBindings.find(i) != defaultKeyBindings.end())
mInputBinder->addKeyBinding(control, static_cast<SDL_Keycode>(defaultKeyBindings[i]), ICS::Control::INCREASE); mInputBinder->addKeyBinding(control, defaultKeyBindings[i], ICS::Control::INCREASE);
else if (defaultMouseButtonBindings.find(i) != defaultMouseButtonBindings.end()) else if (defaultMouseButtonBindings.find(i) != defaultMouseButtonBindings.end())
mInputBinder->addMouseButtonBinding (control, defaultMouseButtonBindings[i], ICS::Control::INCREASE); mInputBinder->addMouseButtonBinding (control, defaultMouseButtonBindings[i], ICS::Control::INCREASE);
} }
@ -992,8 +992,8 @@ namespace MWInput
ICS::Control* c = mInputBinder->getChannel (action)->getAttachedControls ().front().control; ICS::Control* c = mInputBinder->getChannel (action)->getAttachedControls ().front().control;
if (mInputBinder->getKeyBinding (c, ICS::Control::INCREASE) != SDLK_UNKNOWN) if (mInputBinder->getKeyBinding (c, ICS::Control::INCREASE) != SDL_SCANCODE_UNKNOWN)
return mInputBinder->keyCodeToString (mInputBinder->getKeyBinding (c, ICS::Control::INCREASE)); return mInputBinder->scancodeToString (mInputBinder->getKeyBinding (c, ICS::Control::INCREASE));
else if (mInputBinder->getMouseButtonBinding (c, ICS::Control::INCREASE) != ICS_MAX_DEVICE_BUTTONS) else if (mInputBinder->getMouseButtonBinding (c, ICS::Control::INCREASE) != ICS_MAX_DEVICE_BUTTONS)
return "#{sMouse} " + boost::lexical_cast<std::string>(mInputBinder->getMouseButtonBinding (c, ICS::Control::INCREASE)); return "#{sMouse} " + boost::lexical_cast<std::string>(mInputBinder->getMouseButtonBinding (c, ICS::Control::INCREASE));
else else
@ -1054,10 +1054,10 @@ namespace MWInput
} }
void InputManager::keyBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control void InputManager::keyBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
, SDL_Keycode key, ICS::Control::ControlChangingDirection direction) , SDL_Scancode key, ICS::Control::ControlChangingDirection direction)
{ {
//Disallow binding escape key //Disallow binding escape key
if(key==SDLK_ESCAPE) if(key==SDL_SCANCODE_ESCAPE)
return; return;
clearAllBindings(control); clearAllBindings(control);
@ -1108,7 +1108,7 @@ namespace MWInput
void InputManager::clearAllBindings (ICS::Control* control) void InputManager::clearAllBindings (ICS::Control* control)
{ {
// right now we don't really need multiple bindings for the same action, so remove all others first // 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) != SDLK_UNKNOWN) if (mInputBinder->getKeyBinding (control, ICS::Control::INCREASE) != SDL_SCANCODE_UNKNOWN)
mInputBinder->removeKeyBinding (mInputBinder->getKeyBinding (control, ICS::Control::INCREASE)); mInputBinder->removeKeyBinding (mInputBinder->getKeyBinding (control, ICS::Control::INCREASE));
if (mInputBinder->getMouseButtonBinding (control, ICS::Control::INCREASE) != ICS_MAX_DEVICE_BUTTONS) if (mInputBinder->getMouseButtonBinding (control, ICS::Control::INCREASE) != ICS_MAX_DEVICE_BUTTONS)
mInputBinder->removeMouseButtonBinding (mInputBinder->getMouseButtonBinding (control, ICS::Control::INCREASE)); mInputBinder->removeMouseButtonBinding (mInputBinder->getMouseButtonBinding (control, ICS::Control::INCREASE));

@ -108,7 +108,7 @@ namespace MWInput
, ICS::InputControlSystem::NamedAxis axis, ICS::Control::ControlChangingDirection direction); , ICS::InputControlSystem::NamedAxis axis, ICS::Control::ControlChangingDirection direction);
virtual void keyBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control virtual void keyBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
, SDL_Keycode key, ICS::Control::ControlChangingDirection direction); , SDL_Scancode key, ICS::Control::ControlChangingDirection direction);
virtual void mouseButtonBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control virtual void mouseButtonBindingDetected(ICS::InputControlSystem* ICS, ICS::Control* control
, unsigned int button, ICS::Control::ControlChangingDirection direction); , unsigned int button, ICS::Control::ControlChangingDirection direction);

@ -424,7 +424,7 @@ namespace ICS
control.SetAttribute( "axisBindable", "false" ); control.SetAttribute( "axisBindable", "false" );
} }
if(getKeyBinding(*o, Control/*::ControlChangingDirection*/::INCREASE) != SDLK_UNKNOWN) if(getKeyBinding(*o, Control/*::ControlChangingDirection*/::INCREASE) != SDL_SCANCODE_UNKNOWN)
{ {
TiXmlElement keyBinder( "KeyBinder" ); TiXmlElement keyBinder( "KeyBinder" );
@ -434,7 +434,7 @@ namespace ICS
control.InsertEndChild(keyBinder); control.InsertEndChild(keyBinder);
} }
if(getKeyBinding(*o, Control/*::ControlChangingDirection*/::DECREASE) != SDLK_UNKNOWN) if(getKeyBinding(*o, Control/*::ControlChangingDirection*/::DECREASE) != SDL_SCANCODE_UNKNOWN)
{ {
TiXmlElement keyBinder( "KeyBinder" ); TiXmlElement keyBinder( "KeyBinder" );
@ -801,14 +801,13 @@ namespace ICS
mDetectingBindingControl = NULL; mDetectingBindingControl = NULL;
} }
std::string InputControlSystem::keyCodeToString(SDL_Keycode key) std::string InputControlSystem::scancodeToString(SDL_Scancode key)
{ {
return std::string(SDL_GetKeyName(key)); SDL_Keycode code = SDL_GetKeyFromScancode(key);
} if (code == SDLK_UNKNOWN)
return std::string(SDL_GetScancodeName(key));
SDL_Keycode InputControlSystem::stringToKeyCode(std::string key) else
{ return std::string(SDL_GetKeyName(code));
return SDL_GetKeyFromName(key.c_str());
} }
void InputControlSystem::adjustMouseRegion(Uint16 width, Uint16 height) void InputControlSystem::adjustMouseRegion(Uint16 width, Uint16 height)

@ -118,14 +118,14 @@ namespace ICS
//TODO: does this have an SDL equivalent? //TODO: does this have an SDL equivalent?
//bool sliderMoved(const OIS::JoyStickEvent &evt, int index); //bool sliderMoved(const OIS::JoyStickEvent &evt, int index);
void addKeyBinding(Control* control, SDL_Keycode key, Control::ControlChangingDirection direction); void addKeyBinding(Control* control, SDL_Scancode key, Control::ControlChangingDirection direction);
void addMouseAxisBinding(Control* control, NamedAxis axis, Control::ControlChangingDirection direction); void addMouseAxisBinding(Control* control, NamedAxis axis, Control::ControlChangingDirection direction);
void addMouseButtonBinding(Control* control, unsigned int button, Control::ControlChangingDirection direction); void addMouseButtonBinding(Control* control, unsigned int button, Control::ControlChangingDirection direction);
void addJoystickAxisBinding(Control* control, int deviceId, int axis, 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 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 addJoystickPOVBinding(Control* control, int deviceId, int index, POVAxis axis, Control::ControlChangingDirection direction);
void addJoystickSliderBinding(Control* control, int deviceId, int index, Control::ControlChangingDirection direction); void addJoystickSliderBinding(Control* control, int deviceId, int index, Control::ControlChangingDirection direction);
void removeKeyBinding(SDL_Keycode key); void removeKeyBinding(SDL_Scancode key);
void removeMouseAxisBinding(NamedAxis axis); void removeMouseAxisBinding(NamedAxis axis);
void removeMouseButtonBinding(unsigned int button); void removeMouseButtonBinding(unsigned int button);
void removeJoystickAxisBinding(int deviceId, int axis); void removeJoystickAxisBinding(int deviceId, int axis);
@ -133,7 +133,7 @@ namespace ICS
void removeJoystickPOVBinding(int deviceId, int index, POVAxis axis); void removeJoystickPOVBinding(int deviceId, int index, POVAxis axis);
void removeJoystickSliderBinding(int deviceId, int index); void removeJoystickSliderBinding(int deviceId, int index);
SDL_Keycode getKeyBinding(Control* control, ICS::Control::ControlChangingDirection direction); SDL_Scancode getKeyBinding(Control* control, ICS::Control::ControlChangingDirection direction);
NamedAxis getMouseAxisBinding(Control* control, ICS::Control::ControlChangingDirection direction); NamedAxis getMouseAxisBinding(Control* control, ICS::Control::ControlChangingDirection direction);
unsigned int getMouseButtonBinding(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); int getJoystickAxisBinding(Control* control, int deviceId, ICS::Control::ControlChangingDirection direction);
@ -141,8 +141,7 @@ namespace ICS
POVBindingPair getJoystickPOVBinding(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 getJoystickSliderBinding(Control* control, int deviceId, ICS::Control::ControlChangingDirection direction);
std::string keyCodeToString(SDL_Keycode key); std::string scancodeToString(SDL_Scancode key);
SDL_Keycode stringToKeyCode(std::string key);
void enableDetectingBindingState(Control* control, Control::ControlChangingDirection direction); void enableDetectingBindingState(Control* control, Control::ControlChangingDirection direction);
void cancelDetectingBindingState(); void cancelDetectingBindingState();
@ -186,7 +185,7 @@ namespace ICS
std::string mFileName; std::string mFileName;
typedef std::map<SDL_Keycode, ControlKeyBinderItem> ControlsKeyBinderMapType; // <KeyCode, [direction, control]> typedef std::map<SDL_Scancode, ControlKeyBinderItem> ControlsKeyBinderMapType; // <Scancode, [direction, control]>
typedef std::map<int, ControlAxisBinderItem> ControlsAxisBinderMapType; // <axis, [direction, control]> typedef std::map<int, ControlAxisBinderItem> ControlsAxisBinderMapType; // <axis, [direction, control]>
typedef std::map<int, ControlButtonBinderItem> ControlsButtonBinderMapType; // <button, [direction, control]> typedef std::map<int, ControlButtonBinderItem> ControlsButtonBinderMapType; // <button, [direction, control]>
typedef std::map<int, ControlPOVBinderItem> ControlsPOVBinderMapType; // <index, [direction, control]> typedef std::map<int, ControlPOVBinderItem> ControlsPOVBinderMapType; // <index, [direction, control]>
@ -233,7 +232,7 @@ namespace ICS
{ {
public: public:
virtual void keyBindingDetected(InputControlSystem* ICS, Control* control virtual void keyBindingDetected(InputControlSystem* ICS, Control* control
, SDL_Keycode key, Control::ControlChangingDirection direction); , SDL_Scancode key, Control::ControlChangingDirection direction);
virtual void mouseAxisBindingDetected(InputControlSystem* ICS, Control* control virtual void mouseAxisBindingDetected(InputControlSystem* ICS, Control* control
, InputControlSystem::NamedAxis axis, Control::ControlChangingDirection direction); , InputControlSystem::NamedAxis axis, Control::ControlChangingDirection direction);

@ -43,16 +43,16 @@ namespace ICS
dir = Control::DECREASE; dir = Control::DECREASE;
} }
addKeyBinding(mControls.back(), FromString<int>(xmlKeyBinder->Attribute("key")), dir); addKeyBinding(mControls.back(), SDL_Scancode(FromString<int>(xmlKeyBinder->Attribute("key"))), dir);
xmlKeyBinder = xmlKeyBinder->NextSiblingElement("KeyBinder"); xmlKeyBinder = xmlKeyBinder->NextSiblingElement("KeyBinder");
} }
} }
void InputControlSystem::addKeyBinding(Control* control, SDL_Keycode key, Control::ControlChangingDirection direction) void InputControlSystem::addKeyBinding(Control* control, SDL_Scancode key, Control::ControlChangingDirection direction)
{ {
ICS_LOG("\tAdding KeyBinder [key=" ICS_LOG("\tAdding KeyBinder [key="
+ keyCodeToString(key) + ", direction=" + scancodeToString(key) + ", direction="
+ ToString<int>(direction) + "]"); + ToString<int>(direction) + "]");
ControlKeyBinderItem controlKeyBinderItem; ControlKeyBinderItem controlKeyBinderItem;
@ -61,7 +61,7 @@ namespace ICS
mControlsKeyBinderMap[ key ] = controlKeyBinderItem; mControlsKeyBinderMap[ key ] = controlKeyBinderItem;
} }
void InputControlSystem::removeKeyBinding(SDL_Keycode key) void InputControlSystem::removeKeyBinding(SDL_Scancode key)
{ {
ControlsKeyBinderMapType::iterator it = mControlsKeyBinderMap.find(key); ControlsKeyBinderMapType::iterator it = mControlsKeyBinderMap.find(key);
if(it != mControlsKeyBinderMap.end()) if(it != mControlsKeyBinderMap.end())
@ -70,7 +70,7 @@ namespace ICS
} }
} }
SDL_Keycode InputControlSystem::getKeyBinding(Control* control SDL_Scancode InputControlSystem::getKeyBinding(Control* control
, ICS::Control::ControlChangingDirection direction) , ICS::Control::ControlChangingDirection direction)
{ {
ControlsKeyBinderMapType::iterator it = mControlsKeyBinderMap.begin(); ControlsKeyBinderMapType::iterator it = mControlsKeyBinderMap.begin();
@ -83,7 +83,7 @@ namespace ICS
it++; it++;
} }
return SDLK_UNKNOWN; return SDL_SCANCODE_UNKNOWN;
} }
void InputControlSystem::keyPressed(const SDL_KeyboardEvent &evt) void InputControlSystem::keyPressed(const SDL_KeyboardEvent &evt)
{ {
@ -91,7 +91,7 @@ namespace ICS
{ {
if(!mDetectingBindingControl) if(!mDetectingBindingControl)
{ {
ControlsKeyBinderMapType::const_iterator it = mControlsKeyBinderMap.find(evt.keysym.sym); ControlsKeyBinderMapType::const_iterator it = mControlsKeyBinderMap.find(evt.keysym.scancode);
if(it != mControlsKeyBinderMap.end()) if(it != mControlsKeyBinderMap.end())
{ {
it->second.control->setIgnoreAutoReverse(false); it->second.control->setIgnoreAutoReverse(false);
@ -115,7 +115,7 @@ namespace ICS
else if(mDetectingBindingListener) else if(mDetectingBindingListener)
{ {
mDetectingBindingListener->keyBindingDetected(this, mDetectingBindingListener->keyBindingDetected(this,
mDetectingBindingControl, evt.keysym.sym, mDetectingBindingDirection); mDetectingBindingControl, evt.keysym.scancode, mDetectingBindingDirection);
} }
} }
} }
@ -124,7 +124,7 @@ namespace ICS
{ {
if(mActive) if(mActive)
{ {
ControlsKeyBinderMapType::const_iterator it = mControlsKeyBinderMap.find(evt.keysym.sym); ControlsKeyBinderMapType::const_iterator it = mControlsKeyBinderMap.find(evt.keysym.scancode);
if(it != mControlsKeyBinderMap.end()) if(it != mControlsKeyBinderMap.end())
{ {
it->second.control->setChangingDirection(Control::STOP); it->second.control->setChangingDirection(Control::STOP);
@ -133,14 +133,14 @@ namespace ICS
} }
void DetectingBindingListener::keyBindingDetected(InputControlSystem* ICS, Control* control void DetectingBindingListener::keyBindingDetected(InputControlSystem* ICS, Control* control
, SDL_Keycode key, Control::ControlChangingDirection direction) , SDL_Scancode key, Control::ControlChangingDirection direction)
{ {
// if the key is used by another control, remove it // if the key is used by another control, remove it
ICS->removeKeyBinding(key); ICS->removeKeyBinding(key);
// if the control has a key assigned, remove it // if the control has a key assigned, remove it
SDL_Keycode oldKey = ICS->getKeyBinding(control, direction); SDL_Scancode oldKey = ICS->getKeyBinding(control, direction);
if(oldKey != SDLK_UNKNOWN) if(oldKey != SDL_SCANCODE_UNKNOWN)
{ {
ICS->removeKeyBinding(oldKey); ICS->removeKeyBinding(oldKey);
} }

Loading…
Cancel
Save