this post was submitted on 23 May 2024
7 points (88.9% liked)

Game Development

3430 readers
7 users here now

Welcome to the game development community! This is a place to talk about and post anything related to the field of game development.

Community Wiki

founded 1 year ago
MODERATORS
 
package int poll_win_RawInput(ref InputEvent output) nothrow @nogc {
	MSG msg;
	BOOL bret = PeekMessageW(&msg, null, 0, 0, PM_REMOVE);
	if (bret) {
		////Some code that supposed to swallow WM_SYSKEY and the likes, but does not work as intended////
		DispatchMessageW(&msg);//In the aforementioned block
		////Function that optionally gets text input messages////
 		switch (msg.message & 0xFF_FF) {
////Regular user input handling via RawInput and some legacy stuff + XInput handling in separate function////

Since it's for games, the default Alt key behavior is undesirable for me. It makes my test application hang and make error noises since it doesn't have a menubar. I checked whether my window had a flag that enabled the menubar or not, but couldn't find it.

you are viewing a single comment's thread
view the rest of the comments
[–] ZILtoid1991@lemmy.world 3 points 5 months ago (1 children)

Found the solution, I have to put the following lines into the part that handles/intercepts the events related to the window itself:

case WM_SYSCHAR, WM_SYSDEADCHAR, WM_SYSKEYUP, WM_SYSKEYDOWN:
	return 0;

Otherwise all event that goes through this window goes to DefWindowProcW(); even if interrupted.

[–] blazebra@programming.dev 2 points 5 months ago (1 children)

If you’d have any user input, this would break it. Even if you emulate it using key codes later, localisation will be hard

[–] ZILtoid1991@lemmy.world 1 points 5 months ago (2 children)

I'll be letting though certain keypresses in the future, and will only be blocking the alt key from hanging my app and such. It also blocks the Alt+F4 key combination and co.

[–] blazebra@programming.dev 2 points 5 months ago

One more thing I forgot to say. If default function of the alt key is to open menu, that it’s defined somewhere in your game, settings or the engine. If you try default loop in win32 api app with an empty window, alt key does nothing and you need actually bind it to change its behaviour to show menu. So I recommend to blame settings or an engine first before disabling events on so low level.

Also such way of disabling events would prevent you of porting your app to other OSes like Linux and macOS

[–] blazebra@programming.dev 2 points 5 months ago

The test of behaviour I tell is an input field, allowing to type letters of European languages like ü, ä, ą and so on. I’m quite disappointed when I can’t input something like „Łabądź” as a player name, but able to edit in memory or in save file.

Also I prefer to have Alt-F4 as an emergency exit