SDL3 Events.
This commit is contained in:
@@ -4,6 +4,7 @@ Release: ReiLua version 0.9.0 Using raylib 5.5 and Forked Raygui 4.0
|
|||||||
KEY CHANGES:
|
KEY CHANGES:
|
||||||
- CHANGE: Switch to raylib 5.5.
|
- CHANGE: Switch to raylib 5.5.
|
||||||
- CHANGE: InitWindow is not called anymore before main.lua is called, but still is before RL.init.
|
- CHANGE: InitWindow is not called anymore before main.lua is called, but still is before RL.init.
|
||||||
|
- ADDED: SDL3 Support.
|
||||||
|
|
||||||
DETAILED CHANGES:
|
DETAILED CHANGES:
|
||||||
- CHANGE: Is*Ready to Is*Valid functions.
|
- CHANGE: Is*Ready to Is*Valid functions.
|
||||||
@@ -41,6 +42,7 @@ DETAILED CHANGES:
|
|||||||
- FIXED: uluaPushTransform translation field name fix.
|
- FIXED: uluaPushTransform translation field name fix.
|
||||||
- FIXED: Added rlDisableShader for SetShaderValue* functions to prevent bugs.
|
- FIXED: Added rlDisableShader for SetShaderValue* functions to prevent bugs.
|
||||||
Should be removed if added back in raylib.
|
Should be removed if added back in raylib.
|
||||||
|
- ADDED: SDL3 Events.
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
Release: ReiLua version 0.8.0 Using Raylib 5.0 and Forked Raygui 4.0
|
Release: ReiLua version 0.8.0 Using Raylib 5.0 and Forked Raygui 4.0
|
||||||
|
|||||||
1
devnotes
1
devnotes
@@ -10,7 +10,6 @@ Backlog {
|
|||||||
* Platform desktop SDL
|
* Platform desktop SDL
|
||||||
* Text input not working on gui. Could this be Raylib issue?
|
* Text input not working on gui. Could this be Raylib issue?
|
||||||
* Haptic functions.
|
* Haptic functions.
|
||||||
* SDL3 Pen.
|
|
||||||
* SDL3 GPU?
|
* SDL3 GPU?
|
||||||
* Audio
|
* Audio
|
||||||
* AudioStream.
|
* AudioStream.
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ function RL.init()
|
|||||||
RL.SetWindowState( RL.FLAG_VSYNC_HINT )
|
RL.SetWindowState( RL.FLAG_VSYNC_HINT )
|
||||||
|
|
||||||
RL.SetTextLineSpacing( 24 )
|
RL.SetTextLineSpacing( 24 )
|
||||||
|
|
||||||
|
-- RL.EnableEventWaiting()
|
||||||
|
-- RL.DisableEventWaiting()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function getEventType( event )
|
local function getEventType( event )
|
||||||
@@ -67,46 +70,54 @@ end
|
|||||||
local mousePos = { 0, 0 }
|
local mousePos = { 0, 0 }
|
||||||
local cursorMode = 1
|
local cursorMode = 1
|
||||||
|
|
||||||
function RL.event( event )
|
local pen = {
|
||||||
text = "Event: "..getEventType( event ).."\n"
|
state = RL.SDL_EVENT_PEN_UP,
|
||||||
|
pos = { 0, 0 },
|
||||||
|
pressure = 0,
|
||||||
|
down = false,
|
||||||
|
eraser = false,
|
||||||
|
}
|
||||||
|
|
||||||
if event.type == RL.GLFW_WINDOW_SIZE_EVENT then
|
function RL.event( event )
|
||||||
text = text.."width: "..event.width.." height: "..event.height
|
-- text = "Event: "..getEventType( event ).."\n"
|
||||||
elseif event.type == RL.GLFW_WINDOW_MAXIMIZE_EVENT then
|
|
||||||
text = text.."maximized: "..event.maximized
|
-- if event.type == RL.GLFW_WINDOW_SIZE_EVENT then
|
||||||
elseif event.type == RL.GLFW_WINDOW_ICONYFY_EVENT then
|
-- text = text.."width: "..event.width.." height: "..event.height
|
||||||
text = text.."iconified: "..event.iconified
|
-- elseif event.type == RL.GLFW_WINDOW_MAXIMIZE_EVENT then
|
||||||
elseif event.type == RL.GLFW_WINDOW_FOCUS_EVENT then
|
-- text = text.."maximized: "..event.maximized
|
||||||
text = text.."focused: "..event.focused
|
-- elseif event.type == RL.GLFW_WINDOW_ICONYFY_EVENT then
|
||||||
elseif event.type == RL.GLFW_WINDOW_DROP_EVENT then
|
-- text = text.."iconified: "..event.iconified
|
||||||
text = text.."count: "..event.count.."\n"
|
-- elseif event.type == RL.GLFW_WINDOW_FOCUS_EVENT then
|
||||||
for _, path in ipairs( event.paths ) do
|
-- text = text.."focused: "..event.focused
|
||||||
text = text..path.."\n"
|
-- elseif event.type == RL.GLFW_WINDOW_DROP_EVENT then
|
||||||
end
|
-- text = text.."count: "..event.count.."\n"
|
||||||
elseif event.type == RL.GLFW_KEY_EVENT then
|
-- for _, path in ipairs( event.paths ) do
|
||||||
text = text.."key: "..event.key.." scancode: "..event.scancode.." action: "..getAction( event.action ).." mods: "..event.mods
|
-- text = text..path.."\n"
|
||||||
text = text .."\nkeyName: "..keyName( event.key )
|
-- end
|
||||||
elseif event.type == RL.GLFW_CHAR_EVENT then
|
-- elseif event.type == RL.GLFW_KEY_EVENT then
|
||||||
text = text.."key: "..event.key
|
-- text = text.."key: "..event.key.." scancode: "..event.scancode.." action: "..getAction( event.action ).." mods: "..event.mods
|
||||||
-- text = text .."\nchar: "..string.char( event.key )
|
-- text = text .."\nkeyName: "..keyName( event.key )
|
||||||
text = text .."\nchar: "..utf8.char( event.key )
|
-- elseif event.type == RL.GLFW_CHAR_EVENT then
|
||||||
elseif event.type == RL.GLFW_MOUSE_BUTTON_EVENT then
|
-- text = text.."key: "..event.key
|
||||||
text = text.."button: "..event.button.." action: "..getAction( event.action ).." mods: "..event.mods
|
-- -- text = text .."\nchar: "..string.char( event.key )
|
||||||
elseif event.type == RL.GLFW_MOUSE_CURSOR_POS_EVENT then
|
-- text = text .."\nchar: "..utf8.char( event.key )
|
||||||
text = text.."x: "..event.x.." y: "..event.y
|
-- elseif event.type == RL.GLFW_MOUSE_BUTTON_EVENT then
|
||||||
elseif event.type == RL.GLFW_MOUSE_SCROLL_EVENT then
|
-- text = text.."button: "..event.button.." action: "..getAction( event.action ).." mods: "..event.mods
|
||||||
text = text.."xoffset: "..event.xoffset.." yoffset: "..event.yoffset
|
-- elseif event.type == RL.GLFW_MOUSE_CURSOR_POS_EVENT then
|
||||||
elseif event.type == RL.GLFW_CURSOR_ENTER_EVENT then
|
-- text = text.."x: "..event.x.." y: "..event.y
|
||||||
text = text.."enter: "..event.enter
|
-- elseif event.type == RL.GLFW_MOUSE_SCROLL_EVENT then
|
||||||
cursorIn = event.enter
|
-- text = text.."xoffset: "..event.xoffset.." yoffset: "..event.yoffset
|
||||||
elseif event.type == RL.EVENT_JOYSTICK then
|
-- elseif event.type == RL.GLFW_CURSOR_ENTER_EVENT then
|
||||||
text = text.."jid: "..event.jid.." event: "..event.event
|
-- text = text.."enter: "..event.enter
|
||||||
if event.event == RL.GLFW_CONNECTED then
|
-- cursorIn = event.enter
|
||||||
text = text.."\nConnected"
|
-- elseif event.type == RL.EVENT_JOYSTICK then
|
||||||
elseif event.event == RL.GLFW_DISCONNECTED then
|
-- text = text.."jid: "..event.jid.." event: "..event.event
|
||||||
text = text.."\nDisconnected"
|
-- if event.event == RL.GLFW_CONNECTED then
|
||||||
end
|
-- text = text.."\nConnected"
|
||||||
end
|
-- elseif event.event == RL.GLFW_DISCONNECTED then
|
||||||
|
-- text = text.."\nDisconnected"
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
|
||||||
-- Some SDL events.
|
-- Some SDL events.
|
||||||
|
|
||||||
@@ -148,6 +159,45 @@ function RL.event( event )
|
|||||||
-- elseif event.type == RL.GLFW_PEN_TABLET_PROXIMITY_EVENT then
|
-- elseif event.type == RL.GLFW_PEN_TABLET_PROXIMITY_EVENT then
|
||||||
-- print( event.state )
|
-- print( event.state )
|
||||||
-- end
|
-- end
|
||||||
|
|
||||||
|
-- Some SDL3 events.
|
||||||
|
|
||||||
|
text = event.type.."\n\n"
|
||||||
|
|
||||||
|
if event.type == RL.SDL_EVENT_KEY_DOWN or event.type == RL.SDL_EVENT_KEY_UP then
|
||||||
|
text = text.."key: "..event.key.." repeat: "..tostring( event.repeating )
|
||||||
|
elseif event.type == RL.SDL_EVENT_PEN_AXIS then
|
||||||
|
text = text.."pen_state: "..event.pen_state.." axis: "..event.axis.." value: "..event.value
|
||||||
|
pen.pressure = event.value
|
||||||
|
pen.state = event.pen_state
|
||||||
|
pen.pos[1] = event.x
|
||||||
|
pen.pos[2] = event.y
|
||||||
|
elseif event.type == RL.SDL_EVENT_PEN_MOTION then
|
||||||
|
text = text.."pen_state: "..event.pen_state.." pos: "..event.x..", "..event.y
|
||||||
|
pen.pos[1] = event.x
|
||||||
|
pen.pos[2] = event.y
|
||||||
|
elseif event.type == RL.SDL_EVENT_PEN_DOWN or event.type == RL.SDL_EVENT_PEN_UP then
|
||||||
|
pen.down = event.down
|
||||||
|
pen.eraser = event.eraser
|
||||||
|
elseif event.type == RL.SDL_EVENT_CLIPBOARD_UPDATE then
|
||||||
|
print( "SDL_EVENT_CLIPBOARD_UPDATE:" )
|
||||||
|
for i, t in ipairs( event.mime_types ) do
|
||||||
|
print( i, t )
|
||||||
|
end
|
||||||
|
elseif event.type == RL.SDL_EVENT_GAMEPAD_AXIS_MOTION then
|
||||||
|
text = text.."axis: "..event.axis.."value: "..event.value
|
||||||
|
print( "axis: "..event.axis.." value: "..event.value )
|
||||||
|
elseif event.type == RL.SDL_EVENT_GAMEPAD_ADDED then
|
||||||
|
print( "SDL_EVENT_GAMEPAD_ADDED" )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function drawSDL3PenCircle()
|
||||||
|
RL.DrawCircleLines( pen.pos, 32, RL.GREEN )
|
||||||
|
|
||||||
|
if pen.down then
|
||||||
|
RL.DrawCircle( pen.pos, pen.pressure * 32, pen.eraser and RL.YELLOW or RL.BLUE )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function RL.draw()
|
function RL.draw()
|
||||||
@@ -157,5 +207,7 @@ function RL.draw()
|
|||||||
RL.ClearBackground( RL.RED )
|
RL.ClearBackground( RL.RED )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
drawSDL3PenCircle()
|
||||||
|
|
||||||
RL.DrawText( text, textPos, 20, RL.BLACK )
|
RL.DrawText( text, textPos, 20, RL.BLACK )
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef PLATFORM_DESKTOP_SDL2
|
#if defined PLATFORM_DESKTOP_SDL2 || defined PLATFORM_DESKTOP_SDL3
|
||||||
#define PLATFORM_SDL_EVENT_QUEUE_LEN 128
|
#define PLATFORM_SDL_EVENT_QUEUE_LEN 128
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ typedef struct {
|
|||||||
GLFWpentabletdatafun glfwTabletDataCallback;
|
GLFWpentabletdatafun glfwTabletDataCallback;
|
||||||
GLFWpentabletcursorfun glfwTabletCursorCallback;
|
GLFWpentabletcursorfun glfwTabletCursorCallback;
|
||||||
GLFWpentabletproximityfun glfwTabletProximityCallback;
|
GLFWpentabletproximityfun glfwTabletProximityCallback;
|
||||||
#elif PLATFORM_DESKTOP_SDL2
|
#elif defined PLATFORM_DESKTOP_SDL2 || defined PLATFORM_DESKTOP_SDL3
|
||||||
int SDL_eventQueueLen;
|
int SDL_eventQueueLen;
|
||||||
SDL_Event* SDL_eventQueue;
|
SDL_Event* SDL_eventQueue;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1453,7 +1453,8 @@ void luaCallInit() {
|
|||||||
|
|
||||||
|
|
||||||
void luaCallUpdate() {
|
void luaCallUpdate() {
|
||||||
#if defined PLATFORM_DESKTOP_SDL2 && defined LUA_EVENTS
|
// #if defined PLATFORM_DESKTOP_SDL2 && defined LUA_EVENTS
|
||||||
|
#if ( defined PLATFORM_DESKTOP_SDL2 || defined PLATFORM_DESKTOP_SDL3 ) && defined LUA_EVENTS
|
||||||
platformSendEvents();
|
platformSendEvents();
|
||||||
#endif
|
#endif
|
||||||
lua_State* L = state->luaState;
|
lua_State* L = state->luaState;
|
||||||
|
|||||||
@@ -530,6 +530,7 @@ Event occurs an event of type SDL_DOLLARGESTURE or SDL_DOLLARRECORD is reported.
|
|||||||
call = true;
|
call = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
/* End of events. */
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -18,6 +18,11 @@ bool stateInit( int argn, const char** argc, const char* basePath ) {
|
|||||||
state->mouseOffset = (Vector2){ 0, 0 };
|
state->mouseOffset = (Vector2){ 0, 0 };
|
||||||
state->mouseScale = (Vector2){ 1, 1 };
|
state->mouseScale = (Vector2){ 1, 1 };
|
||||||
|
|
||||||
|
#if defined PLATFORM_DESKTOP_SDL2 || defined PLATFORM_DESKTOP_SDL3
|
||||||
|
state->SDL_eventQueue = malloc( PLATFORM_SDL_EVENT_QUEUE_LEN * sizeof( SDL_Event ) );
|
||||||
|
state->SDL_eventQueueLen = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
return state->run;
|
return state->run;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,10 +34,6 @@ void stateContextInit() {
|
|||||||
state->defaultTexture = (Texture){ 1, 1, 1, 1, 7 };
|
state->defaultTexture = (Texture){ 1, 1, 1, 1, 7 };
|
||||||
state->shapesTexture = (Texture){ 1, 1, 1, 1, 7 };
|
state->shapesTexture = (Texture){ 1, 1, 1, 1, 7 };
|
||||||
state->RLGLcurrentShaderLocs = malloc( RL_MAX_SHADER_LOCATIONS * sizeof( int ) );
|
state->RLGLcurrentShaderLocs = malloc( RL_MAX_SHADER_LOCATIONS * sizeof( int ) );
|
||||||
#ifdef PLATFORM_DESKTOP_SDL2
|
|
||||||
state->SDL_eventQueue = malloc( PLATFORM_SDL_EVENT_QUEUE_LEN * sizeof( SDL_Event ) );
|
|
||||||
state->SDL_eventQueueLen = 0;
|
|
||||||
#endif
|
|
||||||
int* defaultShaderLocs = rlGetShaderLocsDefault();
|
int* defaultShaderLocs = rlGetShaderLocsDefault();
|
||||||
|
|
||||||
for ( int i = 0; i < RL_MAX_SHADER_LOCATIONS; i++ ) {
|
for ( int i = 0; i < RL_MAX_SHADER_LOCATIONS; i++ ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user