updated lua bindings + inputmanager
This commit is contained in:
@@ -26,6 +26,8 @@ Luna<Vector_BindLua>::FunctionType Vector_BindLua::methods[] = {
|
||||
lunamethod(Vector_BindLua, Cross),
|
||||
lunamethod(Vector_BindLua, Lerp),
|
||||
lunamethod(Vector_BindLua, Slerp),
|
||||
lunamethod(Vector_BindLua, Clamp),
|
||||
lunamethod(Vector_BindLua, Normalize),
|
||||
lunamethod(Vector_BindLua, QuaternionMultiply),
|
||||
lunamethod(Vector_BindLua, QuaternionFromRollPitchYaw),
|
||||
{ NULL, NULL }
|
||||
@@ -326,6 +328,44 @@ int Vector_BindLua::Slerp(lua_State* L)
|
||||
wiLua::SError(L, "QuaternionSlerp(Vector v1,v2, float t) not enough arguments!");
|
||||
return 0;
|
||||
}
|
||||
int Vector_BindLua::Clamp(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 2)
|
||||
{
|
||||
Vector_BindLua* vec = Luna<Vector_BindLua>::lightcheck(L, 1);
|
||||
float a = wiLua::SGetFloat(L, 2);
|
||||
float b = wiLua::SGetFloat(L, 3);
|
||||
if (vec != nullptr)
|
||||
{
|
||||
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMVectorClamp(vec->vector,XMVectorSet(a,a,a,a),XMVectorSet(b,b,b,b))));
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "Clamp(Vector vector, float min,max) argument is not a Vector!");
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "Clamp(Vector vector, float min,max) not enough arguments!");
|
||||
return 0;
|
||||
}
|
||||
int Vector_BindLua::Saturate(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
{
|
||||
Vector_BindLua* vec = Luna<Vector_BindLua>::lightcheck(L, 1);
|
||||
if (vec != nullptr)
|
||||
{
|
||||
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMVectorSaturate(vec->vector)));
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "Saturate(Vector vector) argument is not a Vector!");
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "Saturate(Vector vector) not enough arguments!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Vector_BindLua::Bind()
|
||||
{
|
||||
|
||||
@@ -38,6 +38,8 @@ public:
|
||||
int Add(lua_State* L);
|
||||
int Subtract(lua_State* L);
|
||||
int Lerp(lua_State* L);
|
||||
int Clamp(lua_State* L);
|
||||
int Saturate(lua_State* L);
|
||||
|
||||
|
||||
int QuaternionMultiply(lua_State* L);
|
||||
|
||||
@@ -136,3 +136,10 @@ XMFLOAT4 wiInputManager::pointer()
|
||||
#endif
|
||||
return XMFLOAT4(0, 0, 0, 0);
|
||||
}
|
||||
void wiInputManager::setpointer(const XMFLOAT4& props)
|
||||
{
|
||||
#ifndef WINSTORE_SUPPORT
|
||||
SetCursorPos((int)props.x, (int)props.y);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -54,8 +54,10 @@ public:
|
||||
static bool press(DWORD button, InputType inputType = InputType::KEYBOARD, short playerindex = 0);
|
||||
//check if a button is held down
|
||||
static bool hold(DWORD button, DWORD frames = 30, bool continuous = false, InputType inputType = InputType::KEYBOARD, short playerIndex = 0);
|
||||
//get pointer position (eg. mouse pointer)
|
||||
//get pointer position (eg. mouse pointer) + 2 unused
|
||||
static XMFLOAT4 pointer();
|
||||
//set pointer position (eg. mouse pointer) + 2 unused
|
||||
static void setpointer(const XMFLOAT4& props);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ Luna<wiInputManager_BindLua>::FunctionType wiInputManager_BindLua::methods[] = {
|
||||
lunamethod(wiInputManager_BindLua, Press),
|
||||
lunamethod(wiInputManager_BindLua, Hold),
|
||||
lunamethod(wiInputManager_BindLua, Pointer),
|
||||
lunamethod(wiInputManager_BindLua, SetPointer),
|
||||
{ NULL, NULL }
|
||||
};
|
||||
Luna<wiInputManager_BindLua>::PropertyType wiInputManager_BindLua::properties[] = {
|
||||
@@ -59,6 +60,25 @@ int wiInputManager_BindLua::Pointer(lua_State* L)
|
||||
Luna<Vector_BindLua>::push(L, new Vector_BindLua(XMLoadFloat4(&wiInputManager::pointer())));
|
||||
return 1;
|
||||
}
|
||||
int wiInputManager_BindLua::SetPointer(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 0)
|
||||
{
|
||||
Vector_BindLua* vec = Luna<Vector_BindLua>::lightcheck(L, 1);
|
||||
if (vec != nullptr)
|
||||
{
|
||||
XMFLOAT4 props;
|
||||
XMStoreFloat4(&props, vec->vector);
|
||||
wiInputManager::setpointer(props);
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "SetPointer(Vector props) argument is not a Vector!");
|
||||
}
|
||||
else
|
||||
wiLua::SError(L, "SetPointer(Vector props) not enough arguments!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void wiInputManager_BindLua::Bind()
|
||||
{
|
||||
@@ -68,6 +88,8 @@ void wiInputManager_BindLua::Bind()
|
||||
initialized = true;
|
||||
Luna<wiInputManager_BindLua>::Register(wiLua::GetGlobal()->GetLuaState());
|
||||
wiLua::GetGlobal()->RunText("input = InputManager()");
|
||||
|
||||
//Keyboard
|
||||
wiLua::GetGlobal()->RunText("VK_UP = 0x26");
|
||||
wiLua::GetGlobal()->RunText("VK_DOWN = 0x28");
|
||||
wiLua::GetGlobal()->RunText("VK_LEFT = 0x25");
|
||||
@@ -76,5 +98,9 @@ void wiInputManager_BindLua::Bind()
|
||||
wiLua::GetGlobal()->RunText("VK_RETURN = 0x0D");
|
||||
wiLua::GetGlobal()->RunText("VK_RSHIFT = 0xA1");
|
||||
wiLua::GetGlobal()->RunText("VK_LSHIFT = 0xA0");
|
||||
|
||||
//Mouse
|
||||
wiLua::GetGlobal()->RunText("VK_LBUTTON = 0x01");
|
||||
wiLua::GetGlobal()->RunText("VK_RBUTTON = 0x02");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ public:
|
||||
int Press(lua_State* L);
|
||||
int Hold(lua_State* L);
|
||||
int Pointer(lua_State* L);
|
||||
int SetPointer(lua_State* L);
|
||||
|
||||
|
||||
static void Bind();
|
||||
|
||||
Reference in New Issue
Block a user