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>
#include "scriptel-proscript.h"
int main() {
scriptel_device* device;
//Initialize the library.
scriptel_init();
//List the devices.
if(scriptel_list_devices(&device) == SCRIPTEL_CODE_SUCCESS) {
//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.
if(scriptel_open_device(device) == SCRIPTEL_CODE_SUCCESS) {
printf("Successfully connected to %s - %s at: %s\n", device->manufacturer, device->model, device->path);
//Basic black and white colors
scriptel_color black;
black.alpha = 255;
black.red = 0;
black.green = 0;
black.blue = 0;
scriptel_color white;
white.alpha = 0;
white.red = 255;
white.green = 255;
white.blue = 255;
//Create a resource. In this example, we will create a text resource.
scriptel_hid_feature_resource* text = malloc(sizeof(scriptel_hid_feature_resource));
memset(text, 0, sizeof(scriptel_hid_feature_resource));
text->resource_number = 3;
text->resource_type = SCRIPTEL_RESOURCE_TYPE_TEXT;
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_run_mode(device, SCRIPTEL_RUNMODE_COMMAND);
scriptel_set_resource(device, text);
free(text);
scriptel_set_run_mode(device, SCRIPTEL_RUNMODE_PEN);
//Create new regions. The buttons will serve as a connection back to the regular screens.
//Text Region to hold the text resource.
scriptel_hid_feature_region* textPrompt = malloc(sizeof(scriptel_hid_feature_region));
memset(textPrompt, 0, sizeof(scriptel_hid_feature_region));
textPrompt->common.region_index = 10;
textPrompt->common.region_type = SCRIPTEL_REGION_TYPE_TEXT;
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;
textPrompt->text.horizontal_justification = SCRIPTEL_JUSTIFICATION_CENTER;
textPrompt->text.vertical_justification = SCRIPTEL_JUSTIFICATION_TOP;
scriptel_set_region_contents(device, textPrompt);
free(textPrompt);
//Button will lead back to the main splash screen.
scriptel_hid_feature_region* splashButton = malloc(sizeof(scriptel_hid_feature_region));
memset(splashButton, 0, sizeof(scriptel_hid_feature_region));
splashButton->common.region_index = 11;
splashButton->common.region_type = SCRIPTEL_REGION_TYPE_BUTTON;
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.
scriptel_hid_feature_region* sigButton = malloc(sizeof(scriptel_hid_feature_region));
memset(sigButton, 0, sizeof(scriptel_hid_feature_region));
sigButton->common.region_index = 12;
sigButton->common.region_type = SCRIPTEL_REGION_TYPE_BUTTON;
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.
scriptel_hid_feature_screen* testScreen = malloc(sizeof(scriptel_hid_feature_screen));
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.
scriptel_set_active_screen(device, 4);
} 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
@ SCRIPTEL_RUNMODE_PEN
Pen mode, configures the digitizer to accept pen input.
Definition: scriptel-hid-reports.h:585
SCRIPTEL_RUNMODE_COMMAND
@ SCRIPTEL_RUNMODE_COMMAND
Command mode, turns off the ASIC and accepts commands.
Definition: scriptel-hid-reports.h:576
SCRIPTEL_JUSTIFICATION_CENTER
@ SCRIPTEL_JUSTIFICATION_CENTER
Justifies the resouce to the center.
Definition: scriptel-hid-reports.h:3221
SCRIPTEL_JUSTIFICATION_TOP
@ SCRIPTEL_JUSTIFICATION_TOP
Justifies the resouce to the top.
Definition: scriptel-hid-reports.h:3209
SCRIPTEL_REGION_TYPE_BUTTON
@ SCRIPTEL_REGION_TYPE_BUTTON
Type for buttons.
Definition: scriptel-hid-reports.h:672
SCRIPTEL_REGION_TYPE_TEXT
@ SCRIPTEL_REGION_TYPE_TEXT
Type for text.
Definition: scriptel-hid-reports.h:684
SCRIPTEL_RESOURCE_TYPE_TEXT
@ SCRIPTEL_RESOURCE_TYPE_TEXT
Rext resource.
Definition: scriptel-hid-reports.h:2779
scriptel-proscript.h
This file contains the headers for the core of the Scriptel ScripTouch ProScript library.
scriptel_init
void scriptel_init(void)
This function should be called prior to using any other library functions.
scriptel_count_device_list
unsigned int scriptel_count_device_list(scriptel_device *list)
This function counts the number of devices in a given device list.
scriptel_set_resource
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_list_devices
scriptel_error_code scriptel_list_devices(scriptel_device **start)
This function takes a pointer and will attempt to enumerate any attached ScripTouch devices.
scriptel_set_region_contents
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_set_screen
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_open_device
scriptel_error_code scriptel_open_device(scriptel_device *device)
This function attempts to open a local device returned by scriptel_list_devices().
scriptel_get_last_error
char * scriptel_get_last_error(void)
This function gets the last error message generated by the library.
SCRIPTEL_CODE_SUCCESS
@ SCRIPTEL_CODE_SUCCESS
This code indicates that the function did succeed.
Definition: scriptel-proscript.h:96
scriptel_set_active_screen
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_set_run_mode
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.
scriptel_color
This structure describes a particular color in 32-bit space.
Definition: scriptel-hid-reports.h:2308
scriptel_color::red
unsigned char red
The red channel of this color.
Definition: scriptel-hid-reports.h:2324
scriptel_color::green
unsigned char green
The green channel of this color.
Definition: scriptel-hid-reports.h:2320
scriptel_color::blue
unsigned char blue
The blue channel of this color.
Definition: scriptel-hid-reports.h:2316
scriptel_color::alpha
unsigned char alpha
The alpha channel of this color.
Definition: scriptel-hid-reports.h:2312
scriptel_device
This structure represents a physically attached Scriptel ScripTouch device.
Definition: scriptel-proscript.h:284
scriptel_device::path
char * path
The path to the device.
Definition: scriptel-proscript.h:290
scriptel_device::model
char * model
The textual name of the device as returned by the operating system's HID driver.
Definition: scriptel-proscript.h:305
scriptel_device::manufacturer
char * manufacturer
The textual name of the manufacturer as returned by the operating system's HID driver.
Definition: scriptel-proscript.h:310
scriptel_hid_feature_region_button::highlight_on_select
unsigned char highlight_on_select
Button highlights when it is selected.
Definition: scriptel-hid-reports.h:3134
scriptel_hid_feature_region_button::caption
char caption[100]
Button caption.
Definition: scriptel-hid-reports.h:3170
scriptel_hid_feature_region_button::enabled
unsigned char enabled
Button is enabled.
Definition: scriptel-hid-reports.h:3130
scriptel_hid_feature_region_common::background_color
scriptel_color background_color
Background color of the region.
Definition: scriptel-hid-reports.h:3092
scriptel_hid_feature_region_common::x1
unsigned short x1
X minimum of the region.
Definition: scriptel-hid-reports.h:3072
scriptel_hid_feature_region_common::region_type
scriptel_region_type region_type
The type of region this represents.
Definition: scriptel-hid-reports.h:3014
scriptel_hid_feature_region_common::decode_region
unsigned char decode_region
Whether or not this region gets decoded.
Definition: scriptel-hid-reports.h:3024
scriptel_hid_feature_region_common::y1
unsigned short y1
Y minimum of the region.
Definition: scriptel-hid-reports.h:3080
scriptel_hid_feature_region_common::x2
unsigned short x2
X maximum of the region.
Definition: scriptel-hid-reports.h:3076
scriptel_hid_feature_region_common::has_frame
unsigned char has_frame
Whether or not there is a frame around the region.
Definition: scriptel-hid-reports.h:3028
scriptel_hid_feature_region_common::region_index
unsigned char region_index
The region index on the device.
Definition: scriptel-hid-reports.h:3010
scriptel_hid_feature_region_common::foreground_color
scriptel_color foreground_color
Foreground color of the region.
Definition: scriptel-hid-reports.h:3088
scriptel_hid_feature_region_common::accepts_touch
unsigned char accepts_touch
Whether or not this region accepts touch.
Definition: scriptel-hid-reports.h:3018
scriptel_hid_feature_region_common::y2
unsigned short y2
Y maximum of the region.
Definition: scriptel-hid-reports.h:3084
scriptel_hid_feature_region_text::resource_number
unsigned char resource_number
Resource number where the text is stored.
Definition: scriptel-hid-reports.h:3282
scriptel_hid_feature_region_text::vertical_justification
scriptel_resource_justification vertical_justification
Vertical justification of the text in this region.
Definition: scriptel-hid-reports.h:3294
scriptel_hid_feature_region_text::horizontal_justification
scriptel_resource_justification horizontal_justification
Horizontal justification of the text in this region.
Definition: scriptel-hid-reports.h:3290
scriptel_hid_feature_resource
Defines a structure for a resource on the device.
Definition: scriptel-hid-reports.h:2855
scriptel_hid_feature_resource::resource_size
unsigned long resource_size
The total size of the resource in bytes.
Definition: scriptel-hid-reports.h:2881
scriptel_hid_feature_resource::resource_number
unsigned char resource_number
index of the resource on the device.
Definition: scriptel-hid-reports.h:2863
scriptel_hid_feature_resource::resource_type
scriptel_resource_type resource_type
Defines what kind of resource this currently represents.
Definition: scriptel-hid-reports.h:2867
scriptel_hid_feature_resource::resource_data
unsigned char resource_data[1024]
The data, in bytes.
Definition: scriptel-hid-reports.h:2917
scriptel_hid_feature_resource::bytes_valid
unsigned short bytes_valid
Number of valid bytes incoming or outgoing in this structure.
Definition: scriptel-hid-reports.h:2913
scriptel_hid_feature_screen
Structure that can be used to get or set a screen on the device.
Definition: scriptel-hid-reports.h:3329
scriptel_hid_feature_screen::timeout_screen_next
unsigned char timeout_screen_next
The screen index that the device moves to when this screen times out.
Definition: scriptel-hid-reports.h:3405
scriptel_hid_feature_screen::screen_next_list
unsigned char screen_next_list[100]
Corresponds to region_list, determines the next screen for each region interaction.
Definition: scriptel-hid-reports.h:3417
scriptel_hid_feature_screen::screen_number
unsigned char screen_number
Index of the screen these variables represent.
Definition: scriptel-hid-reports.h:3337
scriptel_hid_feature_screen::region_count
unsigned char region_count
Number of regions on this screen.
Definition: scriptel-hid-reports.h:3409
scriptel_hid_feature_screen::region_list
unsigned char region_list[100]
List of regions featured on this screen in draw order.
Definition: scriptel-hid-reports.h:3413
scriptel_hid_feature_region
This union contains all region information.
Definition: scriptel-hid-reports.h:3299
scriptel_hid_feature_region::text
scriptel_hid_feature_region_text text
Text region.
Definition: scriptel-hid-reports.h:3323
scriptel_hid_feature_region::common
scriptel_hid_feature_region_common common
Common, the foundation of all regions.
Definition: scriptel-hid-reports.h:3303
scriptel_hid_feature_region::button
scriptel_hid_feature_region_button button
Button region.
Definition: scriptel-hid-reports.h:3311