Fixing line directive codegen for ifs, handling vkey codes
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#import "Base.core"
|
||||
#import "MathVec3.core"
|
||||
#import "Math.core"
|
||||
#import "Arena.core"
|
||||
W32 :: #load "win32_multimedia.core"
|
||||
|
||||
@@ -16,13 +16,13 @@ MU :: struct
|
||||
|
||||
key: [Key.Count]KeyState
|
||||
frame_count: U64
|
||||
time: MuTime
|
||||
time: MUTime
|
||||
quit: Bool
|
||||
|
||||
frame_arena: Arena
|
||||
os: W32.OS
|
||||
|
||||
MuTime :: struct
|
||||
MUTime :: struct
|
||||
total : F64
|
||||
delta : F64 // @modifiable
|
||||
start : F64
|
||||
|
||||
@@ -137,6 +137,11 @@ StartMultimedia :: (x: S64 = 1280, y: S64 = 720, title: String = "Hello people!"
|
||||
Mu.y = Mu.os.bitmap.size.y
|
||||
|
||||
UpdateMultimedia :: (): Bool
|
||||
msg: MSG
|
||||
for PeekMessageW(&msg, Mu.os.window, 0, 0, PM_REMOVE) == 1
|
||||
TranslateMessage(&msg)
|
||||
DispatchMessageW(&msg)
|
||||
|
||||
Mu.frame_count += 1
|
||||
frame_time := Time() - Mu.time.frame_start
|
||||
Mu.time.total += frame_time
|
||||
@@ -156,18 +161,21 @@ UpdateMultimedia :: (): Bool
|
||||
return !Mu.quit
|
||||
|
||||
WindowProc :: (hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM): LRESULT
|
||||
result: LRESULT
|
||||
if msg == WM_DESTROY
|
||||
PostQuitMessage(0)
|
||||
return 0
|
||||
elif msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN
|
||||
key := MapVKToKey(msg)
|
||||
key := MapVKToKey(wparam)
|
||||
Mu.key[key].is_down = true
|
||||
elif msg == WM_KEYUP || msg == WM_SYSKEYUP
|
||||
key := MapVKToKey(msg)
|
||||
key := MapVKToKey(wparam)
|
||||
Mu.key[key].is_down = false
|
||||
|
||||
|
||||
else;; return DefWindowProcW(hwnd, msg, wparam, lparam)
|
||||
else;; result = DefWindowProcW(hwnd, msg, wparam, lparam)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
/*#
|
||||
@@ -244,9 +252,9 @@ el = ""
|
||||
for val,map in mapping:
|
||||
print(f" {el}if vk == {map} ;; return Key.{val}")
|
||||
el = "el"
|
||||
print(" Assert(false, \"Unidentified Virtual Key\")")
|
||||
print(" return Key.None")
|
||||
*/
|
||||
MapVKToKey :: (vk: U32): Key
|
||||
MapVKToKey :: (vk: WPARAM): Key
|
||||
if vk == VK_UP ;; return Key.Up
|
||||
elif vk == VK_DOWN ;; return Key.Down
|
||||
elif vk == VK_LEFT ;; return Key.Left
|
||||
@@ -305,5 +313,5 @@ MapVKToKey :: (vk: U32): Key
|
||||
elif vk == '7' ;; return Key.K7
|
||||
elif vk == '8' ;; return Key.K8
|
||||
elif vk == '9' ;; return Key.K9
|
||||
Assert(false, "Unidentified Virtual Key")
|
||||
return Key.Nil
|
||||
/*END*/
|
||||
Reference in New Issue
Block a user