Skip to content

Commit

Permalink
* Allow disabling all keybinds too.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbens committed Mar 7, 2011
1 parent b5644d9 commit e885046
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,17 @@ void input_enableAll (void)
}


/**
* @brief Disables all the keybinds.
*/
void input_disableAll (void)
{
int i;
for (i=0; strcmp(keybind_info[i][0],"end"); i++)
input_keybinds[i].disabled = 1;
}


/**
* @brief Enables or disables a keybind.
*/
Expand Down
1 change: 1 addition & 0 deletions src/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const char *input_keyAlreadyBound( KeybindType type, int key, SDLMod mod );
*/
SDLMod input_translateMod( SDLMod mod );
void input_enableAll (void);
void input_disableAll (void);
void input_toggleEnable( const char *key, int enable );

/*
Expand Down
16 changes: 16 additions & 0 deletions src/nlua_naev.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ static int naev_lang( lua_State *L );
static int naev_keyGet( lua_State *L );
static int naev_keyEnable( lua_State *L );
static int naev_keyEnableAll( lua_State *L );
static int naev_keyDisableAll( lua_State *L );
static const luaL_reg naev_methods[] = {
{ "lang", naev_lang },
{ "keyGet", naev_keyGet },
{ "keyEnable", naev_keyEnable },
{ "keyEnableAll", naev_keyEnableAll },
{ "keyDisableAll", naev_keyDisableAll },
{0,0}
}; /**< NAEV Lua methods. */

Expand Down Expand Up @@ -175,4 +177,18 @@ static int naev_keyEnableAll( lua_State *L )
}


/**
* @brief Disables all inputs.
*
* @usage naev.keyDisableAll() -- Disables all inputs
* @luafunc keyDisableAll()
*/
static int naev_keyDisableAll( lua_State *L )
{
(void) L;
input_disableAll();
return 0;
}



0 comments on commit e885046

Please sign in to comment.