When programming glovepie to control left4dead2 with the wiimote, tried to take in account the positioning of the device relatively to the screen, to have a better pointing device feel.
The effect is visible when you use the device to control the desktop cursor.
Actually the way the cursor moves according to wrist rotation is ideal only if the screens where spherical.
You turn the wrist one degree an the cursor moves 1 pixel
Since the screen is flat it should have a motion of tan(1 degree)
So the code was this
When you face the screen, if you rotate the pointer +10° on yaw axis, the mouse cursor should move on the screen by a trigonometric function of x=k*tangeant(10°)
// proportional to angle (rotate )
//var.diy=MapRange(wiimote.gyroPitch, -90 degrees,90 degrees, var.pitchrange mickeys,-var.pitchrange mickeys)
//var.dix=MapRange(wiimote.gyroYaw, -90 degrees,90 degrees, -var.yawrange mickeys,var.yawrange mickeys)
// proportional to pointed surface (aiming)
var.diysin=-MapRange(tan(wiimote.gyroPitch), -1, 1, -var.pitchrange mickeys, var.pitchrange mickeys)
var.dixsin=MapRange(tan(wiimote.gyroYaw), -1, 1, -var.yawrange mickeys,var.yawrange mickeys)
mouse.DirectInputX += delta(var.dixsin)
mouse.DirectInputY += delta(var.diysin)
Actually it seems it's linear, and the cursor moves linearily with the wrist rotation, like x=k*10° .
This is interesting in FPS, because it create a natural rotate acceleration the more you go away from the center.
It means :
- you can look around very quickly, even behind you with a reduced wrist movement
- you still have a good precision when you are pointing around the center of the screen
- you don't need to rachet as much when doing wide movements.
Sine function is the simplest way to do that, but ideally we should be able to customise the curb, so we can choose the treshold where we trade aiming precision for wide movement quickness.