codeanticode / tablet

Tablet is a library for using pen tablets from Processing.
http://processing.andrescolubri.net/libraries/tablet/
Other
24 stars 2 forks source link

Incompatibly with Syphon library #2

Open codeanticode opened 10 years ago

codeanticode commented 10 years ago

Users have reported errors when a sketch using Tablet also depends on the Syphon library:

http://forum.processing.org/two/discussion/655/syphon-tablet-error#Item_3

codeanticode commented 7 years ago

I don't see error when using both libs together, but sometimes, tablet events stop being received for a brief interval (a second or so), but then they resume:

import codeanticode.tablet.*;
import codeanticode.syphon.*;

SyphonServer server;

Tablet tablet;

boolean useCallback = false;
float pressure;
int levelEventCalls;

//String renderer = JAVA2D;
String renderer = P2D;

void settings() {
  size(720, 720, renderer);
  PJOGL.profile=1;
}

void setup() {
  server = new SyphonServer(this, "Processing Syphon");
  frameRate(120);
  smooth(8);
  tablet = new Tablet(this);
  textFont(createFont("Arial", 30));
  background(180);
}

void draw() {
  stroke(0);
  if (useCallback) strokeWeight(25 * pressure);
  else strokeWeight(25 * tablet.getPressure());  
  if (mousePressed) {
    line(mouseX, mouseY, pmouseX, pmouseY);
  }      

  noStroke();
  fill(255, 0, 0);
  rect(0, 0, width, 50);
  fill(255);
  text(frameCount + " - " + levelEventCalls, 20, 40);
  server.sendScreen();
}

void keyPressed() {
  if (key == ' ') background(180);
  else if (key == 'c') {
    useCallback  = !useCallback;
    println("Using callback", useCallback);
  }
}

void penLevelEvent(Tablet t) {

  levelEventCalls++;
  pressure = t.getPressure();
}