SDL events input routing
This commit is contained in:
parent
9679514ff2
commit
86d56cf5e6
|
|
@ -32,6 +32,7 @@ pub fn getArgs() !NwArgs {
|
||||||
// to conditionally start up feature modules within the engine
|
// to conditionally start up feature modules within the engine
|
||||||
|
|
||||||
var shutdownList: std.ArrayListUnmanaged(*const fn (std.mem.Allocator) void) = .{};
|
var shutdownList: std.ArrayListUnmanaged(*const fn (std.mem.Allocator) void) = .{};
|
||||||
|
var shutdownModuleNames: std.ArrayListUnmanaged([]const u8) = .{};
|
||||||
|
|
||||||
pub fn start_modules(comptime programSpec: anytype, maybeArgs: ?NwArgs, allocator: std.mem.Allocator) !void {
|
pub fn start_modules(comptime programSpec: anytype, maybeArgs: ?NwArgs, allocator: std.mem.Allocator) !void {
|
||||||
const Backlog = @This();
|
const Backlog = @This();
|
||||||
|
|
@ -46,6 +47,7 @@ pub fn start_modules(comptime programSpec: anytype, maybeArgs: ?NwArgs, allocato
|
||||||
try Struct.start_module(programSpec, NwArgs{}, allocator);
|
try Struct.start_module(programSpec, NwArgs{}, allocator);
|
||||||
}
|
}
|
||||||
try shutdownList.append(allocator, Struct.shutdown_module);
|
try shutdownList.append(allocator, Struct.shutdown_module);
|
||||||
|
try shutdownModuleNames.append(allocator, feature);
|
||||||
core.engine_logs("module started >>>> " ++ feature ++ " <<<<");
|
core.engine_logs("module started >>>> " ++ feature ++ " <<<<");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -55,9 +57,11 @@ pub fn start_modules(comptime programSpec: anytype, maybeArgs: ?NwArgs, allocato
|
||||||
pub fn shutdown_modules(allocator: std.mem.Allocator) void {
|
pub fn shutdown_modules(allocator: std.mem.Allocator) void {
|
||||||
var i: isize = @intCast(shutdownList.items.len - 1);
|
var i: isize = @intCast(shutdownList.items.len - 1);
|
||||||
while (i >= 0) : (i -= 1) {
|
while (i >= 0) : (i -= 1) {
|
||||||
|
core.engine_log("module shutting down >>>> {s} <<<<", .{shutdownModuleNames.items[@intCast(i)]});
|
||||||
shutdownList.items[@intCast(i)](allocator);
|
shutdownList.items[@intCast(i)](allocator);
|
||||||
}
|
}
|
||||||
shutdownList.deinit(allocator);
|
shutdownList.deinit(allocator);
|
||||||
|
shutdownModuleNames.deinit(allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start_everything(comptime spec: anytype, allocator: std.mem.Allocator, maybeArgs: ?NwArgs) !void {
|
pub fn start_everything(comptime spec: anytype, allocator: std.mem.Allocator, maybeArgs: ?NwArgs) !void {
|
||||||
|
|
|
||||||
|
|
@ -139,13 +139,10 @@ pub fn start_module(comptime programSpec: anytype, args: anytype, allocator: std
|
||||||
|
|
||||||
_ = try inputs.initInputStack();
|
_ = try inputs.initInputStack();
|
||||||
|
|
||||||
logs("core module starting up... ");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn shutdown_module(_: std.mem.Allocator) void {
|
pub fn shutdown_module(_: std.mem.Allocator) void {
|
||||||
logs("core module shutting down...");
|
|
||||||
|
|
||||||
MemoryTracker.MTPrintStatsDelta();
|
MemoryTracker.MTPrintStatsDelta();
|
||||||
|
|
||||||
logging.shutdownLogging();
|
logging.shutdownLogging();
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,45 @@ pub const BindingType = enum(u8) {
|
||||||
|
|
||||||
const glfw_release = 0;
|
const glfw_release = 0;
|
||||||
|
|
||||||
|
pub fn convertEvent(event: *const sdl3.Event) ?IOEvent {
|
||||||
|
switch (event.type) {
|
||||||
|
sdl3.events.key_down, sdl3.events.key_up => {
|
||||||
|
const scan: Key = @enumFromInt(event.key.scancode);
|
||||||
|
|
||||||
|
return IOEvent{
|
||||||
|
.key = .{
|
||||||
|
.key = scan,
|
||||||
|
.scancode = scan,
|
||||||
|
.action = if (event.key.down) .keyDown else .keyUp,
|
||||||
|
.mods = 0,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
sdl3.events.mouse_button_down, sdl3.events.mouse_button_up => {
|
||||||
|
const scan: Key = @enumFromInt(@as(u32, @intCast(event.button.button)) + 10000);
|
||||||
|
|
||||||
|
return IOEvent{
|
||||||
|
.key = .{
|
||||||
|
.key = scan,
|
||||||
|
.scancode = scan,
|
||||||
|
.action = if (event.key.down) .keyDown else .keyUp,
|
||||||
|
.mods = 0,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
else => {
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
pub const IOEvent = union(enum(u8)) {
|
pub const IOEvent = union(enum(u8)) {
|
||||||
windowFocused: struct { focused: c_int },
|
windowFocused: struct { focused: c_int },
|
||||||
mousePosition: struct { x: f64, y: f64 },
|
mousePosition: struct { x: f64, y: f64 },
|
||||||
mouseButton: struct { button: c_int, action: c_int, mods: c_int },
|
|
||||||
scroll: struct { xoffset: f64, yoffset: f64 },
|
scroll: struct { xoffset: f64, yoffset: f64 },
|
||||||
key: struct { key: c_int, scancode: c_int, action: c_int, mods: c_int },
|
key: struct { key: Key, scancode: Key, action: ActionEvent, mods: c_int },
|
||||||
windowResize: struct { newSize: core.Vector2f },
|
windowResize: struct { newSize: core.Vector2f },
|
||||||
codepoint: c_uint,
|
codepoint: c_uint,
|
||||||
};
|
};
|
||||||
|
|
@ -562,15 +595,9 @@ pub const InputStack = struct {
|
||||||
pub fn routeEvent(self: *@This(), eventToRoute: IOEvent) void {
|
pub fn routeEvent(self: *@This(), eventToRoute: IOEvent) void {
|
||||||
switch (eventToRoute) {
|
switch (eventToRoute) {
|
||||||
.key => |key| {
|
.key => |key| {
|
||||||
const keyEvent: ActionEvent = @enumFromInt(@as(u8, @intCast(key.action)));
|
const keyEvent: ActionEvent = key.action; // @enumFromInt(@as(u8, @intCast(key.action)));
|
||||||
if (keyEvent != .keyHeld) {
|
if (keyEvent != .keyHeld) {
|
||||||
self.routeKeyEvent(@enumFromInt(key.key), keyEvent);
|
self.routeKeyEvent(key.key, keyEvent);
|
||||||
}
|
|
||||||
},
|
|
||||||
.mouseButton => |button| {
|
|
||||||
const keyEvent: ActionEvent = @enumFromInt(@as(u8, @intCast(button.action)));
|
|
||||||
if (keyEvent != .keyHeld) {
|
|
||||||
self.routeKeyEvent(@enumFromInt(button.button + 10001), keyEvent);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
else => {},
|
else => {},
|
||||||
|
|
@ -614,6 +641,7 @@ pub fn initInputStack() !void {
|
||||||
const lua = core.lua;
|
const lua = core.lua;
|
||||||
const pod = lua.pod;
|
const pod = lua.pod;
|
||||||
|
|
||||||
const Key = @import("keys.zig").Key;
|
pub const Key = @import("keys.zig").Key;
|
||||||
|
const sdl3 = @import("sdl3");
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const core = @import("../core.zig");
|
const core = @import("../core.zig");
|
||||||
|
|
|
||||||
|
|
@ -1,128 +1,509 @@
|
||||||
pub const Key = enum(i32) {
|
pub const sdl3 = @import("sdl3");
|
||||||
Unknown = -1,
|
|
||||||
Space = 32,
|
pub const Key = enum(c_uint) {
|
||||||
Apostrophe = 39,
|
unknown,
|
||||||
Comma = 44,
|
|
||||||
Period = 45,
|
//**
|
||||||
Slash = 47,
|
//* \name Usage page 0x07
|
||||||
@"0" = 48,
|
//*
|
||||||
@"1" = 49,
|
//* These values are from usage page 0x07 (USB keyboard page).
|
||||||
@"2" = 50,
|
//*/
|
||||||
@"3" = 51,
|
//* @{ */
|
||||||
@"4" = 52,
|
|
||||||
@"5" = 53,
|
a = 4,
|
||||||
@"6" = 54,
|
b = 5,
|
||||||
@"7" = 55,
|
c = 6,
|
||||||
@"8" = 56,
|
d = 7,
|
||||||
@"9" = 57,
|
e = 8,
|
||||||
Semicolon = 59,
|
f = 9,
|
||||||
Equal = 61,
|
g = 10,
|
||||||
A = 65,
|
h = 11,
|
||||||
B = 66,
|
i = 12,
|
||||||
C = 67,
|
j = 13,
|
||||||
D = 68,
|
k = 14,
|
||||||
E = 69,
|
l = 15,
|
||||||
F = 70,
|
m = 16,
|
||||||
G = 71,
|
n = 17,
|
||||||
H = 72,
|
o = 18,
|
||||||
I = 73,
|
p = 19,
|
||||||
J = 74,
|
q = 20,
|
||||||
K = 75,
|
r = 21,
|
||||||
L = 76,
|
s = 22,
|
||||||
M = 77,
|
t = 23,
|
||||||
N = 78,
|
u = 24,
|
||||||
O = 79,
|
v = 25,
|
||||||
P = 80,
|
w = 26,
|
||||||
Q = 81,
|
x = 27,
|
||||||
R = 82,
|
y = 28,
|
||||||
S = 83,
|
z = 29,
|
||||||
T = 84,
|
|
||||||
U = 85,
|
@"1" = 30,
|
||||||
V = 86,
|
@"2" = 31,
|
||||||
W = 87,
|
@"3" = 32,
|
||||||
X = 88,
|
@"4" = 33,
|
||||||
Y = 89,
|
@"5" = 34,
|
||||||
Z = 90,
|
@"6" = 35,
|
||||||
LeftBrackSq = 91,
|
@"7" = 36,
|
||||||
BackSlash = 92,
|
@"8" = 37,
|
||||||
RightBrackSq = 93,
|
@"9" = 38,
|
||||||
Grave = 96,
|
@"0" = 39,
|
||||||
World1 = 161,
|
|
||||||
World2 = 162,
|
@"return" = 40,
|
||||||
Escape = 256,
|
escape = 41,
|
||||||
Enter = 257,
|
backspace = 42,
|
||||||
Tab = 258,
|
tab = 43,
|
||||||
Backspace = 259,
|
space = 44,
|
||||||
Insert = 260,
|
|
||||||
Delete = 261,
|
minus = 45,
|
||||||
Right = 262,
|
equals = 46,
|
||||||
Left = 263,
|
leftbracket = 47,
|
||||||
Down = 264,
|
rightbracket = 48,
|
||||||
Up = 265,
|
backslash = 49, //**< Located at the lower left of the return
|
||||||
PageUp = 266,
|
// * key on ISO keyboards and at the right end
|
||||||
PageDown = 267,
|
// * of the QWERTY row on ANSI keyboards.
|
||||||
Home = 268,
|
// * Produces REVERSE SOLIDUS (backslash) and
|
||||||
End = 269,
|
// * VERTICAL LINE in a US layout, REVERSE
|
||||||
CapsLock = 280,
|
// * SOLIDUS and VERTICAL LINE in a UK Mac
|
||||||
ScrollLock = 281,
|
// * layout, NUMBER SIGN and TILDE in a UK
|
||||||
NumLock = 282,
|
// * Windows layout, DOLLAR SIGN and POUND SIGN
|
||||||
PrintScreen = 283,
|
// * in a Swiss German layout, NUMBER SIGN and
|
||||||
Pause = 284,
|
// * APOSTROPHE in a German layout, GRAVE
|
||||||
F1 = 290,
|
// * ACCENT and POUND SIGN in a French Mac
|
||||||
F2 = 291,
|
// * layout, and ASTERISK and MICRO SIGN in a
|
||||||
F3 = 292,
|
// * French Windows layout.
|
||||||
F4 = 293,
|
// */
|
||||||
F5 = 294,
|
nonushash = 50, //**< iso usb keyboards actually use this code
|
||||||
F6 = 295,
|
//* instead of 49 for the same key, but all
|
||||||
F7 = 296,
|
//* OSes I've seen treat the two codes
|
||||||
F8 = 297,
|
//* identically. So, as an implementor, unless
|
||||||
F9 = 298,
|
//* your keyboard generates both of those
|
||||||
F10 = 299,
|
//* codes and your OS treats them differently,
|
||||||
F11 = 300,
|
//* you should generate SDL_SCANCODE_BACKSLASH
|
||||||
F12 = 301,
|
//* instead of this code. As a user, you
|
||||||
F13 = 302,
|
//* should not rely on this code because SDL
|
||||||
F14 = 303,
|
//* will never generate it with most (all?)
|
||||||
F15 = 304,
|
//* keyboards.
|
||||||
F16 = 305,
|
//*/
|
||||||
F17 = 306,
|
semicolon = 51,
|
||||||
F18 = 307,
|
apostrophe = 52,
|
||||||
F19 = 308,
|
grave = 53, //**< located in the top left corner (on both ansi
|
||||||
F20 = 309,
|
//* and ISO keyboards). Produces GRAVE ACCENT and
|
||||||
F21 = 310,
|
//* TILDE in a US Windows layout and in US and UK
|
||||||
F22 = 311,
|
//* Mac layouts on ANSI keyboards, GRAVE ACCENT
|
||||||
F23 = 312,
|
//* and NOT SIGN in a UK Windows layout, SECTION
|
||||||
F24 = 313,
|
//* SIGN and PLUS-MINUS SIGN in US and UK Mac
|
||||||
F25 = 314,
|
//* layouts on ISO keyboards, SECTION SIGN and
|
||||||
Kp0 = 320,
|
//* DEGREE SIGN in a Swiss German layout (Mac:
|
||||||
Kp1 = 321,
|
//* only on ISO keyboards), CIRCUMFLEX ACCENT and
|
||||||
Kp2 = 322,
|
//* DEGREE SIGN in a German layout (Mac: only on
|
||||||
Kp3 = 323,
|
//* ISO keyboards), SUPERSCRIPT TWO and TILDE in a
|
||||||
Kp4 = 324,
|
//* French Windows layout, COMMERCIAL AT and
|
||||||
Kp5 = 325,
|
//* NUMBER SIGN in a French Mac layout on ISO
|
||||||
Kp6 = 326,
|
//* keyboards, and LESS-THAN SIGN and GREATER-THAN
|
||||||
Kp7 = 327,
|
//* SIGN in a Swiss German, German, or French Mac
|
||||||
Kp8 = 328,
|
//* layout on ANSI keyboards.
|
||||||
Kp9 = 329,
|
//*/
|
||||||
KpDecimal = 330,
|
comma = 54,
|
||||||
KpDivide = 331,
|
period = 55,
|
||||||
KpMultiply = 332,
|
slash = 56,
|
||||||
KpSubtract = 333,
|
|
||||||
KpAdd = 334,
|
capslock = 57,
|
||||||
KpEnter = 335,
|
|
||||||
KpEqual = 336,
|
f1 = 58,
|
||||||
LeftShift = 340,
|
f2 = 59,
|
||||||
LeftControl = 341,
|
f3 = 60,
|
||||||
LeftAlt = 342,
|
f4 = 61,
|
||||||
LeftSuper = 343,
|
f5 = 62,
|
||||||
RightShift = 344,
|
f6 = 63,
|
||||||
RightControl = 345,
|
f7 = 64,
|
||||||
RightAlt = 346,
|
f8 = 65,
|
||||||
RightSuper = 347,
|
f9 = 66,
|
||||||
Menu = 348,
|
f10 = 67,
|
||||||
Mouse1 = 10001,
|
f11 = 68,
|
||||||
Mouse2 = 10002,
|
f12 = 69,
|
||||||
Mouse3 = 10003,
|
|
||||||
Mouse4 = 10004,
|
printscreen = 70,
|
||||||
Mouse5 = 10005,
|
scrolllock = 71,
|
||||||
_,
|
pause = 72,
|
||||||
|
insert = 73, //**< insert on pc, help on some mac keyboards (but
|
||||||
|
// does send code 73, not 117) */
|
||||||
|
home = 74,
|
||||||
|
pageup = 75,
|
||||||
|
delete = 76,
|
||||||
|
end = 77,
|
||||||
|
pagedown = 78,
|
||||||
|
right = 79,
|
||||||
|
left = 80,
|
||||||
|
down = 81,
|
||||||
|
up = 82,
|
||||||
|
|
||||||
|
numlockclear = 83, //**< num lock on pc, clear on mac keyboards
|
||||||
|
//*/
|
||||||
|
kp_divide = 84,
|
||||||
|
kp_multiply = 85,
|
||||||
|
kp_minus = 86,
|
||||||
|
kp_plus = 87,
|
||||||
|
kp_enter = 88,
|
||||||
|
kp_1 = 89,
|
||||||
|
kp_2 = 90,
|
||||||
|
kp_3 = 91,
|
||||||
|
kp_4 = 92,
|
||||||
|
kp_5 = 93,
|
||||||
|
kp_6 = 94,
|
||||||
|
kp_7 = 95,
|
||||||
|
kp_8 = 96,
|
||||||
|
kp_9 = 97,
|
||||||
|
kp_0 = 98,
|
||||||
|
kp_period = 99,
|
||||||
|
|
||||||
|
nonusbackslash = 100, //**< this is the additional key that iso
|
||||||
|
//* keyboards have over ANSI ones,
|
||||||
|
//* located between left shift and Y.
|
||||||
|
//* Produces GRAVE ACCENT and TILDE in a
|
||||||
|
//* US or UK Mac layout, REVERSE SOLIDUS
|
||||||
|
//* (backslash) and VERTICAL LINE in a
|
||||||
|
//* US or UK Windows layout, and
|
||||||
|
//* LESS-THAN SIGN and GREATER-THAN SIGN
|
||||||
|
//* in a Swiss German, German, or French
|
||||||
|
//* layout. */
|
||||||
|
application = 101, //**< windows contextual menu, compose */
|
||||||
|
power = 102, //**< the usb document says this is a status flag,
|
||||||
|
// * not a physical key - but some Mac keyboards
|
||||||
|
// * do have a power key. */
|
||||||
|
kp_equals = 103,
|
||||||
|
f13 = 104,
|
||||||
|
f14 = 105,
|
||||||
|
f15 = 106,
|
||||||
|
f16 = 107,
|
||||||
|
f17 = 108,
|
||||||
|
f18 = 109,
|
||||||
|
f19 = 110,
|
||||||
|
f20 = 111,
|
||||||
|
f21 = 112,
|
||||||
|
f22 = 113,
|
||||||
|
f23 = 114,
|
||||||
|
f24 = 115,
|
||||||
|
execute = 116,
|
||||||
|
help = 117, //**< al integrated help center */
|
||||||
|
menu = 118, //**< menu (show menu) */
|
||||||
|
select = 119,
|
||||||
|
stop = 120, //**< ac stop */
|
||||||
|
again = 121, //**< ac redo/repeat */
|
||||||
|
undo = 122, //**< ac undo */
|
||||||
|
cut = 123, //**< ac cut */
|
||||||
|
copy = 124, //**< ac copy */
|
||||||
|
paste = 125, //**< ac paste */
|
||||||
|
find = 126, //**< ac find */
|
||||||
|
mute = 127,
|
||||||
|
volumeup = 128,
|
||||||
|
volumedown = 129,
|
||||||
|
///* not sure whether there's a reason to enable these */
|
||||||
|
///* sdl_scancode_lockingcapslock = 130, */
|
||||||
|
///* sdl_scancode_lockingnumlock = 131, */
|
||||||
|
///* sdl_scancode_lockingscrolllock = 132, */
|
||||||
|
kp_comma = 133,
|
||||||
|
kp_equalsas400 = 134,
|
||||||
|
|
||||||
|
international1 = 135, // **< used on asian keyboards, see
|
||||||
|
// footnotes in usb doc */
|
||||||
|
international2 = 136,
|
||||||
|
international3 = 137, //**< yen */
|
||||||
|
international4 = 138,
|
||||||
|
international5 = 139,
|
||||||
|
international6 = 140,
|
||||||
|
international7 = 141,
|
||||||
|
international8 = 142,
|
||||||
|
international9 = 143,
|
||||||
|
lang1 = 144, //**< hangul/english toggle */
|
||||||
|
lang2 = 145, //**< hanja conversion */
|
||||||
|
lang3 = 146, //**< katakana */
|
||||||
|
lang4 = 147, //**< hiragana */
|
||||||
|
lang5 = 148, //**< zenkaku/hankaku */
|
||||||
|
lang6 = 149, //**< reserved */
|
||||||
|
lang7 = 150, //**< reserved */
|
||||||
|
lang8 = 151, //**< reserved */
|
||||||
|
lang9 = 152, //**< reserved */
|
||||||
|
|
||||||
|
alterase = 153, //**< erase-eaze */
|
||||||
|
sysreq = 154,
|
||||||
|
cancel = 155, //**< ac cancel */
|
||||||
|
clear = 156,
|
||||||
|
prior = 157,
|
||||||
|
return2 = 158,
|
||||||
|
separator = 159,
|
||||||
|
out = 160,
|
||||||
|
oper = 161,
|
||||||
|
clearagain = 162,
|
||||||
|
crsel = 163,
|
||||||
|
exsel = 164,
|
||||||
|
|
||||||
|
kp_00 = 176,
|
||||||
|
kp_000 = 177,
|
||||||
|
thousandsseparator = 178,
|
||||||
|
decimalseparator = 179,
|
||||||
|
currencyunit = 180,
|
||||||
|
currencysubunit = 181,
|
||||||
|
kp_leftparen = 182,
|
||||||
|
kp_rightparen = 183,
|
||||||
|
kp_leftbrace = 184,
|
||||||
|
kp_rightbrace = 185,
|
||||||
|
kp_tab = 186,
|
||||||
|
kp_backspace = 187,
|
||||||
|
kp_a = 188,
|
||||||
|
kp_b = 189,
|
||||||
|
kp_c = 190,
|
||||||
|
kp_d = 191,
|
||||||
|
kp_e = 192,
|
||||||
|
kp_f = 193,
|
||||||
|
kp_xor = 194,
|
||||||
|
kp_power = 195,
|
||||||
|
kp_percent = 196,
|
||||||
|
kp_less = 197,
|
||||||
|
kp_greater = 198,
|
||||||
|
kp_ampersand = 199,
|
||||||
|
kp_dblampersand = 200,
|
||||||
|
kp_verticalbar = 201,
|
||||||
|
kp_dblverticalbar = 202,
|
||||||
|
kp_colon = 203,
|
||||||
|
kp_hash = 204,
|
||||||
|
kp_space = 205,
|
||||||
|
kp_at = 206,
|
||||||
|
kp_exclam = 207,
|
||||||
|
kp_memstore = 208,
|
||||||
|
kp_memrecall = 209,
|
||||||
|
kp_memclear = 210,
|
||||||
|
kp_memadd = 211,
|
||||||
|
kp_memsubtract = 212,
|
||||||
|
kp_memmultiply = 213,
|
||||||
|
kp_memdivide = 214,
|
||||||
|
kp_plusminus = 215,
|
||||||
|
kp_clear = 216,
|
||||||
|
kp_clearentry = 217,
|
||||||
|
kp_binary = 218,
|
||||||
|
kp_octal = 219,
|
||||||
|
kp_decimal = 220,
|
||||||
|
kp_hexadecimal = 221,
|
||||||
|
|
||||||
|
lctrl = 224,
|
||||||
|
lshift = 225,
|
||||||
|
lalt = 226, //**< alt, option */
|
||||||
|
lgui = 227, //**< windows, command (apple), meta */
|
||||||
|
rctrl = 228,
|
||||||
|
rshift = 229,
|
||||||
|
ralt = 230, //**< alt gr, option */
|
||||||
|
rgui = 231, //**< windows, command (apple), meta */
|
||||||
|
|
||||||
|
mode = 257, //**< i'm not sure if this is really not covered
|
||||||
|
//* by any of the above, but since there's a
|
||||||
|
//* special sdl_kmod_mode for it i'm adding it here
|
||||||
|
//*/
|
||||||
|
|
||||||
|
//* @} *//* Usage page 0x07 */
|
||||||
|
|
||||||
|
///**
|
||||||
|
// * \name Usage page 0x0C
|
||||||
|
// *
|
||||||
|
// * These values are mapped from usage page 0x0C (USB consumer page).
|
||||||
|
// *
|
||||||
|
// * There are way more keys in the spec than we can represent in the
|
||||||
|
// * current scancode range, so pick the ones that commonly come up in
|
||||||
|
// * real world usage.
|
||||||
|
// */
|
||||||
|
///* @{ */
|
||||||
|
sleep = 258, //**< sleep */
|
||||||
|
wake = 259, //**< wake */
|
||||||
|
|
||||||
|
channel_increment = 260, //**< channel increment */
|
||||||
|
channel_decrement = 261, //**< channel decrement */
|
||||||
|
|
||||||
|
media_play = 262, //**< play */
|
||||||
|
media_pause = 263, //**< pause */
|
||||||
|
media_record = 264, //**< record */
|
||||||
|
media_fast_forward = 265, //**< fast forward */
|
||||||
|
media_rewind = 266, //**< rewind */
|
||||||
|
media_next_track = 267, //**< next track */
|
||||||
|
media_previous_track = 268, //**< previous track */
|
||||||
|
media_stop = 269, //**< stop */
|
||||||
|
media_eject = 270, //**< eject */
|
||||||
|
media_play_pause = 271, //**< play / pause */
|
||||||
|
media_select = 272, //* media select */
|
||||||
|
|
||||||
|
ac_new = 273, //**< ac new */
|
||||||
|
ac_open = 274, //**< ac open */
|
||||||
|
ac_close = 275, //**< ac close */
|
||||||
|
ac_exit = 276, //**< ac exit */
|
||||||
|
ac_save = 277, //**< ac save */
|
||||||
|
ac_print = 278, //**< ac print */
|
||||||
|
ac_properties = 279, //**< ac properties */
|
||||||
|
|
||||||
|
ac_search = 280, //**< ac search */
|
||||||
|
ac_home = 281, //**< ac home */
|
||||||
|
ac_back = 282, //**< ac back */
|
||||||
|
ac_forward = 283, //**< ac forward */
|
||||||
|
ac_stop = 284, //**< ac stop */
|
||||||
|
ac_refresh = 285, //**< ac refresh */
|
||||||
|
ac_bookmarks = 286, //**< ac bookmarks */
|
||||||
|
|
||||||
|
//* @} *//* Usage page 0x0C */
|
||||||
|
|
||||||
|
//**
|
||||||
|
//* \name Mobile keys
|
||||||
|
//*
|
||||||
|
//* These are values that are often used on mobile phones.
|
||||||
|
//*/
|
||||||
|
//* @{ */
|
||||||
|
|
||||||
|
softleft = 287, //**< usually situated below the display on phones and
|
||||||
|
// used as a multi-function feature key for selecting
|
||||||
|
// a software defined function shown on the bottom left
|
||||||
|
// of the display. */
|
||||||
|
softright = 288, //**< usually situated below the display on phones and
|
||||||
|
// used as a multi-function feature key for selecting
|
||||||
|
// a software defined function shown on the bottom right
|
||||||
|
// of the display. */
|
||||||
|
call = 289, //**< used for accepting phone calls. */
|
||||||
|
endcall = 290, //**< used for rejecting phone calls. */
|
||||||
|
|
||||||
|
//* @} *//* Mobile keys */
|
||||||
|
//* Add any other keys here. */
|
||||||
|
|
||||||
|
reserved = 400, //**< 400-500 reserved for dynamic keycodes */
|
||||||
|
|
||||||
|
count = 512, //**< not a key, just marks the number of scancodes for array bounds */
|
||||||
|
|
||||||
|
// BacklogEngine extensions.. will treat mouse button events as a key much like a scancode.
|
||||||
|
Mouse1 = 10001, // Left
|
||||||
|
Mouse2 = 10002, // Middle
|
||||||
|
Mouse3 = 10003, // Right
|
||||||
|
Mouse4 = 10004, // Mouse 4
|
||||||
|
Mouse5 = 10005, // Mouse 5
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// pub const Key = enum(i32) {
|
||||||
|
// Unknown = -1,
|
||||||
|
// Space = 32,
|
||||||
|
// Apostrophe = 39,
|
||||||
|
// Comma = 44,
|
||||||
|
// Period = 45,
|
||||||
|
// Slash = 47,
|
||||||
|
// @"0" = 48,
|
||||||
|
// @"1" = 49,
|
||||||
|
// @"2" = 50,
|
||||||
|
// @"3" = 51,
|
||||||
|
// @"4" = 52,
|
||||||
|
// @"5" = 53,
|
||||||
|
// @"6" = 54,
|
||||||
|
// @"7" = 55,
|
||||||
|
// @"8" = 56,
|
||||||
|
// @"9" = 57,
|
||||||
|
// Semicolon = 59,
|
||||||
|
// Equal = 61,
|
||||||
|
// A = 65,
|
||||||
|
// B = 66,
|
||||||
|
// C = 67,
|
||||||
|
// D = 68,
|
||||||
|
// E = 69,
|
||||||
|
// F = 70,
|
||||||
|
// G = 71,
|
||||||
|
// H = 72,
|
||||||
|
// I = 73,
|
||||||
|
// J = 74,
|
||||||
|
// K = 75,
|
||||||
|
// L = 76,
|
||||||
|
// M = 77,
|
||||||
|
// N = 78,
|
||||||
|
// O = 79,
|
||||||
|
// P = 80,
|
||||||
|
// Q = 81,
|
||||||
|
// R = 82,
|
||||||
|
// S = 83,
|
||||||
|
// T = 84,
|
||||||
|
// U = 85,
|
||||||
|
// V = 86,
|
||||||
|
// W = 87,
|
||||||
|
// X = 88,
|
||||||
|
// Y = 89,
|
||||||
|
// Z = 90,
|
||||||
|
// LeftBrackSq = 91,
|
||||||
|
// BackSlash = 92,
|
||||||
|
// RightBrackSq = 93,
|
||||||
|
// Grave = 96,
|
||||||
|
// World1 = 161,
|
||||||
|
// World2 = 162,
|
||||||
|
// Escape = 256,
|
||||||
|
// Enter = 257,
|
||||||
|
// Tab = 258,
|
||||||
|
// Backspace = 259,
|
||||||
|
// Insert = 260,
|
||||||
|
// Delete = 261,
|
||||||
|
// Right = 262,
|
||||||
|
// Left = 263,
|
||||||
|
// Down = 264,
|
||||||
|
// Up = 265,
|
||||||
|
// PageUp = 266,
|
||||||
|
// PageDown = 267,
|
||||||
|
// Home = 268,
|
||||||
|
// End = 269,
|
||||||
|
// CapsLock = 280,
|
||||||
|
// ScrollLock = 281,
|
||||||
|
// NumLock = 282,
|
||||||
|
// PrintScreen = 283,
|
||||||
|
// Pause = 284,
|
||||||
|
// F1 = 290,
|
||||||
|
// F2 = 291,
|
||||||
|
// F3 = 292,
|
||||||
|
// F4 = 293,
|
||||||
|
// F5 = 294,
|
||||||
|
// F6 = 295,
|
||||||
|
// F7 = 296,
|
||||||
|
// F8 = 297,
|
||||||
|
// F9 = 298,
|
||||||
|
// F10 = 299,
|
||||||
|
// F11 = 300,
|
||||||
|
// F12 = 301,
|
||||||
|
// F13 = 302,
|
||||||
|
// F14 = 303,
|
||||||
|
// F15 = 304,
|
||||||
|
// F16 = 305,
|
||||||
|
// F17 = 306,
|
||||||
|
// F18 = 307,
|
||||||
|
// F19 = 308,
|
||||||
|
// F20 = 309,
|
||||||
|
// F21 = 310,
|
||||||
|
// F22 = 311,
|
||||||
|
// F23 = 312,
|
||||||
|
// F24 = 313,
|
||||||
|
// F25 = 314,
|
||||||
|
// Kp0 = 320,
|
||||||
|
// Kp1 = 321,
|
||||||
|
// Kp2 = 322,
|
||||||
|
// Kp3 = 323,
|
||||||
|
// Kp4 = 324,
|
||||||
|
// Kp5 = 325,
|
||||||
|
// Kp6 = 326,
|
||||||
|
// Kp7 = 327,
|
||||||
|
// Kp8 = 328,
|
||||||
|
// Kp9 = 329,
|
||||||
|
// KpDecimal = 330,
|
||||||
|
// KpDivide = 331,
|
||||||
|
// KpMultiply = 332,
|
||||||
|
// KpSubtract = 333,
|
||||||
|
// KpAdd = 334,
|
||||||
|
// KpEnter = 335,
|
||||||
|
// KpEqual = 336,
|
||||||
|
// LeftShift = 340,
|
||||||
|
// LeftControl = 341,
|
||||||
|
// LeftAlt = 342,
|
||||||
|
// LeftSuper = 343,
|
||||||
|
// RightShift = 344,
|
||||||
|
// RightControl = 345,
|
||||||
|
// RightAlt = 346,
|
||||||
|
// RightSuper = 347,
|
||||||
|
// Menu = 348,
|
||||||
|
// Mouse1 = 10001,
|
||||||
|
// Mouse2 = 10002,
|
||||||
|
// Mouse3 = 10003,
|
||||||
|
// Mouse4 = 10004,
|
||||||
|
// Mouse5 = 10005,
|
||||||
|
// _,
|
||||||
|
// };
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ pub fn setWindowSettings(params: windowing.PlatformParams) void {
|
||||||
pub fn start_module(comptime programSpec: anytype, args: anytype, allocator: std.mem.Allocator) !void {
|
pub fn start_module(comptime programSpec: anytype, args: anytype, allocator: std.mem.Allocator) !void {
|
||||||
_ = args;
|
_ = args;
|
||||||
_ = programSpec;
|
_ = programSpec;
|
||||||
core.engine_log("shader compile test sizeof Scene = {d}", .{@sizeOf(test_vert.Scene)});
|
|
||||||
if (core.isUtility()) {
|
if (core.isUtility()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -42,7 +41,6 @@ pub fn shutdown_module(allocator: std.mem.Allocator) void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
core.engine_logs("Shutting down platform");
|
|
||||||
gPlatformInstance.deinit();
|
gPlatformInstance.deinit();
|
||||||
|
|
||||||
// I have a bug somewhere. need to find out where it is
|
// I have a bug somewhere. need to find out where it is
|
||||||
|
|
|
||||||
|
|
@ -119,8 +119,11 @@ pub const PlatformInstance = struct {
|
||||||
core.setupEnginePlatform(self, setupWindow, enginePoll, processEvents);
|
core.setupEnginePlatform(self, setupWindow, enginePoll, processEvents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// runs pinned on io thread.
|
||||||
|
// old glfw needed to do it's polling here.
|
||||||
pub fn enginePoll(opaqueSelf: *anyopaque) core.EngineDataEventError!void {
|
pub fn enginePoll(opaqueSelf: *anyopaque) core.EngineDataEventError!void {
|
||||||
_ = opaqueSelf;
|
_ = opaqueSelf;
|
||||||
|
// this polling event should probably be used for IO, now that we have a free thread for doing w.e
|
||||||
// var self: *@This() = @alignCast(@ptrCast(opaqueSelf));
|
// var self: *@This() = @alignCast(@ptrCast(opaqueSelf));
|
||||||
// self.pollEvents();
|
// self.pollEvents();
|
||||||
}
|
}
|
||||||
|
|
@ -129,11 +132,6 @@ pub const PlatformInstance = struct {
|
||||||
try self.listeners.append(RawInputObjectRef.from(listener));
|
try self.listeners.append(RawInputObjectRef.from(listener));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn convertEvent(event: *const sdl3.Event) ?IOEvent {
|
|
||||||
_ = event;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn processEvents(ptr: *anyopaque, frameNumber: u64) core.EngineDataEventError!void {
|
pub fn processEvents(ptr: *anyopaque, frameNumber: u64) core.EngineDataEventError!void {
|
||||||
_ = frameNumber;
|
_ = frameNumber;
|
||||||
|
|
||||||
|
|
@ -145,7 +143,7 @@ pub const PlatformInstance = struct {
|
||||||
const inputStack = core.getInputStack();
|
const inputStack = core.getInputStack();
|
||||||
inputStack.updatePreviousInputs();
|
inputStack.updatePreviousInputs();
|
||||||
while (sdl3.pollEvent()) |event| {
|
while (sdl3.pollEvent()) |event| {
|
||||||
if (convertEvent(event)) |converted| {
|
if (core.inputs.convertEvent(event)) |converted| {
|
||||||
inputStack.routeEvent(converted);
|
inputStack.routeEvent(converted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ pub fn build(b: *std.Build) void {
|
||||||
|
|
||||||
//const tracy_enabled = b.option(bool, "tracy", "Enables tracy integration") orelse false;
|
//const tracy_enabled = b.option(bool, "tracy", "Enables tracy integration") orelse false;
|
||||||
|
|
||||||
const tracy_enabled: bool = true; //if (b.graph.env_map.hash_map.get("WITH_TRACY") != null) true else false;
|
const tracy_enabled: bool = false; //if (b.graph.env_map.hash_map.get("WITH_TRACY") != null) true else false;
|
||||||
// if (b.graph.env_map.hash_map.get("WITH_TRACY")) |with_tracy| {
|
// if (b.graph.env_map.hash_map.get("WITH_TRACY")) |with_tracy| {
|
||||||
// tracy_enabled = with_tracy;
|
// tracy_enabled = with_tracy;
|
||||||
// }
|
// }
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,23 @@ pub fn prepare_game(self: *@This()) !void {
|
||||||
try core.fs().addContentPath("sampleGame");
|
try core.fs().addContentPath("sampleGame");
|
||||||
try script.loadTypes("scripts");
|
try script.loadTypes("scripts");
|
||||||
try script.runScriptFile("scripts/prepare.lua");
|
try script.runScriptFile("scripts/prepare.lua");
|
||||||
|
|
||||||
|
const exitInput = try core.ActionBinding.create(core.MakeName("exit"));
|
||||||
|
exitInput.addKey(.escape, .keyDown);
|
||||||
|
_ = exitInput.data.addListener(null, onExit);
|
||||||
|
exitInput.activate();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn onExit(ctx: ?*anyopaque, action: core.ActionEvent) void {
|
||||||
|
_ = ctx;
|
||||||
|
_ = action;
|
||||||
|
|
||||||
|
core.exitNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tick(self: *@This(), _: f64) void {
|
pub fn tick(self: *@This(), _: f64) void {
|
||||||
_ = self;
|
_ = self;
|
||||||
|
std.time.sleep(6000 * 1000); // just gonna put this here...
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deinit(self: *@This()) void {
|
pub fn deinit(self: *@This()) void {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue