forked from 0ad/0ad
also add code here to reset buttons when alt+tabbing out, analogous to CGUI (thanks to Philip for mentioning the problem)
This was SVN commit r3004.
This commit is contained in:
parent
0d6dd7836d
commit
0a202da843
@ -23,6 +23,18 @@ InReaction GlobalsInputHandler(const SDL_Event* ev)
|
||||
{
|
||||
case SDL_ACTIVEEVENT:
|
||||
g_active = (ev->active.gain != 0);
|
||||
|
||||
// tasked out
|
||||
if(ev->active.gain == 0)
|
||||
{
|
||||
// reset all key/button state, so that we don't get any
|
||||
// phantom events when returning to our app.
|
||||
// see CGUI::ClearMouseState.
|
||||
for(uint i = 0; i < ARRAY_SIZE(g_mouse_buttons); i++)
|
||||
g_mouse_buttons[i] = 0;
|
||||
for(uint i = 0; i < ARRAY_SIZE(g_keys); i++)
|
||||
g_keys[i] = 0;
|
||||
}
|
||||
return IN_PASS;
|
||||
|
||||
case SDL_MOUSEMOTION:
|
||||
|
@ -319,10 +319,23 @@ void hotkeyRegisterGUIObject( const CStr& objName, const CStr& hotkeyName )
|
||||
|
||||
InReaction hotkeyInputHandler( const SDL_Event* ev )
|
||||
{
|
||||
int keycode;
|
||||
int keycode = 0;
|
||||
|
||||
switch( ev->type )
|
||||
{
|
||||
case SDL_ACTIVEEVENT:
|
||||
// tasked out
|
||||
if(ev->active.gain == 0)
|
||||
{
|
||||
// reset all key/button state, so that we don't get any
|
||||
// phantom events when returning to our app.
|
||||
// see CGUI::ClearMouseState.
|
||||
for(uint i = 0; i < ARRAY_SIZE(hotkeys); i++)
|
||||
hotkeys[i] = 0;
|
||||
}
|
||||
// don't continue with the code below (this wasn't an input event)
|
||||
return IN_PASS;
|
||||
|
||||
case SDL_KEYDOWN:
|
||||
case SDL_KEYUP:
|
||||
keycode = (int)ev->key.keysym.sym;
|
||||
|
Loading…
Reference in New Issue
Block a user