Comments (12)
0.24
has been released and it includes this fix
from rust_minifb.
Not that I know of. If you do if window.is_key_down(Key::F10) { ... }
in the window update loop (not callback) does that work as expected?
from rust_minifb.
Thank you for your answer
I tested your snippet with F9 and F10 and it works properly with F9 but not with F10.
I guess it does not comes from my keyboard as I reproduced this problem on two different computers (and so keyboards)
from rust_minifb.
I see. Which OS do you see this behavior on?
from rust_minifb.
I am running on windows 10 for both computers
from rust_minifb.
Alright. I will try on a Windows 10 machine here and see if the same thing happens for me.
from rust_minifb.
I get the same behavior here. When searching around I found this https://gamedev.net/forums/topic/644254-pressing-f10-pause-main-loop/5069517 and the suggestion here is to
switch(message)
{
case WM_SYSCOMMAND:
{
switch (wParam)
{
// Disables System Menu (F10 Key)
case SC_KEYMENU:
{
return 0;
}//SC_KEYMENU
break;
So I tried to add this code inside the minifb code:
winuser::WM_SYSCOMMAND => {
if wparam == winuser::SC_KEYMENU {
return 0;
}
}
And that indeed gets rid of the "freezing" of the application, but it still don't get the F10 key sent to the application so something more needs to be changed.
from rust_minifb.
Ok, I have a potential fix if you want to test it locally
index 2ea0511..fc11588 100644
--- a/src/os/windows/mod.rs
+++ b/src/os/windows/mod.rs
@@ -207,6 +207,12 @@ unsafe extern "system" fn wnd_proc(
let mut wnd: &mut Window = mem::transmute(user_data);
match msg {
+ winuser::WM_SYSCOMMAND => {
+ if wparam == winuser::SC_KEYMENU {
+ return 0;
+ }
+ }
+
winuser::WM_MOUSEWHEEL => {
let scroll = ((((wparam as u32) >> 16) & 0xffff) as i16) as f32 * 0.1;
wnd.mouse.scroll = scroll;
@@ -269,6 +275,11 @@ unsafe extern "system" fn wnd_proc(
return 0;
}
+ winuser::WM_SYSKEYUP => {
+ update_key_state(wnd, (lparam as u32) >> 16, false);
+ return 0;
+ }
+
winuser::WM_COMMAND => {
if lparam == 0 {
wnd.accel_key = (wparam & 0xffff) as usize;
from rust_minifb.
I tried this and did it seem to work, although i only receive the state false events.
With this patch I receive both :
index 2ea0511..1aec629 100644
--- a/src/os/windows/mod.rs
+++ b/src/os/windows/mod.rs
@@ -207,6 +207,12 @@ unsafe extern "system" fn wnd_proc(
let mut wnd: &mut Window = mem::transmute(user_data);
match msg {
+ winuser::WM_SYSCOMMAND => {
+ if wparam == winuser::SC_KEYMENU {
+ return 0;
+ }
+ }
+
winuser::WM_MOUSEWHEEL => {
let scroll = ((((wparam as u32) >> 16) & 0xffff) as i16) as f32 * 0.1;
wnd.mouse.scroll = scroll;
@@ -224,6 +230,11 @@ unsafe extern "system" fn wnd_proc(
return 0;
}
+ winuser::WM_SYSKEYDOWN => {
+ update_key_state(wnd, (lparam as u32) >> 16, true);
+ return 0;
+ }
+
winuser::WM_CHAR => {
char_down(wnd, wparam as u32);
}
@@ -269,6 +280,11 @@ unsafe extern "system" fn wnd_proc(
return 0;
}
+ winuser::WM_SYSKEYUP => {
+ update_key_state(wnd, (lparam as u32) >> 16, false);
+ return 0;
+ }
+
winuser::WM_COMMAND => {
if lparam == 0 {
wnd.accel_key = (wparam & 0xffff) as usize;
from rust_minifb.
Cool. I will make the change and try to release a new version with the fix today.
from rust_minifb.
Thanks for your fast answers
The lib is very helpful
from rust_minifb.
Great to hear :)
from rust_minifb.
Related Issues (20)
- Is it possible to update the window while resizing it? HOT 2
- invisible window HOT 3
- Is it possible to completely remove the title bar? HOT 1
- Upgrade wayland-client version HOT 2
- Mouse coordinates are off in fullscreen, MacOS HOT 2
- Cursor style doesn't change on MacOS HOT 2
- Window::set_title no longer works on Linux since minifb 0.24 HOT 6
- How to show image subsequently like video? HOT 6
- Support raw_window_handle HOT 3
- Window is borderless even though borderless is set to false on WSL2 HOT 1
- Windows 11 cant make window transperant. HOT 4
- Menus do not Work on macOS Before Reselecting Window HOT 3
- Deprecate "limit_update_rate" in favor of "set_target_fps" HOT 6
- segfault on mouseDown on macOS HOT 4
- Mouse clicks aren't processed while the pointer is outside the window HOT 2
- Window::get_mouse_pos with mode set to MouseMode::Discard returns last obtained location instead of None HOT 1
- Attempt to negate with overflow on latest rust nightly when running example code.
- [Left/RightShift + <key>] not picked up by get_keys on wayland HOT 1
- Window always renders white on Windows 11 in release build. HOT 19
- Document transparency support in buffers
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust_minifb.