Hi, I have a little problem to detect a keypress. I have to be able to detect a key press in a loop in order to stop it. I tryed to use PhKeyEvent_t, but without any result. Here is my code :
/* Standard headers */
#include <stdio.h>
#include <stdlib.h>
/* Toolkit headers */
#include <Ph.h>
#include <photon/PkKeyDef.h>
int main ()
{
PhKeyEvent_t touche;
int i=0;
touche.key_scan=Pk_KP_Space;
while(i==0)
{
if (touche.key_flags==Pk_KF_Key_Down)
{
printf("loop stopped");
i=1;
}
}
return(0);
}
I also tried :
/* Standard headers */
#include <stdio.h>
#include <stdlib.h>
/* Toolkit headers */
#include <Ph.h>
#include <photon/PkKeyDef.h>
int main ()
{
PhKeyEvent_t touche;
int i=0;
touche.key_flags=Pk_KF_Cap_Valid;
while(i==0)
{
if (touche.key_cap==Pk_KP_Space)
{
printf("loop stopped");
i=1;
}
}
return(0);
}
But it doesn’t work and I have to press ctrl+z to stop it.
I saw searching on the Internet that I may have to use the function PhGetData(), but I don’t understand how.
Does anybody know how to use this structure and this function (or maybe I’m totally wrong and this is not the correct mean at all )?
Thanks
guillaume