Wiimote Script Compilation

Wiimote Script Compilation

Postby MarkusOrelius » Tue 04 May, 2010 8:45 am

I thought i would compile a list of links to existing scripts. as well as some basic information about connecting the wii devices to the PC. I know a lot of people will most likely pop by the forums to get the information. so why not. Make it easy for people to hop into this.

Please post any links or just advice for which bluetooth stackts etc to use.

Short Wiimote Connection guide *information coming soon*

Synching Wii Devices with PC *coming soon*
Last edited by MarkusOrelius on Tue 04 May, 2010 1:42 pm, edited 1 time in total.
MarkusOrelius
 
Posts: 31
Joined: Wed 27 Jan, 2010 4:57 am

Re: Wiimote Script Compilation

Postby MarkusOrelius » Tue 04 May, 2010 8:56 am

WiiMote Links
Glovepie WIKI
http://glovepie.org/w/index.php?title=Script_Examples
A few script examples.

http://www.squarephoenix.com/glovepie_scripts.html
External link - Assorted Scripts include:
VLC Remote
Zsnes for two Players
PPJoy joystick for ppjoy setup
Universal Media Remote


Wiimote

Wiimote + Nunchuck

WM+

WM+ and Nunchuck
http://glovepie.org/forum/viewtopic.php?f=6&t=246#p979 - Code Samples for General FPS gameplay control

http://glovepie.org/forum/viewtopic.php?f=6&t=312#p1132 - Dark Mesiah of Might and Magic - scroll down to find the code windown with the final script

Wii Fit Board
http://chardish.nfshost.com/bodysurf/index.html - This is for the game bodysurf, but can perhaps be used as a starter for more advanced scripts and other games

Lednerg's scripts. - Air gyrom mouse
http://glovepie.org/forum/viewtopic.php?f=6&t=17 - Code window in first post has code you can copy paste to make his Air Gyro work
http://lednerg.home.comcast.net/WMPM%202010.01.24.PIE - my personal favorite simple because it works best for me.


I also thought that perhaps we could try to ever month or every 6 months, compile a New Master script. a master script would function by having one key set aside to on the fly switch between different profiles. ie,
for example the homekey will will cycle through a bunch of states, while state a or state 1 is active, a basic mouse script (for that controller) would be in use, state b or 2 would turn the wiimote into a media remote for playing movies.
so on and so forth,
while each state activeted checks for the approriate addons and applies the approriate script. a Kinda GPie Wii Framework, whcih ideally would support multiple wiimotes as well as wii fit pad. or any other peripherals?
Last edited by MarkusOrelius on Tue 04 May, 2010 1:38 pm, edited 2 times in total.
MarkusOrelius
 
Posts: 31
Joined: Wed 27 Jan, 2010 4:57 am

Re: Wiimote Script Compilation

Postby TiagoTiago » Tue 04 May, 2010 1:11 pm

GlovePIE's own wiki should probably be linked in this thread too, even if it's not as big as other online collections of GPIE scripts yet
(notifications don't always get to my inbox, if you think it happened please let me know)
TiagoTiago
 
Posts: 411
Joined: Fri 08 Jan, 2010 3:08 am

Re: Wiimote Script Compilation

Postby MarkusOrelius » Tue 04 May, 2010 1:34 pm

TiagoTiago wrote:GlovePIE's own wiki should probably be linked in this thread too, even if it's not as big as other online collections of GPIE scripts yet


Done :)

im having a huge problem testing some of these scripts, actually im having connections problems. not with standard wiimotes but i cant get glovepie to recognise the balance board. herd bluesoleil was meant to be good, but didnt feel like paying for the stack. ouch...

when i figure this out im gonna start linking to stacks that work.

if you guys find any scripts etc, just post them here, ill add them to the post and make sure we get something going here. glovepie seems to get most hits off the net for connecting wii stuff anyway
MarkusOrelius
 
Posts: 31
Joined: Wed 27 Jan, 2010 4:57 am

Re: Wiimote Script Compilation

Postby TiagoTiago » Tue 04 May, 2010 1:55 pm

