gratefulfrog_ProcessingAndroidMode/MyProcessingAndroidCode/Test_15_BT_Cursors_00/UI.pde
void mousePressed(){
  if (mouseY <= 100 && mouseX > 0 && mouseX < width/3)
    KetaiKeyboard.toggle(this);
  else if (mouseY <= 100 && mouseX > width/3 && mouseX < 2*(width/3)) //config button
    isConfiguring=true;
  else if (mouseY <= 100 && mouseX > 2*(width/3) && mouseX < width){ // draw button
    if (isConfiguring){
      background(78, 93, 75);
      isConfiguring=false;
    }
  }
}

void keyPressed() {
  if (key =='c'){
    //If we have not discovered any devices, try prior paired devices
    if (bt.getDiscoveredDeviceNames().size() > 0)
      connectionList = new KetaiList(this, bt.getDiscoveredDeviceNames());
    else if (bt.getPairedDeviceNames().size() > 0)
      connectionList = new KetaiList(this, bt.getPairedDeviceNames());
  }
  else if (key == 'd')
    bt.discoverDevices();
  else if (key == 'b')
    bt.makeDiscoverable();
}

void drawUI(){
  pushStyle();
  fill(0);
  stroke(255);
  rect(0, 0, width/3, 100);
  
  if (isConfiguring){
    noStroke();
    fill(78, 93, 75);
  }
  else
    fill(0);
    
  rect(width/3, 0, width/3, 100);
  if (!isConfiguring){
    noStroke();
    fill(78, 93, 75);
  }
  else {
  fill(0);
  stroke(255);
  }
  rect((width/3)*2, 0, width/3, 100);
  fill(255);
  text("Keyboard", 5, 70);
  text("Bluetooth", width/3+5, 70);
  text("Interact", width/3*2+5, 70);
  popStyle();
}

void onKetaiListSelection(KetaiList connectionList) {
  String selection = connectionList.getSelection();
  bt.connectToDeviceByName(selection);
  connectionList = null;
}  