summaryrefslogtreecommitdiff
path: root/src/luaconsole.c
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2011-08-20 17:18:09 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-08-20 17:18:09 (GMT)
commit99b67598aa7400300d7e548bc5d0293f09632c25 (patch)
treeb690bb37dab412500f7118077bd179891ac4b475 /src/luaconsole.c
parent03ee03ed1e735352082fa35a06444bbf389bf9c6 (diff)
downloadpowder-99b67598aa7400300d7e548bc5d0293f09632c25.zip
powder-99b67598aa7400300d7e548bc5d0293f09632c25.tar.gz
Changes to unify mouse and keyboard events for Lua
Diffstat (limited to 'src/luaconsole.c')
-rw-r--r--src/luaconsole.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/luaconsole.c b/src/luaconsole.c
index 186764d..1376252 100644
--- a/src/luaconsole.c
+++ b/src/luaconsole.c
@@ -39,6 +39,10 @@ void luacon_open(){
{"unregister_mouseclick", &luatpt_unregister_mouseclick},
{"register_keypress", &luatpt_register_keypress},
{"unregister_keypress", &luatpt_unregister_keypress},
+ {"register_mouseevent", &luatpt_register_mouseclick},
+ {"unregister_mouseevent", &luatpt_unregister_mouseclick},
+ {"register_keyevent", &luatpt_register_keypress},
+ {"unregister_keyevent", &luatpt_unregister_keypress},
{"input", &luatpt_input},
{"message_box", &luatpt_message_box},
{"get_numOfParts", &luatpt_get_numOfParts},
@@ -70,7 +74,7 @@ void luacon_open(){
lua_pushinteger(l, 0);
lua_setfield(l, tptProperties, "mousey");
}
-int luacon_keypress(char key, int modifier){
+int luacon_keyevent(char key, int modifier, int event){
int i = 0, kpcontinue = 1;
if(keypress_function_count){
for(i = 0; i < keypress_function_count && kpcontinue; i++){
@@ -78,7 +82,8 @@ int luacon_keypress(char key, int modifier){
lua_pushstring(l, &key);
lua_pushinteger(l, key);
lua_pushinteger(l, modifier);
- lua_pcall(l, 3, 1, 0);
+ lua_pushinteger(l, event);
+ lua_pcall(l, 4, 1, 0);
if(lua_isboolean(l, -1)){
kpcontinue = lua_toboolean(l, -1);
}
@@ -87,15 +92,15 @@ int luacon_keypress(char key, int modifier){
}
return kpcontinue;
}
-int luacon_mouseclick(int mx, int my, int mb, int mbq){
+int luacon_mouseevent(int mx, int my, int mb, int event){
int i = 0, mpcontinue = 1;
if(mouseclick_function_count){
for(i = 0; i < mouseclick_function_count && mpcontinue; i++){
lua_rawgeti(l, LUA_REGISTRYINDEX, mouseclick_functions[i]);
- lua_pushinteger(l, mbq);
- lua_pushinteger(l, mb);
lua_pushinteger(l, mx);
lua_pushinteger(l, my);
+ lua_pushinteger(l, mb);
+ lua_pushinteger(l, event);
lua_pcall(l, 4, 1, 0);
if(lua_isboolean(l, -1)){
mpcontinue = lua_toboolean(l, -1);
@@ -107,12 +112,12 @@ int luacon_mouseclick(int mx, int my, int mb, int mbq){
}
int luacon_step(int mx, int my){
int tempret = 0, tempb, i, callret;
+ lua_pushinteger(l, my);
+ lua_pushinteger(l, mx);
+ lua_setfield(l, tptProperties, "mousex");
+ lua_setfield(l, tptProperties, "mousey");
if(step_functions[0]){
//Set mouse globals
- lua_pushinteger(l, my);
- lua_pushinteger(l, mx);
- lua_setfield(l, tptProperties, "mousex");
- lua_setfield(l, tptProperties, "mousey");
for(i = 0; i<6; i++){
if(step_functions[i]){
lua_rawgeti(l, LUA_REGISTRYINDEX, step_functions[i]);