Permalink
Browse files

Processing example: Count connected controllers (issue 30)

  • Loading branch information...
1 parent 5c52d44 commit c7033316c0644fe4960625343280bdfe0bd18cb0 @thp committed Nov 5, 2012
Showing with 11 additions and 4 deletions.
  1. +11 −4 examples/processing/multiple_controllers_tracker/multiple_controllers_tracker.pde
@@ -2,18 +2,25 @@
// Import the PS Move API Package
import io.thp.psmove.*;
+// Tracker and controller handles
PSMoveTracker tracker;
+PSMove [] controllers; // Define an array of controllers
+// Variables for storing the camera image
PImage img;
byte [] pixels;
-int connectedControllers = 2; // Number of connected Move controllers (a more generic solution would be to use count_connected() in the setup)
-PSMove[] controllers; // Define an array of controllers
-
void setup() {
size(640, 480);
- controllers = new PSMove[connectedControllers];
+ int connected = psmoveapi.count_connected();
+
+ // This is only fun if we actually have controllers
+ if (connected == 0) {
+ print("WARNING: No controllers connected.");
+ }
+
+ controllers = new PSMove[connected];
// Fill the array with controllers and light them up in white
for (int i = 0; i<controllers.length; i++) {

1 comment on commit c703331

Contributor

SableRaf commented on c703331 Nov 5, 2012

Great!

Please sign in to comment.