Hi everybody,
I just now got client-side input filters working. With the input filters system, a
client or server piece of code can intercept events at any point in this filter chain,
modify them, and return them to the filter chain. Here's an example of a C client that
prints all keyboard events recieved, and converts them to uppercase before
retransmitting them. All other types of events are uneffected.
------------8<------------
#include <picogui.h>
#include <ctype.h>
int myFilter(struct pgEvent *evt) {
union pg_client_trigger *trig = evt->e.data.trigger;
char c;
/* We should have a PG_TRIGGER_CHAR event now, print out the character value
*/
c = trig->content.u.kbd.key;
if (c=='\r') c = '\n';
write(0,&c,1);
/* Force the input to uppercase, then retransmit it where it left off
*/
trig->content.u.kbd.key = toupper(trig->content.u.kbd.key);
pgInFilterSend(trig);
}
int main(int argc, char **argv) {
pgInit(argc,argv);
/* Insert our input filter after the KEY_PREPROCESS filter,
* get a copy of all CHAR triggers, and don't automatically pass them through
*/
pgNewInFilter(pgGetServerRes(PGRES_INFILTER_KEY_PREPROCESS),
PG_TRIGGER_CHAR, PG_TRIGGER_CHAR);
pgBind(PGBIND_ANY, PG_NWE_INFILTER, myFilter, NULL);
pgEventLoop();
return 0;
}
------------>8------------
The catch however, is that this was accomplished with huge modifications to
pgserver... so the code still needs more testing. This new code is available under the
"input_filters" CVS branch. The following are known items on my todo list of this code:
- document protocol changes
- implement all new requests in cli_c and cli_python
- fix sprite bugs
- store hotspot cursor position on divtree stack
- Add compile-time option in Security section to disable client-side input filters
- Reimplement PGKEY_ALPHA in a server-side input filter
- Reimplement touchscreen code in a server-side input filter
Once I've got these items out of the way, I'd appreciate it if anyone interested would
do a test run of the new input_filters branch. I changed some APIs, so I'd like to
resolve any compatibility problems before merging it back to the main branch.
For now this is just a sneak preview ;)
--
Only you can prevent creeping featurism!
_______________________________________________________________
Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm
_______________________________________________
Pgui-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/pgui-devel