AndersMalmgren / FreePIE

Programmable Input Emulator
649 stars 144 forks source link

Wiimote gyro data 'fastModeFactor' incorrectly assigned. (solution posted) #188

Open ProtonAbyss opened 4 years ago

ProtonAbyss commented 4 years ago

I discovered that DolphiimoteWiimoteData.cs has the wrong 'slow_modes' assigned to the gyro axis of the wiimote. From my understanding, the assignment is to allow for a 'fastModeFactor' correction to gyro sensor reading, where changes to gyro movement speeds, cause variations in outputs that aren't consistent. The current assignment makes accurate mouse mappings from gyro data, impossible. I discovered it while swinging my wiimote fast (using a gyro-mouse script), which causes a large vertical dip — or rise — to mouse movements, when making a horizontal swing. The opposite would happen when making a vertical swing with the wiimote. According to the DolphiimoteDLL.cs file, "Yaw = 0x1, Roll = 0x2, Pitch = 0x4." This data is applied to the DolphiimoteWiimoteData.cs file as,

(motionplus.slow_modes & 0x1) == 0x1 ? gyro.Value.x : gyro.Value.x * fastModeFactor, (motionplus.slow_modes & 0x4) == 0x4 ? gyro.Value.y : gyro.Value.y * fastModeFactor, (motionplus.slow_modes & 0x2) == 0x2 ? gyro.Value.z : gyro.Value.z * fastModeFactor));

It should be — I've tested it on both the old and new version of wiimotes and it fixes the issue (3 remotes in total).

(motionplus.slow_modes & 0x4) == 0x4 ? gyro.Value.x : gyro.Value.x * fastModeFactor, (motionplus.slow_modes & 0x2) == 0x2 ? gyro.Value.y : gyro.Value.y * fastModeFactor, (motionplus.slow_modes & 0x1) == 0x1 ? gyro.Value.z : gyro.Value.z * fastModeFactor));

If you use the correct changes, it no longer makes sense to use the DolphiimoteDLL.cs definitions. They should be updated to be "Yaw = 0x4, Roll = 0x1, Pitch = 0x2."