updated lua bindings
This commit is contained in:
@@ -11,9 +11,11 @@ wiInputManager::InputCollection wiInputManager::inputs;
|
||||
#ifndef WINSTORE_SUPPORT
|
||||
#define KEY_DOWN(vk_code) (GetAsyncKeyState(vk_code) < 0)
|
||||
#define KEY_TOGGLE(vk_code) ((GetAsyncKeyState(vk_code) & 1) != 0)
|
||||
#define MOUSEBUTTONDOWN(vk_code) (GetAsyncKeyState(vk_code) & 0x8000)
|
||||
#else
|
||||
#define KEY_DOWN(vk_code) (false)
|
||||
#define KEY_TOGGLE(vk_code) (false)
|
||||
#define MOUSEBUTTONDOWN(vk_code) (false)
|
||||
#endif //WINSTORE_SUPPORT
|
||||
#define KEY_UP(vk_code) (!KEY_DOWN(vk_code))
|
||||
|
||||
@@ -88,6 +90,9 @@ bool wiInputManager::down(DWORD button, InputType inputType, short playerindex)
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case MOUSE:
|
||||
return MOUSEBUTTONDOWN(static_cast<int>(button)) != 0;
|
||||
break;
|
||||
default:break;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -19,11 +19,13 @@ public:
|
||||
static void Update();
|
||||
static void CleanUp();
|
||||
|
||||
// do not change order! (it is used in lua)
|
||||
enum InputType{
|
||||
DIRECTINPUT_JOYPAD,
|
||||
XINPUT_JOYPAD,
|
||||
KEYBOARD,
|
||||
RAWINPUT_JOYPAD,
|
||||
MOUSE,
|
||||
INPUTTYPE_COUNT
|
||||
};
|
||||
struct Input{
|
||||
|
||||
@@ -23,7 +23,12 @@ int wiInputManager_BindLua::Down(lua_State* L)
|
||||
if (argc > 0)
|
||||
{
|
||||
int code = wiLua::SGetInt(L, 1);
|
||||
wiLua::SSetBool( L, wiInputManager::down((DWORD)code) );
|
||||
wiInputManager::InputType type = wiInputManager::KEYBOARD;
|
||||
if (argc > 1)
|
||||
{
|
||||
type = (wiInputManager::InputType)wiLua::SGetInt(L, 2);
|
||||
}
|
||||
wiLua::SSetBool(L, wiInputManager::down((DWORD)code, type));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@@ -34,7 +39,12 @@ int wiInputManager_BindLua::Press(lua_State* L)
|
||||
if (argc > 0)
|
||||
{
|
||||
int code = wiLua::SGetInt(L, 1);
|
||||
wiLua::SSetBool(L, wiInputManager::press((DWORD)code));
|
||||
wiInputManager::InputType type = wiInputManager::KEYBOARD;
|
||||
if (argc > 1)
|
||||
{
|
||||
type = (wiInputManager::InputType)wiLua::SGetInt(L, 2);
|
||||
}
|
||||
wiLua::SSetBool(L, wiInputManager::press((DWORD)code, type));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@@ -50,7 +60,17 @@ int wiInputManager_BindLua::Hold(lua_State* L)
|
||||
{
|
||||
duration = wiLua::SGetInt(L, 2);
|
||||
}
|
||||
wiLua::SSetBool(L, wiInputManager::hold((DWORD)code, (DWORD)duration));
|
||||
bool continuous = false;
|
||||
if (argc > 2)
|
||||
{
|
||||
continuous = wiLua::SGetBool(L, 3);
|
||||
}
|
||||
wiInputManager::InputType type = wiInputManager::KEYBOARD;
|
||||
if (argc > 3)
|
||||
{
|
||||
type = (wiInputManager::InputType)wiLua::SGetInt(L, 4);
|
||||
}
|
||||
wiLua::SSetBool(L, wiInputManager::hold((DWORD)code, (DWORD)duration, continuous, type));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@@ -89,6 +109,13 @@ void wiInputManager_BindLua::Bind()
|
||||
Luna<wiInputManager_BindLua>::Register(wiLua::GetGlobal()->GetLuaState());
|
||||
wiLua::GetGlobal()->RunText("input = InputManager()");
|
||||
|
||||
//Input types
|
||||
wiLua::GetGlobal()->RunText("DIRECTINPUT_JOYPAD = 0");
|
||||
wiLua::GetGlobal()->RunText("XINPUT_JOYPAD = 1");
|
||||
wiLua::GetGlobal()->RunText("KEYBOARD = 2");
|
||||
wiLua::GetGlobal()->RunText("RAWINPUT_JOYPAD = 3");
|
||||
wiLua::GetGlobal()->RunText("MOUSE = 4");
|
||||
|
||||
//Keyboard
|
||||
wiLua::GetGlobal()->RunText("VK_UP = 0x26");
|
||||
wiLua::GetGlobal()->RunText("VK_DOWN = 0x28");
|
||||
|
||||
Reference in New Issue
Block a user