It seems RA_HandleInput(winobj, code) always returns the rawkey into code even if you set IDCMP_VANILLAKEY.
Which seems a bit odd. The only way to convert rawkey to an ascii value seems to be MapRawKey(). However that function requires an input event. Unfortunately you don't get access to any input event inside a RA_HandleInput() loop.
Anyone got an idea how to obtain ascii values inside a RA_HandleInput loop?
You should not examine the code without knowing which message you got. You will get a raw code for a RAWKEY message and an ASCII code for a VANILLAKEY message.
If you request both, Intuition will send a VANILLAKEY message for all keys for which one ASCII characer exists (i.e. letters, numbers, Esc, Return etc.) and a RAWKEY message for all other keys (i.e. cursor keys, function keys, qualifiers etc.)
i've used RAWKEY right now for Gnash and is better to use this one instead of VANILLAKEY except if you want basic char keys. By the way i didn't use RA_OpenWindow but a simply intuition window
I was using IDCMP_RAWKEY | IDCMP_VANILLAKEY in NetSurf previously, and it worked exactly as described in the AutoDocs - WMHI_VANILLAKEY messages for everything that can be described as a printable character, WMHI_RAWKEY messages for everything else. I don't know why it wouldn't be working for you - do you have a code snippet?
but why don't you remove IDCMP_RAWKEY since you don't need it? If you use both, from my little experience, you will receive standard ascii chars in VANILLAKEY but not in RAWKEY.
i've used this code to get keys (is a small copy & paste from gnash source so it is possible that something is miss)
unsigned char code[10];
struct InputEvent ie;
int actual = 0;
switch(imsg->Code & ~IECODE_UP_PREFIX)
{ case RAWKEY_CRSRUP:
c = gnash::key::UP; break;
case RAWKEY_CRSRDOWN:
c = gnash::key::DOWN;
break;
case RAWKEY_CRSRRIGHT:
c = gnash::key::RIGHT;
break;
case RAWKEY_CRSRLEFT:
c = gnash::key::LEFT;
break;
case RAWKEY_INSERT:
c = gnash::key::INSERT;
break;
case RAWKEY_HOME:
c = gnash::key::HOME;
break;
case RAWKEY_END:
c = gnash::key::END;
break;
case RAWKEY_PAGEUP:
c = gnash::key::PGUP;
break;
case RAWKEY_PAGEDOWN:
c = gnash::key::PGDN;
break;
case RAWKEY_LSHIFT:
case RAWKEY_RSHIFT:
c = gnash::key::SHIFT;
break;
case RAWKEY_LCTRL:
c = gnash::key::CONTROL;
break;
case RAWKEY_LALT:
case RAWKEY_RALT:
c = gnash::key::ALT;
break;
case RAWKEY_F1:
c = gnash::key::F1;
break;
case RAWKEY_F2:
c = gnash::key::F2;
break;
case RAWKEY_F3:
c = gnash::key::F3;
break;
case RAWKEY_F4:
c = gnash::key::F4;
break;
case RAWKEY_F5:
c = gnash::key::F5;
break;
case RAWKEY_F6:
c = gnash::key::F6;
break;
case RAWKEY_F7:
c = gnash::key::F7;
break;
case RAWKEY_F8:
c = gnash::key::F8;
break;
case RAWKEY_F9:
c = gnash::key::F9;
break;
case RAWKEY_F10:
c = gnash::key::F10;
break;
case RAWKEY_F11:
c = gnash::key::F11;
break;
case RAWKEY_F12:
c = gnash::key::F12;
break;
default:
c = gnash::key::INVALID;
break;
}
"but why don't you remove IDCMP_RAWKEY since you don't need it? If you use both, from my little experience, you will receive standard ascii chars in VANILLAKEY but not in RAWKEY."
Does not matter, code is still in rawkey format.
As for the rest, did I not mention that I use RA_HandleInput()? I think I did, several times in fact.
As far as I understand to get the vanilla key code from a WMHI_VANILLAKEY event you need to mask the result (not code) from WM_HANDLEINPUT with WMHI_KEYMASK. At least that is the only way I could see it working with the latest window.class version.
Judging from the lack of any example code (or any code for that matter) using WMHI_VANILLAKEY it is also possible that it hasn't been very well tested and is a little broken as a result.
As an alternative you could use WMHI_RAWKEY and handle the mapping yourself with MapRawKey() (I use this method in SSHTerm):
struct InputEvent *ie;
char vanilla;
case WMHI_RAWKEY:
IIntuition->GetAttr(WINDOW_InputEvent, window, (ULONG *)&ie);
if (IKeymap->MapRawKey(ie, &vanilla, 1, NULL) == 1)
{
/* vanilla key */
}
else
{
/* raw key */
}
Main issue for me is that there is no WMHI_VANILLAKEY event at all. Should it be reported to BZ?
Yes, please do so.
Looking at the window.class code it looks like vanilla key events will only be generated if WINDOW_Layout is not NULL so that's probably why you are not getting any.