If you already have code to return x,y positions (and it looks like Shane's
suggestion will do that) it should be easy. An input driver's whole job is to
call dispatch_key() or dispatch_pointing() to sent events to the rest of
PicoGUI. The input driver can monitor it's source of input by polling or by
waiting for activity on a file descriptor.
The ncursesinput driver is probably the simplest. (SDL used to be simplest, but
now it has all those decorations :)
ncursesinput_regfunc() registers four functions by putting pointers in the inlib
structure: init, close, fd_activate, and fd_init
- init() is called when the driver is loaded. Remember that the driver might be
unloaded then reloaded. If there's an error, return a g_error. Don't just exit
the program!
- close() should clean up anything that was allocated in init()
- fd_activate() is called whenever the file descriptor being monitored is
available for reading. It takes the file descriptor as a parameter.
- fd_init() is called before PicoGUI's main select() loop to add extra file
descriptors. The parameters are the same as those offered by select(). This
function may increase n, add extra fd's to readfds, and decrease the timeout. It
should not decrease n, remove fd's or increase the timeout.
In fd_activate(), the event is decoded and the appropriate dispatch function is
called.
To write a polling driver, only set the timeout in fd_init, and implement poll
instead of fd_activate. The poll function is called when the select() timeout
expires.
Well, that's basically how to write an input driver. To make PicoGUI recognize
it as a new driver:
- Add the file to input/Makefile.am
- Add a prototype for the regfunc near the end of include/pgserver/input.h
- Add an entry into gcore/inputdrivers.inc to associate the regfunc with a
driver name.
Quoting "Gray, Tim" <[EMAIL PROTECTED]>:
> I have a side project that I need to write a touchscreen driver for.
> I was wondering, would it be easier to modify the existing helio
> touchscreen
> driver to suit my needs or just writing the whole thing from scratch.
> I
> currently can access the touchscreen, and I wrote a simple C app to
> display
> the X,Y coordinates when that location is touched. The problem is that
> I
> have a 48X64 matrix with the lower left corner is 0,0... so the
> translation
> to screen coordinates is going to be blocky, which is fine as I'm not
> interested in doing anything but clicking on buttons.
>
> anyone have any pointers on how to go about writing a Pgserver driver?
>
>
> thanks.
>
>
> _______________________________________________
> Pgui-devel mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/pgui-devel
>
_______________________________________________
Pgui-devel mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/pgui-devel