Skip to content

Commit

Permalink
core: win32: various improvements
Browse files Browse the repository at this point in the history
Added fullscreen mode.
Added borderless mode.
Implemented keyPressed, keyRelease, ... functions
Added mouse wheel event.
Added modifiers to keyboard and mouse events.

Added more scancode conversions in win32 platform.
Default scaling is stretch in d3d12 backend.
Display mode borderless and fullscreen behave the same for now.
The fullscreen implementation will be reviewed later to include
display mode change.
  • Loading branch information
hordurj authored and slimsag committed Aug 25, 2024
1 parent a5a3d31 commit 1287bf9
Show file tree
Hide file tree
Showing 4 changed files with 346 additions and 195 deletions.
28 changes: 16 additions & 12 deletions src/Core.zig
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ pub const InitOptions = struct {
};

fn update(core: *Mod, entities: *mach.Entities.Mod) !void {
_ = core; // autofix
_ = entities; // autofix
_ = core;
_ = entities;
}

fn init(core: *Mod, entities: *mach.Entities.Mod) !void {
Expand Down Expand Up @@ -517,6 +517,7 @@ pub const Key = enum {
kp_8,
kp_9,
kp_decimal,
kp_comma,
kp_equal,
kp_enter,

Expand Down Expand Up @@ -561,6 +562,9 @@ pub const Key = enum {
slash,
grave,

iso_backslash,
international1,

unknown,

pub const max = Key.unknown;
Expand Down Expand Up @@ -968,17 +972,14 @@ pub fn printTitle(
comptime fmt: []const u8,
args: anytype,
) !void {
_ = core;
_ = window_id;
_ = fmt;
_ = args;
// TODO: NO OP
// // Free any previous window title slice
// if (core.get(window_id, .title)) |slice| core.state().allocator.free(slice);

// // Allocate and assign a new window title slice.
// const slice = try std.fmt.allocPrintZ(core.state().allocator, fmt, args);
// try core.set(window_id, .title, slice);
// Allocate and assign a new window title slice.
const slice = try std.fmt.allocPrintZ(core.allocator, fmt, args);
defer core.allocator.free(slice);
core.setTitle(slice);

// TODO: This function does not have access to *core.Mod to update
// try core.Mod.set(window_id, .title, slice);
}

fn exit(core: *Mod) void {
Expand Down Expand Up @@ -1054,6 +1055,7 @@ pub fn deinitLinuxGamemode() void {
comptime {
// Core
assertHasField(Platform, "surface_descriptor");
assertHasField(Platform, "refresh_rate");

assertHasDecl(Platform, "init");
assertHasDecl(Platform, "deinit");
Expand Down Expand Up @@ -1093,6 +1095,8 @@ comptime {
assertHasDecl(Platform, "mouseReleased");
assertHasDecl(Platform, "mousePosition");

// TODO: EventIterator is used

// Timer
assertHasDecl(@This().Timer, "start");
assertHasDecl(@This().Timer, "read");
Expand Down
Loading

0 comments on commit 1287bf9

Please sign in to comment.