# (c) Tuomas J. Lukka import vob def testRelativeAxis(): modelA = vob.input.impl.StandardBoundedFloatModel(0,1) adapterA = vob.input.BoundedFloatLinearAbsoluteAdapter(modelA) modelB = vob.input.impl.StandardBoundedFloatModel(5,10) adapterB = vob.input.BoundedFloatLogAbsoluteAdapter(modelB) modelA.value = .5 modelB.value = .5 axis = vob.input.impl.RelativeAxis("Foo") state = vob.input.InputDeviceManager # Calibrate between 0 and 100, but shift first to make it hard axis.changedRelative(42) axis.setState(state.STATE_CALIBRATING) axis.changedRelative(100) axis.changedRelative(-100) axis.changedRelative(50) axis.changedRelative(50) axis.changedRelative(-100) axis.setState(state.STATE_NORMAL) axis.setMainListener(adapterA) assert modelA.value == 0, modelA.value def approx(a, b): return abs(a-b) < .0001 axis.changedRelative(10) assert approx(modelA.value, 0.1), modelA.value