Imgui: Separating/flagging SDLK_ codes with high bit set (1<<30) from standard keys

Created on 9 Jul 2016  Â·  7Comments  Â·  Source: ocornut/imgui

On linux, in C++.

I have a situation where I cannot differentiate between (0x40000063) SDLK_KP_PERIOD (or rather SDLK_SCANCODE_KP_0) and SDLK_c (0x63) using ImGui::IsKeyPressed() because the upper bit is well outside of the normal 512 entry limits of the KeyDown[] array.

So when I press the numeric-pad del/. key, my ImGui program responds as if I pressed the 'c' key as well.

Any recommendations on a path to chase with this?

backenbinding inputs

All 7 comments

You can make some special code to handle those keys and remap them in an available range. For example:

if(0x4000000 & key) key |= 0x100;
key &= 0x1ff;

What I should have asked, before my reaction, is "Where would be the most appropriate place to insert such code" ?

Where you fill out the keysDown array. This is essentially remapping the range of 0x40000** to 0x1**

okay, thanks. That's going to be the fun part, because either this application is using a default/built-in to populate the keysDown array, or I'm completely missing it.

Thanks for your help, appreciated.

Have you looked at what the SDL example does?
I think it's using the other sets of SDL defines.

Otherwise you can just set KeysMap[] to be an identity array (index=value), and then set the KeysDown[] array accordingly. You don't need to use the SDLK codes as indices into that array.

On 9 Jul 2016, at 21:49, Inflex [email protected] wrote:

okay, thanks. That's going to be the fun part, because either this application is using a default/built-in to populate the keysDown array, or I'm completely missing it.

Thanks for your help, appreciated.

―
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

Thanks @ocornut , I'll go on a bit of an adventure and see what I can do.

Greatly appreciate all the work you've done to date.

Good news, I found where it was being done and am now on my way :)

//int key = event->key.keysym.sym & ~SDLK_SCANCODE_MASK; // original code
            int key = event->key.keysym.sym & ~SDLK_SCANCODE_MASK;
                if (event->key.keysym.sym  & (1<<30)) {
                    fprintf(stderr,"SDL Highbit remask %x -> %x\n", event->key.keysym.sym, key);
                    key |= 0x100;
                }
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ocornut picture ocornut  Â·  3Comments

mnemode2 picture mnemode2  Â·  3Comments

NPatch picture NPatch  Â·  3Comments

the-lay picture the-lay  Â·  3Comments

ghost picture ghost  Â·  3Comments