MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / wndproc

Function wndproc

native/windows/src/lib.rs:108–206  ·  view source on GitHub ↗
(hwnd: HWND, msg: u32, wparam: WPARAM, lparam: LPARAM)

Source from the content-addressed store, hash-verified

106 }
107
108 unsafe extern "system" fn wndproc(hwnd: HWND, msg: u32, wparam: WPARAM, lparam: LPARAM) -> LRESULT {
109 match msg {
110 WM_DESTROY => {
111 PostQuitMessage(0);
112 if let Some(eng) = ENGINE.get_mut() {
113 eng.should_close = true;
114 }
115 LRESULT(0)
116 }
117 WM_KEYDOWN => {
118 let bloom_key = map_keycode(wparam.0 as u32);
119 if bloom_key > 0 {
120 if let Some(eng) = ENGINE.get_mut() {
121 eng.input.set_key_down(bloom_key);
122 }
123 }
124 DefWindowProcW(hwnd, msg, wparam, lparam)
125 }
126 WM_KEYUP => {
127 let bloom_key = map_keycode(wparam.0 as u32);
128 if bloom_key > 0 {
129 if let Some(eng) = ENGINE.get_mut() {
130 eng.input.set_key_up(bloom_key);
131 }
132 }
133 DefWindowProcW(hwnd, msg, wparam, lparam)
134 }
135 WM_MOUSEMOVE => {
136 let x = (lparam.0 & 0xFFFF) as i16 as f64;
137 let y = ((lparam.0 >> 16) & 0xFFFF) as i16 as f64;
138 if let Some(eng) = ENGINE.get_mut() {
139 eng.input.set_mouse_position(x, y);
140 }
141 DefWindowProcW(hwnd, msg, wparam, lparam)
142 }
143 WM_LBUTTONDOWN => {
144 if let Some(eng) = ENGINE.get_mut() {
145 eng.input.set_mouse_button_down(0);
146 }
147 DefWindowProcW(hwnd, msg, wparam, lparam)
148 }
149 WM_LBUTTONUP => {
150 if let Some(eng) = ENGINE.get_mut() {
151 eng.input.set_mouse_button_up(0);
152 }
153 DefWindowProcW(hwnd, msg, wparam, lparam)
154 }
155 WM_RBUTTONDOWN => {
156 if let Some(eng) = ENGINE.get_mut() {
157 eng.input.set_mouse_button_down(1);
158 }
159 DefWindowProcW(hwnd, msg, wparam, lparam)
160 }
161 WM_RBUTTONUP => {
162 if let Some(eng) = ENGINE.get_mut() {
163 eng.input.set_mouse_button_up(1);
164 }
165 DefWindowProcW(hwnd, msg, wparam, lparam)

Callers

nothing calls this directly

Calls 11

dpi_scaleFunction · 0.85
get_mutMethod · 0.80
set_key_downMethod · 0.80
set_key_upMethod · 0.80
set_mouse_positionMethod · 0.80
set_mouse_button_downMethod · 0.80
set_mouse_button_upMethod · 0.80
physical_widthMethod · 0.80
physical_heightMethod · 0.80
map_keycodeFunction · 0.70
resizeMethod · 0.45

Tested by

no test coverage detected