// ------- Unity Builtin Functions ------- public void Start() { for (int i = 0; i < MAX_CONTROLLERS; i++) { moveControllers[i] = new MoveController(i); } sendClient = new UdpClient(ipAddress, 23460); startReceiveThread(); sendMessageToServer("connect"); }
/* * Desc: Resets the orientation of the controller. * The server will interpret the orientation of the controller as the 'home' position. * That is, facing the screen, no roll and no pitch. * DON'T use this continously. */ public void Send_calibrateOrientation(MoveController move) { String msg = "d " + move.controllerNumber + " 0 0 1 0 0 0 0 0" + '\0'; sendMessageToServer(msg); }
// ------- 'Send' public functions. Talks to server ------- /* * Desc: Sets the rumble (0-255) on a controller. * You must continually update this to keep rumble on (or server will timeout). * IMPORTANT: Always remember to send a rumble of 0 when you want the rumble to stop. * If you don't, all other sent packets will send your last rumble value. * Hacky as, gotta fix. */ public void Send_rumbleController(MoveController move, int amount) { if (amount < 0 || amount > 255) print("WARNING: Rumble amount is out of bounds: " + amount); String msg = "d " + move.controllerNumber + " 1 " + amount + " 0 0 0 0 0 0" + '\0'; sendMessageToServer(msg); }
/* * Desc: Resets the move controller's light to the one it was assigned by the tracker. * This of course requires the tracker to be working. */ public void Send_resetMoveLight(MoveController move) { String msg = "d " + move.controllerNumber + " 0 0 0 1 0 0 0 0" + '\0'; sendMessageToServer(msg); }
/* * Desc: Sets color of the controller using r, g, b values (all between 0-255). * NOTE: Changing the color of a tracked controller will most likely cause the tracker to lose it. * Call 'Send_resetMoveLight' to get the controller back to the tracked color. */ public void Send_setMoveLight(MoveController move, int r, int g, int b) { String msg = "d " + move.controllerNumber + " 0 0 0 0 1 " + r + " " + g + " " + b + '\0'; sendMessageToServer(msg); }