Skip to content

Latest commit

 

History

History
38 lines (24 loc) · 8.21 KB

motion.md

File metadata and controls

38 lines (24 loc) · 8.21 KB

Motion

What the game reads as motion, how it is encoded, and what the numbers mean.

What is emulated. The console module implements the complete protocol the game expects from a remote with MotionPlus: radio channels, report modes, extension port, MotionPlus calibration block, challenge sequence, speaker registers, infrared camera and the LED and rumble state machine. The game talks to the module as if it were the real controller and has no way to distinguish the origin of the data.

Rate encoding. The calibration block presented to the game declares a reference of plus or minus 4352 counts for 270 degrees per second in slow mode and 1200 degrees per second in fast mode. The conversion from the raw units of the controller uses factors of 984 and 221 thousandths respectively, which reproduce that scale exactly: 16.384 counts per degree per second multiplied by 0.984 gives 16.1185 counts per degree per second, and 4352 divided by that value gives 270 degrees per second. The selection between slow and fast mode uses hysteresis to avoid oscillations: fast mode is entered above approximately 500 degrees per second and slow mode is restored below approximately 470, always inside the useful range of slow mode, which extends to about 508 degrees per second. The encoding uses 32 bit arithmetic with saturation, so that a violent movement can never overflow the 14 bit value the game reads.

Accelerometer. The accelerometer is converted into the units of the remote, with zero at 512 and 104 counts per g. In the vertical orientation, it is filtered with a weighted average of 75 and 25 percent: that filter imitates the analogue chain of the original remote, absorbing the mechanical spikes that appear when the arm stops abruptly and preventing spurious rolls, without attenuating the immediate response of gestures. In the horizontal (wheel) orientation, values are mapped directly without the low-pass filter to maintain instant steering response. In both modes, the path preserves the scale and the direction of gravity in a one to one correspondence, as detailed in the verification section below.

Usage orientations. The axis mapping supports two ways of holding the controller. In the vertical orientation, pitch, roll and yaw are obtained from the controller axes with their corresponding signs, and the accelerometer is mapped so that a flat controller delivers one g on the Z axis. In the horizontal orientation, intended for racing and sideways games, the physical correspondence is reordered: the controller Z axis becomes the X axis of the remote, the X axis becomes the Y axis and the Y axis becomes the Z axis, so that the player can hold the controller like a steering wheel without the game receiving an inconsistent orientation. The orientation is switched on the fly by holding the L1 and R3 combo for 500 milliseconds, and the state is reflected on the controller light bar by dimming its colour intensity. Games that use the MotionPlus rely on the standard vertical 3D spatial reference and are played in standard orientation. The L1 and L3 combo, with the same hold time, toggles the classic controller mode, which changes the extension the game sees and forces the vertical orientation on entry.

The gain calibration. The rates reported to the game carry a gain of 128.5 percent (1285 per thousand) on all three axes, applied in the console module under the name DS4_MP_GAIN_PERMIL in the source, where one thousand means unmodified physical data. The gain exists because the game produced about 78 percent of the physical rotation with the DualShock 4, while a real remote with MotionPlus produced a one to one correspondence in the same game with the same gesture. The difference is linear and uniform: the same percentage on all three axes, equal going and returning, equal in flat spins and in complete turns, and correctable with a single constant factor at every speed. A constant factor is exactly what the compensation applies, so the physical data stays intact upstream and the proportions between slow and fast movements are not distorted.

Every stage of the chain is verified correct: the gyroscope integration of the controller is exact, the USB transport does not alter the values, the MotionPlus encoding matches the reference, and the game reads a constant rate injected from the module proportionally. The mechanism behind the difference is therefore not identified: what is compensated is an observable and measured difference against the real hardware, not a known error in the chain. The value is tuned so that a complete turn of 360 degrees matches the physical gesture; 125 percent left five to eight degrees short per turn, 127 percent fell slightly short after two consecutive turns, 128 percent fell behind after three turns, 129 percent overshot slightly on the first turn and accumulated error, and 128.5 percent is the value in use.

Gain Result in game
125 percent Five to eight degrees short per 360 turn
127 percent Slightly short after two consecutive turns
128 percent Fell behind after three turns
129 percent Overshot slightly on first turn, accumulating error
128.5 percent A complete turn matches the physical gesture

Verification instruments and methodology. The verification of the motion pipeline relied on three complementary instruments:

  1. In-game measurement: complete turns of 360 degrees compared against the physical gesture and against a real remote with MotionPlus, in the same game, with the same gesture and in the same scenario.
  2. USB link analysis from a computer: timestamps per report to measure the real delivery rate, the freshness of samples, interval distribution, gaps and sensor liveliness.
  3. Rate injection from the module: injecting constant angular rates directly from the module to separate game engine interpretation from hardware inputs. If the game responds proportionally to an injected rate, then it applies no hidden non-linear tables or gains.

Results of the data path. The gyroscope integration of the controller measures 360.0 degrees over a complete turn in direct measurement, and 360.2 degrees through the adapter, confirming that transport does not alter the information. The link delivers 247.6 reports per second with 246.0 fresh gyroscope samples per second, meaning practically every report carries a new sample without decimation. The accelerometer preserves scale (104 counts per g) and direction in a one to one correspondence with the remote, and internal coherence between gyroscope and accelerometer was verified with tilt tests.

Results of the emulation. The MotionPlus encoding matches the reference scale, with the useful slow-mode range extending to about 508 degrees per second so the fast/slow mode hysteresis (fast mode entered above ~500 deg/s and slow mode restored below ~470 deg/s) operates cleanly within range. With constant rates injected from the module, the game responds proportionally across the tested range. The gyroscope path towards the game contains no smoothing, artificial filters or dead zones: it is a direct copy with the corresponding scale conversion.

Results in game. With the gain compensation at its final value of 128.5 percent, a complete turn of 360 degrees measured in game matches the physical gesture, identically tracking a real remote with MotionPlus across slow and fast turns, flat spins, complete turns, and all three physical axes.

Open points. Features that depend strictly on the accelerometer magnitude, such as shakes or force gestures, were not compared end-to-end against the real remote via stream capture due to capture unreliability on the reference remote, though their data path is verified in scale and direction. Comparison against original hardware was therefore performed in game and through physical gesture measurement.

One open invitation. The compensation exists because the in game deficit is real and its mechanism is unidentified. If it is ever found — if some part of the consumption chain is understood and can be corrected at the source, so that the gain becomes unnecessary — the project would take that change gladly. It would have to respect the same standard as everything else here: measured, explained, and delicate with the behaviour that already works. Pull requests are welcome.