GP2X Minimal Lib - Feature- Panic Key


tuskenraider2k

Certified Guru
Joined
Nov 1, 2002
Messages
117
I think a panic key or key sequence would be nice as default functionallity :)

It is surely not cleanly implemented, but it works:

pthread_t gp2x_panic_tester_thread=0;

static void *gp2x_panic_mode_loop(void *blah)
{
while (1)
{
unsigned long nKey = gp2x_joystick_read();
if ((nKey&GP2X_L) && (nKey&GP2X_R) && (nKey&GP2X_PUSH)) {
printf("PANIC LOOP - exit\n");
exit(0);
}
Sleep(200);
}
return NULL;
}

void init()
{
pthread_create( &gp2x_panic_tester_thread, NULL, gp2x_panic_mode_loop, NULL);
}
 
Then I thought of a global linux-task, which kills all new started linux programs and restarts the gp2xmenu
 
Another way is to use the USB Serial module and run bash over it in the background. Then you could run your stuff from the menu as normal, and if it locks up, you can 'ps' and 'kill' :)

Although I usually prefer to run my apps from bash so I can have debug output and gdb support. If you run 'screen' as well, you even get CTRL+C support, which is a perfect way of breaking out of your program.
 
Another way is to use the USB Serial module and run bash over it in the background. Then you could run your stuff from the menu as normal, and if it locks up, you can 'ps' and 'kill' :)

Although I usually prefer to run my apps from bash so I can have debug output and gdb support. If you run 'screen' as well, you even get CTRL+C support, which is a perfect way of breaking out of your program.
I have Ctrl+C support through the standard serial cable and I just run my apps through gp2xmenu. Why should I need to run screen to get Ctrl+C support? Or is that only when using the USB serial module?
 
Last edited by a moderator:
Yeah, since we're not using getty and just redirecting bash in and output, ctrl+c doesn't work over usb serial
 
CTRL+C over serial worked fine for me until my serial adaptor broke, and it doesn't work over USB, hence the need for screen to get it back.
 
Back
Top