Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
111 user(s) are online (82 user(s) are browsing Forums)

Members: 0
Guests: 111

more...

Headlines

 
  Register To Post  

getting status of shift key
Supreme Council
Supreme Council


See User information
What's the best way to obtain the current status of the shift keys etc?

Reading RAKEY in an event loop doesn't work since the user can press/release the shift key when your window isn't active and before/after your program is started.

Please provide a code example if you can. An answer like "use keyboard.device" won't help me since I don't know how to do that.

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: getting status of shift key
Supreme Council
Supreme Council


See User information
@orgin

This does not work:

IIntuition->GetAttrs(winobj, WINDOW_Qualifier, &qualifier, TAG_END);

It only returns the qualifiers for RAWKEY events and not any other event.

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: getting status of shift key
Just popping in
Just popping in


See User information
@orgin

A quick scan trough the autodocs:

qualifier = IInput->PeekQualifier();
or
key = ILowLevel->GetKey();

see input.doc or lowlevel.doc

Go to top
Re: getting status of shift key
Supreme Council
Supreme Council


See User information
@orgin

Okey seems there's a method in IInput called PeekQualifier()


PLEASE anyone post some complete code for obtaining the IInput interface, including whatever is needed in terms of opening devices.

(Edit: and no auto stuff please)

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: getting status of shift key
Supreme Council
Supreme Council


See User information
@Gazelle

ILowLevel->GetKey();

Always returns 255 no matter what keys you press.

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: getting status of shift key
Not too shy to talk
Not too shy to talk


See User information
@orgin

There is a example that shows how to open timer.device in SDK:Documentation/Developer Info/General/os4_migration_guide.pdf.

Go to top
Re: getting status of shift key
Just popping in
Just popping in


See User information
@orgin

Here is the code from the pdf ZeroG mentioned updated for input device:

struct MsgPort *InputMP;
struct IORequest *InputIO;
struct Library *InputBase;
struct InputIFace *IInput;
BOOL InputIO_used FALSE;

UWORD qualifier;


InputMP IExec->AllocSysObject(ASOT_PORTNULL);
if (!
InputMPcleanexit("Cannot create input message port");

InputIO IExec->AllocSysObjectTags(ASOT_IOREQUEST,
                                    
ASOIOR_Sizesizeof(struct IORequest),
                                    
ASOIOR_ReplyPortInputMP,
                                    
TAG_DONE);
if (!
InputIOcleanexit("Cannot allocate IORequest");

if (
IExec->OpenDevice(INPUTNAME0InputIO0))
    
cleanexit("cannot open input device");

InputBase = (struct Library *)InputIO->io_Device;
IInput = (struct InputIFace *)IExec->GetInterface(InputBase"main"1NULL);
if (!
IInputcleanexit("Cannot obtain input interface");

// ... call input functions, i.e.
qualifier IInput->PeekQualifier();

/* set this to true if you are using InputIO
InputIO_used = TRUE;
*/

if (InputIO_used)
{
    if (!
IExec->CheckIO(InputIO))
        
IExec->AbortIO(InputIO);

    
IExec->WaitIO(InputIO);
}
IExec->DropInterface((struct Interface *)IInput);
IExec->CloseDevice(InputIO);
IExec->FreeSysObject(ASOT_IOREQUESTInputIO);
IExec->FreeSysObject(ASOT_PORTInputMP);


/edit: updated InputIO handling


Edited by Gazelle on 2009/4/18 14:59:57
Go to top
Re: getting status of shift key
Amigans Defender
Amigans Defender


See User information
@orgin

Quote:
This does not work:

IIntuition->GetAttrs(winobj, WINDOW_Qualifier, &qualifier, TAG_END);

It only returns the qualifiers for RAWKEY events and not any other event.


Hmm, I've been using that outside of RAWKEY without any bother. Mind you, I'm also keeping track of which keys are pressed within RAWKEY so it's possible it doesn't work and I just haven't noticed.

Go to top
Re: getting status of shift key
Supreme Council
Supreme Council


See User information
@Gazelle

WaitIO always crashes though. Removing it and it works.

Thanks everyone, I can now use "shift" as a qualifier when klicking in my listbrowser :)

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
Go to top
Re: getting status of shift key
Home away from home
Home away from home


See User information
@orgin

Quote:

WaitIO always crashes though. Removing it and it works.


Probably because there was no IO started with a SendIO.

In fact I suspect that CheckIO is returning a false positive as well as the autodocs say it's result is not valid unless the IO has been starting with a SendIO or BeginIO.


Basicaly you aren't using the IOrequest as such thus you don't need to wait for it (or even abort it?)

Just to check. When you say it crashes does it hang or grim?

from the WaitIO autodoc

Note that WaitIO() will not work on I/O requests that haven't been
used before. Only use WaitIO() with I/O requests which have been
started via SendIO() or BeginIO(). If you did not start the I/O
request with either SendIO() or BeginIO(), do not call WaitIO()
since it will hang.

Go to top
Re: getting status of shift key
Just popping in
Just popping in


See User information
@orgin

But shouldn't the "InputEvent.ie_Qualifier" tell you what you want?

Go to top
Re: getting status of shift key
Supreme Council
Supreme Council


See User information
@Gazelle

Nope.

Vacca foeda. Sum, ergo edo

Mr Bobo Cornwater
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