MrcSnm/HipremeEngine

Key out of range

p0nce opened this issue · 4 comments

p0nce commented

Hello,

Engine sounds very promising!

How to reproduce:
On Windows, when I press the Fn key, or the "sound mute" key on my keyboard, the engine closes with message:

core.exception.AssertError@source\hip\event\dispatcher.d(270): Key out of range
----------------
0x00007FF76476EB49 in d_assert_msg
0x00007FF76461CD9B in hip::event::dispatcher::getHipKeyFromSystem at C:\Users\guill\Desktop\HipremeEngine\source\hip\event\dispatcher.d(270)
0x00007FF76461C635 in hip::event::dispatcher::EventDispatcher::this::__lambda2 at C:\Users\guill\Desktop\HipremeEngine\source\hip\event\dispatcher.d(58)
0x00007FF76472C8CD in hip::windowing::platforms::windows::WndProc at C:\Users\guill\Desktop\HipremeEngine\modules\windowing\source\hip\windowing\platforms\windows.d(61)
0x00007FFB93B58231 in DispatchMessageW
0x00007FFB93B57A7B in CallWindowProcW
0x00007FFB825D1D74 in wglSwapBuffers
0x00007FFB93B58231 in DispatchMessageW
0x00007FFB93B57CF1 in DispatchMessageW

Expected behaviour: key being ignored instead of closing game.
So cannot hit F5 on that keyboard for now since I need Fn key

p0nce commented

For the Fn key specifically:

What do you think?

p0nce commented

Arguably since a lot of key are incorrectly translated right now (cast), an unknown key should return a special value.

MrcSnm commented

Interestingly enough, in my keyboard, Fn doesn't even generate an event. I believe that HipKey.NONE is nice.
I noticed also that the assert only check whether it is less, not less equal. I'm going to update that real quickly

MrcSnm commented

The key should actually return the special value:

default:
                version(HipCheckUnknownKeycode)
                {
                    import hip.util.conv:to;
                    assert(false, "Unknown key received ("~to!string(k)~")");
                }
                else
                    return cast(HipKey)k;

The thing is that it was failing in the assert above because it didn't correctly check 0xFF