Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
140 user(s) are online (107 user(s) are browsing Forums)

Members: 0
Guests: 140

more...

Headlines

 
  Register To Post  

[Solved] rawkey/vanillakey
Supreme Council
Supreme Council


See User information
I'm experimenting with IDCMP_RAWKEY/VANILLAKEY.

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?


Edited by orgin on 2009/5/22 10:28:21
Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: rawkey/vanillakey
Not too shy to talk
Not too shy to talk


See User information
@orgin

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.)

Bye,
Thomas

Go to top
Re: rawkey/vanillakey
Supreme Council
Supreme Council


See User information
@thomas

Here's the deal. I'm doing just that. The code is _still_ rawkey and not ascii for some unknown reason.

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: rawkey/vanillakey
Amigans Defender
Amigans Defender


See User information
@orgin

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'm really tired...
Go to top
Re: rawkey/vanillakey
Supreme Council
Supreme Council


See User information
@afxgroup

I need basic char keys or I wouldn't ask.

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: rawkey/vanillakey
Amigans Defender
Amigans Defender


See User information
@orgin

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?

Go to top
Re: rawkey/vanillakey
Supreme Council
Supreme Council


See User information
@Chris

...
WA_IDCMPIDCMP_MOUSEBUTTONS|IDCMP_MENUVERIFY|IDCMP_EXTENDEDMOUSE|IDCMP_VANILLAKEY|IDCMP_RAWKEY,
...

...

...

  while( (
result RA_HandleInput(inst->WinObj, &code)) != WMHI_LASTMSG)
  {
   switch(
result WMHI_CLASSMASK)
   {


...
...

case 
WMHI_RAWKEY:
 ...
 
// code is in rawkey format here
...
 break;

...
...
case 
WMHI_VANILLAKEY:

...
 
// code is in rawkey format here
...
 break;

 }
}

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: rawkey/vanillakey
Amigans Defender
Amigans Defender


See User information
@orgin

So you are actually getting the WMHI_VANILLAKEY message? Are you absolutely sure it is in rawkey format? What does printf("%s\n",code); give you?

Go to top
Re: rawkey/vanillakey
Supreme Council
Supreme Council


See User information
@Chris

Yes, Yes, Rawkey

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: rawkey/vanillakey
Amigans Defender
Amigans Defender


See User information
@orgin

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:        
gnash::key::UP;           break;           
case 
RAWKEY_CRSRDOWN:    
gnash::key::DOWN;         
break;            
case 
RAWKEY_CRSRRIGHT:    
gnash::key::RIGHT;        
break;            
case 
RAWKEY_CRSRLEFT:    
gnash::key::LEFT;         
break;            
case 
RAWKEY_INSERT:        
gnash::key::INSERT;       
break;            
case 
RAWKEY_HOME:        
gnash::key::HOME;         
break;            
case 
RAWKEY_END:        
gnash::key::END;          
break;            
case 
RAWKEY_PAGEUP:        
gnash::key::PGUP;         
break;            
case 
RAWKEY_PAGEDOWN:    
gnash::key::PGDN;         
break;            
case 
RAWKEY_LSHIFT:            
case 
RAWKEY_RSHIFT:        
gnash::key::SHIFT;        
break;            
case 
RAWKEY_LCTRL:        
gnash::key::CONTROL;      
break;            
case 
RAWKEY_LALT:            
case 
RAWKEY_RALT:        
gnash::key::ALT;          
break;         
case 
RAWKEY_F1:         
gnash::key::F1;         
break;         
case 
RAWKEY_F2:         
gnash::key::F2;         
break;         
case 
RAWKEY_F3:         
gnash::key::F3;         
break;         
case 
RAWKEY_F4:         
gnash::key::F4;         
break;         
case 
RAWKEY_F5:         
gnash::key::F5;         
break;         
case 
RAWKEY_F6:         
gnash::key::F6;         
break;         
case 
RAWKEY_F7:         
gnash::key::F7;         
break;         
case 
RAWKEY_F8:         
gnash::key::F8;         
break;         
case 
RAWKEY_F9:         
gnash::key::F9;         
break;         
case 
RAWKEY_F10:         
gnash::key::F10;         
break;         
case 
RAWKEY_F11:         
gnash::key::F11;         
break;         
case 
RAWKEY_F12:         
gnash::key::F12;         
break;             
default:                 
gnash::key::INVALID;     
break;     
}

ie.ie_NextEvent    NULL;
ie.ie_Class        IECLASS_RAWKEY;
ie.ie_SubClass        0;
ie.ie_Code         imsg->Code;
ie.ie_Qualifier    imsg->Qualifier;
ie.ie_EventAddress=(APTR *) *((ULONG *)imsg->IAddress);
actual IKeymap->MapRawKey(&ie, (STRPTR)code10NULL);
if (
actual == 1)
= (gnash::key::code)(int)code[0];


So IMHO use RAWKEY instead of VANILLAKEY even the second one is more simply since you receive directly the char

i'm really tired...
Go to top
Re: rawkey/vanillakey
Supreme Council
Supreme Council


See User information
@afxgroup

"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.

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: [Solved] rawkey/vanillakey
Supreme Council
Supreme Council


See User information
@orgin

