Suppress keyboard from running commands in terminal!


foft

Certified Guru
Joined
Mar 14, 2004
Messages
480
Location
London, UK
Website
www.scrameta.net
I noticed that when I run the program I'm developing from pnd_run after I quit it runs anything I've typed in the terminal. In the app I poll the keys using EVIOCGKEY on evdev. Anyway if I happen to type ls+enter its not bad, but if I happen to type 'rm -rf /' then its not good!


I want to ensure this doesn't happen so I wrapped it in a script to flush the buffer after my app exits.


One method of doing this I found it:



Code:
read -t 0.1 -N 1000000



However the pandora version does not understand this. So I found a perl version:



Code:
/usr/bin/perl -e 'use Fcntl; system("/bin/stty raw"); fcntl(STDIN,F_SETFL,O_NONBLOCK); my $buf; while(sysread(STDIN,$buf,4096)){}; system("/bin/stty cooked");'


I put this at the end of the script and in a 'set -e' block.


This version works when I run from pnd_run. However if I have focus on a terminal open then run the pnd from the menu the commands are run in the terminal!


I'm clearly missing something since this shouldn't be hard - what is the trick here?


Thanks,


Mark
 
I guess I need to capture keyboard/mouse focus for X. Perhaps a fullscreen xterm? I guess if my pnd runs in minimenu then there is no X so I need to detect if X is running first.
 
Yeah you either need to create a window to eat all X events, or even use those events in your program instead of evdev.


You can also use "op_runfbapp ./yourapp" to do that for you (op_runfbapp comes with the firmware).
 
Back
Top