#include <WacomIntuos4LED.h>
Public Member Functions | |
WacomIntuos4LED () | |
~WacomIntuos4LED () | |
bool | init (uint16_t vendor_id, uint16_t product_id) |
bool | autoDetectTablet () |
bool | displayPalette (bool right_handed=true) |
bool | setLibraryIcon (unsigned int button, const string name, bool right_handed=true) |
bool | setImage (unsigned int button, const string file, bool right_handed=true) |
bool | dumpImageAsStaticData (const string file, const string name="icon") |
void | dumpIconAsStaticData (unsigned char *icon, string name="icon") const |
bool | clearButton (unsigned int button, bool right_handed=true) |
bool | clearAllButtons () |
void | dumpIconNames () const |
Private Member Functions | |
void | initIconLibrary () |
int | sendControlMsg (uint8_t bm_request_type, uint8_t b_request, uint16_t w_value, uint16_t w_index, unsigned char *data, uint16_t w_length, unsigned int timeout, unsigned int retries) |
bool | deviceEnabled () const |
bool | deviceDisabled () const |
void | flipIconVertically (unsigned char *icon) const |
void | flipIconHorizontally (unsigned char *icon) const |
int | toIndex (int x, int y) const |
unsigned char | transformShade (double shade) const |
bool | setTransferMode (bool mode) |
bool | setIcon (unsigned int button, const unsigned char *icon, bool right_handed=true) |
bool | imageToIcon (const string &file, unsigned char *icon) const |
Private Attributes | |
libusb_context * | context |
libusb_device_handle * | dev_handle |
map< string, const unsigned char * > | icon_table |
This class provides methods to access the LED button display of the Wacom Intuos4 Tablet.
Definition at line 23 of file WacomIntuos4LED.h.
WacomIntuos4LED::WacomIntuos4LED | ( | ) |
Constructor.
Definition at line 60 of file WacomIntuos4LED.cpp.
WacomIntuos4LED::~WacomIntuos4LED | ( | ) |
Destructor.
Definition at line 100 of file WacomIntuos4LED.cpp.
bool WacomIntuos4LED::autoDetectTablet | ( | ) |
Autodetect and initialize the first tablet.
Definition at line 377 of file WacomIntuos4LED.cpp.
bool WacomIntuos4LED::clearAllButtons | ( | ) |
Clear the icons of all buttons.
Definition at line 339 of file WacomIntuos4LED.cpp.
bool WacomIntuos4LED::clearButton | ( | unsigned int | button, | |
bool | right_handed = true | |||
) |
Clear the image of a button.
This method can be used to clear the icon of a particular button.
button | number of the button to which the icon is assigned (must be between 0 and 7). | |
right_handed | orientation of the tablet. |
Definition at line 329 of file WacomIntuos4LED.cpp.
bool WacomIntuos4LED::deviceDisabled | ( | ) | const [private] |
Check whether the device is disabled.
This method can be used to check whether the device is disabled, i.e., dev_handle equals NULL.
Definition at line 173 of file WacomIntuos4LED.cpp.
bool WacomIntuos4LED::deviceEnabled | ( | ) | const [private] |
Check whether the device is enabled.
This method can be used to check whether the device is enabled, i.e., dev_handle is non-null.
Definition at line 169 of file WacomIntuos4LED.cpp.
bool WacomIntuos4LED::displayPalette | ( | bool | right_handed = true |
) |
Display a palette of all colors (gray tones) of the Intuos 4 LEDs.
This method displays all available colors of the Intuos 4 tablet.
Definition at line 177 of file WacomIntuos4LED.cpp.
void WacomIntuos4LED::dumpIconAsStaticData | ( | unsigned char * | icon, | |
string | name = "icon" | |||
) | const |
icon | pointer to the 1024 byte array containing the icon data. | |
name | name of the C static array. |
Definition at line 473 of file WacomIntuos4LED.cpp.
void WacomIntuos4LED::dumpIconNames | ( | ) | const |
Dump names of library icons to standard output.
Definition at line 464 of file WacomIntuos4LED.cpp.
bool WacomIntuos4LED::dumpImageAsStaticData | ( | const string | file, | |
const string | name = "icon" | |||
) |
Dump an image as a C static array.
This method dumps an image file as a 1024 byte C static array. The method may be used to extend the icon library.
file | name of the image file. | |
name | name of the C static array. |
Definition at line 236 of file WacomIntuos4LED.cpp.
void WacomIntuos4LED::flipIconHorizontally | ( | unsigned char * | icon | ) | const [private] |
Flip an icon horizontally.
icon | pointer to a 1024 byte array including the icon data |
Definition at line 128 of file WacomIntuos4LED.cpp.
void WacomIntuos4LED::flipIconVertically | ( | unsigned char * | icon | ) | const [private] |
Flip an icon vertically.
icon | pointer to a 1024 byte array including the icon data |
Definition at line 116 of file WacomIntuos4LED.cpp.
bool WacomIntuos4LED::imageToIcon | ( | const string & | file, | |
unsigned char * | icon | |||
) | const [private] |
Convert an image to an icon.
file | name of the image file. | |
icon | pointer to an 1024 byte block to store the converted image |
Definition at line 299 of file WacomIntuos4LED.cpp.
bool WacomIntuos4LED::init | ( | uint16_t | vendor_id, | |
uint16_t | product_id | |||
) |
Initialization of the tablet.
This method initializes the tablet and the class data structures.
vendor_id | vendor id of the tablet | |
product_id | product id of the table |
Definition at line 348 of file WacomIntuos4LED.cpp.
void WacomIntuos4LED::initIconLibrary | ( | ) | [private] |
Init the icon library.
This method sets up the icon library, this is, stores all available icons with their respective names in the icon_table map.
Definition at line 64 of file WacomIntuos4LED.cpp.
int WacomIntuos4LED::sendControlMsg | ( | uint8_t | bm_request_type, | |
uint8_t | b_request, | |||
uint16_t | w_value, | |||
uint16_t | w_index, | |||
unsigned char * | data, | |||
uint16_t | w_length, | |||
unsigned int | timeout, | |||
unsigned int | retries | |||
) | [private] |
Send a control message to the USB device.
This function is a wrapper to the underlying function of the USB library.
bm_request_type | the request type field for the setup packet | |
b_request | the request field for the setup packet | |
w_value | the value field for the setup packet | |
w_index | the index field for the setup packet | |
data | data buffer to be transmitted | |
w_length | length field for the setup packet. The data buffer should be at least this size. | |
timeout | timeout (in millseconds) that this function should wait before giving up due to no response being received. For an unlimited timeout, use value 0. | |
retries | number of retries in case of a transmission error. |
Definition at line 148 of file WacomIntuos4LED.cpp.
bool WacomIntuos4LED::setIcon | ( | unsigned int | button, | |
const unsigned char * | icon, | |||
bool | right_handed = true | |||
) | [private] |
Transfer an icon to the tablet.
Ths method transfers an icon to the tablet.
button | number of the button to which the icon is assigned (must be between 0 and 7). | |
icon | pointer to a 1024 byte block which contains the bitmap. | |
right_handed | orientation of the tablet. |
Definition at line 248 of file WacomIntuos4LED.cpp.
bool WacomIntuos4LED::setImage | ( | unsigned int | button, | |
const string | file, | |||
bool | right_handed = true | |||
) |
Ths method transfers an image to the tablet.
This method can be used to transfer an image to the tablet. The image MUST have a dimension of 64 columns and 32 rows. Before the transmission the image is converted to a grayscale image and thereafter approximated by an image with 16 grayscale values.
button | number of the button to which the icon is assigned (must be between 0 and 7). | |
file | name of the image file. | |
right_handed | orientation of the tablet. |
Definition at line 225 of file WacomIntuos4LED.cpp.
bool WacomIntuos4LED::setLibraryIcon | ( | unsigned int | button, | |
const string | name, | |||
bool | right_handed = true | |||
) |
Ths method transfers an library icon to the tablet.
This method can be used to transfer a predefined library icon to the tablet.
button | number of the button to which the icon is assigned (must be between 0 and 7). | |
name | of the library icon. | |
right_handed | orientation of the tablet. |
Definition at line 216 of file WacomIntuos4LED.cpp.
bool WacomIntuos4LED::setTransferMode | ( | bool | mode | ) | [private] |
Set the transfer mode of the tablet.
This method is used to activate or deactivate the icon transfer mode of the tablet.
mode | true = enable transfer mode, false = disable transfer mode |
Definition at line 193 of file WacomIntuos4LED.cpp.
int WacomIntuos4LED::toIndex | ( | int | x, | |
int | y | |||
) | const [private] |
Map a 2-dimensional coordinate to an array index.
This method is used internally to to flip the icons vertically or horizontally.
x | x coordinate | |
y | y coordinate |
Definition at line 112 of file WacomIntuos4LED.cpp.
unsigned char WacomIntuos4LED::transformShade | ( | double | shade | ) | const [private] |
Transform a grayscale value to a 4-bit graytone.
grayscale | as a floating point value |
Definition at line 106 of file WacomIntuos4LED.cpp.
libusb_context* WacomIntuos4LED::context [private] |
libusb_device_handle* WacomIntuos4LED::dev_handle [private] |
Device handle for tablet access.
This handle is used to access the device. If no device was detected and initialized, this pointer equals NULL.
Definition at line 39 of file WacomIntuos4LED.h.
map<string,const unsigned char*> WacomIntuos4LED::icon_table [private] |
Table with icons.
This table contains (pointers to) icons to be used with the intuos 4 led displays. For simplicity, the icons can be accessed by a unique name.
Definition at line 47 of file WacomIntuos4LED.h.