Okey I found way. (thanks to AC^x86 on IRC who told me that you probably don't need to set ie.is_EventAddress.)

Final code:
char buffer[11];
  
struct InputEvent ie;
  
ie.ie_NextEvent NULL;
  
ie.ie_Class IECLASS_RAWKEY;
  
ie.ie_SubClass 0;
  
ie.ie_Code code;
  
ie.ie_Qualifier IInput->PeekQualifier();
  
ie.ie_EventAddress NULL;
  
IKeymap->MapRawKey(&iebuffer10,NULL);
  
fprintf(stderr"%i\n", (int)buffer[0]);


With no IDCMP_VANILLAKEY on the window and catching events in WMHI_RAWKEY.

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: [Solved] rawkey/vanillakey
Not too shy to talk
Not too shy to talk


See User information
@orgin

Here on this site I go under the name RWO.. actual its only on IRC I use AC as that is my scene handle.

RWO

Go to top
Re: [Solved] rawkey/vanillakey
Supreme Council
Supreme Council


See User information
@orgin

Or perhaps you could have used WINDOW_InputEvent which is explained in the window_cl.doc.

Simon

Go to top
Re: [Solved] rawkey/vanillakey
Supreme Council
Supreme Council


See User information
@Rigo

I tried that, since it's in the autodoc, but it didn't work, so I created this thread.

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: [Solved] rawkey/vanillakey
Quite a regular
Quite a regular


See User information
@orgin

I don't use VANILLAKEY, only RAWKEY. Here is the code snippet that I use.
It's been edited to protect the innocent, but you get the idea...

int32
IDCMPHookFunc (struct Hook *hook, APTR junk, struct IntuiMessage *intuiMsg)
{
struct InputEvent *iEventPtr,
InputEvent;
int32 msgClass = 0;

...
msgClass = intuiMsg->Class;

switch (msgClass)
{
case IDCMP_RAWKEY:
iEventPtr = &InputEvent;

if (iEventPtr != NULL)
{
iEventPtr->ie_Class = IECLASS_RAWKEY;
iEventPtr->ie_SubClass = 0;

iEventPtr->ie_Code = intuiMsg->Code;
iEventPtr->ie_Qualifier = intuiMsg->Qualifier;
iEventPtr->ie_EventAddress = (APTR *) *((ULONG *)intuiMsg->IAddress);

actual = IKeymap->MapRawKey(iEventPtr, KeyCodeBuff, KEYBUFFSIZE, KeyMap);
}
break;

case ...:
...
}
}

BTW, the currently-released WINDOW_InputEvent function has some issues with qualifiers and "dead" keys, that you might like to avoid.

cheers
tony
Go to top
Re: vanillakey events missing
Just can't stay away
Just can't stay away


See User information
I'm trying to migrate some code to use window class but vanilla key events stopped working.

Can anybody see issues in the attached example?

#include <proto/intuition.h>
#include <classes/window.h>

#include <stdio.h>

int main()
{
    
ObjectIIntuition->NewObject(NULL"window.class",
        
WA_Title"Vanilla key test",
        
WA_IDCMPIDCMP_CLOSEWINDOW IDCMP_VANILLAKEY IDCMP_RAWKEY,
        
WA_Width100,
        
WA_Height100,
        
WA_ActivateTRUE,
        
WA_CloseGadgetTRUE,
        
TAG_DONE);

    if (
o) {
        
struct Window= (struct Window *)IIntuition->IDoMethod(oWM_OPEN);

        if (
w) {
            
BOOL running TRUE;

            
uint32 result;
            
int16 code 0;

            while (
running) {
                while ((
result IIntuition->IDoMethod(oWM_HANDLEINPUT, &code)) != WMHI_LASTMSG) {
                    switch (
result WMHI_CLASSMASK) {
                        case 
WMHI_CLOSEWINDOW:
                            
running FALSE;
                            break;
                        case 
WMHI_VANILLAKEY:
                            
printf("VANILLA %x, %lx\n"coderesult);
                            break;
                        case 
WMHI_RAWKEY:
                            
printf("RAW %x, %lx\n"coderesult);
                            break;
                        default:
                            
printf("Unhandled event - result %lx, code %x\n"resultcode);
                            break;
                    }
                }
            }
        }

        
IIntuition->DisposeObject(o);
    }

    return 
0;
}


Go to top
Re: vanillakey events missing
Just can't stay away
Just can't stay away


See User information
@Capehill

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_InputEventwindow, (ULONG *)&ie);
    if (
IKeymap->MapRawKey(ie, &vanilla1NULL) == 1)
    {
        
/* vanilla key */
    
}
    else
    {
        
/* raw key */
    
}

Go to top
Re: vanillakey events missing
Just can't stay away
Just can't stay away


See User information
@salass00

Main issue for me is that there is no WMHI_VANILLAKEY event at all. Should it be reported to BZ?

AutoDoc is not mentioning WMHI_KEYMASK either so it would be a nice addition.

I guess I will use WMHI_RAWKEYs for time being. Thanks.

Go to top
Re: vanillakey events missing
Just can't stay away
Just can't stay away


See User information
@Capehill

Quote:

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.

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2023 The XOOPS Project