Do you use Microsoft's or Widdcomm's (sp?) stack?
(notifications don't always get to my inbox, if you think it happened please let me know)
TiagoTiago
 
Posts: 411
Joined: Fri 08 Jan, 2010 3:08 am

Re: Wiimote Script Compilation

Postby NrDesign » Wed 05 May, 2010 7:56 pm

I'm using the Toshiba/Sitecom stack. It came with my nano-Bluetooth dongle; works very well!
NrDesign
 

Re: Wiimote Script Compilation

Postby MarkusOrelius » Mon 10 May, 2010 12:40 am

I acutally got it working now, enough to test that im getting keypresses, trying to learn the scripting myself at the moment, (For wiiboard)
at elast i can make it repeat W pressed :P

im using microsfot stack. thinking about getting a new bluetooth device though. I need somethign that is easier to keep synced and not time out
MarkusOrelius
 
Posts: 31
Joined: Wed 27 Jan, 2010 4:57 am

Re: Wiimote Script Compilation

Postby MarkusOrelius » Mon 10 May, 2010 12:25 pm

An incomplete tutorial/example for WASD movement.

the jumping works relativly well too. not as precise as fingers, but lets face it, a few smaller fingers are just plain faster than moving yoru entire flipping leg :P... however it does work, and in my case i find it actually tires was my puny leg mucles fairly quickly

Code: Select all
// ==========================================================================================================================
// Wii Fit Balance Board Example
// ==========================================================================================================================
// Script for WASD movement and jumping. Developed primarly for Age of Conan play, but should be useful
// for anyone wanting to quickly see how it works.
//
// the wii board has a bunch of different values you can read, here are some preset up variables, and examples on how to debug those values
// to the glovepie window
//
// The following piece has been taken directly from the glovepie documentation
//
// ==========================================================================================================================
// NEW! Wii Fit Balance Board
//
// The Wii Fit (or Wii Fitness) Balance Board is a new Wii controller that you stand on. It has four weight/pressure sensors, one in each corner.
//
// Balance Boards support is working now, although I haven’t implemented any gesture recognition like walking, jumping, crouching, etc. yet.
//
// The Balance Board  behaves like an extra dummy Wiimote with a Balance Board attachment plugged in. The dummy Wiimote’s LED1 controls the power
// LED on the top of the board, and the dummy Wiimote’s A button is actually the power button on the Balance Board. The other things on the dummy
// Wiimote do nothing, except the built-in balance board “attachment”.
//
// NEW! The Balance Board is now in a separate category from Wii Remotes, so you can read from the first Balance Board with “BalanceBoard1”.
//
// You can read your total weight like this:
//
// Weight
//
// You can read the weights on the four sensors (in kilograms) like this:
//
// FrontLeft, FrontRight
// BackLeft, BackRight
//
// You can also read the weights on each side like this:
//
// WeightFront, WeightBack,
// WeightLeft, WeightRight
//
// You can read the raw values of the four sensors like this:
//
// BalanceBoard.RawFrontLeft
// BalanceBoard.RawFrontRight
// BalanceBoard.RawBackLeft
// BalanceBoard.RawBackRight
//
// Unlike the previous version, the sensors now have the correct names. The back is the side with the power button.
//
// Different sensors vary quite a bit.
//
// There are some unknown values you can try:
//
// BalanceBoard.EE
// BalanceBoard.QuestionQuestion
//
// You can set the LED like this:
//
// eg. BalanceBoard.LED = true
//
// You can read the button like this:
//
// BalanceBoard.Button
//
// ==========================================================================================================================
//
// Actual Code Starts below, With Comments.
//
// ==========================================================================================================================
//



if Wiimote1.HasBalanceBoard
   var.BbFl = BalanceBoard.RawFrontLeft                 //raw sensor data
   var.BbFr = BalanceBoard.RawFrontRight
   var.BbBl = BalanceBoard.RawBackLeft
   var.BbBr = BalanceBoard.RawBackRight
   var.BbFlKg = BalanceBoard.FrontLeft              //Individual Sensor Data in Kilograms
   var.BbFrKg = BalanceBoard.FrontRight         // *Note* you can add or subtract these to eacthoer if you wanna do some advanced logic.
   var.BbBlKg = BalanceBoard.BackLeft         //
   var.BbBrKg = BalanceBoard.BackRight
   var.BbF = BalanceBoard.WeightFront         //Data in Kilograms, for each side
   var.BbL = BalanceBoard.WeightLeft         // *When you step on a specific area of the wii balance board, because of the way its built,
   var.BbB = BalanceBoard.WeightBack         //  you will actually put extra pressure on nearby sensors as well.
   var.BbR = BalanceBoard.WeightRight         // playing with these gives you the total for that particular side
   var.BbKgTotal = BalanceBoard.Weight

       Keyboard.RepeatFakeKeys = False
//Keyboard.RepeatRate = 1 Hz
//Keyboard.RepeatDelay = 1.0 seconds
   // The following line disaplys a bunch of variables in the dbegug area, in this case, they happen to display the
   // debug= "Fl:" + var.BbFlKg + " *** Fr:" + var.BbFrKg + " *** Bl:" + var.BbBlKg + " *** Br:" + var.BbBrKg + " *** Total:" + var.BbKgTotal
   debug= "Front:" + var.BbF + " *** Back:" + var.BbB + " *** Left:" + var.BbL + " *** Right:" + var.BbR
elseif !Wiimote1.HasBalanceBoard
   debug = "Boo NOT CONNECTED"
endif



Key.W = BalanceBoard1.WeightFront > 13
Key.A = BalanceBoard1.WeightLeft > 9.5
Key.S = BalanceBoard1.WeightBack > 11
Key.D = BalanceBoard1.WeightRight > 9.5
Key.Space = BalanceBoard1.WeightFront > 20.5
Key.Space = BalanceBoard1.WeightBack > 20.5
MarkusOrelius
 
Posts: 31
Joined: Wed 27 Jan, 2010 4:57 am

Re: Wiimote Script Compilation

Postby ninjarawr49 » Wed 04 Jan, 2012 2:40 pm

Good work on the compilation guys! Let's keep this thread alive and keep the scripts coming - maybe we can build a script library!
ninjarawr49
 
Posts: 9
Joined: Tue 03 Jan, 2012 12:06 pm

Re: Wiimote Script Compilation

Postby Sico » Sun 12 Feb, 2012 3:35 am

I dont know if this will be a lot of use to people but MarkusOrelius mentioned having a "Master script" and this is the one I use:

Code: Select all
if Wiimote.Led1 = true then
if wiimote.led2 = false then
if wiimote.led3 = false then
if wiimote.led4 = false then

if wiimote.up then
  key.A = nunchuk.c
  key.B = nunchuk.z
  key.C = nunchuk.JoyY <  -0.5
  key.D = nunchuk.JoyY > 0.5
  key.E = nunchuk.Joyx < -0.5
  key.F = nunchuk.Joyx > 0.5

 elseif wiimote.down then
  key.G = nunchuk.c
  key.H = nunchuk.z
  key.I = nunchuk.JoyY <  -0.5
  key.J = nunchuk.JoyY > 0.5
  key.K = nunchuk.Joyx < -0.5
  key.L = nunchuk.Joyx > 0.5

 elseif wiimote.left then
  key.M = nunchuk.c
  key.N = nunchuk.z
  key.O = nunchuk.JoyY <  -0.5
  key.P = nunchuk.JoyY > 0.5
  key.Q = nunchuk.Joyx < -0.5
  key.R = nunchuk.Joyx > 0.5

 elseif wiimote.right then
  key.S = nunchuk.c
  key.T = nunchuk.z
  key.U = nunchuk.JoyY <  -0.5
  key.V = nunchuk.JoyY > 0.5
  key.W = nunchuk.Joyx < -0.5
  key.X = nunchuk.Joyx > 0.5

 elsif wiimote.a then
  key.Y = nunchuk.c
  key.Z = nunchuk.z
  key.dot = nunchuk.JoyY <  -0.5
  key.comma = nunchuk.JoyY > 0.5
  key.Space = nunchuk.Joyx < -0.5
  key.tab = nunchuk.Joyx > 0.5
  key.shift = wiimote.b

 elseif wiimote.b then
  key.Windows + d = nunchuk.JoyY > 0.5 // Desktop - down
  key.Alt + key.f4 = nunchuk.JoyY <  -0.5 // Close - up
  key.Enter =nunchuk.Joyx > 0.5   // Enter - right
  key.BackSpace = nunchuk.Joyx < -0.5   // Backspace - left
  mouse.MiddleButton = nunchuck.C  // Mouse middle - C
  key.ctrl = wiimote.2
  key.tab = wiimote.1 // 2 then 1 will swap "Tabs" on Internet Explorer

//will Execute programs you use,
 elseif wiimote.Home then
  if nunchuk.JoyY > 0.5 then
  execute "d:\stuff\D" // Hardrive - down
  wait 0.5 second
  endif
  if nunchuk.JoyY <  -0.5 then
  execute "d:\stuff\WMP" // Media player - up
  wait 0.5 second
  endif
  if nunchuk.Joyx > 0.5 then
  execute "d:\stuff\Mes"  // Windows messenger - right
  wait 0.5 second
  endif
  if nunchuk.Joyx < -0.5 then
  execute "d:\stuff\ie"  // Internet - left
  wait 0.5 second
  endif
  if nunchuk.C then
  execute "d:\stuff\osk"// OSK C
  wait 0.5 second
  endif
  key.windows + key.up = nunchuk.Z  // Maximise window

 elseif nunchuk.z then     
  key.down = nunchuk.JoyY > 0.1
  key.up = nunchuk.JoyY <  -0.1
  key.right = nunchuk.Joyx > 0.1
  key.left = nunchuk.Joyx < -0.1
  mouse.RightButton = nunchuk.c
  key.alt = wiimote.2
  key.tab = wiimote.1  // 2 then 1 will swap between windows

 elseif wiimote.1 then
  key.1 = nunchuk.c
  key.2 = nunchuk.JoyY <  -0.5
  key.3 = nunchuk.JoyY > 0.5
  key.4 = nunchuk.Joyx < -0.5
  key.5 = nunchuk.Joyx > 0.5

 elseif wiimote.2 then
  key.6 = nunchuk.c
  key.7 = nunchuk.JoyY <  -0.5
  key.8 = nunchuk.JoyY > 0.5
  key.9 = nunchuk.Joyx < -0.5
  key.0 = nunchuk.Joyx > 0.5

 else
  if Nunchuk.JoyY > 0.1 then mouse.DirectInputy += 1
  if Nunchuk.JoyY < -0.1 then mouse.DirectInputy -= 1
  if Nunchuk.joyx > 0.1 then mouse.DirectInputx += 1
  if Nunchuk1.joyx < -0.1 then mouse.DirectInputx -= 1
  if Nunchuk.JoyY > 0.3 then mouse.DirectInputy += 4
  if Nunchuk.JoyY < -0.3 then mouse.DirectInputy -= 4
  if Nunchuk.joyx > 0.3 then mouse.DirectInputx += 4
  if Nunchuk1.joyx < -0.3 then mouse.DirectInputx -= 4
  if Nunchuk.JoyY > 0.5 then mouse.DirectInputy += 8
  if Nunchuk.JoyY < -0.5 then mouse.DirectInputy -= 8
  if Nunchuk.joyx > 0.5 then mouse.DirectInputx += 8
  if Nunchuk1.joyx < -0.5 then mouse.DirectInputx -= 8
  if Nunchuk.JoyY > 0.7 then mouse.DirectInputy += 12
  if Nunchuk.JoyY < -0.7 then mouse.DirectInputy -= 12
  if Nunchuk.joyx > 0.7 then mouse.DirectInputx += 12
  if Nunchuk1.joyx < -0.7 then mouse.DirectInputx -= 12
  if Nunchuk.JoyY > 1 then mouse.DirectInputy += 16
  if Nunchuk.JoyY < -1 then mouse.DirectInputy -= 16
  if Nunchuk.joyx > 1 then mouse.DirectInputx += 16
  if Nunchuk1.joyx < -1 then mouse.DirectInputx -= 16
  Mouse.LeftButton = nunchuk.C
 endif

endif
endif
endif
endif


As you can see, it doesnt use gyros or IR, so it wont be alot of use to people that want to use those but a few tweeks will sort that. You'll also notice that buttons + and - aren't used, that's becasue I use them to switch between controller configurations, ie This script, Media player controller, specific controls for cirtain games etc. What I use to change between those is this:

Code: Select all
if wiimote.plus then
 if nunchuk.JoyY <  -0.5 then
 Wiimote.Led1 = true
 Wiimote.Led2 = false
 Wiimote.Led3 = false
 Wiimote.Led4 = false
 endif
endif

if wiimote.plus then
 if nunchuk.JoyY > 0.5 then
 Wiimote.Led1 = false
 Wiimote.Led2 = true
 Wiimote.Led3 = false
 Wiimote.Led4 = false
 endif
endif

if wiimote.plus then
 if nunchuk.Joyx < -0.5 then
 Wiimote.Led1 = false
 Wiimote.Led2 = false
 Wiimote.Led3 = true
 Wiimote.Led4 = false
 endif
endif

if wiimote.plus then
 if nunchuk.Joyx > 0.5 then
 Wiimote.Led1 = false
 Wiimote.Led2 = false
 Wiimote.Led3 = false
 Wiimote.Led4 = true
 endif
endif

if wiimote.plus then
 if nunchuk.z then
 Wiimote.Led1 = true
 Wiimote.Led2 = true
 Wiimote.Led3 = true
 Wiimote.Led4 = true
 endif
endif

if wiimote.minus then
 if nunchuk.JoyY <  -0.5 then
 Wiimote.Led1 = true
 Wiimote.Led2 = true
 Wiimote.Led3 = false
 Wiimote.Led4 = false
 endif
endif

if wiimote.minus then
 if nunchuk.JoyY > 0.5 then
 Wiimote.Led1 = true
 Wiimote.Led2 = false
 Wiimote.Led3 = true
 Wiimote.Led4 = false
 endif
endif

if wiimote.minus then
 if nunchuk.Joyx < -0.5 then
 Wiimote.Led1 = true
 Wiimote.Led2 = false
 Wiimote.Led3 = false
 Wiimote.Led4 = true
 endif
endif

if wiimote.minus then
 if nunchuk.Joyx > 0.5 then
 Wiimote.Led1 = false
 Wiimote.Led2 = true
 Wiimote.Led3 = true
 Wiimote.Led4 = false
 endif
endif

if wiimote.minus then
 if nunchuk.C then
 Wiimote.Led1 = false
 Wiimote.Led2 = true
 Wiimote.Led3 = false
 Wiimote.Led4 = true
 endif
endif

if wiimote.minus then
 if nunchuk.z then
 Wiimote.Led1 = false
 Wiimote.Led2 = false
 Wiimote.Led3 = true
 Wiimote.Led4 = true
 endif
endif


As you can see, Im using the LEDs as confirmation to which setup im using.

Hope this helps.
Sico
 
Posts: 38
Joined: Sun 22 Jan, 2012 2:03 am

Re: Wiimote Script Compilation

Postby bg4m3r » Thu 22 Mar, 2012 10:19 am

Hey, I just stumbled across this thread, and happen to be working on a GlovePIE/Wiimote site to share my scripts and provide a list of resources for people to find scripts and info. I'm just getting started on it, so there isn't a lot there (just 3 of my scripts and these forums), but I have a solid handful of scripts to put up, so I thought I would add a link here. :)

Wiimote & GlovePIE: Control Your PC!
bg4m3r
 
Posts: 2
Joined: Thu 22 Mar, 2012 8:59 am

Re: Wiimote Script Compilation

Postby e2zippo » Thu 10 May, 2012 6:48 am

Hey guys! Just setup rom collection browser in XBMC and now i'm using my Wii Classic Controller to play my Snes-games!

This is the script I'm running right now, but i would like to add some stuff and I need help doing it :D


//Super Nintendo Controller Setup by serotoninzero

//Start Programs

//SNES
Key.Alt && Key.LeftShift && Key.ScrollLock = (-1.2 < Wiimote1.Classic.Joy1Y < -0.5) && Wiimote1.Classic.Home

//Directionals
Key.Up = Wiimote1.Classic.Up
Key.Down = Wiimote1.Classic.Down
Key.Left = Wiimote1.Classic.Left
Key.Right = Wiimote1.Classic.Right

//A,B,X,Y,L,R
Key.X = Wiimote1.Classic.a
Key.Z = Wiimote1.Classic.B
Key.S = Wiimote1.Classic.x
Key.A = Wiimote1.Classic.Y
Key.D = Wiimote1.Classic.LFull
Key.C = Wiimote1.Classic.RFull

//Start, Select

Key.RightShift = Wiimote1.Classic.Minus
Key.Enter = Wiimote1.Classic.Plus

//State Save, State Load, In-game Reset

Key.F4 = Wiimote1.Classic.ZL
Key.F2 = Wiimote1.Classic.ZR
Key.Q = Wiimote1.Classic.Home
key.w = wiimote1.Classic.minus && wiimote1.Classic.Plus && wiimote1.Classic.ZR && wiimote1.Classic.ZL (this one doesn't work)


And the other ones I'd like to map are these
* When long pressing Wiimote1.Classic.Home (approx 2 seconds) i want the emulator to exit, in other words Alt+F4
* When long pressing (2 seconds) minus, plus, ZL, ZR i want to reset the game, like above but with delay.
e2zippo
 
Posts: 10
Joined: Thu 10 May, 2012 5:55 am

Re: Wiimote Script Compilation

Postby Shinesprite » Sat 19 May, 2012 7:47 am

@e2zippo This should do the trick:
Code: Select all
Key.Alt + Key.F4 = HeldDown(Wiimote1.Classic.Home, 2s)
key.w = HeldDown(wiimote1.Classic.minus + wiimote1.Classic.Plus + wiimote1.Classic.ZR + wiimote1.Classic.ZL, 2s)

;)
User avatar
Shinesprite
 
Posts: 29
Joined: Sat 19 May, 2012 7:33 am

Re: Wiimote Script Compilation

Postby e2zippo » Sun 20 May, 2012 3:48 pm

I got som help in another thread already, looked really similar, thanks! :)
e2zippo
 
Posts: 10
Joined: Thu 10 May, 2012 5:55 am

Re: Wiimote Script Compilation

Postby Shinesprite » Wed 06 Jun, 2012 11:21 am

Ok, so here is the script I wrote for Portal. It's not perfect, but I'm welcome to friendly input.

EDIT: (updated - now properly supports analog movement)
Code: Select all
/*
     Portal (1)                             v 2012.06.27
     by Shinesprite - adapted (in part) from lednerg WiiMotion PlusMouse (v 2010.01.14)
*/

if Wiimote.HasNunchuk then //&& Wiimote.HasMotionPlus then
   /*
        Emulates the basic aiming mechanic of a FPS.
        Requires GlovePIE version .42 or higher.

        Using the default in-game controlls settings:
        Leave the Wiimote on your desk when starting so it can calibrate.

        --Controls--
        Hold Down on the D-pad to aim and use the nunchuk control stick to move.
        Press up on the D-pad at any time to reset the reticle (mouse)

        B to shoot a Blue Portal
        Z to shoot an Orange Portal

        A to jump
        Left on the D-pad, Left on the D-pad, or 1 to crouch
        C to pickup items

        +/- to Pause
        Home for Steam interface
   */


//if you want to toggle aiming on/off (instead of holding down a button)

   /*if starting then var.MoveButton = false
   if pressed(wiimote.B)then{
      if var.MoveButton==false then{
         say "false"
         var.MoveButton=true
      }else{
         say "true"
         var.MoveButton=false
           }
      }
   //if var.MoveButton = false && wiimote.B then {
   //   var.MoveButton = true
      }*/

   Wiimote1.Led1 = true
   Wiimote1.Led2 = false
   Wiimote1.Led3 = false
   Wiimote1.Led4 = false

   var.MoveButton =  wiimote.Down
   var.ResetPointer = wiimote.Up
   mouse.LeftButton = wiimote.B
   mouse.RightButton = nunchuk.Z
   key.E = nunchuk.C
   key.Space = wiimote.A
   key.Ctrl = wiimote.Left || wiimote.Right || wiimote.One
   key.Escape = wiimote.Minus || wiimote.Plus
   key.Shift + key.Tab =  wiimote.Home

   //***Analog Movement*** (must "Enable Gamepad" in-game)
   PPjoy1.Analog0 = Deadzone(Wiimote1.Classic.JoyX*1)
   PPjoy1.Analog1 = Deadzone(Wiimote1.Classic.JoyY*1)

   /*key.A = -3 < Wiimote1.Nunchuk.JoyX < -0.4
   key.D = 3 > Wiimote1.Nunchuk.JoyX > 0.4
   key.W = -3 < Wiimote1.Nunchuk.JoyY < -0.4
   key.S = 3 > Wiimote1.Nunchuk.JoyY > 0.4*/

   //***Pointer Controls***
   var.Speed = 85   // 0 to 100

   PIE.FrameRate = 120hz
   if wiimote.HasMotionPlus = false then
      debug = "WiiMotion Plus NOT DETECTED!"
   else
      debug = "WiiMotion Plus DETECTED!"
   endif

   //Center mouse
   if (var.ResetPointer = true) then// && var.MoveButton=true) {
         mouse.x = 0.5//between 0 and 1
         mouse.y = 0.5//between 0 and 1
   endif

   if (wiimote.HasMotionPlus = true and var.MoveButton = true) then
      var.YawSpeed = wiimote.MotionPlus.YawSpeed
      var.PitchSpeed = wiimote.MotionPlus.PitchSpeed
      if SameValue( Smooth(wiimote.SmoothRoll, 10), wiimote.SmoothRoll, 10) then
         var.Roll = Smooth(wiimote.SmoothRoll, 10)
      else
         var.Roll = wiimote.SmoothRoll
      endif
      if var.Roll < 0 and var.Roll >= -90 then
         var.XYswap = 1 - EnsureMapRange(var.Roll, -90, 0, 0, 1)
         var.RightDown = -1
         var.TopUp = 1
      endif
      if var.Roll <= 90 and var.Roll >= 0 then
         var.XYswap = 1 - EnsureMapRange(var.Roll, 90, 0, 0, 1)
         var.RightDown = 1
         var.TopUp = 1
      endif
      if var.Roll > 90 and var.Roll <= 180 then
         var.XYswap = 1 - EnsureMapRange(var.Roll, 90, 180, 0, 1)
         var.RightDown = 1
         var.TopUp = -1
      endif
      if var.Roll < -90 and var.Roll >= -180 then
         var.XYswap = 1 - EnsureMapRange(var.Roll, -90, -180, 0, 1)
         var.RightDown = -1
         var.TopUp = -1
      endif
      var.SpeedX = var.TopUp * var.YawSpeed - (var.TopUp * var.YawSpeed * var.XYswap) + ( var.RightDown * var.PitchSpeed * var.XYswap )
      var.SpeedY = var.TopUp * var.PitchSpeed - (var.TopUp * var.PitchSpeed * var.XYswap) + ( -var.RightDown * var.YawSpeed * var.XYswap )
      Fakemouse.DirectInputX = int(var.MouseX)
      Fakemouse.DirectInputY = int(var.MouseY)
      var.MouseX += (var.SpeedX / (10500000 - EnsureMapRange(var.Speed, 0, 100, 0, 10000000) ) )
      var.MouseY -= (var.SpeedY / (10500000 - EnsureMapRange(var.Speed, 0, 100, 0, 10000000) ) )
   /* // for Fakemouse.x and Fakemouse.y instead
      Fakemouse.x = var.MouseX
      Fakemouse.y = var.MouseY
      var.MouseX = var.MouseX + ( var.SpeedX / (20500 - EnsureMapRange(var.Speed, 0, 100, 0, 20000) ) )
      var.MouseY = var.MouseY - ( var.SpeedY / (20500 - EnsureMapRange(var.Speed, 0, 100, 0, 20000) ) )
   */
   endif
   if var.MoveButton = false then
      var.MouseX = Fakemouse.DirectInputX
      var.MouseY = Fakemouse.DirectInputY
   /* // for Fakemouse.x and Fakemouse.y instead
      var.MouseX = mouse.x
      var.MouseY = mouse.y
   */
   endif
else if Wiimote.HasClassic then  // This script turns the Wiimote Classic Controller into a joystick, allowing you to use the controller in many different games.
   /*
        Requires GlovePIE version .42 or higher.

        Using the default in-game controlls settings:

        --Controls--
        Use the left control stick to move and the right control stick to aim.

        R to shoot a Blue Portal
        L to shoot an Orange Portal

        b to jump
        a or ZR to crouch
        y or ZL to pickup items

        +/- to Pause
        Home for Steam interface
   */

      var.ClsscSpeed = 20   // 0 to 100

      Wiimote1.Led1 = true
      Wiimote1.Led2 = false
      Wiimote1.Led3 = false
      Wiimote1.Led4 = false

      //ArrowKeys = Classic.DPad
      WASD = Classic.DPad

      mouse.LeftButton = wiimote.Classic.R
      mouse.RightButton = wiimote.Classic.L

      key.E = wiimote.Classic.y || wiimote.Classic.ZL
      //= wiimote.Classic.x
      key.Space = wiimote.Classic.b
      key.Ctrl = wiimote.Classic.a || wiimote.Classic.ZR

      key.Escape = wiimote.Minus || wiimote.Classic.Minus || wiimote.Plus || wiimote.Classic.Plus
      key.Shift + key.Tab =  wiimote.Classic.Home || wiimote.Home

      //***Analog Movement*** (must "Enable Gamepad" in-game)
      PPjoy1.Analog0 = Deadzone(Wiimote1.Classic.Joy1X*1)
      PPjoy1.Analog1 = Deadzone(Wiimote1.Classic.Joy1Y*1)

      /*key.A = -3 < Wiimote1.Classic.Joy1X < -0.4
      key.D = 3 > Wiimote1.Classic.Joy1X > 0.4
      key.W = -3 < Wiimote1.Classic.Joy1Y < -0.4
      key.S = 3 > Wiimote1.Classic.Joy1Y > 0.4*/

      //***Pointer Controls***
      //Fakemouse.DirectInputX += var.ClsscSpeed * Deadzone(Wiimote1.Classic.Joy2X*1.1) // make the number 1 higher or lower to change sensitivity
      //Fakemouse.DirectInputY += var.ClsscSpeed * Deadzone(Wiimote1.Classic.Joy2Y*1)   // but only use small variations, like 1.1 or 0.9

      //If the game is set for joystick aiming
      PPJoy1.Analog2 = Deadzone(Wiimote1.Classic.Joy2X*1.1)
      PPJoy1.Analog3 = Deadzone(Wiimote1.Classic.Joy2Y*1)

else  //If idle (if undefined controller configuration)
      var.timing = 131ms


      wiimote.led1 = true
      wiimote.led2 = false
      wait var.timing
      wiimote.led2 = true
      wiimote.led1 = false
      wait var.timing
      wiimote.led3 = true
      wiimote.led2 = false
      wait var.timing
      wiimote.led4 = true
      wiimote.led3 = false
      wait var.timing
      wiimote.led3 = true
      wiimote.led4 = false
      wait var.timing
      wiimote.led2 = true
      wiimote.led3 = false
      wait var.timing
      //wiimote.Led1 = true
      //wiimote.led2 = false
      //wait 100ms
      //wait 100ms
      //wait 100ms
      //wait 100ms
      //PPJoy1.Digital10 = Wiimote1.Home
endif


If you are are having trouble switching between controller configurations, I guess you could just use the chunks of code separately.
User avatar
Shinesprite
 
Posts: 29
Joined: Sat 19 May, 2012 7:33 am

Re: Wiimote Script Compilation

Postby Shinesprite » Thu 28 Jun, 2012 10:10 am

Lately, I've started playing another game on my PC. So, naturally, this warrants another golvepie script.
With this Sonic & Sega All-Stars Racing script, I was able to successfully implement Multi-Configuration switching, meaning that whether you choose to play with either the Wii wheel (or not), nunchuk + Wiimote combo, or simply a Classic Controller the mapping will adapt to what's currently plugged in.
Code: Select all
/*
     Sonic & Sega All-Stars Racing          v 2012.06.27
     by Shinesprite - adapted (in part) from Pvt. John Doe's Steering Wheel Script
*/

//For those interested in modifying this sript:

//PPjoy INPUT   x360ce OUTPUT       IN-GAME RESULT
   //Analog0 is leftJoyX            [Menu (Left/Right)/Steer]
   //Analog1 is leftJoyY            [Menu (Up/Down)]
   //Analog2 is rightJoyX
   //Analog3 is rightJoyY
   //Analog5 is LT                  [Reverse/Drift/Trick]
   //Analog6 is RT                  [Gas]
   //Digital0 is X                  [F1/look backwards]
   //Digital1 is A                  [Menu accept/horn/item]
   //Digital2 is B                  [Menu decline]
   //Digital3 is Y                  [F2]
   //Digital4 is LB                 [Reverse/Drift/Trick]
   //Digital5 is RB                 [Gas]
   //Digital6 is LT (see CC section)[Reverse/Drift/Trick]
   //Digital7 is RT (see CC section)[Gas]
   //Digital8 is Back
   //Digital9 is Start              [Start/Pause]
   //Digital10 is leftjoy button
   //Digital11 is rightjoy button
   //Digital16 is D-pad Up          [Menu Up]
   //Digital17 is D-pad Down        [Menu Down]
   //Digital18 is D-pad Left        [Menu Left/Steer Left]
   //Digital19 is D-pad Right       [Menu Right/Steer Right]

Wiimote1.Led1 = true
Wiimote1.Led2 = false
Wiimote1.Led3 = false
Wiimote1.Led4 = false

if Wiimote1.HasNunchuk then
 /*This script attempts to recreate the nunchuk controls found in Mario Kart Wii.

   --Controls--
   Thumbstick [Menu navigation/Steer]
   D-pad      [Menu navigation/Steer]

   A          [Gas]
   B          [Reverse/Drift/Trick]
   1          [Menu decline]
   2          [F2]

   C          [F1/look backwards]
   Z          [Menu accept/horn/item]

   -
   Home       [Steam interface]
   +          [Start/Pause]
 */
   PPJoy1.Analog0 = Deadzone(Wiimote1.Nunchuk.JoyX*1) // make the number 1 higher or lower to change sensitivity
   PPJoy1.Analog1 = Deadzone(Wiimote1.Nunchuk.JoyY*1) // but only use small variations, like 1.1 or 0.9

   PPJoy1.Digital16 = Wiimote1.Up
   PPJoy1.Digital19 = Wiimote1.Right
   PPJoy1.Digital18 = Wiimote1.Left
   PPJoy1.Digital17 = Wiimote1.Down

   PPJoy1.Digital5 = Wiimote1.A
   PPJoy1.Digital4 = Wiimote1.B
   PPJoy1.Digital2 = Wiimote1.One
   PPJoy1.Digital3 = Wiimote1.Two

   PPJoy1.Digital0 = Wiimote1.Nunchuk.C
   PPJoy1.Digital1 = Wiimote1.Nunchuk.Z

   PPJoy1.Digital8 = Wiimote1.Minus
   key.Shift + key.Tab = Wiimote1.Home
   PPJoy1.Digital9 = Wiimote1.Plus

   //Sometimes, disconnecting the classic controller leaves certain buttons/axes
   //pressed.  Since there are other buttons/axes which accomplish the same job
   //(in-game), it is best to set these as false.
   PPJoy1.Analog2 = 0
   PPJoy1.Analog3 = 0
   PPJoy1.Analog5 = 0
   PPJoy1.Analog6 = 0

   PPJoy1.Digital6 = false
   PPJoy1.Digital7 = false
else if Wiimote1.HasClassic then
 /*This script attempts to recreate the game's original Xbox 360 controls using the Wiimote Classic Controller.

   --Controls--
   Left Thumbstick [Menu navigation/Steer]
   Right Thumbstick
   D-pad           [Menu navigation/Steer]

   a/A             [Menu accept/horn/item]
   b/B             [Menu decline]
   x/2             [F2]
   y/1             [F1/look backwards]

   L               [F1/look backwards]
   R               [Menu accept/horn/item]
   ZL              [F1/look backwards]
   ZR              [Menu accept/horn/item]

   -
   Home            [Steam interface]
   +               [Start/Pause]
 */
   PPJoy1.Analog0 = Deadzone(Wiimote1.Classic.Joy1X*1.1) // make the number 1 higher or lower to change sensitivity
   PPJoy1.Analog1 = Deadzone(Wiimote1.Classic.Joy1Y*1)   // but only use small variations, like 1.1 or 0.9
   PPJoy1.Analog2 = Deadzone(Wiimote1.Classic.Joy2X*1.1)
   PPJoy1.Analog3 = Deadzone(Wiimote1.Classic.Joy2Y*1)

   PPJoy1.Digital16 = Wiimote1.Classic.Up || Wiimote1.Up
   PPJoy1.Digital19 = Wiimote1.Classic.Right || Wiimote1.Right
   PPJoy1.Digital18 = Wiimote1.Classic.Left || Wiimote1.Left
   PPJoy1.Digital17 = Wiimote1.Classic.Down || Wiimote1.Down

   PPJoy1.Digital0 = Wiimote1.Classic.y || Wiimote1.One
   PPJoy1.Digital1 = Wiimote1.Classic.a || Wiimote1.A
   PPJoy1.Digital2 = Wiimote1.Classic.b || Wiimote1.B
   PPJoy1.Digital3 = Wiimote1.Classic.x || Wiimote1.Two

   PPJoy1.Digital8 = Wiimote1.Classic.Minus || Wiimote1.Minus
   key.Shift + key.Tab = Wiimote1.Classic.Home || Wiimote1.Home
   PPJoy1.Digital9 = Wiimote1.Classic.Plus || Wiimote1.Plus

   PPJoy1.Digital4 = Wiimote1.Classic.ZL
   PPJoy1.Digital5 = Wiimote1.Classic.ZR

   //For Analog Triggers
   if Wiimote1.Classic.LFull then
      PPJoy1.Analog5 = 1
   else
      PPJoy1.Analog5 = Deadzone(Smooth(Wiimote1.Classic.L)) //if your triggers have moderate wear, sometimes they will fail to fully depress
   endif
   if Wiimote1.Classic.RFull then
      PPJoy1.Analog6 = 1
   else
      PPJoy1.Analog6 = Deadzone(Smooth(Wiimote1.Classic.R)) //if your triggers have moderate wear, sometimes they will fail to fully depress
   endif

   //For Digital Triggers
   //PPJoy1.Digital6 = Deadzone(Wiimote1.Classic.L) || wiimote1.Classic.LFull //need to change x360ce.ini so that Left Trigger=7
   //PPJoy1.Digital7 = Deadzone(Wiimote1.Classic.R) || Wiimote1.Classic.RFull //need to change x360ce.ini so that Right Trigger=8
else
 /*This script attempts to recreate the WiiWheel controls found in Mario Kart Wii
   (but can also be used like those in Excite Truck).

   --Controls-- (assuming the Wiimote is held horizontally with the 1 & 2 buttons to the right)
   Left/Right Steering (motion) [Horizontal Menu navigation/Steer]
   D-pad Up                     [Menu up]
   D-pad Down                   [Menu down]

   D-pad Left                   [Menu accept/horn/item]
   D-pad Right                  [Menu decline]

   A                            [F1/look backwards]
   B/1                          [Reverse/Drift/Trick]
   2                            [Gas]

   -                            [F2]
   Home                         [Steam interface]
   +                            [Start/Pause]


   If the motion controls do not work for you, try the following:
      ------------< Pvt. John Doe's Steering Wheel Script >------------
     | This is my script for car racing games.  It has smooth steering,|
     | so you can tilt the controller a little bit or a lot to steer   |
     | accordingly.  Hold the Wii remote with the buttons facing up,   |
     | as if you were playing Excite Truck.  Steering is mapped to the |
     | X axis.  The Wii remote's buttons are mapped from button 1 to   |
     | button 11.  Set them up however you like in the game.  The Y    |
     | axis is mapped to the tilt of the controller forward and back.  |
     | This could come in handy for flight sims or shifting.           |
      -----------------------------------------------------------------

      !!!! Follow Steps 1 - 3 to get your remote working properly !!!!
           Be sure you have PPJoy installed before continuing.

      ------------(Step 1 - Set up PPJoy Virtual Joystick)------------
     |   1. In GlovePIE, go to CP-Settings > PPJoy.                   |
     |   2. Click on Add, then select "Constoller 1".                 |
     |   3. Select "PPJoy Virtual Joystick 1" and click Mapping.      |
     |   4. Choose "Set a custom mapping..." and click Next.          |
     |   5. Select 8 axes, 16 Buttons, and 2 POV hats, then click     |
     |      Next.                                                     |
     |   6. Click Next again.                                         |
     |   7. Set Button1 to "Digital 0", Button2 to "Digital 1", etc., |
     |      then click next.                                          |
     |   8. Click finish.                                             |
      ----------------------------------------------------------------

      ------------(Step 2 - Fill in the following values)-------------
      Run this script and user the info that is displayed in the debug
      area of GlovePIE. */

   var.zmin = -14.5 // 1. Stand remote on IR end. Put the number next to RawZ here.
   var.zmax = 20.5  // 2. Stand remote on expansion port. Put the number next to RawZ here.

   var.xmin = -43   // 3. Lay remote on right side. Put the number next to RawX here.
   var.xmax = 15    // 4. Lay remote on left side.   Put the number next to RawX here.

   /*  ---------------------(Step 3 - Center Axes) -----------------------
      |   1. In GlovePIE, go to CP-Settings > Joystick.                   |
      |   2. Select "PPJoy Virtual Joystick 1" and click Properties.      |
      |   3. Lay your remote on a flat surface with the buttons facing up.|
      |   4. Change the following values to center the axes.              |
       ------------------------------------------------------------------- */

   var.zoffset = -0 // This is shown as the X axis.
   var.xoffset = -2 // This is shown as the Y axis.

   /* Now you're done.  All that is left is to configure your game
      to your liking.  Have fun!

      Note: This (sub)script was originally designed for Need For Speed.
            Menus in NFS can be navigated by tilting the controller
            forward & back ( for up & down) and left & right. */


   //var.z = Wiimote1.RawForceZ
   var.x = Wiimote1.RawForceX

   //Wiimote1.Leds = 1 + 8 /* No fancy LED animations here. :) */

   var.z = Smooth(Wiimote1.RawForceZ + var.zoffset)
   var.x = var.x + var.xoffset

   PPjoy1.analog0 = Deadzone(EnsureMapRange(var.z, var.zmin, var.zmax, -1, 1))
   //PPjoy1.analog1 = MapRange(var.x, var.xmin, var.xmax, -1, 1)

   PPJoy1.Digital1 = Wiimote1.Up
   PPJoy1.Digital2 = Wiimote1.Down
   PPJoy1.Digital17 = Wiimote1.Left
   PPJoy1.Digital16 = Wiimote1.Right

   PPJoy1.Digital0 = Wiimote1.A
   PPJoy1.Digital4 = Wiimote1.B || Wiimote1.One
   PPJoy1.Digital5 = Wiimote1.Two

   PPJoy1.Digital3 = Wiimote1.Minus
   key.Shift + key.Tab = Wiimote1.Home
   PPJoy1.Digital9 = Wiimote1.Plus

   //debug = 'RawX: ' + Wiimote1.RawForceX + ' RawZ: ' + Wiimote1.RawForceZ

   //Sometimes, disconnecting the classic controller leaves certain buttons/axes
   //pressed.  Since there are other buttons/axes which accomplish the same job
   //(in-game), it is best to set these as false.
   PPJoy1.Analog1 = 0
   PPJoy1.Analog2 = 0
   PPJoy1.Analog3 = 0
   PPJoy1.Analog5 = 0
   PPJoy1.Analog6 = 0

   PPJoy1.Digital6 = false
   PPJoy1.Digital7 = false
endif


/*Want to add more players?  Un-comment and copy the above code into the appropriate
  layer below.  Be sure to add another PPjoy controller (8 axes, 16 Buttons, and
  2 POV hats) and change all references to "Wiimote1", "PPJoy1" accordingly, as well
  as the illuminated Leds.*/

/*if Wiimote2.Exists then
   if Wiimote3.Exists then
      if Wiimote4.Exists then
      endif
   endif
endif*/


Unfortunately, as some of you may know, Sonic & Sega All-Stars Racing does not natively support standard gamepads, so you'll have to jump an extra hoop with x360ce. Just drop the x360ce files in the game's root folder (for those with Windows 7 x64 and the Steam version of the game, that's C:\Program Files (x86)\Steam\steamapps\common\Sonic and SEGA All Stars Racing) to trick your game into thinking your gamepad is an Xbox 360 controller. Sadly, the latest version of the program didn’t recognize PPjoy’s virtual controllers, so I had to settle for the tried-and-true version 3.1.4.1 which can be found here.

Below are the contents of my d x360.ini file which I modified to allow for multiple players and analog triggers when using the classic controller.
Code: Select all
[Options]
UseInitBeep=1             #use 0 to 1; default 1; beep on init
Log=0                     #use 0 to 1; creates a log file in folder 'x360ce logs'
FakeAPI=0                 #use API patching

[PAD1]
Index=0                   #controller index in system game controllers list; 0 is first; -1 to ignore this pad
Native=0                  #experimental native mode, calls system xinput1_3.dll to support xinput compatible controller together with emulated
VID=0x0                   #controller VID
PID=0x0                   #controller PID
Left Analog X=1           #axis index; use - to invert; precede with 's' for a slider eg; s-1; 7 to disable
Left Analog Y=-2          #axis index; use - to invert; precede with 's' for a slider eg; s-1; 7 to disable
Right Analog X=3          #axis index; use - to invert; precede with 's' for a slider eg; s-1; 7 to disable
Right Analog Y=-6         #axis index; use - to invert; precede with 's' for a slider eg; s-1; 7 to disable
Left Analog X+ Button=0   #button id; 0 to disable
Left Analog X- Button=0   #button id; 0 to disable
Left Analog Y+ Button=0   #button id; 0 to disable
Left Analog Y- Button=0   #button id; 0 to disable
Right Analog X+ Button=0  #button id; 0 to disable
Right Analog X- Button=0  #button id; 0 to disable
Right Analog Y+ Button=0  #button id; 0 to disable
Right Analog Y- Button=0  #button id; 0 to disable
D-pad POV=1               #POV index; 0 to disable
D-pad Up=0                #button id; 0 to disable
D-pad Down=0              #button id; 0 to disable
D-pad Left=0              #button id; 0 to disable
D-pad Right=0             #button id; 0 to disable
A=2                       #button id; 0 to disable
B=3                       #button id; 0 to disable
X=1                       #button id; 0 to disable
Y=4                       #button id; 0 to disable
Left Shoulder=5           #button id; 0 to disable
Right Shoulder=6          #button id; 0 to disable
Back=9                    #button id; 0 to disable
Start=10                  #button id; 0 to disable
Left Thumb=11             #button id; 0 to disable
Right Thumb=12            #button id; 0 to disable
TriggerDeadzone=5         #use 0 to 255; default 0; add deadzone to trigger
Left Trigger=x4           #button id; precede with 'a' for an axis; 's' for a slider; 'x' for a half range axis; 'h' for half slider; use '-' to invert ie. x-2;
Right Trigger=x5          #button id; precede with 'a' for an axis; 's' for a slider; 'x' for a half range axis; 'h' for half slider; use '-' to invert ie. x-2;
UseForceFeedback=1        #use 0 to 1; default 0
SwapMotor=0               #use 0 to 1; default 0
ForcePercent=100          #use 0 to 100; default 100
ControllerType=1          #GAMEPAD 1; WHEEL 2; STICK 3; FLIGHT_SICK 4; DANCE_PAD 5; GUITAR 6; DRUM_KIT 8;   //WILDS
AxisToDPad=0              #Use Axis to control DPad (0 disabled, 1 enabled)                                 //WILDS
AxisToDPadDeadZone=256    #Dead zone for Axis                                                               //WILDS
AxisToDPadOffset=0        #                                                                                 //WILDS
POVXReverse=0             #Reverse POV Up/Down
POVYReverse=0             #Reverse POV Left/Right

[PAD2]
Index=1                   #controller index in system game controllers list; 0 is first; -1 to ignore this pad
Native=0                  #experimental native mode, calls system xinput1_3.dll to support xinput compatible controller together with emulated
VID=0x0                   #controller VID
PID=0x0                   #controller PID
Left Analog X=1           #axis index; use - to invert; precede with 's' for a slider eg; s-1; 7 to disable
Left Analog Y=-2          #axis index; use - to invert; precede with 's' for a slider eg; s-1; 7 to disable
Right Analog X=3          #axis index; use - to invert; precede with 's' for a slider eg; s-1; 7 to disable
Right Analog Y=-6         #axis index; use - to invert; precede with 's' for a slider eg; s-1; 7 to disable
Left Analog X+ Button=0   #button id; 0 to disable
Left Analog X- Button=0   #button id; 0 to disable
Left Analog Y+ Button=0   #button id; 0 to disable
Left Analog Y- Button=0   #button id; 0 to disable
Right Analog X+ Button=0  #button id; 0 to disable
Right Analog X- Button=0  #button id; 0 to disable
Right Analog Y+ Button=0  #button id; 0 to disable
Right Analog Y- Button=0  #button id; 0 to disable
D-pad POV=1               #POV index; 0 to disable
D-pad Up=0                #button id; 0 to disable
D-pad Down=0              #button id; 0 to disable
D-pad Left=0              #button id; 0 to disable
D-pad Right=0             #button id; 0 to disable
A=2                       #button id; 0 to disable
B=3                       #button id; 0 to disable
X=1                       #button id; 0 to disable
Y=4                       #button id; 0 to disable
Left Shoulder=5           #button id; 0 to disable
Right Shoulder=6          #button id; 0 to disable
Back=9                    #button id; 0 to disable
Start=10                  #button id; 0 to disable
Left Thumb=11             #button id; 0 to disable
Right Thumb=12            #button id; 0 to disable
TriggerDeadzone=5         #use 0 to 255; default 0; add deadzone to trigger
Left Trigger=x4           #button id; precede with 'a' for an axis; 's' for a slider; 'x' for a half range axis; 'h' for half slider; use '-' to invert ie. x-2;
Right Trigger=x5          #button id; precede with 'a' for an axis; 's' for a slider; 'x' for a half range axis; 'h' for half slider; use '-' to invert ie. x-2;
UseForceFeedback=1        #use 0 to 1; default 0
SwapMotor=0               #use 0 to 1; default 0
ForcePercent=100          #use 0 to 100; default 100
ControllerType=1          #GAMEPAD 1; WHEEL 2; STICK 3; FLIGHT_SICK 4; DANCE_PAD 5; GUITAR 6; DRUM_KIT 8;   //WILDS
AxisToDPad=0              #Use Axis to control DPad (0 disabled, 1 enabled)                                 //WILDS
AxisToDPadDeadZone=256    #Dead zone for Axis                                                               //WILDS
AxisToDPadOffset=0        #                                                                                 //WILDS
POVXReverse=0             #Reverse POV Up/Down
POVYReverse=0             #Reverse POV Left/Right

[PAD3]
Index=2                   #controller index in system game controllers list; 0 is first; -1 to ignore this pad
Native=0                  #experimental native mode, calls system xinput1_3.dll to support xinput compatible controller together with emulated
VID=0x0                   #controller VID
PID=0x0                   #controller PID
Left Analog X=1           #axis index; use - to invert; precede with 's' for a slider eg; s-1; 7 to disable
Left Analog Y=-2          #axis index; use - to invert; precede with 's' for a slider eg; s-1; 7 to disable
Right Analog X=3          #axis index; use - to invert; precede with 's' for a slider eg; s-1; 7 to disable
Right Analog Y=-6         #axis index; use - to invert; precede with 's' for a slider eg; s-1; 7 to disable
Left Analog X+ Button=0   #button id; 0 to disable
Left Analog X- Button=0   #button id; 0 to disable
Left Analog Y+ Button=0   #button id; 0 to disable
Left Analog Y- Button=0   #button id; 0 to disable
Right Analog X+ Button=0  #button id; 0 to disable
Right Analog X- Button=0  #button id; 0 to disable
Right Analog Y+ Button=0  #button id; 0 to disable
Right Analog Y- Button=0  #button id; 0 to disable
D-pad POV=1               #POV index; 0 to disable
D-pad Up=0                #button id; 0 to disable
D-pad Down=0              #button id; 0 to disable
D-pad Left=0              #button id; 0 to disable
D-pad Right=0             #button id; 0 to disable
A=2                       #button id; 0 to disable
B=3                       #button id; 0 to disable
X=1                       #button id; 0 to disable
Y=4                       #button id; 0 to disable
Left Shoulder=5           #button id; 0 to disable
Right Shoulder=6          #button id; 0 to disable
Back=9                    #button id; 0 to disable
Start=10                  #button id; 0 to disable
Left Thumb=11             #button id; 0 to disable
Right Thumb=12            #button id; 0 to disable
TriggerDeadzone=5         #use 0 to 255; default 0; add deadzone to trigger
Left Trigger=x4           #button id; precede with 'a' for an axis; 's' for a slider; 'x' for a half range axis; 'h' for half slider; use '-' to invert ie. x-2;
Right Trigger=x5          #button id; precede with 'a' for an axis; 's' for a slider; 'x' for a half range axis; 'h' for half slider; use '-' to invert ie. x-2;
UseForceFeedback=1        #use 0 to 1; default 0
SwapMotor=0               #use 0 to 1; default 0
ForcePercent=100          #use 0 to 100; default 100
ControllerType=1          #GAMEPAD 1; WHEEL 2; STICK 3; FLIGHT_SICK 4; DANCE_PAD 5; GUITAR 6; DRUM_KIT 8;   //WILDS
AxisToDPad=0              #Use Axis to control DPad (0 disabled, 1 enabled)                                 //WILDS
AxisToDPadDeadZone=256    #Dead zone for Axis                                                               //WILDS
AxisToDPadOffset=0        #                                                                                 //WILDS
POVXReverse=0             #Reverse POV Up/Down
POVYReverse=0             #Reverse POV Left/Right

[PAD4]
Index=3                   #controller index in system game controllers list; 0 is first; -1 to ignore this pad
Native=0                  #experimental native mode, calls system xinput1_3.dll to support xinput compatible controller together with emulated
VID=0x0                   #controller VID
PID=0x0                   #controller PID
Left Analog X=1           #axis index; use - to invert; precede with 's' for a slider eg; s-1; 7 to disable
Left Analog Y=-2          #axis index; use - to invert; precede with 's' for a slider eg; s-1; 7 to disable
Right Analog X=3          #axis index; use - to invert; precede with 's' for a slider eg; s-1; 7 to disable
Right Analog Y=-6         #axis index; use - to invert; precede with 's' for a slider eg; s-1; 7 to disable
Left Analog X+ Button=0   #button id; 0 to disable
Left Analog X- Button=0   #button id; 0 to disable
Left Analog Y+ Button=0   #button id; 0 to disable
Left Analog Y- Button=0   #button id; 0 to disable
Right Analog X+ Button=0  #button id; 0 to disable
Right Analog X- Button=0  #button id; 0 to disable
Right Analog Y+ Button=0  #button id; 0 to disable
Right Analog Y- Button=0  #button id; 0 to disable
D-pad POV=1               #POV index; 0 to disable
D-pad Up=0                #button id; 0 to disable
D-pad Down=0              #button id; 0 to disable
D-pad Left=0              #button id; 0 to disable
D-pad Right=0             #button id; 0 to disable
A=2                       #button id; 0 to disable
B=3                       #button id; 0 to disable
X=1                       #button id; 0 to disable
Y=4                       #button id; 0 to disable
Left Shoulder=5           #button id; 0 to disable
Right Shoulder=6          #button id; 0 to disable
Back=9                    #button id; 0 to disable
Start=10                  #button id; 0 to disable
Left Thumb=11             #button id; 0 to disable
Right Thumb=12            #button id; 0 to disable
TriggerDeadzone=5         #use 0 to 255; default 0; add deadzone to trigger
Left Trigger=x4           #button id; precede with 'a' for an axis; 's' for a slider; 'x' for a half range axis; 'h' for half slider; use '-' to invert ie. x-2;
Right Trigger=x5          #button id; precede with 'a' for an axis; 's' for a slider; 'x' for a half range axis; 'h' for half slider; use '-' to invert ie. x-2;
UseForceFeedback=1        #use 0 to 1; default 0
SwapMotor=0               #use 0 to 1; default 0
ForcePercent=100          #use 0 to 100; default 100
ControllerType=1          #GAMEPAD 1; WHEEL 2; STICK 3; FLIGHT_SICK 4; DANCE_PAD 5; GUITAR 6; DRUM_KIT 8;   //WILDS
AxisToDPad=0              #Use Axis to control DPad (0 disabled, 1 enabled)                                 //WILDS
AxisToDPadDeadZone=256    #Dead zone for Axis                                                               //WILDS
AxisToDPadOffset=0        #                                                                                 //WILDS
POVXReverse=0             #Reverse POV Up/Down
POVYReverse=0             #Reverse POV Left/Right


. . . Oh, and for PPjoy settings, I used the defaults (8 axes, 16 Buttons, and 2 POV hats).
That's about it for this script. As always, feel to modify and critique as you see fit. ;)
User avatar
Shinesprite
 
Posts: 29
Joined: Sat 19 May, 2012 7:33 am

Re: Wiimote Script Compilation

Postby shermanpk » Fri 12 Oct, 2012 9:11 pm

I have a few scripts I wrote for Wiimotes playing PJ64 via PPJoy. Should I share?
shermanpk
 
Posts: 8
Joined: Thu 10 Nov, 2011 2:26 pm

Re: Wiimote Script Compilation

Postby Shinesprite » Mon 02 Sep, 2013 6:55 am

@shermanpk Sure, why not? ;)
User avatar
Shinesprite
 
Posts: 29
Joined: Sat 19 May, 2012 7:33 am

Re: Wiimote Script Compilation

Postby Shinesprite » Sat 07 Sep, 2013 12:31 pm

Hey guys, I know, it's been a while, but I just thought I'd make a quick post for using a classic controller with Sonic Generations.
I am aware of the game's infamous sidestepping glitch, so, with the help of YouTuber InauspiciousGamer, and a program known of as x360ce, I was able to circumvent the issue.

If you are following along, you will also need to use PPJoy, and (of course) GlovePIE.

Without further adieu, here's my fairly general script classic-controller script:
Code: Select all
/*
        Sonic Generations               v 2013.09.02
        by Shinesprite - adapted from WiiAreVenom's Classic Controller as xbox360 Controller
*/

    //Joystick mapping
    PPJoy.Analog0 = Deadzone(Wiimote1.Classic.Joy1X)
    PPJoy.Analog1 = Deadzone(Wiimote1.Classic.Joy1Y)
    PPJoy.Analog2 = Deadzone(Wiimote1.Classic.Joy2X)
    PPJoy.Analog3 = Deadzone(Wiimote1.Classic.Joy2Y)

    /* L\R Analog triggers
     * (with more robust deadzones to accomodate controller wear)*/

    if (Wiimote1.Classic.R  >= 0.075)
       PPJoy.Analog5 = Deadzone(Smooth(Wiimote1.Classic.L))
    else
       PPJoy.Analog5 = 0.0
    endif

    if (Wiimote1.Classic.R  >= 0.075)
       PPJoy.Analog6 = Deadzone(Smooth(Wiimote1.Classic.R))
    else
       PPJoy.Analog6 = 0.0
    endif

    //Face buttons
    PPJoy.Digital0 = Wiimote1.Classic.b
    PPJoy.Digital1 = Wiimote1.Classic.a
    PPJoy.Digital2 = Wiimote1.Classic.y
    PPJoy.Digital3 = Wiimote1.Classic.x

    //D-Pad as functional buttons in-game
    PPJoy.Digital16 = Wiimote1.Classic.Up
    PPJoy.Digital18 = Wiimote1.Classic.Left
    PPJoy.Digital17 = Wiimote1.Classic.Down
    PPJoy.Digital19 = Wiimote1.Classic.Right

    //Back/Select and Start Buttons
    PPJoy.Digital8 = Wiimote1.Classic.Minus
    PPJoy.Digital9 = Wiimote1.Classic.Plus

    //Hold HOME and press ZL or ZR to activate the joystick buttons
    if wiimote1.Classic.home = true
       PPJoy.digital4 = false
       PPJoy.digital5 = false
       PPJoy.digital10 = Wiimote1.Classic.ZL
       PPJoy.digital11 = wiimote1.Classic.ZR
    else
       PPJoy.digital4 = wiimote1.Classic.ZL
       PPJoy.digital5 = wiimote1.Classic.ZR
       PPJoy.digital10 = false
       PPJoy.digital11 = false
    endif


For PPjoy, just create a virtual controller from the default settings.

Lastly, you will need to use a mixture of x360ce 2.1.2.191 and 2.0.2.163. They both have their advantages and drawbacks, so I will describe them in further detail.
2.0.2.163 - works with Sonic Generations, but unfortunately has a narrow range of supported devices/controllers
2.1.2.191 - works with more devices/controllers (including PPJoy virtual controllers), but breaks support for Sonic Generations

Start by unzipping the x360ceApp-2.0.2.163.zip file to the Sonic Generations game root folder (I know that x360ce has other folder options, but for the sake of simplicity, we'll use this directory). On a Windows 7 system running the Steam version of the game, it will be something like: C:\Program Files (x86)\Steam\steamapps\common\sonic generations\
Image

Next,launch x360ce.exe and let it generate the necessary support files. You'll probably notice that your PPJoy virtual controller was not detected.
Image

After that, close the application and delete the x360ce.exe and all generated files EXCEPT for the newly created xinput1_3.dll (this was the reason for using x360ce 2.0.2.163).
Image

Then, unzip the x360ce.App-2.1.2.191.zip into the same folder, launch x360ce.exe, and decline the popup to update xinput1_3.dll (you may generate/update any other files if you are prompted to do so).
Image

You should then be notified that your PPjoy (and whatever other controllers you have connected) have been found. Click through, let it do the search, and click finish when prompted.
Image

You should now have a properly configured installation of x360ce that will will auto-execute when you launch Sonic Generations. Just configure the controller (you can see mine below), save, close the application, and you'll be all set! ;)
Image
User avatar
Shinesprite
 
Posts: 29
Joined: Sat 19 May, 2012 7:33 am


Return to Nintendo Wii Remote

Who is online

Users browsing this forum: Bing [Bot] and 1 guest