Rename lovr.event.pump to lovr.system.pollEvents;

This commit is contained in:
bjorn 2023-05-10 00:54:20 +01:00
parent 027dd0563b
commit da107f4387
6 changed files with 12 additions and 12 deletions

View File

@ -106,8 +106,8 @@ function lovr.run()
if lovr.timer then lovr.timer.step() end
if lovr.load then lovr.load(arg) end
return function()
if lovr.system then lovr.system.pollEvents() end
if lovr.event then
lovr.event.pump()
for name, a, b, c, d in lovr.event.poll() do
if name == 'restart' then
local cookie = lovr.restart and lovr.restart()

View File

@ -222,11 +222,6 @@ static int l_lovrEventPoll(lua_State* L) {
return 1;
}
static int l_lovrEventPump(lua_State* L) {
lovrEventPump();
return 0;
}
static int l_lovrEventPush(lua_State* L) {
CustomEvent eventData;
const char* name = luaL_checkstring(L, 1);
@ -256,7 +251,6 @@ static int l_lovrEventRestart(lua_State* L) {
static const luaL_Reg lovrEvent[] = {
{ "clear", l_lovrEventClear },
{ "poll", l_lovrEventPoll },
{ "pump", l_lovrEventPump },
{ "push", l_lovrEventPush },
{ "quit", l_lovrEventQuit },
{ "restart", l_lovrEventRestart },

View File

@ -189,6 +189,11 @@ static int l_lovrSystemGetWindowDensity(lua_State* L) {
return 1;
}
static int l_lovrSystemPollEvents(lua_State* L) {
lovrSystemPollEvents();
return 0;
}
static int l_lovrSystemIsKeyDown(lua_State* L) {
os_key key = luax_checkenum(L, 1, KeyboardKey, NULL);
lua_pushboolean(L, lovrSystemIsKeyDown(key));
@ -234,6 +239,7 @@ static const luaL_Reg lovrSystem[] = {
{ "getWindowHeight", l_lovrSystemGetWindowHeight },
{ "getWindowDimensions", l_lovrSystemGetWindowDimensions },
{ "getWindowDensity", l_lovrSystemGetWindowDensity },
{ "pollEvents", l_lovrSystemPollEvents },
{ "isKeyDown", l_lovrSystemIsKeyDown },
{ "getMouseX", l_lovrSystemGetMouseX },
{ "getMouseY", l_lovrSystemGetMouseY },

View File

@ -1,6 +1,5 @@
#include "event/event.h"
#include "thread/thread.h"
#include "core/os.h"
#include "util.h"
#include <stdlib.h>
#include <string.h>
@ -46,10 +45,6 @@ void lovrEventDestroy(void) {
memset(&state, 0, sizeof(state));
}
void lovrEventPump(void) {
os_poll_events();
}
void lovrEventPush(Event event) {
#ifndef LOVR_DISABLE_THREAD
if (event.type == EVENT_THREAD_ERROR) {

View File

@ -122,6 +122,10 @@ float lovrSystemGetWindowDensity(void) {
return os_window_get_pixel_density();
}
void lovrSystemPollEvents(void) {
os_poll_events();
}
void lovrSystemGetMousePosition(double* x, double* y) {
*x = state.mouseX;
*y = state.mouseY;

View File

@ -18,6 +18,7 @@ void lovrSystemOpenWindow(struct os_window_config* config);
bool lovrSystemIsWindowOpen(void);
void lovrSystemGetWindowSize(uint32_t* width, uint32_t* height);
float lovrSystemGetWindowDensity(void);
void lovrSystemPollEvents(void);
bool lovrSystemIsKeyDown(int keycode);
void lovrSystemGetMousePosition(double* x, double* y);
bool lovrSystemIsMouseDown(int button);