Commit c02cf281 authored by TheOnlyJoey's avatar TheOnlyJoey
Browse files

Introduced getAsKeyCode (Currently just for linux) to be able to map string to keycode

parent a3f509e2
...@@ -281,6 +281,18 @@ namespace OIS ...@@ -281,6 +281,18 @@ namespace OIS
Alt = 0x0000100 Alt = 0x0000100
}; };
/**
@remarks
Translates string to KeyCode representation.
For example, "Enter" will be KC_ENTER - Locale
specific of course.
@param str
string to convert
@returns
The matching KeyCode
*/
virtual OIS::KeyCode getAsKeyCode(std::string str) = 0;
/** /**
@remarks @remarks
Check modifier status Check modifier status
......
...@@ -42,6 +42,9 @@ namespace OIS ...@@ -42,6 +42,9 @@ namespace OIS
/** @copydoc Keyboard::getAsString */ /** @copydoc Keyboard::getAsString */
virtual const std::string& getAsString( KeyCode kc ); virtual const std::string& getAsString( KeyCode kc );
/** @copydoc Keyboard::getAsKeyCode */
virtual OIS::KeyCode getAsKeyCode( std::string str );
/** @copydoc Keyboard::copyKeyStates */ /** @copydoc Keyboard::copyKeyStates */
virtual void copyKeyStates( char keys[256] ) const; virtual void copyKeyStates( char keys[256] ) const;
......
...@@ -54,6 +54,7 @@ namespace OIS ...@@ -54,6 +54,7 @@ namespace OIS
// Returns a description of the given key // Returns a description of the given key
virtual std::string& getAsString( KeyCode key ); virtual std::string& getAsString( KeyCode key );
virtual KeyCode getAsKeyCode( std::string str ) {/*TODO: Implement OS version*/;}
virtual Interface* queryInterface( Interface::IType type ) { return 0; } virtual Interface* queryInterface( Interface::IType type ) { return 0; }
......
...@@ -50,6 +50,9 @@ namespace OIS ...@@ -50,6 +50,9 @@ namespace OIS
/** @copydoc Keyboard::getAsString */ /** @copydoc Keyboard::getAsString */
virtual const std::string& getAsString(KeyCode kc); virtual const std::string& getAsString(KeyCode kc);
/** @copydoc Keyboard::getAsKeyCode */
virtual KeyCode getAsKeyCode( std::string str ) {/*TODO: Implement OS version*/;}
/** @copydoc Keyboard::copyKeyStates */ /** @copydoc Keyboard::copyKeyStates */
virtual void copyKeyStates(char keys[256]) const; virtual void copyKeyStates(char keys[256]) const;
......
...@@ -284,6 +284,7 @@ void LinuxKeyboard::capture() ...@@ -284,6 +284,7 @@ void LinuxKeyboard::capture()
while( XPending(display) > 0 ) while( XPending(display) > 0 )
{ {
XNextEvent(display, &event); XNextEvent(display, &event);
if(KeyPress == event.type) if(KeyPress == event.type)
{ {
unsigned int character = 0; unsigned int character = 0;
...@@ -323,7 +324,8 @@ void LinuxKeyboard::capture() ...@@ -323,7 +324,8 @@ void LinuxKeyboard::capture()
event.xkey.state &= ~LockMask; event.xkey.state &= ~LockMask;
XLookupString(&event.xkey,NULL,0,&key,NULL); XLookupString(&event.xkey,NULL,0,&key,NULL);
_injectKeyUp(key); } _injectKeyUp(key);
}
} }
} }
...@@ -422,6 +424,17 @@ const std::string& LinuxKeyboard::getAsString( KeyCode kc ) ...@@ -422,6 +424,17 @@ const std::string& LinuxKeyboard::getAsString( KeyCode kc )
return mGetString; return mGetString;
} }
//-------------------------------------------------------------------//
OIS::KeyCode LinuxKeyboard::getAsKeyCode( std::string str )
{
OIS::KeyCode mGetKeyCode;
KeySym X11Key = XStringToKeysym(str.c_str());
mGetKeyCode = keyConversion.at(X11Key);
return mGetKeyCode;
}
//-------------------------------------------------------------------// //-------------------------------------------------------------------//
void LinuxKeyboard::copyKeyStates( char keys[256] ) const void LinuxKeyboard::copyKeyStates( char keys[256] ) const
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment