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 05:20
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.     Wiimote1.Led1 = False
  15.     Wiimote1.Led2 = False
  16.     Wiimote1.Led3 = False
  17.     Wiimote1.Led4 = False
  18.  
  19. Endif
  20.  
  21. /*********************************************************************/
  22. //                          Classic Controller
  23. //               Everything works, including analog triggers
  24. //               Digital Triggers also work, read comments.
  25. /*********************************************************************/
  26.  
  27. If Wiimote1.Classic.Exists
  28.  
  29.   // constants
  30.   Var.DeadZone = 0.15;
  31.   Var.LiveZone = 1.0 - Var.DeadZone;
  32.  
  33.  
  34.  
  35.   // apply deadzone to X axis
  36.   If Var.JoyX < -Var.DeadZone
  37.      Var.JoyX = (Var.JoyX + Var.DeadZone) / Var.LiveZone;
  38.   Else
  39.     If Var.JoyX > Var.DeadZone
  40.       Var.JoyX = (Var.JoyX - Var.DeadZone) / Var.LiveZone;
  41.     Else
  42.       Var.JoyX = 0
  43.     EndIf
  44.   EndIf
  45.  
  46.   // apply deadzone to Y axis
  47.   If Var.JoyY < -Var.DeadZone
  48.      Var.JoyY = (Var.JoyY + Var.DeadZone) / Var.LiveZone;
  49.   Else
  50.       If Var.JoyY > Var.DeadZone
  51.         Var.JoyY = (Var.JoyY - Var.DeadZone) / Var.LiveZone;
  52.       Else
  53.         Var.JoyY = 0
  54.       EndIf
  55.   EndIf
  56.  
  57.   If !Var.Init
  58.      Var.Init = true
  59.      Var.ControlMode = "Standard"
  60.   EndIf
  61.  
  62.   If Pressed(HeldDown(Wiimote.Home, 1s))||Pressed(HeldDown(Wiimote.B, 1s))||Pressed(HeldDown(Wiimote.A, 1s))
  63.      If Var.ControlMode == "Standard"
  64.         Var.ControlMode = "VirtualOn"
  65.      Elseif Var.ControlMode = "VirtualOn"
  66.         Var.ControlMode = "Standard"
  67.      EndIf
  68.      EndIf
  69.  
  70.  
  71.     PPJoy1.Digital1 = Wiimote1.Classic.x
  72.     PPJoy1.Digital2 = Wiimote1.Classic.b
  73.     PPJoy1.Digital8 = Wiimote1.Classic.Plus
  74.     PPJoy1.Digital9 = Wiimote1.Classic.Minus
  75.     PPJoy1.Digital10 = Wiimote1.Classic.Home
  76.  
  77.     PPJoy1.Digital20 = Wiimote1.Classic.Up
  78.     PPJoy1.Digital21 = Wiimote1.Classic.Down
  79.     PPJoy1.Digital22 = Wiimote1.Classic.Left
  80.     PPJoy1.Digital23 = Wiimote1.Classic.Right
  81.  
  82.     // In configuration of your emulator,
  83.     // slightly depress the triggers to
  84.     // have them act as "axis buttons"
  85.     // in order to get proper analog trigger
  86.     // support
  87.     If Wiimote1.Classic.L > 0.4
  88.         PPJoy1.Analog4 = Wiimote1.Classic.L
  89.     Else
  90.         PPJoy1.Analog4 = 0
  91.     EndIf
  92.     If Wiimote1.Classic.R > 0.4
  93.         PPJoy1.Analog5 = Wiimote1.Classic.R
  94.     Else
  95.         PPJoy1.Analog5 = 0
  96.     EndIf
  97.     // This is for digital versions of these buttons
  98.     PPJoy1.Digital16 = Wiimote1.Classic.L
  99.     PPJoy1.Digital17 = Wiimote1.Classic.R
  100.     PPJoy1.Digital18 = Wiimote1.Classic.LFull
  101.     PPJoy1.Digital19 = Wiimote1.Classic.RFull
  102.  
  103.   If Var.ControlMode == "Standard"
  104.     Wiimote1.Led1 = True
  105.     Wiimote1.Led2 = False
  106.     Wiimote1.Led3 = False
  107.     Wiimote1.Led4 = True
  108.  
  109.     // This is for stupid
  110.     // programs that can't detect the first joystick button
  111.     PPJoy1.Digital15 = Wiimote1.Classic.y
  112.  
  113.     PPJoy1.Digital0 = Wiimote1.Classic.y
  114.     PPJoy1.Digital3 = Wiimote1.Classic.a
  115.  
  116.     PPJoy1.Digital6 = Wiimote1.Classic.ZL
  117.     PPJoy1.Digital7 = Wiimote1.Classic.ZR
  118.     PPJoy1.Digital4 = Wiimote1.Classic.L
  119.     PPJoy1.Digital5 = Wiimote1.Classic.R
  120.    
  121.    
  122.     PPJoy1.Digital11 = Wiimote1.A
  123.     PPJoy1.Digital12 = Wiimote1.B
  124.     PPJoy1.Digital13 = Wiimote1.1
  125.     PPJoy1.Digital14 = Wiimote1.2
  126.    
  127.  
  128.    
  129.     PPJoy1.Digital24 = Wiimote1.Up
  130.     PPJoy1.Digital25 = Wiimote1.Down
  131.     PPJoy1.Digital26 = Wiimote1.Left
  132.     PPJoy1.Digital27 = Wiimote1.Right
  133.    
  134.     PPJoy1.Analog2 = Wiimote1.Classic.Joy2X
  135.     PPJoy1.Analog3 = Wiimote1.Classic.Joy2Y
  136.  
  137.     PPJoy1.Analog6 = Wiimote1.RawForceX
  138.     PPJoy1.Analog7 = Wiimote1.RawForceY
  139.     PPJoy1.Analog8 = Wiimote1.RawForceZ
  140.    
  141.    
  142.     Var.JoyX = Wiimote1.Classic.Joy1X
  143.     Var.JoyY = Wiimote1.Classic.Joy1Y
  144.  
  145.     PPJoy1.Analog0 = Var.JoyX
  146.     PPJoy1.Analog1 = Var.JoyY
  147.   EndIf
  148.  
  149.  
  150.   If Var.ControlMode == "VirtualOn"
  151.     Wiimote1.Led1 = False
  152.     Wiimote1.Led2 = True
  153.     Wiimote1.Led3 = True
  154.     Wiimote1.Led4 = False
  155.  
  156.  
  157.  
  158.  
  159.      Var.JoyDead = 0.3
  160.      // Move Forward
  161.      If ((Wiimote1.Classic.Joy1Y < -Var.JoyDead)&&(Wiimote1.Classic.Joy2Y < -Var.JoyDead))||Wiimote1.Classic.Up == True
  162.         PPJoy1.Digital20 = True
  163.      Else
  164.         PPJoy1.Digital20 = False
  165.      EndIf
  166.      // Move Backward
  167.      If ((Wiimote1.Classic.Joy1Y > Var.JoyDead)&&(Wiimote1.Classic.Joy2Y > Var.JoyDead))||Wiimote1.Classic.Down == True
  168.         PPJoy1.Digital21 = True
  169.      Else
  170.         PPJoy1.Digital21 = False
  171.      EndIf
  172.      // Move Left
  173.      If ((Wiimote1.Classic.Joy1X < -Var.JoyDead)&&(Wiimote1.Classic.Joy2X < -Var.JoyDead))||Wiimote1.Classic.Left == True
  174.         PPJoy1.Digital22 = True
  175.      Else
  176.         PPJoy1.Digital22 = False
  177.      EndIf
  178.      // Move Right
  179.      If ((Wiimote1.Classic.Joy1X > Var.JoyDead)&&(Wiimote1.Classic.Joy2X > Var.JoyDead))||Wiimote1.Classic.Right == True
  180.         PPJoy1.Digital23 = True
  181.      Else
  182.         PPJoy1.Digital23 = False
  183.      EndIf
  184.      // Turn Left
  185.      If (Wiimote1.Classic.Joy1Y < -Var.JoyDead)&&(Wiimote1.Classic.Joy2Y > Var.JoyDead)
  186.         PPJoy1.Analog0 = 0.5
  187.         Var.TurnRight = True
  188.      Else
  189.         Var.TurnRight = False
  190.      EndIf
  191.      // Turn Right
  192.      If (Wiimote1.Classic.Joy1Y > Var.JoyDead)&&(Wiimote1.Classic.Joy2Y < -Var.JoyDead)
  193.       PPJoy1.Analog0 = -0.5
  194.       Var.TurnLeft = True
  195.      Else
  196.       Var.TurnLeft = False
  197.      EndIf
  198.      // No Turn
  199.      If ((Var.TurnLeft == False)&&(Var.TurnRight == False))
  200.       PPJoy1.Analog0 = 0
  201.      EndIf
  202.      // Jump
  203.      If (Wiimote1.Classic.Joy1X < -Var.JoyDead)&&(Wiimote1.Classic.Joy2X > Var.JoyDead)
  204.         PPJoy1.Digital15 = True
  205.         PPJoy1.Digital1 = True
  206.      Else
  207.         PPJoy1.Digital15 = False
  208.         PPJoy1.Digital1 = False
  209.      EndIf
  210.      // Crouch
  211.      If ((Wiimote1.Classic.Joy1X > Var.JoyDead)&&(Wiimote1.Classic.Joy2X < -Var.JoyDead))||Wiimote1.Classic.b == True
  212.         PPJoy1.Digital2 = True
  213.      Else
  214.         PPJoy1.Digital2 = False
  215.      EndIf
  216.  
  217.     PPJoy1.Digital15 = Wiimote1.Classic.ZR
  218.     PPJoy1.Digital3 = Wiimote1.Classic.ZL
  219.  
  220.     If PPJoy1.Digital15 == True || PPJoy.Digital3 == True
  221.         PPJoy1.Digital0 = True
  222.         Wiimote1.Rumble = True
  223.     Else
  224.         PPJoy1.Digital0 = False
  225.         Wiimote1.Rumble = False
  226.     EndIf
  227.  
  228.  
  229.   EndIf
  230.   debug = "Classic Controller Connected; " + Var.ControlMode + ". Xtra: " + PPJoy1.Digital15
  231. EndIf
  232.  
  233.  
  234.  
  235. /*********************************************************************/
  236. //                      Nunchuk Controls (Virtual On)
  237. //               These controls were designed specifically
  238. //               for the Dreamcast "Virtual On" sequel.
  239. //
  240. //               In addition, the directional buttons
  241. //               on the Wiimote can navigate the menus
  242. /*********************************************************************/
  243.  
  244.  
  245. /*********************************************************************/
  246. //                      Joystick Controls
  247. //                 This is general joystick control
  248. //                 management. It lets you keep track
  249. //                 of which way our virtual joysticks
  250. //                 are pointed. Var.WiiLS_Left means :
  251. //
  252. //                 LS = Left Stick (Nunchuk)
  253. //                 _Left = Pointed Left
  254. //                 RS for Right Stick (Wiimote) and _Up/_Down/_Right
  255. //                 for those respective directions
  256. /*********************************************************************/
  257.  
  258.   // Wiimote/Nunchuk's minimum push for
  259.   // left or right Directions
  260.   Var.MinRightStick = 0.25
  261.   Var.MinLeftStick = 0.25
  262.  
  263.   // Wiimote/Nunchuk's minimum push for
  264.   // forward and backward directions
  265.   Var.MinRightForward = 0.5
  266.   Var.MinRightBackward = 0.3
  267.   Var.MinLeftForward = 0.5
  268.   Var.MinLeftBackward = 0.3
  269.  
  270.  
  271.  
  272. If Nunchuk1.Exists
  273.  
  274.    //Right weapon
  275.   If Wiimote1.B
  276.     Key.C = True
  277.     Wiimote1.LED4 = True
  278.   Else
  279.     Key.C = False
  280.     Wiimote1.LED4 = False
  281.   EndIf
  282.  
  283.   //Left weapon
  284.   If Nunchuk1.Zbutton
  285.     Wiimote1.LED1 = True
  286.     Key.D = True
  287.   Else
  288.     Wiimote1.LED1 = False
  289.     Key.D = False
  290.   EndIf
  291.  
  292.   //Dash
  293.   If Wiimote1.A  || Nunchuk1.CButton
  294.     Wiimote1.Rumble = True //Rumble feedback will be on while dashing
  295.     Wiimote1.LED2 and Wiimote1.LED3 = True //The two center LEDs will show us that we're dashing
  296.   Else
  297.     Key.X = False
  298.     Wiimote1.Rumble = False
  299.     Wiimote1.LED2 and Wiimote1.LED3 = False
  300.   EndIf
  301.   //Start
  302.   Key.Space = Wiimote1.Home
  303.  
  304.  
  305.  
  306.  
  307.   // Right stick
  308.   // Moving to the left
  309.   If Wiimote1.GX > Var.MinRightStick
  310.     Var.WiiRS_Left = True
  311.     Wiimote1.LED4 = True
  312.   Else
  313.     Var.WiiRS_Left = False
  314.     Wiimote1.LED4 = False
  315.   EndIf
  316.   // Moving to the right
  317.   If Wiimote1.GX < -Var.MinRightStick
  318.     Var.WiiRS_Right = True
  319.     Wiimote1.LED3 = True
  320.   Else
  321.     Var.WiiRS_Right = False
  322.     Wiimote1.LED3 = False
  323.   EndIf
  324.   // Tilted forward
  325.   If Wiimote1.GY > Var.MinRightForward
  326.   Var.WiiRS_Up = True
  327.   Else
  328.     Var.WiiRS_Up = False
  329.   EndIf
  330.  
  331.   // Tilted backward
  332.   If Wiimote1.GY < -Var.MinRightBackward
  333.     Var.WiiRS_Down = True
  334.   Else
  335.     Var.WiiRS_Down = False
  336.   EndIf
  337.  
  338.  
  339.   // Left stick
  340.   // Moving to the left
  341.   If Nunchuk1.GX > Var.MinLeftStick
  342.     Var.WiiLS_Left = True
  343.     Wiimote1.LED4 = True
  344.   Else
  345.     Var.WiiLS_Left = False
  346.     Wiimote1.LED4 = False
  347.   EndIf
  348.   // Moving to the right
  349.   If Nunchuk1.GX < -Var.MinLeftStick
  350.     Var.WiiLS_Right = True
  351.     Wiimote1.LED3 = True
  352.   Else
  353.     Var.WiiLS_Right = False
  354.     Wiimote1.LED3 = False
  355.   EndIf
  356.   // Tilted forward
  357.   If Nunchuk1.GY > Var.MinLeftForward
  358.     Var.WiiLS_Up = True
  359.   Else
  360.     Var.WiiLS_Up = False
  361.   EndIf
  362.   // Tilted backward
  363.   If Nunchuk1.GY < -Var.MinLeftBackward
  364.     Var.WiiLS_Down = True
  365.   Else
  366.     Var.WiiLS_Down = False
  367.   EndIf
  368.  
  369. *********************************************************************/
  370. //               If you're playing Virtual On
  371. //               somewhere else, or simply using
  372. //               another game that has dual joystick
  373. //               inputs, this is where you should start
  374. //               modifying the script. Remember to use
  375. //               WiiLS_Left and so forth as your source input.
  376. *********************************************************************/
  377.  
  378.   // Move Right
  379.   If (((Var.WiiLS_Right == True)&&(Var.WiiRS_Right == True))||(Wiimote1.Right == True))
  380.     Var.DebugText = "Moving Right"
  381.     PPJoy1.Digital23 = True
  382.   Else
  383.     PPJoy1.Digital23 = False
  384.   EndIf
  385.   // Move Left
  386.   If (((Var.WiiLS_Left == True)&&(Var.WiiRS_Left == True))||(Wiimote1.Left == True))
  387.     Var.DebugText = "Moving Left"
  388.     PPJoy1.Digital22 = True
  389.   Else
  390.     PPJoy1.Digital22 = False
  391.   EndIf
  392.   // Move Forward
  393.   If (((Var.WiiLS_Up == True)&&(Var.WiiRS_Up == True))||(Wiimote1.Up == True))
  394.     Var.DebugText = "Moving Forward"
  395.     PPJoy1.Digital20 = True
  396.   Else
  397.     PPJoy1.Digital20 = False
  398.   EndIf
  399.   // Move Backward
  400.   If (((Var.WiiLS_Down == True)&&(Var.WiiRS_Down == True))||(Wiimote1.Down == True))
  401.     Var.DebugText = "Moving Backward"
  402.     PPJoy1.Digital21 = True
  403.   Else
  404.     PPJoy1.Digital21 = False
  405.   EndIf
  406.   // Turn Right
  407.   If ((Var.WiiLS_Up == True)&&(Var.WiiRS_Down == True))
  408.     Var.DebugText = "Turning Right"
  409.     PPJoy1.Analog0 = Nunchuk1.GY
  410.     Var.TurningRight = True
  411.   Else
  412.     Var.TurningRight = False
  413.   EndIf
  414.   // Turn Left
  415.   If ((Var.WiiLS_Down == True)&&(Var.WiiRS_Up == True))
  416.     Var.DebugText = "Turning Left"
  417.     PPJoy1.Analog0 = Nunchuk1.GY
  418.     Var.TurningLeft = True
  419.   Else
  420.     Var.TurningLeft = False
  421.   EndIf
  422.   // No Turning
  423.   // The main reason I keep those TurningLeft
  424.   // and TurningRight variables is because I'm
  425.   // controlling the analog stick. Therefore I can't
  426.   // simply check button states to see if it's not turning
  427.   // in either direction
  428.   If ((Var.TurningRight == False)&&(Var.TurningLeft == False))
  429.     PPJoy1.Analog0 = 0
  430.   EndIf
  431.   // Flying
  432.   If ((Var.WiiLS_Left == True)&&(Var.WiiRS_Right == True))
  433.     Var.DebugText = "Flying"
  434.     PPJoy1.Digital1 = True
  435.   Else
  436.     PPJoy1.Digital1 = False
  437.   EndIf
  438.  
  439.   // Crouching
  440.   If (((Var.WiiLS_Right == True)&&(Var.WiiRS_Left == True))||(Wiimote1.Minus == True))
  441.     Var.DebugText = "Crouching"
  442.     PPJoy1.Digital2 = True
  443.   Else
  444.     PPJoy1.Digital2 = False
  445.   EndIf
  446.  
  447.   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))
  448.     Var.DebugText = "Neutral"
  449.   EndIf
  450.   // These are the Dreamcast Buttons
  451.   // They match up with the Classic Controller
  452.   // Dreamcast Script I have, so you only need
  453.   // to configure your emulator *once*.
  454.  
  455.   // This pauses
  456.   //PPJoy1.Digital10 = Wiimote1.Plus
  457.   PPJoy1.Digital8 = Wiimote1.Plus
  458.   // This is turbo AND cancel in the menus
  459.   PPJoy1.Digital3 = Wiimote1.A
  460.   // This is just turbo
  461.   PPJoy1.Digital0 = Nunchuk1.CButton
  462.   // This is for dumb programs that don't
  463.   // accept input from the first joystick
  464.   // button. Same on Classic Script
  465.   PPJoy1.Digital15 = Nunchuk1.CButton
  466.   // This is the left firing trigger
  467.   //PPJoy1.Digital6 = Nunchuk1.ZButton
  468.   If Nunchuk1.ZButton == True
  469.     PPJoy1.Digital16 = True
  470.     PPJoy1.Digital18 = True
  471.     PPJoy1.Analog4 = 1.0
  472.   Else
  473.     PPJoy1.Digital16 = False
  474.     PPJoy1.Digital18 = False
  475.     PPJoy1.Analog4 = 0
  476.   Endif
  477.   // This is the right firing trigger
  478.   //PPJoy1.Digital7 = Wiimote1.B
  479.   If Wiimote1.B == True
  480.     PPJoy1.Digital17 = True
  481.     PPJoy1.Digital19 = True
  482.     PPJoy1.Analog5 = 1.0
  483.   Else
  484.     PPJoy1.Digital17 = False
  485.     PPJoy1.Digital19 = False
  486.     PPJoy1.Analog5 = 0
  487.   Endif
  488.  
  489.  
  490.  
  491.   If ((Wiimote1.GX > -Var.MinRightStick)&&(Wiimote1.GX < Var.MinRightStick)&&(Wiimote1.GY < Var.MinRightForward)&&(Wiimote1.GY > Var.MinRightBackward))
  492.   var.debugR = "Neutral"
  493.   EndIf
  494.  
  495.   If ((Nunchuk1.GX > -Var.MinLeftStick)&&(Nunchuk1.GX < Var.MinLeftStick)&&(Nunchuk1.GY < Var.MinLeftForward)&&(Nunchuk1.GY > Var.MinLeftBackward))
  496.   var.debugL = "Neutral"
  497.   EndIf
  498.  
  499.   //debug = Var.DebugText + " StickX : " + Wiimote1.GX + ". StickY : " + Wiimote1.GY
  500.   debug = "Wiimote : " + Wiimote1.GX + "/" + Wiimote1.GY + ". Nunchuk : " + PPJoy1.Analog0 + "/" + PPJoy1.Analog1 + "    " + Var.DebugText
  501.  
  502. 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.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me