[Qt-interest] Transforming Qt Keycodes to SDL like keycodes

Girish Ramakrishnan girish at forwardbias.in
Tue Nov 30 07:23:14 CET 2010


Hi Nathan,

On Mon, Nov 29, 2010 at 8:12 PM, Nathan Hüsken <nathan.huesken at posteo.de> wrote:
> Hey,
>
> I have an application that deals with SDL Keyboard input, but should now
> deal with QT Key events.
>
> Now, a key event has the key(), the nativeVirtualKey() e.t.c.
>
> I thought I translate the key() in a big switch/case. But then I realized:
>
> - there is no right control vs. left control
> - there is no difference between numpad and non-numpad numbers.
> ...
>
> So I am wondering:
> - What exactly does nativeVirtualKey return?

The virtual key. On X11 this would be the keysym and on Windows this
would be the virtual key i.e VK_* (MapVirtualKey).

> - Which output of the key event is most useful for this task?

I think you have to write a platform specific mapper from virtual key
to SDL. On Windows, you should get VK_LCONTROL, VK_RCONTROL etc. On
X11, XK_Control_L, XK_Control_R etc.

Maybe you should inverse map the tables in src/corelib/kernel/qkeymapper*.

Girish




More information about the Qt-interest-old mailing list