1. Compiling the source code:

Requirements: gtk-2.0 and libusb-1.0 development files.

It these requirements are met by your setup, all you have to do is to type './configure', 'make' and 'make install' (as root). In the source directory.

2. Structure:

Although this is just a small software package, attention was paid to make the structure as modular as possible.

The core of the package is pegasus_usb: It is independant of the rest of the code and servers as a low-level library to communicate with the device. Users who wish to build their own software for the Pegasus Pen can just use this file as it is in their application. A simple example of how it can be used this way is shown later.

A second part is document: It represents a multi-page document, which can be saved in postscript format.

Using document, scribble as the third part presents an independant notetaking interface, which has two globally available functions for adding new input: scribble_line_to() and scribble_move_to().

Another part is cursor. It uses X11 to move the mouse to specified positions and create clicks.

All these individual parts are brought together by pegasus_scribble, which also contains the main() function.

3. pegasus_usb:

pegasus_usb.h contains the definition of the constants which are related to the device. Additionally, it declares struct pegasus:

struct pegasus {

    int connected;
    char mode;
    char orientation;
    char scale;

    void (*connect_callback) (void);
    void (*disconnect_callback) (void);

    void (*change_mode_callback) (void);

    void (*pen_callback) (short x, short y,
                          char hov, char tip,
			  char button, char battery);

    void (*mouse_callback) (short x, short y,
		            char sw1, char sw2,
			    char tip);

Most important are the callback functions which users of the library can register to struct pegasus:

4. A simple example using pegasus_usb:

struct pegasus *peg = NULL;

void new_mouse_data(short x, short y, char sw1, char sw2, char tip)
    printf("new mouse data: (%d, %d)\n", x, y);

void connected(void)
    /* This starts polling mouse and pen data in different threads.
     * It can be stopped by pegasus_stop_polling(peg).

int main(void)
    /* Allocate a new instance */
    peg = pegasus_init();

    /* Register the callback functions */
    peg->mouse_callback = new_mouse_data;

    /* This will try in a different thread to connect to the device
     * and call the connect() callback functions when it succeeded.

    /* do something in-between */

    /* exit and cleanup. peg may not be used afterwards. */

For more information, look at the source code. It's well documented.