var documentHasFocus = false; var theJoystick = null; var theJoystickObjectCreation = "createDefaultJoystickObject()"; var theJoystickActionSetup = "setupDefaultJoystickAction(theJoystick)"; function JoystickInstance(joystickControl,joystickAction,commandAction) { this.control = joystickControl; this.action = joystickAction; this.command = commandAction; pollInProgress = false; return (this); } function resetJoystickAction(joystick,feedNumber) { var buttons = new Array(); for (i = 0; i < 16; ++ i) { buttons[i] = 0; } joystick.command.setTarget(feedNumber,false); joystick.action.testAndDoAction(0,0,0,buttons); } function refreshJoystickAction(joystick,feedNumber) { var buttons = new Array(); for (i = 0; i < 16; ++ i) { buttons[i] = joystick.control.getB(1 + i) ? 1 : 0; } joystick.command.setTarget(feedNumber,false); joystick.action.testAndDoAction(joystick.control.getX(),joystick.control.getY(),joystick.control.getZ(),buttons); } function runJoystick(joystick) { if (joystick.control.acquireDevice(1)) { joystick.control.setPollInterval(1); joystick.control.setXRange(-10010, 10010); joystick.control.setYRange(-10010, 10010); joystick.control.setZRange(-10010, 10010); joystick.control.setXYZScale(1,1,-1); joystick.control.poll(); joystick.control.setXYZCalibration(); joystick.control.setXYZPedestal(500,500,1000); joystick.control.setPollInterval(0); } pollJoystick(joystick); } function createDefaultJoystickObject() { return(createIVCDIJoystick()); } function setupDefaultJoystickAction(joystick) { joystick.command = new RelayServerCommandActionClass(); joystick.action.setXYZRepetitionAllowance(3,3); joystick.action.setXYZStepQuantum(100,100); joystick.action.enableXYZDirectionalFilter(false,false); /* X/Y axises controls the pan/tilt */ joystick.action.setXYAction("theJoystick.command.startPanTilt()","theJoystick.command.stopPanTilt()"); /* Z axis controls the zoom */ joystick.action.setZAction("theJoystick.command.startZoom()","theJoystick.command.stopZoom()"); /* Button #11 is focus far, #12 is focus near. When these two buttons are off, then focus stop. When these two buttons are on, then auto-focus. */ joystick.action.addButtonAction(new Array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,0,-1,-1,-1,-1),"theJoystick.command.startFocusFar(10000)"); joystick.action.addButtonAction(new Array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,-1,-1,-1,-1),"theJoystick.command.startFocusNear(10000)"); joystick.action.addButtonAction(new Array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,0,-1,-1,-1,-1),"theJoystick.command.stopFocus()"); joystick.action.addButtonAction(new Array(-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,1,-1,-1,-1,-1),"theJoystick.command.autoFocus()"); /* Button #1 to #10 are goto preset #1 to #10. */ joystick.action.addButtonAction(new Array(1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1),"theJoystick.command.gotoPreset(1)"); joystick.action.addButtonAction(new Array(-1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1),"theJoystick.command.gotoPreset(2)"); joystick.action.addButtonAction(new Array(-1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1),"theJoystick.command.gotoPreset(3)"); joystick.action.addButtonAction(new Array(-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1),"theJoystick.command.gotoPreset(4)"); joystick.action.addButtonAction(new Array(-1,-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1),"theJoystick.command.gotoPreset(5)"); joystick.action.addButtonAction(new Array(-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1),"theJoystick.command.gotoPreset(6)"); joystick.action.addButtonAction(new Array(-1,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1),"theJoystick.command.gotoPreset(7)"); joystick.action.addButtonAction(new Array(-1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1),"theJoystick.command.gotoPreset(8)"); joystick.action.addButtonAction(new Array(-1,-1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1),"theJoystick.command.gotoPreset(9)"); joystick.action.addButtonAction(new Array(-1,-1,-1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,-1),"theJoystick.command.gotoPreset(10)"); } function pollJoystick(joystick) { joystick.pollInProgress = true; if (documentHasFocus) { refreshJoystickAction(joystick,feedId); time=setTimeout("pollJoystick(theJoystick)", 333); } joystick.pollInProgress = false; } function initializeTheJoystick() { var joystickControl; if(null == theJoystickObjectCreation) { joystickControl = createDefaultJoystickObject(); } else { joystickControl = eval(theJoystickObjectCreation); } if (null != joystickControl) { theJoystick = JoystickInstance(joystickControl,new JoystickActionClass(),null); if (null == theJoystickActionSetup) { setupDefaultJoystickAction(theJoystick); } else { eval(theJoystickActionSetup); } } }