|
jogdial events |
|
|
JOGDIAL and KEYS catching
If you want to make a game, a demo or any application contrary to standard ;) you will need to catch jog and keys events.
In download section, you will find "Clie Analyser", an simple application using those concept to catch events.
The following listings come from this application.
After the begin of the application, the main form is loaded and the MainFormInit is launched. The characteristics are displayed :
static void MainFormInit()
{
SonySysFtrSysInfoP sonySysFtrSysInfoP;
Err errorHR = 0;
Err error;
UInt16 nbPenDown = 0;
if ((error = FtrGet(sonySysFtrCreator,sonySysFtrNumSysInfoP, (UInt32*)&sonySysFtrSysInfoP))) {
Displaying("This is not a Clie !");
} else {
Displaying("This is a Clie");
if (sonySysFtrSysInfoP->extn & sonySysFtrSysInfoExtnJog)
Displaying("Jog available");
else
Displaying("Jog unavailable");
if (sonySysFtrSysInfoP->libr & sonySysFtrSysInfoLibrHR) {
Displaying("High Resolution available");
if ((errorHR = SysLibFind(sonySysLibNameHR, &refNum))){
if (errorHR == sysErrLibNotFound) {
errorHR = SysLibLoad( 'libr', sonySysFileCHRLib,&refNum );
}
}
} else
Displaying("High Resolution unavailable");
if (sonySysFtrSysInfoP->libr & sonySysFtrSysInfoLibrFm) {
Displaying("Sound Manager available");
if ((error = SysLibFind(sonySysLibNameSound, &refNum)))
if (error == sysErrLibNotFound)
error = SysLibLoad( 'libr', sonySysFileCSoundLib, &refNum );
} else
Displaying("Sound Manager unavailable");
if (sonySysFtrSysInfoP->status & sonySysFtrSysInfoStatusHP)
Displaying("Headphones connected");
else
Displaying("Headphones not connected");
if (sonySysFtrSysInfoP->msStatus & sonySysFtrSysInfoMsStatus1MS) {
if (sonySysFtrSysInfoP->msStatus & sonySysFtrSysInfoMsStatus1WP)
Displaying("Memory Stick detected & protected");
else
Displaying("Memory Stick detected & unprotected");
} else
Displaying("Memory Stick unavailable");
}
Displaying("-- USE MENU TO QUIT --");
}
The MainFormHandleEvent procedure is linked to the main page. So it will be called when an event appears.
Boolean MainFormHandleEvent(EventPtr eventP)
{
Boolean handled = false;
FormPtr frmP;
switch (eventP->eType)
{
case menuEvent:
........
break;
case frmOpenEvent:
........
break;
case keyDownEvent:
RctSetRectangle(&rect, 0, 110, 160, 40);
WinEraseRectangle (&rect, 0);
if (eventP->data.keyDown.chr == vchrJogPush) Displaying("Jog Push",10,120);
else if (eventP->data.keyDown.chr == vchrJogRelease) Displaying("Jog vchrJogRelease",10,120);
else if (eventP->data.keyDown.chr == vchrJogPushRepeat) Displaying("Jog vchrJogPushRepeat",10,120);
else if (eventP->data.keyDown.chr == vchrJogBack) Displaying("Jog vchrJogBack",10,120);
else if (eventP->data.keyDown.chr == vchrJogUp) Displaying("Jog vchrJogUp",10,120);
else if (eventP->data.keyDown.chr == vchrJogPushedUp) Displaying("Jog vchrJogPushedUp",10,120);
else if (eventP->data.keyDown.chr == vchrJogDown) Displaying("Jog vchrJogDown",10,120);
else if (eventP->data.keyDown.chr == vchrJogPushedDown) Displaying("Jog vchrJogPushedDown",10,120);
else {
Displaying(eventP->data.keyDown.chr,10,120);
}
handled = true;
break;
default:
break;
}
return handled;
}
Be carefull : the back button is used to return to palm desktop.
The others jog events are available on the application easyly. For the back button, you must prevent system to handle it.
You can for example block all system handling, or just the back event :
static void AppEventLoop(void)
{
EventType event;
EventPtr eventP;
UInt16 error;
do {
EvtGetEvent(&event, evtNoWait);
eventP = &event;
if(event.eType == keyDownEvent) {
if (eventP->data.keyDown.chr != vchrJogBack)
if (SysHandleEvent(&event)) continue;
} else {
if (SysHandleEvent(&event)) continue;
}
if (MenuHandleEvent(0, &event, &error)) continue;
if (AppHandleEvent(&event)) continue;
FrmDispatchEvent(&event);
} while (event.eType != appStopEvent && !endApplication);
}
That's all ! Not too hard !
Theo
|
|
|
|
|
|
|