Scriptel ScripTouch ProScript C Library
This documentation contains information about the ScripTouch ProScript C Library.
example-screen-editing.c

This is a simple example of how to create screens, regions, and resources.
This example requires firmware 4.0.0 or greater.
This example will not make the screen edits permanent. To do so, please refer to scriptel_set_screen_region_commit().
This example will not expose the new screen to normal operations. To do so, you will need to edit the other screens.

#include <stdio.h>
int main() {
scriptel_device* device;
//Initialize the library.
//List the devices.
//Test to see if we have more than zero devices.
if(device != NULL) {
printf("Found %i devices.\n", scriptel_count_device_list(device));
//Lets open the first device.
printf("Successfully connected to %s - %s at: %s\n", device->manufacturer, device->model, device->path);
//Basic black and white colors
black.alpha = 255;
black.red = 0;
black.green = 0;
black.blue = 0;
white.alpha = 0;
white.red = 255;
white.green = 255;
white.blue = 255;
//Create a resource. In this example, we will create a text resource.
memset(text, 0, sizeof(scriptel_hid_feature_resource));
text->resource_number = 3;
memcpy(text->resource_data, "Please select which screen you would like to appear.", 53);
text->bytes_valid = 53;
text->resource_size = 53;
//When writing a resource to the device, the device must always be in command mode.
scriptel_set_resource(device, text);
free(text);
//Create new regions. The buttons will serve as a connection back to the regular screens.
//Text Region to hold the text resource.
memset(textPrompt, 0, sizeof(scriptel_hid_feature_region));
textPrompt->common.region_index = 10;
textPrompt->common.x1 = 20;
textPrompt->common.x2 = 220;
textPrompt->common.y1 = 2;
textPrompt->common.y2 = 30;
textPrompt->common.foreground_color = black;
textPrompt->common.background_color = white;
textPrompt->text.resource_number = 3;
scriptel_set_region_contents(device, textPrompt);
free(textPrompt);
//Button will lead back to the main splash screen.
memset(splashButton, 0, sizeof(scriptel_hid_feature_region));
splashButton->common.region_index = 11;
splashButton->common.accepts_touch = 1;
splashButton->common.has_frame = 1;
splashButton->common.decode_region = 1;
splashButton->common.x1 = 40;
splashButton->common.x2 = 100;
splashButton->common.y1 = 40;
splashButton->common.y2 = 55;
splashButton->common.foreground_color = black;
splashButton->common.background_color = white;
splashButton->button.enabled = 1;
splashButton->button.highlight_on_select = 1;
memcpy(splashButton->button.caption, "Splash", sizeof("Splash"));
scriptel_set_region_contents(device, splashButton);
free(splashButton);
//Button will lead back to the signature screen.
memset(sigButton, 0, sizeof(scriptel_hid_feature_region));
sigButton->common.region_index = 12;
sigButton->common.accepts_touch = 1;
sigButton->common.has_frame = 1;
sigButton->common.decode_region = 1;
sigButton->common.x1 = 140;
sigButton->common.x2 = 200;
sigButton->common.y1 = 40;
sigButton->common.y2 = 55;
sigButton->common.foreground_color = black;
sigButton->common.background_color = white;
sigButton->button.enabled = 1;
sigButton->button.highlight_on_select = 1;
memcpy(sigButton->button.caption, "Signature", sizeof("Signature"));
scriptel_set_region_contents(device, sigButton);
free(sigButton);
//Create a screen. This example will create screen number 4.
//This screen won't appear once this demo is over.
//Making this screen available requires editing the other screens.
memset(testScreen, 0, sizeof(scriptel_hid_feature_screen));
testScreen->screen_number = 4;
testScreen->timeout_screen_next = 0xFF;
testScreen->region_count = 3;
memcpy(testScreen->region_list, (char[3]){ 10, 11, 12 }, 3);
memcpy(testScreen->screen_next_list, (char[3]){ 0xFF, 1, 2 }, 3);
scriptel_set_screen(device, testScreen);
//Set the active screen to our new Screen.
} else {
printf("Problem opening device: %s\n", scriptel_get_last_error());
return 1;
}
} else {
printf("No devices found!\n");
return 2;
}
} else {
printf("Problem enumerating devices: %s\n", scriptel_get_last_error());
return 3;
}
}
@ SCRIPTEL_RUNMODE_PEN
Pen mode, configures the digitizer to accept pen input.
Definition: scriptel-hid-reports.h:585
@ SCRIPTEL_RUNMODE_COMMAND
Command mode, turns off the ASIC and accepts commands.
Definition: scriptel-hid-reports.h:576
@ SCRIPTEL_JUSTIFICATION_CENTER
Justifies the resouce to the center.
Definition: scriptel-hid-reports.h:3221
@ SCRIPTEL_JUSTIFICATION_TOP
Justifies the resouce to the top.
Definition: scriptel-hid-reports.h:3209
@ SCRIPTEL_REGION_TYPE_BUTTON
Type for buttons.
Definition: scriptel-hid-reports.h:672
@ SCRIPTEL_REGION_TYPE_TEXT
Type for text.
Definition: scriptel-hid-reports.h:684
@ SCRIPTEL_RESOURCE_TYPE_TEXT
Rext resource.
Definition: scriptel-hid-reports.h:2779
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_error_code scriptel_set_resource(scriptel_device *device, scriptel_hid_feature_resource *resource)
This function sets the information of a resource on the device.
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_set_region_contents(scriptel_device *device, scriptel_hid_feature_region *region)
This function sets the information about a region on the device.
scriptel_error_code scriptel_set_screen(scriptel_device *device, scriptel_hid_feature_screen *screen)
This function sets the information about a screen that can be displayed on the device based off the s...
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.
@ SCRIPTEL_CODE_SUCCESS
This code indicates that the function did succeed.
Definition: scriptel-proscript.h:96
scriptel_error_code scriptel_set_active_screen(scriptel_device *device, unsigned char screen_index)
This function sets the index of the active screen on the signature pad.
scriptel_error_code scriptel_set_run_mode(scriptel_device *device, scriptel_device_run_mode run_mode)
This function sets the run mode of the device.
This structure describes a particular color in 32-bit space.
Definition: scriptel-hid-reports.h:2308
unsigned char red
The red channel of this color.
Definition: scriptel-hid-reports.h:2324
unsigned char green
The green channel of this color.
Definition: scriptel-hid-reports.h:2320
unsigned char blue
The blue channel of this color.
Definition: scriptel-hid-reports.h:2316
unsigned char alpha
The alpha channel of this color.
Definition: scriptel-hid-reports.h:2312
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
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
unsigned char highlight_on_select
Button highlights when it is selected.
Definition: scriptel-hid-reports.h:3134
char caption[100]
Button caption.
Definition: scriptel-hid-reports.h:3170
unsigned char enabled
Button is enabled.
Definition: scriptel-hid-reports.h:3130
scriptel_color background_color
Background color of the region.
Definition: scriptel-hid-reports.h:3092
unsigned short x1
X minimum of the region.
Definition: scriptel-hid-reports.h:3072
scriptel_region_type region_type
The type of region this represents.
Definition: scriptel-hid-reports.h:3014
unsigned char decode_region
Whether or not this region gets decoded.
Definition: scriptel-hid-reports.h:3024
unsigned short y1
Y minimum of the region.
Definition: scriptel-hid-reports.h:3080
unsigned short x2
X maximum of the region.
Definition: scriptel-hid-reports.h:3076
unsigned char has_frame
Whether or not there is a frame around the region.
Definition: scriptel-hid-reports.h:3028
unsigned char region_index
The region index on the device.
Definition: scriptel-hid-reports.h:3010
scriptel_color foreground_color
Foreground color of the region.
Definition: scriptel-hid-reports.h:3088
unsigned char accepts_touch
Whether or not this region accepts touch.
Definition: scriptel-hid-reports.h:3018
unsigned short y2
Y maximum of the region.
Definition: scriptel-hid-reports.h:3084
unsigned char resource_number
Resource number where the text is stored.
Definition: scriptel-hid-reports.h:3282
scriptel_resource_justification vertical_justification
Vertical justification of the text in this region.
Definition: scriptel-hid-reports.h:3294
scriptel_resource_justification horizontal_justification
Horizontal justification of the text in this region.
Definition: scriptel-hid-reports.h:3290
Defines a structure for a resource on the device.
Definition: scriptel-hid-reports.h:2855
unsigned long resource_size
The total size of the resource in bytes.
Definition: scriptel-hid-reports.h:2881
unsigned char resource_number
index of the resource on the device.
Definition: scriptel-hid-reports.h:2863
scriptel_resource_type resource_type
Defines what kind of resource this currently represents.
Definition: scriptel-hid-reports.h:2867
unsigned char resource_data[1024]
The data, in bytes.
Definition: scriptel-hid-reports.h:2917
unsigned short bytes_valid
Number of valid bytes incoming or outgoing in this structure.
Definition: scriptel-hid-reports.h:2913
Structure that can be used to get or set a screen on the device.
Definition: scriptel-hid-reports.h:3329
unsigned char timeout_screen_next
The screen index that the device moves to when this screen times out.
Definition: scriptel-hid-reports.h:3405
unsigned char screen_next_list[100]
Corresponds to region_list, determines the next screen for each region interaction.
Definition: scriptel-hid-reports.h:3417
unsigned char screen_number
Index of the screen these variables represent.
Definition: scriptel-hid-reports.h:3337
unsigned char region_count
Number of regions on this screen.
Definition: scriptel-hid-reports.h:3409
unsigned char region_list[100]
List of regions featured on this screen in draw order.
Definition: scriptel-hid-reports.h:3413
This union contains all region information.
Definition: scriptel-hid-reports.h:3299
scriptel_hid_feature_region_text text
Text region.
Definition: scriptel-hid-reports.h:3323
scriptel_hid_feature_region_common common
Common, the foundation of all regions.
Definition: scriptel-hid-reports.h:3303
scriptel_hid_feature_region_button button
Button region.
Definition: scriptel-hid-reports.h:3311