-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.zig
71 lines (54 loc) · 1.54 KB
/
main.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const std = @import("std");
// NOTE: Need full path to lib/lvgl
pub const lv = @cImport({
@cInclude("lib/lvgl/lvgl.h");
@cInclude("lib/lvgl_drv/win32drv.h");
});
// NOTE:
// - Get Demos and Examples folders from https://github.com/lvgl/lvgl
// - Need to add all .C files for demos or examples to work.
//
// pub const lvexamples = @cImport({
// @cInclude("lib/lvgl/examples/lv_examples.h");
// });
// pub const lvdemos = @cImport({
// @cInclude("lib/lvgl/demos/lv_demos.h");
// });
pub fn main() void {
HideConsole();
lv.lv_init();
lv.lv_tick_set_cb(tick_count_callback);
if (!single_display_mode_initialization()) {
return;
}
//lvdemos.lv_demo_widgets();
// //lv_demo_benchmark(LV_DEMO_BENCHMARK_MODE_RENDER_AND_DRIVER);
while (!lv.lv_win32_quit_signal) {
const time_till_next: u32 = lv.lv_timer_handler();
lv.Sleep(time_till_next);
}
}
fn single_display_mode_initialization() bool {
if (!lv.lv_win32_init(
lv.GetModuleHandleW(null),
lv.SW_SHOW,
800,
480,
lv.LoadIconW(lv.GetModuleHandleW(null), null)))
{
return false;
}
lv.lv_win32_add_all_input_devices_to_group(null);
return true;
}
fn tick_count_callback() callconv(.C) u32 {
return lv.GetTickCount();
}
fn HideConsole() void {
const BUF_TITLE = 1024;
var hwndFound: lv.HWND = undefined;
var pszWindowTitle: [BUF_TITLE:0]lv.CHAR = std.mem.zeroes([BUF_TITLE:0]lv.CHAR);
_ = lv.GetConsoleTitleA(&pszWindowTitle, BUF_TITLE);
hwndFound = lv.FindWindowA(null, &pszWindowTitle);
_ = lv.ShowWindow(hwndFound, lv.SW_HIDE);
}