Posted by MukiEX on Sat 17 May 05:20
report abuse | download | new post
- /*********************************************************************/
- // Dreamcast Controls
- // From here we use the joystick
- // control information to map the
- // propery controls to the Dreamcast
- // emulator, PC game, or whatever.
- /*********************************************************************/
- If ((Wiimote1.Classic.Exists == False)&&(Nunchuk1.Exists == False))
- debug = "Please connect a Classic Controller or Nunchuk"
- Wiimote1.Led1 = False
- Wiimote1.Led2 = False
- Wiimote1.Led3 = False
- Wiimote1.Led4 = False
- Endif
- /*********************************************************************/
- // Classic Controller
- // Everything works, including analog triggers
- // Digital Triggers also work, read comments.
- /*********************************************************************/
- If Wiimote1.Classic.Exists
- // constants
- Var.DeadZone = 0.15;
- Var.LiveZone = 1.0 - Var.DeadZone;
- // 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
- EndIf
- EndIf
- // 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
- EndIf
- EndIf
- If !Var.Init
- Var.Init = true
- Var.ControlMode = "Standard"
- EndIf
- If Pressed(HeldDown(Wiimote.Home, 1s))||Pressed(HeldDown(Wiimote.B, 1s))||Pressed(HeldDown(Wiimote.A, 1s))
- If Var.ControlMode == "Standard"
- Var.ControlMode = "VirtualOn"
- Elseif Var.ControlMode = "VirtualOn"
- Var.ControlMode = "Standard"
- EndIf
- EndIf
- PPJoy1.Digital1 = Wiimote1.Classic.x
- PPJoy1.Digital2 = Wiimote1.Classic.b
- PPJoy1.Digital8 = Wiimote1.Classic.Plus
- PPJoy1.Digital9 = Wiimote1.Classic.Minus
- PPJoy1.Digital10 = Wiimote1.Classic.Home
- PPJoy1.Digital20 = Wiimote1.Classic.Up
- PPJoy1.Digital21 = Wiimote1.Classic.Down
- PPJoy1.Digital22 = Wiimote1.Classic.Left
- PPJoy1.Digital23 = Wiimote1.Classic.Right
- // In configuration of your emulator,
- // slightly depress the triggers to
- // have them act as "axis buttons"
- // in order to get proper analog trigger
- // support
- If Wiimote1.Classic.L > 0.4
- PPJoy1.Analog4 = Wiimote1.Classic.L
- Else
- PPJoy1.Analog4 = 0
- EndIf
- If Wiimote1.Classic.R > 0.4
- PPJoy1.Analog5 = Wiimote1.Classic.R
- Else
- PPJoy1.Analog5 = 0
- EndIf
- // This is for digital versions of these buttons
- PPJoy1.Digital16 = Wiimote1.Classic.L
- PPJoy1.Digital17 = Wiimote1.Classic.R
- PPJoy1.Digital18 = Wiimote1.Classic.LFull
- PPJoy1.Digital19 = Wiimote1.Classic.RFull
- If Var.ControlMode == "Standard"
- Wiimote1.Led1 = True
- Wiimote1.Led2 = False
- Wiimote1.Led3 = False
- Wiimote1.Led4 = True
- // This is for stupid
- // programs that can't detect the first joystick button
- PPJoy1.Digital15 = Wiimote1.Classic.y
- PPJoy1.Digital0 = Wiimote1.Classic.y
- PPJoy1.Digital3 = Wiimote1.Classic.a
- PPJoy1.Digital6 = Wiimote1.Classic.ZL
- PPJoy1.Digital7 = Wiimote1.Classic.ZR
- PPJoy1.Digital4 = Wiimote1.Classic.L
- PPJoy1.Digital5 = Wiimote1.Classic.R
- PPJoy1.Digital11 = Wiimote1.A
- PPJoy1.Digital12 = Wiimote1.B
- PPJoy1.Digital13 = Wiimote1.1
- PPJoy1.Digital14 = Wiimote1.2
- PPJoy1.Digital24 = Wiimote1.Up
- PPJoy1.Digital25 = Wiimote1.Down
- PPJoy1.Digital26 = Wiimote1.Left
- PPJoy1.Digital27 = Wiimote1.Right
- PPJoy1.Analog2 = Wiimote1.Classic.Joy2X
- PPJoy1.Analog3 = Wiimote1.Classic.Joy2Y
- PPJoy1.Analog6 = Wiimote1.RawForceX
- PPJoy1.Analog7 = Wiimote1.RawForceY
- PPJoy1.Analog8 = Wiimote1.RawForceZ
- Var.JoyX = Wiimote1.Classic.Joy1X
- Var.JoyY = Wiimote1.Classic.Joy1Y
- PPJoy1.Analog0 = Var.JoyX
- PPJoy1.Analog1 = Var.JoyY
- EndIf
- If Var.ControlMode == "VirtualOn"
- Wiimote1.Led1 = False
- Wiimote1.Led2 = True
- Wiimote1.Led3 = True
- Wiimote1.Led4 = False
- Var.JoyDead = 0.3
- // Move Forward
- If ((Wiimote1.Classic.Joy1Y < -Var.JoyDead)&&(Wiimote1.Classic.Joy2Y < -Var.JoyDead))||Wiimote1.Classic.Up == True
- PPJoy1.Digital20 = True
- Else
- PPJoy1.Digital20 = False
- EndIf
- // Move Backward
- If ((Wiimote1.Classic.Joy1Y > Var.JoyDead)&&(Wiimote1.Classic.Joy2Y > Var.JoyDead))||Wiimote1.Classic.Down == True
- PPJoy1.Digital21 = True
- Else
- PPJoy1.Digital21 = False
- EndIf
- // Move Left
- If ((Wiimote1.Classic.Joy1X < -Var.JoyDead)&&(Wiimote1.Classic.Joy2X < -Var.JoyDead))||Wiimote1.Classic.Left == True
- PPJoy1.Digital22 = True
- Else
- PPJoy1.Digital22 = False
- EndIf
- // Move Right
- If ((Wiimote1.Classic.Joy1X > Var.JoyDead)&&(Wiimote1.Classic.Joy2X > Var.JoyDead))||Wiimote1.Classic.Right == True
- PPJoy1.Digital23 = True
- Else
- PPJoy1.Digital23 = False
- EndIf
- // Turn Left
- If (Wiimote1.Classic.Joy1Y < -Var.JoyDead)&&(Wiimote1.Classic.Joy2Y > Var.JoyDead)
- PPJoy1.Analog0 = 0.5
- Var.TurnRight = True
- Else
- Var.TurnRight = False
- EndIf
- // Turn Right
- If (Wiimote1.Classic.Joy1Y > Var.JoyDead)&&(Wiimote1.Classic.Joy2Y < -Var.JoyDead)
- PPJoy1.Analog0 = -0.5
- Var.TurnLeft = True
- Else
- Var.TurnLeft = False
- EndIf
- // No Turn
- If ((Var.TurnLeft == False)&&(Var.TurnRight == False))
- PPJoy1.Analog0 = 0
- EndIf
- // Jump
- If (Wiimote1.Classic.Joy1X < -Var.JoyDead)&&(Wiimote1.Classic.Joy2X > Var.JoyDead)
- PPJoy1.Digital15 = True
- PPJoy1.Digital1 = True
- Else
- PPJoy1.Digital15 = False
- PPJoy1.Digital1 = False
- EndIf
- // Crouch
- If ((Wiimote1.Classic.Joy1X > Var.JoyDead)&&(Wiimote1.Classic.Joy2X < -Var.JoyDead))||Wiimote1.Classic.b == True
- PPJoy1.Digital2 = True
- Else
- PPJoy1.Digital2 = False
- EndIf
- PPJoy1.Digital15 = Wiimote1.Classic.ZR
- PPJoy1.Digital3 = Wiimote1.Classic.ZL
- If PPJoy1.Digital15 == True || PPJoy.Digital3 == True
- PPJoy1.Digital0 = True
- Wiimote1.Rumble = True
- Else
- PPJoy1.Digital0 = False
- Wiimote1.Rumble = False
- EndIf
- EndIf
- debug = "Classic Controller Connected; " + Var.ControlMode + ". Xtra: " + PPJoy1.Digital15
- EndIf
- /*********************************************************************/
- // Nunchuk Controls (Virtual On)
- // These controls were designed specifically
- // for the Dreamcast "Virtual On" sequel.
- //
- // In addition, the directional buttons
- // on the Wiimote can navigate the menus
- /*********************************************************************/
- /*********************************************************************/
- // Joystick Controls
- // This is general joystick control
- // management. It lets you keep track
- // of which way our virtual joysticks
- // are pointed. Var.WiiLS_Left means :
- //
- // LS = Left Stick (Nunchuk)
- // _Left = Pointed Left
- // RS for Right Stick (Wiimote) and _Up/_Down/_Right
- // for those respective directions
- /*********************************************************************/
- // Wiimote/Nunchuk's minimum push for
- // left or right Directions
- Var.MinRightStick = 0.25
- Var.MinLeftStick = 0.25
- // Wiimote/Nunchuk's minimum push for
- // forward and backward directions
- Var.MinRightForward = 0.5
- Var.MinRightBackward = 0.3
- Var.MinLeftForward = 0.5
- Var.MinLeftBackward = 0.3
- If Nunchuk1.Exists
- //Right weapon
- If Wiimote1.B
- Key.C = True
- Wiimote1.LED4 = True
- Else
- Key.C = False
- Wiimote1.LED4 = False
- EndIf
- //Left weapon
- If Nunchuk1.Zbutton
- Wiimote1.LED1 = True
- Key.D = True
- Else
- Wiimote1.LED1 = False
- Key.D = False
- EndIf
- //Dash
- If Wiimote1.A || Nunchuk1.CButton
- Wiimote1.Rumble = True //Rumble feedback will be on while dashing
- Wiimote1.LED2 and Wiimote1.LED3 = True //The two center LEDs will show us that we're dashing
- Else
- Key.X = False
- Wiimote1.Rumble = False
- Wiimote1.LED2 and Wiimote1.LED3 = False
- EndIf
- //Start
- Key.Space = Wiimote1.Home
- // Right stick
- // Moving to the left
- If Wiimote1.GX > Var.MinRightStick
- Var.WiiRS_Left = True
- Wiimote1.LED4 = True
- Else
- Var.WiiRS_Left = False
- Wiimote1.LED4 = False
- EndIf
- // Moving to the right
- If Wiimote1.GX < -Var.MinRightStick
- Var.WiiRS_Right = True
- Wiimote1.LED3 = True
- Else
- Var.WiiRS_Right = False
- Wiimote1.LED3 = False
- EndIf
- // Tilted forward
- If Wiimote1.GY > Var.MinRightForward
- Var.WiiRS_Up = True
- Else
- Var.WiiRS_Up = False
- EndIf
- // Tilted backward
- If Wiimote1.GY < -Var.MinRightBackward
- Var.WiiRS_Down = True
- Else
- Var.WiiRS_Down = False
- EndIf
- // Left stick
- // Moving to the left
- If Nunchuk1.GX > Var.MinLeftStick
- Var.WiiLS_Left = True
- Wiimote1.LED4 = True
- Else
- Var.WiiLS_Left = False
- Wiimote1.LED4 = False
- EndIf
- // Moving to the right
- If Nunchuk1.GX < -Var.MinLeftStick
- Var.WiiLS_Right = True
- Wiimote1.LED3 = True
- Else
- Var.WiiLS_Right = False
- Wiimote1.LED3 = False
- EndIf
- // Tilted forward
- If Nunchuk1.GY > Var.MinLeftForward
- Var.WiiLS_Up = True
- Else
- Var.WiiLS_Up = False
- EndIf
- // Tilted backward
- If Nunchuk1.GY < -Var.MinLeftBackward
- Var.WiiLS_Down = True
- Else
- Var.WiiLS_Down = False
- EndIf
- *********************************************************************/
- // If you're playing Virtual On
- // somewhere else, or simply using
- // another game that has dual joystick
- // inputs, this is where you should start
- // modifying the script. Remember to use
- // WiiLS_Left and so forth as your source input.
- *********************************************************************/
- // Move Right
- If (((Var.WiiLS_Right == True)&&(Var.WiiRS_Right == True))||(Wiimote1.Right == True))
- Var.DebugText = "Moving Right"
- PPJoy1.Digital23 = True
- Else
- PPJoy1.Digital23 = False
- EndIf
- // Move Left
- If (((Var.WiiLS_Left == True)&&(Var.WiiRS_Left == True))||(Wiimote1.Left == True))
- Var.DebugText = "Moving Left"
- PPJoy1.Digital22 = True
- Else
- PPJoy1.Digital22 = False
- EndIf
- // Move Forward
- If (((Var.WiiLS_Up == True)&&(Var.WiiRS_Up == True))||(Wiimote1.Up == True))
- Var.DebugText = "Moving Forward"
- PPJoy1.Digital20 = True
- Else
- PPJoy1.Digital20 = False
- EndIf
- // Move Backward
- If (((Var.WiiLS_Down == True)&&(Var.WiiRS_Down == True))||(Wiimote1.Down == True))
- Var.DebugText = "Moving Backward"
- PPJoy1.Digital21 = True
- Else
- PPJoy1.Digital21 = False
- EndIf
- // Turn Right
- If ((Var.WiiLS_Up == True)&&(Var.WiiRS_Down == True))
- Var.DebugText = "Turning Right"
- PPJoy1.Analog0 = Nunchuk1.GY
- Var.TurningRight = True
- Else
- Var.TurningRight = False
- EndIf
- // Turn Left
- If ((Var.WiiLS_Down == True)&&(Var.WiiRS_Up == True))
- Var.DebugText = "Turning Left"
- PPJoy1.Analog0 = Nunchuk1.GY
- Var.TurningLeft = True
- Else
- Var.TurningLeft = False
- EndIf
- // No Turning
- // The main reason I keep those TurningLeft
- // and TurningRight variables is because I'm
- // controlling the analog stick. Therefore I can't
- // simply check button states to see if it's not turning
- // in either direction
- If ((Var.TurningRight == False)&&(Var.TurningLeft == False))
- PPJoy1.Analog0 = 0
- EndIf
- // Flying
- If ((Var.WiiLS_Left == True)&&(Var.WiiRS_Right == True))
- Var.DebugText = "Flying"
- PPJoy1.Digital1 = True
- Else
- PPJoy1.Digital1 = False
- EndIf
- // Crouching
- If (((Var.WiiLS_Right == True)&&(Var.WiiRS_Left == True))||(Wiimote1.Minus == True))
- Var.DebugText = "Crouching"
- PPJoy1.Digital2 = True
- Else
- PPJoy1.Digital2 = False
- EndIf
- If ((Var.WiiLS_Right == False)&&(Var.WiiLS_Left == False)&&(Var.WiiLS_Up == False)&&(Var.WiiLS_Down == False)&&(Var.WiiRS_Right == False)&&(Var.WiiRS_Left == False)&&(Var.WiiRS_Up == False)&&(Var.WiiRS_Down == False))
- Var.DebugText = "Neutral"
- EndIf
- // These are the Dreamcast Buttons
- // They match up with the Classic Controller
- // Dreamcast Script I have, so you only need
- // to configure your emulator *once*.
- // This pauses
- //PPJoy1.Digital10 = Wiimote1.Plus
- PPJoy1.Digital8 = Wiimote1.Plus
- // This is turbo AND cancel in the menus
- PPJoy1.Digital3 = Wiimote1.A
- // This is just turbo
- PPJoy1.Digital0 = Nunchuk1.CButton
- // This is for dumb programs that don't
- // accept input from the first joystick
- // button. Same on Classic Script
- PPJoy1.Digital15 = Nunchuk1.CButton
- // This is the left firing trigger
- //PPJoy1.Digital6 = Nunchuk1.ZButton
- If Nunchuk1.ZButton == True
- PPJoy1.Digital16 = True
- PPJoy1.Digital18 = True
- PPJoy1.Analog4 = 1.0
- Else
- PPJoy1.Digital16 = False
- PPJoy1.Digital18 = False
- PPJoy1.Analog4 = 0
- Endif
- // This is the right firing trigger
- //PPJoy1.Digital7 = Wiimote1.B
- If Wiimote1.B == True
- PPJoy1.Digital17 = True
- PPJoy1.Digital19 = True
- PPJoy1.Analog5 = 1.0
- Else
- PPJoy1.Digital17 = False
- PPJoy1.Digital19 = False
- PPJoy1.Analog5 = 0
- Endif
- If ((Wiimote1.GX > -Var.MinRightStick)&&(Wiimote1.GX < Var.MinRightStick)&&(Wiimote1.GY < Var.MinRightForward)&&(Wiimote1.GY > Var.MinRightBackward))
- var.debugR = "Neutral"
- EndIf
- If ((Nunchuk1.GX > -Var.MinLeftStick)&&(Nunchuk1.GX < Var.MinLeftStick)&&(Nunchuk1.GY < Var.MinLeftForward)&&(Nunchuk1.GY > Var.MinLeftBackward))
- var.debugL = "Neutral"
- EndIf
- //debug = Var.DebugText + " StickX : " + Wiimote1.GX + ". StickY : " + Wiimote1.GY
- debug = "Wiimote : " + Wiimote1.GX + "/" + Wiimote1.GY + ". Nunchuk : " + PPJoy1.Analog0 + "/" + PPJoy1.Analog1 + " " + Var.DebugText
- EndIf
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.