It is now using SDL for input instead of OIS.
I agree that it is a bit more complex to set up (in my game I made an entire class for the SDL input in order to get it the way I want) but you can search for these places in the code:
keyPressed (especially things such as CameraMan::keyPressed or Sample_NewInstancing::keyPressed)
keyReleased
textInput
There is no function such as isKeyDown from what I can see (at least in my Ogre version), and in my own class I handle it myself from the keyPressed/keyReleased functions by setting the key state to true/false in my own hashmap variable, then I made my own isKeyDown function in order to be able to check if a key is currently down or not.
Here is my code for it (you can most likely just place it in the normal keyPressed/keyReleased/mousePressed/mouseReleased functions of a sample code):
Code: Select all
class CUnbufferedInputHashMapObject
{
public:
CUnbufferedInputHashMapObject()
{
m_value = false;
m_isEmpty = true;
}
~CUnbufferedInputHashMapObject()
{
}
bool m_isEmpty;
bool m_value;
};
static std::unordered_map<CSDL_Keycode, CUnbufferedInputHashMapObject> m_unbufferedInputsHashMap;
class CUnbufferedInputHashMapObject_Mouse
{
public:
CUnbufferedInputHashMapObject_Mouse()
{
m_value = false;
m_isEmpty = true;
}
~CUnbufferedInputHashMapObject_Mouse()
{
}
bool m_isEmpty;
bool m_value;
};
static std::unordered_map<int, CUnbufferedInputHashMapObject_Mouse> m_unbufferedInputsHashMap_Mouse;
typedef SDL_KeyCode CSDL_Keycode;
enum CSDL_MouseButton
{
BUTTON_LEFT = 1,
BUTTON_MIDDLE = 2,
BUTTON_RIGHT = 3,
BUTTON_X1 = 4,
BUTTON_X2 = 5,
};
void CSDL::KeyPressed(const CSDL_KeyboardEvent& evt)
{
CSDL_Keycode tmpKeyCode = (CSDL_Keycode)evt.keycode;
CUnbufferedInputHashMapObject& tmpUnbufferedInputHashMapObject = m_unbufferedInputsHashMap[tmpKeyCode];
tmpUnbufferedInputHashMapObject.m_isEmpty = false;
tmpUnbufferedInputHashMapObject.m_value = true;
app->KeyPressed(evt);
}
void CSDL::KeyReleased(const CSDL_KeyboardEvent& evt)
{
CSDL_Keycode tmpKeyCode = (CSDL_Keycode)evt.keycode;
CUnbufferedInputHashMapObject& tmpUnbufferedInputHashMapObject = m_unbufferedInputsHashMap[tmpKeyCode];
tmpUnbufferedInputHashMapObject.m_isEmpty = false;
tmpUnbufferedInputHashMapObject.m_value = false;
app->KeyReleased(evt);
}
bool CSDL::IsKeyDown(CSDL_Keycode key)
{
CUnbufferedInputHashMapObject& tmpUnbufferedInputHashMapObject = m_unbufferedInputsHashMap[key];
if (tmpUnbufferedInputHashMapObject.m_isEmpty)
return false;
return tmpUnbufferedInputHashMapObject.m_value;
}
void CSDL::MousePressed(const CSDL_MouseButtonEvent& evt)
{
CUnbufferedInputHashMapObject_Mouse& tmpUnbufferedInputHashMapObject_Mouse = m_unbufferedInputsHashMap_Mouse[(int)evt.button];
tmpUnbufferedInputHashMapObject_Mouse.m_isEmpty = false;
tmpUnbufferedInputHashMapObject_Mouse.m_value = true;
app->MousePressed(evt);
}
void CSDL::MouseReleased(const CSDL_MouseButtonEvent& evt)
{
CUnbufferedInputHashMapObject_Mouse& tmpUnbufferedInputHashMapObject_Mouse = m_unbufferedInputsHashMap_Mouse[(int)evt.button];
tmpUnbufferedInputHashMapObject_Mouse.m_isEmpty = false;
tmpUnbufferedInputHashMapObject_Mouse.m_value = false;
app->MouseReleased(evt);
}
bool CSDL::IsMouseDown(CSDL_MouseButton mouseButton)
{
CUnbufferedInputHashMapObject_Mouse& tmpUnbufferedInputHashMapObject_Mouse = m_unbufferedInputsHashMap_Mouse[(int)mouseButton];
if (tmpUnbufferedInputHashMapObject_Mouse.m_isEmpty)
return false;
return tmpUnbufferedInputHashMapObject_Mouse.m_value;
}