diff --git a/stepmania/src/RageInput.cpp b/stepmania/src/RageInput.cpp index 4ee5bdd9aa..d21fb022fe 100644 --- a/stepmania/src/RageInput.cpp +++ b/stepmania/src/RageInput.cpp @@ -52,6 +52,46 @@ void RageInput::AddHandler( InputHandler *pHandler ) m_pDevices.push_back( pHandler ); } + +// lua start +#include "LuaBinding.h" + +template +class LunaRageInput : public Luna +{ +public: + LunaRageInput() { LUA->Register( Register ); } + + static int GetDescriptions( T* p, lua_State *L ) + { + vector vDevices; + vector vsDescriptions; + p->GetDevicesAndDescriptions( vDevices, vsDescriptions ); + LuaHelpers::CreateTableFromArray( vsDescriptions, L ); + return 1; + } + + static void Register(lua_State *L) + { + ADD_METHOD( GetDescriptions ) + Luna::Register( L ); + + // Add global singleton if constructed already. If it's not constructed yet, + // then we'll register it later when we reinit Lua just before + // initializing the display. + if( INPUTMAN ) + { + lua_pushstring(L, "INPUTMAN"); + INPUTMAN->PushSelf( LUA->L ); + lua_settable(L, LUA_GLOBALSINDEX); + } + } +}; + +LUA_REGISTER_CLASS( RageInput ) +// lua end + + /* * Copyright (c) 2001-2004 Chris Danford, Glenn Maynard * All rights reserved. diff --git a/stepmania/src/RageInput.h b/stepmania/src/RageInput.h index 6623745f6f..29d306d1b7 100644 --- a/stepmania/src/RageInput.h +++ b/stepmania/src/RageInput.h @@ -5,7 +5,9 @@ #include "RageInputDevice.h" +struct lua_State; class InputHandler; + class RageInput { public: @@ -13,10 +15,13 @@ public: ~RageInput(); void Update( float fDeltaTime ); - void GetDevicesAndDescriptions( vector& vDevicesOut, vector& vDescriptionsOut ); + void GetDevicesAndDescriptions( vector& vDevicesOut, vector& vsDescriptionsOut ); void WindowReset(); void AddHandler( InputHandler *pHandler ); + // Lua + void PushSelf( lua_State *L ); + private: vector m_pDevices; };