 |
WiiLi.org a new revolution
|
| View previous topic :: View next topic |
| Author |
Message |
almostconnected

Joined: 15 Feb 2007 Posts: 13 Location: Florida
Digg It |
Posted: Thu Feb 15, 2007 9:32 pm Post subject: Better Joystick Support for Double Dragon 2 and Zelda:LTTP. |
|
|
Hi everyone!
I have been playing around with GlovePIE and I have come up with what I think is a new technique for using the analog stick on games that use a D-Pad. It doesn't work to well on most games but I think with a bit of tweaking and care you might be able to get it to work on your favorite game.
The basic idea is to convert the analog signal of the Joystick into pulses on the D-Pad. The more you move to the left, for example, the faster the left key is "tapped" until you go all the way to the left and the left key is held down.
For now let me just post my Double Dragon 2 script and see how you like it. I've written it for my 360 controller. I'll post my Zelda:LTTP script in my next post, just give me a bit of time to clean it up. (Don't worry, it uses the Wiimote!).
| Code: | /*****************************************************************
Double Dragon 2 - 360 Controller Script 1.1
by almostconnected (almost.technodookie@com)
This script uses default Nestopia key setup:
NES -> PC (Nestopia) -> 360 Controller
D-Pad -> Arrow Keys -> Left Analog
Select -> Right Shift -> Back
Start -> Enter -> Start
B -> , -> X
A -> . -> A
A+B (Jump) -> , and . -> B
*****************************************************************/
// buttons
Key.Comma = Joystick.Button3 or Joystick.Button2 // B
Key.Dot = Joystick.Button1 or Joystick.Button2 // A
Key.RightShift = Joystick.Button7 // select
Key.Enter = Joystick.Button8 // start
// init
if not Var.Init
Var.Init = true
Var.DeadZone = 0.15
Var.LiveZone = 1.0 - Var.DeadZone
end
// change these to use a different device!
Var.JoyX = Joystick.X
Var.JoyY = Joystick.Y
// apply deadzone to X axis
if Var.JoyX < -Var.DeadZone
Var.JoyX = (Var.JoyX + Var.DeadZone) / Var.LiveZone
else if Var.JoyX > Var.DeadZone
Var.JoyX = (Var.JoyX - Var.DeadZone) / Var.LiveZone
else
Var.JoyX = 0
end
// apply deadzone to Y axis
if Var.JoyY < -Var.DeadZone
Var.JoyY = (Var.JoyY + Var.DeadZone) / Var.LiveZone
else if Var.JoyY > Var.DeadZone
Var.JoyY = (Var.JoyY - Var.DeadZone) / Var.LiveZone
else
Var.JoyY = 0
end
// 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
// debug
Debug = "horizontal pulse = " + (Key.Right or Key.Left)
|
Edit 2: Update Script
Last edited by almostconnected on Thu Mar 01, 2007 8:12 pm; edited 2 times in total |
|
| Back to top |
|
 |
almostconnected

Joined: 15 Feb 2007 Posts: 13 Location: Florida
Digg It |
Posted: Thu Feb 15, 2007 10:21 pm Post subject: |
|
|
Okay, here is my Zelda:LTTP script using the pulse technique. The default pulse technique caused Link to jitter and actually slowed him down. My fix at the moment is to scale the joystick vector so that the dominant axis is always -1, 1, or 0 (no movement). The effect is that direction is important but magnitude is not. In other words, you can't tip-toe but you can walk in any direction you like. Here is the script:
Edit 1: Whoops, had Joystick.X and Joystick.Y in there.
Edit 2: Update Script
| Code: | /******************************************************
Zelda: A Link to The Past, Pulse Script 1.3b
GlovePIE Script by almostconnected (almost.technodookie@com)
Suggested Key Mapping
SNES -> PC (Zsnes) -> Wiimote
D-Pad -> Arrow Keys -> Analog Stick
A (interact) -> X -> Z or tap A
B (sword) -> Z -> Swing Wiimote
X (map) -> S -> D-Pad Up
Y (item) -> A -> B
L -> D -> D-Pad Left
R -> C -> D-Pad Right
Select -> Right Shift -> -
Start -> Enter -> +
To perform a spin attack, hold A Button down when
swinging the Wiimote and keep holding it down until you
are ready to attack.
*******************************************************/
// init
if not var.Inited
var.LowBattery = 10 // low battery value
var.RemindWait = 30 seconds // amount of time between low battery reminders
var.SwingThresh = 400.0 // swing threshold (acceleration squared)
var.SwingWait = 125 ms // amount of time to hold the swing button down
var.SwingHold = false // keep holding swing!
var.DeadZone = 0.20 // dead zone for movement
var.LiveZone = 1.0 - var.DeadZone // live zone for movement
var.Inited = true
end
// LEDs (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 batteries are low."
wait var.RemindWait
end
// Buttons
Key.A = Wiimote.B
Key.Enter = Wiimote.Plus
Key.RightShift = Wiimote.Minus
Key.X = Wiimote.Nunchuk.ZButton or (Released (Wiimote.A) and not var.SwingHold)
Key.S = Wiimote.Up
Key.D = Wiimote.Left
Key.C = Wiimote.Right
// Swing Detection
var.Swing = Wiimote.RelAccX*Wiimote.RelAccX + Wiimote.RelAccY*Wiimote.RelAccY
if var.SwingHold // getting ready for a spin attack!
var.SwingHold = Wiimote.A
Key.Z = var.SwingHold
else if var.Swing >= var.SwingThresh // swing!
Key.Z = true
var.SwingHold = Wiimote.A
wait var.SwingWait
else // nothing!
Key.Z = false
end
// analog pulse code
var.JoyX = Wiimote.Nunchuk.JoyX
var.JoyY = Wiimote.Nunchuk.JoyY
// apply deadzone to X axis
if var.JoyX < -var.DeadZone
var.JoyX = (var.JoyX + var.DeadZone) / var.LiveZone
else if var.JoyX > var.DeadZone
var.JoyX = (var.JoyX - var.DeadZone) / var.LiveZone
else
var.JoyX = 0
end
// apply deadzone to Y axis
if var.JoyY < -var.DeadZone
var.JoyY = (var.JoyY + var.DeadZone) / var.LiveZone
else if var.JoyY > var.DeadZone
var.JoyY = (var.JoyY - var.DeadZone) / var.LiveZone
else
var.JoyY = 0
end
// only pulse in the non dominant axis
// (scale so that the dominant axis is -1, 1, or 0)
var.Norm = Max( Abs(var.JoyX), Abs(var.JoyY) )
if var.Norm > 0
var.JoyX = var.JoyX / var.Norm
var.JoyY = var.JoyY / var.Norm
end
// 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
// print battery status
debug = "Battery Power at " + (Wiimote.Battery / 1.92) + "%" |
Please let me know what you think! |
|
| Back to top |
|
 |
almostconnected

Joined: 15 Feb 2007 Posts: 13 Location: Florida
Digg It |
Posted: Sat Mar 03, 2007 4:22 pm Post subject: |
|
|
Well no one has commented, so maybe none of you care. But just in case, I'm letting you know I've made a new Double Dragon 2 script for some 2 Player Wiimote fun! Check it out here: GlovePIE:Double Dragon 2. Of course this script uses my pulsing code to simulate analog joystick support in the game.
I also added Wiili.org entries for Pulsing, with a sample of my method, and for Zelda:LTTP, which has my script displayed at the moment. If you try these scripts out, please let me know what you think! |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|