function IVCDIJoystickClass(target) { this.target = target; /* scale any axis and/or invert polarity */ this.xScale = 1; this.yScale = 1; this.zScale = 1; /* offset when any axis is not centered at 0 */ this.xOffset = 0; this.yOffset = 0; this.zOffset = 0; /* pedestal threshold when any axis fluctuate at center */ this.xPedestal = 0; this.yPedestal = 0; this.zPedestal = 0; this.getDeviceCount = function() { return (this.target.GetDeviceCount()); } this.acquireDevice = function(which) { return (this.target.Acquire(which)); } this.unacquireDevice = function() { return (this.target.Unacquire()); } this.setPollInterval = function(milliseconds) { this.target.PollInterval = milliseconds; } this.setXYZScale = function(x,y,z) { this.xScale = x; this.yScale = y; this.zScale = z; } this.setXRange = function(min,max) { this.target.XMin = min; this.target.XMax = max; } this.setYRange = function(min,max) { this.target.YMin = min; this.target.YMax = max; } this.setZRange = function(min,max) { this.target.ZMin = min; this.target.ZMax = max; } this.clearXYZCalibration = function() { this.xOffset = 0; this.yOffset = 0; this.zOffset = 0; } this.setXYZCalibration = function() { this.xOffset = -this.target.X; this.yOffset = -this.target.Y; this.zOffset = -this.target.Z; } this.setXYZPedestal = function(x,y,z) { this.xPedestal = x; this.yPedestal = y; this.zPedestal = z; } this.poll = function() { this.target.Poll(); } this.getX = function() { var x = (this.target.X + this.xOffset) * this.xScale; return (this.xPedestal <= Math.abs(x) ? x : 0); } this.getY = function() { var y = (this.target.Y + this.yOffset) * this.yScale; return (this.yPedestal <= Math.abs(y) ? y : 0); } this.getZ = function() { var z = (this.target.Z + this.zOffset) * this.zScale; return (this.zPedestal <= Math.abs(z) ? z : 0); } this.getB = function(which) { return (eval("this.target.B" + which)); } } function createIVCDIJoystick() { var joystickControl = new ActiveXObject("ivc_di.Joystick"); return (new IVCDIJoystickClass(joystickControl)); }