Simple Wacom plugin wrapper (RequireJS/RightJS)
// RequireJS module def with some RightJS goodies
// Make sure the plugin is initialized (initPlugin) at your app init
// After that you can getPlugin and access its attrs (see Wacom docs).
// There's also a shortcut for applying pressure.
define({
initPlugin: function() {
if( navigator.mimeTypes["application/x-wacom-tablet"] ) {
$E('embed', {name: 'wacom-plugin', id: 'wacom-plugin',
type: 'application/x-wacom-tablet', HIDDEN: 'TRUE'}).
insertTo(document.body);
}
},
getPlugin: function() {
if(document.embeds.length > 0) {
var plugin = document.embeds[0];
if (plugin.isWacom) {
return plugin;
}
}
return null;
},
applyPressure: function(property) {
var plugin = this.getPlugin();
if(plugin && plugin.pressure > 0) {
return plugin.pressure * property;
}
return property;
}
});