GlovePIE:Psychonauts Script
From WiiLi
[edit] Problems with PPJoy
Psychonauts seems to only recognize the first device listed under Game Controllers in Control Panel. Setting the preferred device will not help. Bluetooth Virtual HID Joystick (or similar device) is usually listed first, and therefore Psychonauts cannot see any PPJoy Joysticks.
[edit] Script
/********************************************************
Psychonauts Script 1.0
by almostconnected (almost#techndookie,com)
Set in game controls to default for the following
setup:
Psychonauts -> Wiimote
Arrow Keys -> Joystick
Jump -> A
Use -> B
Attack -> Swing Wiimote
Back -> -
Journal -> Home
Inventory Menu -> +
Lock On / Float -> Z
Rotate Camera -> hold C and move Joystick
First Person -> double click and hold C and move Joystick
PSI Powers Menu -> D-Pad Up
Power 1 -> D-Pad Left
Power 2 -> D-Pad Down
Power 3 -> D-Pad Right
Show Stats -> 1 or 2
********************************************************/
// system settings
pie.FrameRate = 75 Hz // so first person mode is smooth
// constants
var.LowBattery = 10 // low battery value
var.RemindWait = 30 seconds // time between low batter warnings
Var.SwingThresh = 400.0 // swing threshold (acceleration squared)
Var.SwingTime = 200 ms // time to hold swing button down
var.CamDeadZone = 0.15 // dead zone for camera
var.CamLiveZone = 1.0 - DeadZone // live zone for camera
var.CamSensitivity = 20 // camera sensitivity
var.RunDeadZone = 0.4 // dead zone for running
// show battery power
var.Leds = (Wiimote.Battery + 24) / 48
Wiimote.Led1 = var.Leds >= 1
Wiimote.Led2 = var.Leds >= 2
Wiimote.Led3 = var.Leds >= 3
Wiimote.Led4 = var.Leds >= 4
// check for low battery
if Wiimote.Battery <= var.LowBattery
say "wiimote 1 batteries are low."
wait var.RemindWait
end
// buttons
Key.Space = Wiimote.A // jump
Key.F = Wiimote.B // use
Key.X = Wiimote.Minus // cancel
Key.Esc = Wiimote.Home // journal
Key.LeftBracket = Wiimote.Plus // item inventory
Key.LeftShift = Wiimote.Nunchuk.ZButton // lock
Mouse.MiddleButton = DoubleClicked (Wiimote.Nunchuk.CButton) // first person look
Key.Tab = Wiimote.One or Wiimote.Two // stats
// powers
Mouse.RightButton = Wiimote.Left // power 1
Key.Q = Wiimote.Down // power 2
Key.E = Wiimote.Right // power 3
Key.RightBracket = Wiimote.Up // power inventory
// attack
Var.Swing = Wiimote.RelAccX*Wiimote.RelAccX + Wiimote.RelAccY*Wiimote.RelAccY
if (Var.Swing >= Var.SwingThresh) // swing!
Mouse.LeftButton = true
wait Var.SwingTime
Mouse.LeftButton = false
end
// analog stick
if Wiimote.Nunchuk.CButton // move camera
// stop running
Key.Left = false
Key.Right = false
Key.Up = false
Key.Down = false
var.JoyX = Wiimote.Nunchuk.JoyX
var.JoyY = Wiimote.Nunchuk.JoyY
// apply deadzone to X axis
if Var.JoyX < -Var.CamDeadZone
Var.JoyX = (Var.JoyX + Var.CamDeadZone) / Var.CamLiveZone
else if Var.JoyX > Var.CamDeadZone
Var.JoyX = (Var.JoyX - Var.CamDeadZone) / Var.CamLiveZone
else
Var.JoyX = 0
end
// apply deadzone to Y axis
if Var.JoyY < -Var.CamDeadZone
Var.JoyY = (Var.JoyY + Var.CamDeadZone) / Var.CamLiveZone
else if Var.JoyY > Var.CamDeadZone
Var.JoyY = (Var.JoyY - Var.CamDeadZone) / Var.CamLiveZone
else
Var.JoyY = 0
end
// rotate camera
mouse.DirectInputX = mouse.DirectInputX + var.JoyX * var.CamSensitivity
mouse.DirectInputY = mouse.DirectInputY + var.JoyY * var.CamSensitivity
else // run
Key.Left = Wiimote.Nunchuk.JoyX < -var.RunDeadZone
Key.Right = Wiimote.Nunchuk.JoyX > var.RunDeadZone
Key.Up = Wiimote.Nunchuk.JoyY < -var.RunDeadZone
Key.Down = Wiimote.Nunchuk.JoyY > var.RunDeadZone
end

