pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

Javascript pastebin - collaborative debugging tool View Help


Posted by MukiEX on Sat 17 May 17:48
report abuse | download | new post

  1.  
  2.  
  3. /*********************************************************************/
  4. //                      Dreamcast Controls
  5. //               From here we use the joystick
  6. //               control information to map the
  7. //               propery controls to the Dreamcast
  8. //               emulator, PC game, or whatever.
  9. /*********************************************************************/
  10.  
  11. If ((Wiimote1.Classic.Exists == False)&&(Nunchuk1.Exists == False))
  12. debug = "Please connect a Classic Controller or Nunchuk"
  13.  
  14.     If Wiimote1.Home == True
  15.       If Wiimote1.Battery > (0.25 * 192)
  16.           Wiimote1.Led1 = True
  17.       Else
  18.           Wiimote1.Led1 = False
  19.       Endif
  20.       If Wiimote1.Battery > (0.5 * 192)
  21.           Wiimote1.Led2 = True
  22.       Else
  23.           Wiimote1.Led2 = False
  24.       Endif
  25.       If Wiimote1.Battery > (0.75 * 192)
  26.           Wiimote1.Led3 = True
  27.       Else
  28.           Wiimote1.Led3 = False
  29.       Endif
  30.       If Wiimote1.Battery > (0.9 * 192)
  31.           Wiimote1.Led4 = True
  32.       Else
  33.           Wiimote1.Led4 = False
  34.       Endif
  35.     Endif
  36.     If Wiimote1.Home == False
  37.       Wiimote1.Led1 = False
  38.       Wiimote1.Led2 = False
  39.       Wiimote1.Led3 = False
  40.       Wiimote1.Led4 = False
  41.      Endif
  42.  
  43. Endif
  44.  
  45. /*********************************************************************/
  46. //                          Classic Controller
  47. //               Everything works, including analog triggers
  48. //               Digital Triggers also work, read comments.
  49. /*********************************************************************/
  50.  
  51. If Wiimote1.Classic.Exists
  52.  
  53.   // constants
  54.   Var.DeadZone = 0.15;
  55.   Var.LiveZone = 1.0 - Var.DeadZone;
  56.  
  57.  
  58.  
  59.   // apply deadzone to X axis
  60.   If Var.JoyX1 < -Var.DeadZone
  61.      Var.JoyX1 = (Var.JoyX1 + Var.DeadZone) / Var.LiveZone;
  62.   Else
  63.     If Var.JoyX1 > Var.DeadZone
  64.       Var.JoyX1 = (Var.JoyX1 - Var.DeadZone) / Var.LiveZone;
  65.     Else
  66.       Var.JoyX1 = 0
  67.     EndIf
  68.   EndIf
  69.  
  70.   // apply deadzone to Y axis
  71.   If Var.JoyY1 < -Var.DeadZone
  72.      Var.JoyY1 = (Var.JoyY1 + Var.DeadZone) / Var.LiveZone;
  73.   Else
  74.       If Var.JoyY1 > Var.DeadZone
  75.         Var.JoyY1 = (Var.JoyY1 - Var.DeadZone) / Var.LiveZone;
  76.       Else
  77.         Var.JoyY1 = 0
  78.       EndIf
  79.   EndIf
  80.  
  81.   If !Var.Init
  82.      Var.Init = true
  83.      Var.ControlMode = "Standard"
  84.   EndIf
  85.  
  86.   If Pressed(HeldDown(Wiimote1.Home, 0.5s))||Pressed(HeldDown(Wiimote1.B, 0.5s))||Pressed(HeldDown(Wiimote1.A, 0.5s))
  87.      If Var.ControlMode == "Standard"
  88.         Var.ControlMode = "VirtualOn"
  89.      Elseif Var.ControlMode = "VirtualOn"
  90.         Var.ControlMode = "Standard"
  91.      EndIf
  92.      EndIf
  93.  
  94.  
  95.     PPJoy1.Digital1 = Wiimote1.Classic.x
  96.     PPJoy1.Digital2 = Wiimote1.Classic.b
  97.     PPJoy1.Digital8 = Wiimote1.Classic.Plus
  98.     PPJoy1.Digital9 = Wiimote1.Classic.Minus
  99.     PPJoy1.Digital10 = Wiimote1.Classic.Home
  100.  
  101.     PPJoy1.Digital20 = Wiimote1.Classic.Up
  102.     PPJoy1.Digital21 = Wiimote1.Classic.Down
  103.     PPJoy1.Digital22 = Wiimote1.Classic.Left
  104.     PPJoy1.Digital23 = Wiimote1.Classic.Right
  105.  
  106.     // In configuration of your emulator,
  107.     // slightly depress the triggers to
  108.     // have them act as "axis buttons"
  109.     // in order to get proper analog trigger
  110.     // support
  111.     If Wiimote1.Classic.L > 0.4
  112.         PPJoy1.Analog4 = Wiimote1.Classic.L
  113.     Else
  114.         PPJoy1.Analog4 = 0
  115.     EndIf
  116.     If Wiimote1.Classic.R > 0.4
  117.         PPJoy1.Analog5 = Wiimote1.Classic.R
  118.     Else
  119.         PPJoy1.Analog5 = 0
  120.     EndIf
  121.     // This is for digital versions of these buttons
  122.     PPJoy1.Digital16 = Wiimote1.Classic.L
  123.     PPJoy1.Digital17 = Wiimote1.Classic.R
  124.     PPJoy1.Digital18 = Wiimote1.Classic.LFull
  125.     PPJoy1.Digital19 = Wiimote1.Classic.RFull
  126.  
  127.   If Var.ControlMode == "Standard"
  128.     Wiimote1.Led1 = True
  129.     Wiimote1.Led2 = False
  130.     Wiimote1.Led3 = False
  131.     Wiimote1.Led4 = True
  132.  
  133.     // This is for stupid
  134.     // programs that can't detect the first joystick button
  135.     PPJoy1.Digital15 = Wiimote1.Classic.y
  136.  
  137.     PPJoy1.Digital0 = Wiimote1.Classic.y
  138.     PPJoy1.Digital3 = Wiimote1.Classic.a
  139.  
  140.     PPJoy1.Digital6 = Wiimote1.Classic.ZL
  141.     PPJoy1.Digital7 = Wiimote1.Classic.ZR
  142.     PPJoy1.Digital4 = Wiimote1.Classic.L
  143.     PPJoy1.Digital5 = Wiimote1.Classic.R
  144.    
  145.    
  146.     PPJoy1.Digital11 = Wiimote1.A
  147.     PPJoy1.Digital12 = Wiimote1.B
  148.     PPJoy1.Digital13 = Wiimote1.1
  149.     PPJoy1.Digital14 = Wiimote1.2
  150.    
  151.  
  152.    
  153.     PPJoy1.Digital24 = Wiimote1.Up
  154.     PPJoy1.Digital25 = Wiimote1.Down
  155.     PPJoy1.Digital26 = Wiimote1.Left
  156.     PPJoy1.Digital27 = Wiimote1.Right
  157.    
  158.     PPJoy1.Analog2 = Wiimote1.Classic.Joy2X
  159.     PPJoy1.Analog3 = Wiimote1.Classic.Joy2Y
  160.  
  161.     PPJoy1.Analog6 = Wiimote1.RawForceX
  162.     PPJoy1.Analog7 = Wiimote1.RawForceY
  163.     PPJoy1.Analog8 = Wiimote1.RawForceZ
  164.    
  165.    
  166.     Var.JoyX1 = Wiimote1.Classic.Joy1X
  167.     Var.JoyY1 = Wiimote1.Classic.Joy1Y
  168.  
  169.     PPJoy1.Analog0 = Var.JoyX1
  170.     PPJoy1.Analog1 = Var.JoyY1
  171.   EndIf
  172.  
  173.  
  174.   If Var.ControlMode == "VirtualOn"
  175.     Wiimote1.Led1 = False
  176.     Wiimote1.Led2 = True
  177.     Wiimote1.Led3 = True
  178.     Wiimote1.Led4 = False
  179.  
  180.  
  181.  
  182.  
  183.      Var.JoyDead1 = 0.3
  184.      // Move Forward
  185.      If ((Wiimote1.Classic.Joy1Y < -Var.JoyDead1)&&(Wiimote1.Classic.Joy2Y < -Var.JoyDead1))||Wiimote1.Classic.Up == True
  186.         PPJoy1.Digital20 = True
  187.      Else
  188.         PPJoy1.Digital20 = False
  189.      EndIf
  190.      // Move Backward
  191.      If ((Wiimote1.Classic.Joy1Y > Var.JoyDead1)&&(Wiimote1.Classic.Joy2Y > Var.JoyDead1))||Wiimote1.Classic.Down == True
  192.         PPJoy1.Digital21 = True
  193.      Else
  194.         PPJoy1.Digital21 = False
  195.      EndIf
  196.      // Move Left
  197.      If ((Wiimote1.Classic.Joy1X < -Var.JoyDead1)&&(Wiimote1.Classic.Joy2X < -Var.JoyDead1))||Wiimote1.Classic.Left == True
  198.         PPJoy1.Digital22 = True
  199.      Else
  200.         PPJoy1.Digital22 = False
  201.      EndIf
  202.      // Move Right
  203.      If ((Wiimote1.Classic.Joy1X > Var.JoyDead1)&&(Wiimote1.Classic.Joy2X > Var.JoyDead1))||Wiimote1.Classic.Right == True
  204.         PPJoy1.Digital23 = True
  205.      Else
  206.         PPJoy1.Digital23 = False
  207.      EndIf
  208.      // Turn Left
  209.      If (Wiimote1.Classic.Joy1Y < -Var.JoyDead1)&&(Wiimote1.Classic.Joy2Y > Var.JoyDead1)
  210.         PPJoy1.Analog0 = 0.5
  211.         Var.TurnRight = True
  212.      Else
  213.         Var.TurnRight = False
  214.      EndIf
  215.      // Turn Right
  216.      If (Wiimote1.Classic.Joy1Y > Var.JoyDead1)&&(Wiimote1.Classic.Joy2Y < -Var.JoyDead1)
  217.       PPJoy1.Analog0 = -0.5
  218.       Var.TurnLeft = True
  219.      Else
  220.       Var.TurnLeft = False
  221.      EndIf
  222.      // No Turn
  223.      If ((Var.TurnLeft == False)&&(Var.TurnRight == False))
  224.       PPJoy1.Analog0 = 0
  225.      EndIf
  226.      // Jump
  227.      If (Wiimote1.Classic.Joy1X < -Var.JoyDead1)&&(Wiimote1.Classic.Joy2X > Var.JoyDead1)
  228.         PPJoy1.Digital15 = True
  229.         PPJoy1.Digital1 = True
  230.      Else
  231.         PPJoy1.Digital15 = False
  232.         PPJoy1.Digital1 = False
  233.      EndIf
  234.      // Crouch
  235.      If ((Wiimote1.Classic.Joy1X > Var.JoyDead1)&&(Wiimote1.Classic.Joy2X < -Var.JoyDead1))||Wiimote1.Classic.b == True
  236.         PPJoy1.Digital2 = True
  237.      Else
  238.         PPJoy1.Digital2 = False
  239.      EndIf
  240.  
  241.     PPJoy1.Digital15 = Wiimote1.Classic.ZR
  242.     PPJoy1.Digital3 = Wiimote1.Classic.ZL
  243.  
  244.     If PPJoy1.Digital15 == True || PPJoy.Digital3 == True
  245.         PPJoy1.Digital0 = True
  246.         Wiimote1.Rumble = True
  247.     Else
  248.         PPJoy1.Digital0 = False
  249.         Wiimote1.Rumble = False
  250.     EndIf
  251.  
  252.  
  253.   EndIf
  254.   debug = "Classic Controller Connected; " + Var.ControlMode + ". Xtra: " + PPJoy1.Digital15
  255. EndIf
  256.  
  257.  
  258.  
  259. /*********************************************************************/
  260. //                      Nunchuk Controls (Virtual On)
  261. //               These controls were designed specifically
  262. //               for the Dreamcast "Virtual On" sequel.
  263. //
  264. //               In addition, the directional buttons
  265. //               on the Wiimote can navigate the menus
  266. /*********************************************************************/
  267.  
  268.  
  269. /*********************************************************************/
  270. //                      Joystick Controls
  271. //                 This is general joystick control
  272. //                 management. It lets you keep track
  273. //                 of which way our virtual joysticks
  274. //                 are pointed. Var.WiiLS_Left means :
  275. //
  276. //                 LS = Left Stick (Nunchuk)
  277. //                 _Left = Pointed Left
  278. //                 RS for Right Stick (Wiimote) and _Up/_Down/_Right
  279. //                 for those respective directions
  280. /*********************************************************************/
  281.  
  282.   // Wiimote/Nunchuk's minimum push for
  283.   // left or right Directions
  284.   Var.MinRightStick = 0.25
  285.   Var.MinLeftStick = 0.25
  286.  
  287.   // Wiimote/Nunchuk's minimum push for
  288.   // forward and backward directions
  289.   Var.MinRightForward = 0.5
  290.   Var.MinRightBackward = 0.3
  291.   Var.MinLeftForward = 0.5
  292.   Var.MinLeftBackward = 0.3
  293.  
  294.  
  295.  
  296. If Nunchuk1.Exists
  297.  
  298.    //Right weapon
  299.   If Wiimote1.B
  300.     Key.C = True
  301.     Wiimote1.LED4 = True
  302.   Else
  303.     Key.C = False
  304.     Wiimote1.LED4 = False
  305.   EndIf
  306.  
  307.   //Left weapon
  308.   If Nunchuk1.Zbutton
  309.     Wiimote1.LED1 = True
  310.     Key.D = True
  311.   Else
  312.     Wiimote1.LED1 = False
  313.     Key.D = False
  314.   EndIf
  315.  
  316.   //Dash
  317.   If Wiimote1.A  || Nunchuk1.CButton
  318.     Wiimote1.Rumble = True //Rumble feedback will be on while dashing
  319.     Wiimote1.LED2 and Wiimote1.LED3 = True //The two center LEDs will show us that we're dashing
  320.   Else
  321.     Key.X = False
  322.     Wiimote1.Rumble = False
  323.     Wiimote1.LED2 and Wiimote1.LED3 = False
  324.   EndIf
  325.   //Start
  326.   Key.Space = Wiimote1.Home
  327.  
  328.  
  329.  
  330.  
  331.   // Right stick
  332.   // Moving to the left
  333.   If Wiimote1.GX > Var.MinRightStick
  334.     Var.WiiRS_Left = True
  335.     Wiimote1.LED4 = True
  336.   Else
  337.     Var.WiiRS_Left = False
  338.     Wiimote1.LED4 = False
  339.   EndIf
  340.   // Moving to the right
  341.   If Wiimote1.GX < -Var.MinRightStick
  342.     Var.WiiRS_Right = True
  343.     Wiimote1.LED3 = True
  344.   Else
  345.     Var.WiiRS_Right = False
  346.     Wiimote1.LED3 = False
  347.   EndIf
  348.   // Tilted forward
  349.   If Wiimote1.GY > Var.MinRightForward
  350.   Var.WiiRS_Up = True
  351.   Else
  352.     Var.WiiRS_Up = False
  353.   EndIf
  354.  
  355.   // Tilted backward
  356.   If Wiimote1.GY < -Var.MinRightBackward
  357.     Var.WiiRS_Down = True
  358.   Else
  359.     Var.WiiRS_Down = False
  360.   EndIf
  361.  
  362.  
  363.   // Left stick
  364.   // Moving to the left
  365.   If Nunchuk1.GX > Var.MinLeftStick
  366.     Var.WiiLS_Left = True
  367.     Wiimote1.LED4 = True
  368.   Else
  369.     Var.WiiLS_Left = False
  370.     Wiimote1.LED4 = False
  371.   EndIf
  372.   // Moving to the right
  373.   If Nunchuk1.GX < -Var.MinLeftStick
  374.     Var.WiiLS_Right = True
  375.     Wiimote1.LED3 = True
  376.   Else
  377.     Var.WiiLS_Right = False
  378.     Wiimote1.LED3 = False
  379.   EndIf
  380.   // Tilted forward
  381.   If Nunchuk1.GY > Var.MinLeftForward
  382.     Var.WiiLS_Up = True
  383.   Else
  384.     Var.WiiLS_Up = False
  385.   EndIf
  386.   // Tilted backward
  387.   If Nunchuk1.GY < -Var.MinLeftBackward
  388.     Var.WiiLS_Down = True
  389.   Else
  390.     Var.WiiLS_Down = False
  391.   EndIf
  392.  
  393. *********************************************************************/
  394. //               If you're playing Virtual On
  395. //               somewhere else, or simply using
  396. //               another game that has dual joystick
  397. //               inputs, this is where you should start
  398. //               modifying the script. Remember to use
  399. //               WiiLS_Left and so forth as your source input.
  400. *********************************************************************/
  401.  
  402.   // Move Right
  403.   If (((Var.WiiLS_Right == True)&&(Var.WiiRS_Right == True))||(Wiimote1.Right == True))
  404.     Var.DebugText = "Moving Right"
  405.     PPJoy1.Digital23 = True
  406.   Else
  407.     PPJoy1.Digital23 = False
  408.   EndIf
  409.   // Move Left
  410.   If (((Var.WiiLS_Left == True)&&(Var.WiiRS_Left == True))||(Wiimote1.Left == True))
  411.     Var.DebugText = "Moving Left"
  412.     PPJoy1.Digital22 = True
  413.   Else
  414.     PPJoy1.Digital22 = False
  415.   EndIf
  416.   // Move Forward
  417.   If (((Var.WiiLS_Up == True)&&(Var.WiiRS_Up == True))||(Wiimote1.Up == True))
  418.     Var.DebugText = "Moving Forward"
  419.     PPJoy1.Digital20 = True
  420.   Else
  421.     PPJoy1.Digital20 = False
  422.   EndIf
  423.   // Move Backward
  424.   If (((Var.WiiLS_Down == True)&&(Var.WiiRS_Down == True))||(Wiimote1.Down == True))
  425.     Var.DebugText = "Moving Backward"
  426.     PPJoy1.Digital21 = True
  427.   Else
  428.     PPJoy1.Digital21 = False
  429.   EndIf
  430.   // Turn Right
  431.   If ((Var.WiiLS_Up == True)&&(Var.WiiRS_Down == True))
  432.     Var.DebugText = "Turning Right"
  433.     PPJoy1.Analog0 = Nunchuk1.GY
  434.     Var.TurningRight = True
  435.   Else
  436.     Var.TurningRight = False
  437.   EndIf
  438.   // Turn Left
  439.   If ((Var.WiiLS_Down == True)&&(Var.WiiRS_Up == True))
  440.     Var.DebugText = "Turning Left"
  441.     PPJoy1.Analog0 = Nunchuk1.GY
  442.     Var.TurningLeft = True
  443.   Else
  444.     Var.TurningLeft = False
  445.   EndIf
  446.   // No Turning
  447.   // The main reason I keep those TurningLeft
  448.   // and TurningRight variables is because I'm
  449.   // controlling the analog stick. Therefore I can't
  450.   // simply check button states to see if it's not turning
  451.   // in either direction
  452.   If ((Var.TurningRight == False)&&(Var.TurningLeft == False))
  453.     PPJoy1.Analog0 = 0
  454.   EndIf
  455.   // Flying
  456.   If ((Var.WiiLS_Left == True)&&(Var.WiiRS_Right == True))
  457.     Var.DebugText = "Flying"
  458.     PPJoy1.Digital1 = True
  459.   Else
  460.     PPJoy1.Digital1 = False
  461.   EndIf
  462.  
  463.   // Crouching
  464.   If (((Var.WiiLS_Right == True)&&(Var.WiiRS_Left == True))||(Wiimote1.Minus == True))
  465.     Var.DebugText = "Crouching"
  466.     PPJoy1.Digital2 = True
  467.   Else
  468.     PPJoy1.Digital2 = False
  469.   EndIf
  470.  
  471.   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))
  472.     Var.DebugText = "Neutral"
  473.   EndIf
  474.   // These are the Dreamcast Buttons
  475.   // They match up with the Classic Controller
  476.   // Dreamcast Script I have, so you only need
  477.   // to configure your emulator *once*.
  478.  
  479.   // This pauses
  480.   //PPJoy1.Digital10 = Wiimote1.Plus
  481.   PPJoy1.Digital8 = Wiimote1.Plus
  482.   // This is turbo AND cancel in the menus
  483.   PPJoy1.Digital3 = Wiimote1.A
  484.   // This is just turbo
  485.   PPJoy1.Digital0 = Nunchuk1.CButton
  486.   // This is for dumb programs that don't
  487.   // accept input from the first joystick
  488.   // button. Same on Classic Script
  489.   PPJoy1.Digital15 = Nunchuk1.CButton
  490.   // This is the left firing trigger
  491.   //PPJoy1.Digital6 = Nunchuk1.ZButton
  492.   If Nunchuk1.ZButton == True
  493.     PPJoy1.Digital16 = True
  494.     PPJoy1.Digital18 = True
  495.     PPJoy1.Analog4 = 1.0
  496.   Else
  497.     PPJoy1.Digital16 = False
  498.     PPJoy1.Digital18 = False
  499.     PPJoy1.Analog4 = 0
  500.   Endif
  501.   // This is the right firing trigger
  502.   //PPJoy1.Digital7 = Wiimote1.B
  503.   If Wiimote1.B == True
  504.     PPJoy1.Digital17 = True
  505.     PPJoy1.Digital19 = True
  506.     PPJoy1.Analog5 = 1.0
  507.   Else
  508.     PPJoy1.Digital17 = False
  509.     PPJoy1.Digital19 = False
  510.     PPJoy1.Analog5 = 0
  511.   Endif
  512.  
  513.  
  514.  
  515.   If ((Wiimote1.GX > -Var.MinRightStick)&&(Wiimote1.GX < Var.MinRightStick)&&(Wiimote1.GY < Var.MinRightForward)&&(Wiimote1.GY > Var.MinRightBackward))
  516.   var.debugR = "Neutral"
  517.   EndIf
  518.  
  519.   If ((Nunchuk1.GX > -Var.MinLeftStick)&&(Nunchuk1.GX < Var.MinLeftStick)&&(Nunchuk1.GY < Var.MinLeftForward)&&(Nunchuk1.GY > Var.MinLeftBackward))
  520.   var.debugL = "Neutral"
  521.   EndIf
  522.  
  523.   //debug = Var.DebugText + " StickX : " + Wiimote1.GX + ". StickY : " + Wiimote1.GY
  524.   debug = "Wiimote : " + Wiimote1.GX + "/" + Wiimote1.GY + ". Nunchuk : " + PPJoy1.Analog0 + "/" + PPJoy1.Analog1 + "    " + Var.DebugText
  525.  
  526. EndIf
  527.  
  528.  
  529. // Player Two
  530. // Player 2
  531.  
  532. /*********************************************************************/
  533. //                      Dreamcast Controls
  534. //               From here we use the joystick
  535. //               control information to map the
  536. //               propery controls to the Dreamcast
  537. //               emulator, PC game, or whatever.
  538. /*********************************************************************/
  539.  
  540. If ((Wiimote2.Classic.Exists == False)&&(Nunchuk2.Exists == False))
  541. debug = "Please connect a Classic Controller or Nunchuk"
  542.  
  543.     If Wiimote2.Home == True
  544.       If Wiimote2.Battery > (0.25 * 192)
  545.           Wiimote2.Led1 = True
  546.       Else
  547.           Wiimote2.Led1 = False
  548.       Endif
  549.       If Wiimote2.Battery > (0.5 * 192)
  550.           Wiimote2.Led2 = True
  551.       Else
  552.           Wiimote2.Led2 = False
  553.       Endif
  554.       If Wiimote2.Battery > (0.75 * 192)
  555.           Wiimote2.Led3 = True
  556.       Else
  557.           Wiimote2.Led3 = False
  558.       Endif
  559.       If Wiimote2.Battery > (0.9 * 192)
  560.           Wiimote2.Led4 = True
  561.       Else
  562.           Wiimote2.Led4 = False
  563.       Endif
  564.     Endif
  565.     If Wiimote2.Home == False
  566.       Wiimote2.Led1 = False
  567.       Wiimote2.Led2 = False
  568.       Wiimote2.Led3 = False
  569.       Wiimote2.Led4 = False
  570.      Endif
  571.  
  572. Endif
  573. /*********************************************************************/
  574. //                          Classic Controller
  575. //               Everything works, including analog triggers
  576. //               Digital Triggers also work, read comments.
  577. /*********************************************************************/
  578.  
  579. If Wiimote2.Classic.Exists
  580.  
  581.   // constants
  582.   Var.DeadZone = 0.15;
  583.   Var.LiveZone = 1.0 - Var.DeadZone;
  584.  
  585.  
  586.  
  587.   // apply deadzone to X axis
  588.   If Var.JoyX2 < -Var.DeadZone
  589.      Var.JoyX2 = (Var.JoyX2 + Var.DeadZone) / Var.LiveZone;
  590.   Else
  591.     If Var.JoyX2 > Var.DeadZone
  592.       Var.JoyX2 = (Var.JoyX2 - Var.DeadZone) / Var.LiveZone;
  593.     Else
  594.       Var.JoyX2 = 0
  595.     EndIf
  596.   EndIf
  597.  
  598.   // apply deadzone to Y axis
  599.   If Var.JoyY2 < -Var.DeadZone
  600.      Var.JoyY2 = (Var.JoyY2 + Var.DeadZone) / Var.LiveZone;
  601.   Else
  602.       If Var.JoyY2 > Var.DeadZone
  603.         Var.JoyY2 = (Var.JoyY2 - Var.DeadZone) / Var.LiveZone;
  604.       Else
  605.         Var.JoyY2 = 0
  606.       EndIf
  607.   EndIf
  608.  
  609.   If !Var.Init
  610.      Var.Init = true
  611.      Var.ControlMode = "Standard"
  612.   EndIf
  613.  
  614.   If Pressed(HeldDown(Wiimote2.Home, 0.5s))||Pressed(HeldDown(Wiimote2.B, 0.5s))||Pressed(HeldDown(Wiimote2.A, 0.5s))
  615.      If Var.ControlMode == "Standard"
  616.         Var.ControlMode = "VirtualOn"
  617.      Elseif Var.ControlMode = "VirtualOn"
  618.         Var.ControlMode = "Standard"
  619.      EndIf
  620.      EndIf
  621.  
  622.  
  623.     PPJoy2.Digital1 = Wiimote2.Classic.x
  624.     PPJoy2.Digital2 = Wiimote2.Classic.b
  625.     PPJoy2.Digital8 = Wiimote2.Classic.Plus
  626.     PPJoy2.Digital9 = Wiimote2.Classic.Minus
  627.     PPJoy2.Digital10 = Wiimote2.Classic.Home
  628.  
  629.     PPJoy2.Digital20 = Wiimote2.Classic.Up
  630.     PPJoy2.Digital21 = Wiimote2.Classic.Down
  631.     PPJoy2.Digital22 = Wiimote2.Classic.Left
  632.     PPJoy2.Digital23 = Wiimote2.Classic.Right
  633.  
  634.     // In configuration of your emulator,
  635.     // slightly depress the triggers to
  636.     // have them act as "axis buttons"
  637.     // in order to get proper analog trigger
  638.     // support
  639.     If Wiimote2.Classic.L > 0.4
  640.         PPJoy2.Analog4 = Wiimote2.Classic.L
  641.     Else
  642.         PPJoy2.Analog4 = 0
  643.     EndIf
  644.     If Wiimote2.Classic.R > 0.4
  645.         PPJoy2.Analog5 = Wiimote2.Classic.R
  646.     Else
  647.         PPJoy2.Analog5 = 0
  648.     EndIf
  649.     // This is for digital versions of these buttons
  650.     PPJoy2.Digital16 = Wiimote2.Classic.L
  651.     PPJoy2.Digital17 = Wiimote2.Classic.R
  652.     PPJoy2.Digital18 = Wiimote2.Classic.LFull
  653.     PPJoy2.Digital19 = Wiimote2.Classic.RFull
  654.  
  655.   If Var.ControlMode == "Standard"
  656.     Wiimote2.Led1 = True
  657.     Wiimote2.Led2 = False
  658.     Wiimote2.Led3 = False
  659.     Wiimote2.Led4 = True
  660.  
  661.     // This is for stupid
  662.     // programs that can't detect the first joystick button
  663.     PPJoy2.Digital15 = Wiimote2.Classic.y
  664.  
  665.     PPJoy2.Digital0 = Wiimote2.Classic.y
  666.     PPJoy2.Digital3 = Wiimote2.Classic.a
  667.  
  668.     PPJoy2.Digital6 = Wiimote2.Classic.ZL
  669.     PPJoy2.Digital7 = Wiimote2.Classic.ZR
  670.     PPJoy2.Digital4 = Wiimote2.Classic.L
  671.     PPJoy2.Digital5 = Wiimote2.Classic.R
  672.    
  673.    
  674.     PPJoy2.Digital11 = Wiimote2.A
  675.     PPJoy2.Digital12 = Wiimote2.B
  676.     PPJoy2.Digital13 = Wiimote2.1
  677.     PPJoy2.Digital14 = Wiimote2.2
  678.    
  679.  
  680.    
  681.     PPJoy2.Digital24 = Wiimote2.Up
  682.     PPJoy2.Digital25 = Wiimote2.Down
  683.     PPJoy2.Digital26 = Wiimote2.Left
  684.     PPJoy2.Digital27 = Wiimote2.Right
  685.    
  686.     PPJoy2.Analog2 = Wiimote2.Classic.Joy2X
  687.     PPJoy2.Analog3 = Wiimote2.Classic.Joy2Y
  688.  
  689.     PPJoy2.Analog6 = Wiimote2.RawForceX
  690.     PPJoy2.Analog7 = Wiimote2.RawForceY
  691.     PPJoy2.Analog8 = Wiimote2.RawForceZ
  692.    
  693.    
  694.     Var.JoyX2 = Wiimote2.Classic.Joy1X
  695.     Var.JoyY2 = Wiimote2.Classic.Joy1Y
  696.  
  697.     PPJoy2.Analog0 = Var.JoyX2
  698.     PPJoy2.Analog1 = Var.JoyY2
  699.   EndIf
  700.  
  701.  
  702.   If Var.ControlMode == "VirtualOn"
  703.     Wiimote2.Led1 = False
  704.     Wiimote2.Led2 = True
  705.     Wiimote2.Led3 = True
  706.     Wiimote2.Led4 = False
  707.  
  708.  
  709.  
  710.  
  711.      Var.JoyDead2 = 0.3
  712.      // Move Forward
  713.      If ((Wiimote2.Classic.Joy1Y < -Var.JoyDead2)&&(Wiimote2.Classic.Joy2Y < -Var.JoyDead2))||Wiimote2.Classic.Up == True
  714.         PPJoy2.Digital20 = True
  715.      Else
  716.         PPJoy2.Digital20 = False
  717.      EndIf
  718.      // Move Backward
  719.      If ((Wiimote2.Classic.Joy1Y > Var.JoyDead2)&&(Wiimote2.Classic.Joy2Y > Var.JoyDead2))||Wiimote2.Classic.Down == True
  720.         PPJoy2.Digital21 = True
  721.      Else
  722.         PPJoy2.Digital21 = False
  723.      EndIf
  724.      // Move Left
  725.      If ((Wiimote2.Classic.Joy1X < -Var.JoyDead2)&&(Wiimote2.Classic.Joy2X < -Var.JoyDead2))||Wiimote2.Classic.Left == True
  726.         PPJoy2.Digital22 = True
  727.      Else
  728.         PPJoy2.Digital22 = False
  729.      EndIf
  730.      // Move Right
  731.      If ((Wiimote2.Classic.Joy1X > Var.JoyDead2)&&(Wiimote2.Classic.Joy2X > Var.JoyDead2))||Wiimote2.Classic.Right == True
  732.         PPJoy2.Digital23 = True
  733.      Else
  734.         PPJoy2.Digital23 = False
  735.      EndIf
  736.      // Turn Left
  737.      If (Wiimote2.Classic.Joy1Y < -Var.JoyDead2)&&(Wiimote2.Classic.Joy2Y > Var.JoyDead2)
  738.         PPJoy2.Analog0 = 0.5
  739.         Var.TurnRight = True
  740.      Else
  741.         Var.TurnRight = False
  742.      EndIf
  743.      // Turn Right
  744.      If (Wiimote2.Classic.Joy1Y > Var.JoyDead2)&&(Wiimote2.Classic.Joy2Y < -Var.JoyDead2)
  745.       PPJoy2.Analog0 = -0.5
  746.       Var.TurnLeft = True
  747.      Else
  748.       Var.TurnLeft = False
  749.      EndIf
  750.      // No Turn
  751.      If ((Var.TurnLeft == False)&&(Var.TurnRight == False))
  752.       PPJoy2.Analog0 = 0
  753.      EndIf
  754.      // Jump
  755.      If (Wiimote2.Classic.Joy1X < -Var.JoyDead2)&&(Wiimote2.Classic.Joy2X > Var.JoyDead2)
  756.         PPJoy2.Digital15 = True
  757.         PPJoy2.Digital1 = True
  758.      Else
  759.         PPJoy2.Digital15 = False
  760.         PPJoy2.Digital1 = False
  761.      EndIf
  762.      // Crouch
  763.      If ((Wiimote2.Classic.Joy1X > Var.JoyDead2)&&(Wiimote2.Classic.Joy2X < -Var.JoyDead2))||Wiimote2.Classic.b == True
  764.         PPJoy2.Digital2 = True
  765.      Else
  766.         PPJoy2.Digital2 = False
  767.      EndIf
  768.  
  769.     PPJoy2.Digital15 = Wiimote2.Classic.ZR
  770.     PPJoy2.Digital3 = Wiimote2.Classic.ZL
  771.  
  772.     If PPJoy2.Digital15 == True || PPJoy.Digital3 == True
  773.         PPJoy2.Digital0 = True
  774.         Wiimote2.Rumble = True
  775.     Else
  776.         PPJoy2.Digital0 = False
  777.         Wiimote2.Rumble = False
  778.     EndIf
  779.  
  780.  
  781.   EndIf
  782.   debug = "Classic Controller Connected; " + Var.ControlMode + ". Xtra: " + PPJoy2.Digital15
  783. EndIf
  784.  
  785.  
  786.  
  787. /*********************************************************************/
  788. //                      Nunchuk Controls (Virtual On)
  789. //               These controls were designed specifically
  790. //               for the Dreamcast "Virtual On" sequel.
  791. //
  792. //               In addition, the directional buttons
  793. //               on the Wiimote can navigate the menus
  794. /*********************************************************************/
  795.  
  796.  
  797. /*********************************************************************/
  798. //                      Joystick Controls
  799. //                 This is general joystick control
  800. //                 management. It lets you keep track
  801. //                 of which way our virtual joysticks
  802. //                 are pointed. Var.WiiLS_Left means :
  803. //
  804. //                 LS = Left Stick (Nunchuk)
  805. //                 _Left = Pointed Left
  806. //                 RS for Right Stick (Wiimote) and _Up/_Down/_Right
  807. //                 for those respective directions
  808. /*********************************************************************/
  809.  
  810.   // Wiimote/Nunchuk's minimum push for
  811.   // left or right Directions
  812.   Var.MinRightStick = 0.25
  813.   Var.MinLeftStick = 0.25
  814.  
  815.   // Wiimote/Nunchuk's minimum push for
  816.   // forward and backward directions
  817.   Var.MinRightForward = 0.5
  818.   Var.MinRightBackward = 0.3
  819.   Var.MinLeftForward = 0.5
  820.   Var.MinLeftBackward = 0.3
  821.  
  822.  
  823.  
  824. If Nunchuk2.Exists
  825.  
  826.    //Right weapon
  827.   If Wiimote2.B
  828.     Key.C = True
  829.     Wiimote2.LED4 = True
  830.   Else
  831.     Key.C = False
  832.     Wiimote2.LED4 = False
  833.   EndIf
  834.  
  835.   //Left weapon
  836.   If Nunchuk2.Zbutton
  837.     Wiimote2.LED1 = True
  838.     Key.D = True
  839.   Else
  840.     Wiimote2.LED1 = False
  841.     Key.D = False
  842.   EndIf
  843.  
  844.   //Dash
  845.   If Wiimote2.A  || Nunchuk2.CButton
  846.     Wiimote2.Rumble = True //Rumble feedback will be on while dashing
  847.     Wiimote2.LED2 and Wiimote2.LED3 = True //The two center LEDs will show us that we're dashing
  848.   Else
  849.     Key.X = False
  850.     Wiimote2.Rumble = False
  851.     Wiimote2.LED2 and Wiimote2.LED3 = False
  852.   EndIf
  853.   //Start
  854.   Key.Space = Wiimote2.Home
  855.  
  856.  
  857.  
  858.  
  859.   // Right stick
  860.   // Moving to the left
  861.   If Wiimote2.GX > Var.MinRightStick
  862.     Var.WiiRS_Left = True
  863.     Wiimote2.LED4 = True
  864.   Else
  865.     Var.WiiRS_Left = False
  866.     Wiimote2.LED4 = False
  867.   EndIf
  868.   // Moving to the right
  869.   If Wiimote2.GX < -Var.MinRightStick
  870.     Var.WiiRS_Right = True
  871.     Wiimote2.LED3 = True
  872.   Else
  873.     Var.WiiRS_Right = False
  874.     Wiimote2.LED3 = False
  875.   EndIf
  876.   // Tilted forward
  877.   If Wiimote2.GY > Var.MinRightForward
  878.   Var.WiiRS_Up = True