GlovePIE:Pulsing Algorithm
From WiiLi
The following is an algorithm for Pulse Density Modulation written for GlovePIE. It takes an analog input, such as a Joystick, and converts the signals into a sequence of pulses. The density of the pulses is proportional to the magnitude of the analog input. The implementation is similar to that of a Delta-Sigma Modulator. This script is useful for games that don’t accept analog input or for people who have trouble setting up PPJoy.
[edit] Script
This script assumes the input is mapped from -1 to 1 and set to the variables var.JoyX and var.JoyY. It is highly recommended that you apply Dead Zone to the inputs before running the algorithm.
// pulse X axis
var.PulseX = var.PulseX + Abs(var.JoyX)
if var.PulseX >= 1.0 // pulse!
Key.Left = var.JoyX < 0
Key.Right = var.JoyX > 0
var.PulseX = var.PulseX - 1.0
else
Key.Left = false
Key.Right = false
end
// pulse Y axis
var.PulseY = var.PulseY + Abs(var.JoyY)
if var.PulseY >= 1.0 // pulse!
Key.Up = var.JoyY < 0
Key.Down = var.JoyY > 0
var.PulseY = var.PulseY - 1.0
else
Key.Up = false
Key.Down = false
end
[edit] Problems with Pulsing
Performance varies from game to game. Some games won’t work at all. Games were tapping on the D-Pad causes the player to dash is a good example. In other games, pulsing may make the player’s animation look odd. Moving diagonally can also be a problem.

