OpenQNX :: The QNX Community Portal

Jul 05, 2008 - 11:02 AM
Google
  Web openqnx.com   
     Create an account Home · Submit News · QNX Forums · QNX Download · Search   
_
Main Menu
Who's Online
There are 37 unlogged users and 0 registered users online.

You can log-in or register for a user account here.

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
aaronf
Post subject: Can't get PhEmit to emit Key event  PostPosted: Aug 15, 2007 - 06:39 PM
Active Member


Joined: Feb 08, 2007
Posts: 13

Hi, hopefully somebody can help me here. I'm trying to get an application to emit a key event and the QNX documentation is rather sparse on what exactly I'm supposed to do. I would like to use this eventually for scripting of Photon events (pointer events and key events) for test automation. I already have pointer events working. Currently the code is being invoked from a button activation callback.

Here is the code in question:

PhEvent_t event;
PhPointerEvent_t ptrEventData;
PhKeyEvent_t keyEventData;
PhRect_t rect;

/* eliminate 'unreferenced' warnings */
widget = widget, apinfo = apinfo, cbinfo = cbinfo;

memset( &event, 0, sizeof(event) );
memset( &ptrEventData, 0, sizeof(ptrEventData) );
memset( &keyEventData, 0, sizeof(keyEventData) );
memset( &rect, 0, sizeof(rect) );

event.type = Ph_EV_BUT_PRESS;
event.subtype = 0;
event.flags = 0;
event.num_rects = 1;
event.data_len = sizeof(ptrEventData);
event.emitter.rid = Ph_DEV_RID;
rect.ul.x = rect.lr.x = 537;
rect.ul.y = rect.lr.y = 462;
ptrEventData.buttons = Ph_BUTTON_SELECT;
ptrEventData.flags = 0;
PhEmit( &event, &rect, &ptrEventData );

delay( 80 );

event.type = Ph_EV_BUT_RELEASE;
PhEmit( &event, &rect, &ptrEventData );

delay( 1500 );

event.type = Ph_EV_KEY;
event.data_len = sizeof( keyEventData );
//rect.ul.x = rect.lr.y = 0;
//rect.lr.x = rect.lr.x = 0;
keyEventData.key_cap = 0x09;
keyEventData.key_sym = 0x09;
keyEventData.key_scan = 0x09;
keyEventData.key_mods = 0;
keyEventData.key_flags = ( Pk_KF_Key_Down | Pk_KF_Sym_Valid | Pk_KF_Cap_Valid );
PhEmit( &event, &rect, &keyEventData );

delay( 220 );

keyEventData.key_flags = Pk_KF_Cap_Valid;
PhEmit( &event, &rect, &keyEventData );

delay( 2000 );

event.type = Ph_EV_BUT_PRESS;
event.data_len = sizeof(ptrEventData);
rect.ul.x = rect.lr.x = 841;
rect.ul.y = rect.lr.y = 717;
ptrEventData.buttons = Ph_BUTTON_SELECT;
ptrEventData.flags = 0;
PhEmit( &event, &rect, &ptrEventData );

delay( 450 );

event.type = Ph_EV_BUT_RELEASE;
PhEmit( &event, &rect, &ptrEventData );

return( Pt_CONTINUE );

A note about the scan codes. I'm not sure which type I'm supposed to use (XT or AT) or where they're supposed to go (key_cap, key_sym, or key_scan). 0x09 is supposed to be the '8' key.
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2007 The PNphpBB Group
Credits
All logos and trademarks in this site are property of their respective owners. The comments are property of their posters.
Powered by OpenQNX: The QNX Community Portal Site
QNX and the QNX logo are registered trademarks of QNX Software Systems.