This is a simple example of how to connect to a ScripTouch device and output a PNG image using the Cairo drawing library.
#include <stdio.h>
#include "cairo.h"
cairo_surface_t* surface;
cairo_t* cr;
unsigned char penDown = 0;
printf("Got a coordinate from the device: %4.2f, %4.2f\n", x, y);
cairo_move_to(cr, x, y);
penDown = 1;
} else {
cairo_line_to(cr, x, y);
if(!penDown) {
cairo_stroke(cr);
}
}
printf("Button pressed: %s\n", caption);
if(strcmp(caption, "OK") == 0) {
cairo_surface_write_to_png(surface, "signature_cairo.png");
} else {
cairo_set_source_rgba (cr, 0xFF, 0xFF, 0xFF, 0);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_paint (cr);
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
cairo_set_source_rgba (cr, 0, 0, 0, 0xFF);
}
}
}
int main() {
if(device != NULL) {
cr = cairo_create(surface);
cairo_set_line_width(cr, 1);
cairo_set_source_rgba (cr, 0xFF, 0xFF, 0xFF, 0);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_paint (cr);
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
cairo_set_source_rgba (cr, 0, 0, 0, 0xFF);
}
cairo_surface_destroy(surface);
} else {
return 1;
}
} else {
printf("No devices found!\n");
return 2;
}
} else {
return 3;
}
}
@ SCRIPTEL_INPUT_BUTTONPRESS
The report identifier of the button press input report.
Definition: scriptel-hid-reports.h:297
@ SCRIPTEL_INPUT_EXTENDEDCOORDINATE
The report identifier of the extended coordinate input report.
Definition: scriptel-hid-reports.h:234
This file contains the headers for the core of the Scriptel ScripTouch ProScript library.
void scriptel_init(void)
This function should be called prior to using any other library functions.
unsigned int scriptel_count_device_list(scriptel_device *list)
This function counts the number of devices in a given device list.
scriptel_hid_feature_coordinate_range scriptel_get_coordinate_range(scriptel_device *device)
This function gets the logical coordinate range that will be returned from the device when points are...
scriptel_error_code scriptel_list_devices(scriptel_device **start)
This function takes a pointer and will attempt to enumerate any attached ScripTouch devices.
scriptel_error_code scriptel_close_device(scriptel_device *device)
This function attempts to close a local device that was previously opened.
scriptel_error_code scriptel_open_device(scriptel_device *device)
This function attempts to open a local device returned by scriptel_list_devices().
char * scriptel_get_last_error(void)
This function gets the last error message generated by the library.
void scriptel_free_device_list(scriptel_device *device_list)
This function crawls a scriptel_device list and attempts to free any library managed memory associate...
@ SCRIPTEL_CODE_SUCCESS
This code indicates that the function did succeed.
Definition: scriptel-proscript.h:96
scriptel_error_code scriptel_device_read(scriptel_device *device)
This function attempts to read from the passed in device.
void scriptel_register_input_callback(scriptel_device *device, scriptel_input_callback callback)
This function registers an input callback for a device.
This structure represents a physically attached Scriptel ScripTouch device.
Definition: scriptel-proscript.h:284
char * path
The path to the device.
Definition: scriptel-proscript.h:290
unsigned char open
Indicates whether or not the device is in the open state.
Definition: scriptel-proscript.h:319
scriptel_hid_feature_display_info display_info
Cached display information from the device at open time.
Definition: scriptel-proscript.h:333
char * model
The textual name of the device as returned by the operating system's HID driver.
Definition: scriptel-proscript.h:305
char * manufacturer
The textual name of the manufacturer as returned by the operating system's HID driver.
Definition: scriptel-proscript.h:310
This report is capable of getting the coordinate range from the device.
Definition: scriptel-hid-reports.h:1582
unsigned short x_max
Maximum logical value in the horizontal direction to be returned by the device.
Definition: scriptel-hid-reports.h:1594
unsigned short y_max
Maximum logical value in the vertical direction to be returned by the device.
Definition: scriptel-hid-reports.h:1602
unsigned short y_min
Minimum logical value in the vertical direction to be returned by the device.
Definition: scriptel-hid-reports.h:1598
unsigned short x_min
Minimum logical value in the horizontal direction to be returned by the device.
Definition: scriptel-hid-reports.h:1590
unsigned short width
Width of the on board display in pixels.
Definition: scriptel-hid-reports.h:2341
unsigned short height
Height of the on board display in pixels.
Definition: scriptel-hid-reports.h:2347
unsigned char tip_switch
This will be true if the pen is currently against the screen.
Definition: scriptel-hid-reports.h:799
scriptel_device_region_button button
Button region information.
Definition: scriptel-hid-reports.h:2625
scriptel_sample_info_pen pen
Sample information relevant to only pen input.
Definition: scriptel-hid-reports.h:853