the wierd thing is in a opengl project it works but in an Ogre project it doesnt using the same copy the values are forgotten.
This is the code from the inputMap
Code:
static KeyMap MainKeys[BUTTON_MAX]=
{
{ BUTTON_A, VK_A, false},
{ BUTTON_D, VK_D, false},
{ BUTTON_W, VK_W, false},
{ BUTTON_S, VK_S, false},
{ BUTTON_LEFT, VK_LEFT, false},
{ BUTTON_RIGHT, VK_RIGHT, false},
{ BUTTON_UP, VK_UP, false},
{ BUTTON_DOWN, VK_DOWN, false},
{ MBUTTON_LEFT, VK_LBUTTON, false},
{ BUTTON_ESC, VK_ESCAPE, false},
};
and it is accessed though a class as followed
Code:
namespace Input
{
static class InputSystem
{
private:
HWND hWnd;
int sWidth, sHeight;
bool BPressed;
public:
void InitInput(int width, int height,HWND handle)
{
sWidth = width;
sHeight = height;
hWnd = handle;
BPressed = false;
}
void Update()
{
if(BPressed == false)
return;
for(int i = 0; i < BUTTON_MAX; i++)
{
if(!(GetKeyState(MainKeys[i].Key)& 0x80))
MainKeys[i].keydown = false;
}
}
bool CheckKeyPressed(int button)
{
if(MainKeys[button].keydown)
return false;
if(GetKeyState(MainKeys[button].Key) & 0x80)
{
BPressed = true;
return MainKeys[button].keydown = true;
}
else
{
BPressed = false;
return MainKeys[button].keydown = false;
}
}
}InputSystem;
}
if a press K it is button 10 so CheckKeyPressed(BUTTON_K) would make MainKeys[10].keydown = true; the second it goes out of scope MainKeys[10] is set back to false. if in the Keymap they are set to something different it reverts back to how it was initialised.