WiiLi Wiki frontpage Include your post in the News Get links Hoteles Quito
WiiLi.org Forum Index WiiLi.org
a new revolution
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

flight joystick?

 
Post new topic   Reply to topic    WiiLi.org Forum Index -> Wii Scripts
View previous topic :: View next topic  
Author Message
ww2airborne



Joined: 07 Feb 2007
Posts: 10

Digg It
PostPosted: Mon Mar 12, 2007 7:52 pm    Post subject: flight joystick?

im somewhat (OK very) new to GlovePie
i was wondering if there a good code already made for flight type joystick
iv been playing around a little bit with it but its going to take a newbie like me a while to get the code solid Sad

thanks for the help
Mike Very Happy
Back to top
View user's profile Send private message
US of Anarchy



Joined: 13 Dec 2006
Posts: 41

Digg It
PostPosted: Mon Mar 12, 2007 8:38 pm    Post subject:

You know, I was thinking of making one of these. I'll post this in my own topic as well, but I think this would work as long as you want to hold the wiimote vertically (which is what I gathered)

Code:
//Adjusts mouse sensitivity
var.sensitivity = 10

//Joystick controls
mouse.cursorposx = mouse.cursorposx - wiimote.gx * var.sensitivity
mouse.cursorposy = mouse.cursorposy + wiimote.gy * var.sensitivity
Back to top
View user's profile Send private message Send e-mail
ww2airborne



Joined: 07 Feb 2007
Posts: 10

Digg It
PostPosted: Mon Mar 12, 2007 10:12 pm    Post subject:

wow thanks i was making lots of IF statements
but three lines of code makes it so easy
Back to top
View user's profile Send private message
almostconnected



Joined: 15 Feb 2007
Posts: 13
Location: Florida

Digg It
PostPosted: Tue Mar 13, 2007 12:09 am    Post subject:

I made this one for Star Fox 64. It also works surprisingly well for Mario 64. Point the Wiimote up so that the D-Pad is on the top and facing you. You may need to calculate dead zone.

Code:
var.Range = 30 // max degrees rotated from center position
var.Norm  = sqrt (Wiimote.gx*Wiimote.gx + Wiimote.gy*Wiimote.gy + Wiimote.gz*Wiimote.gz)

PPJoy.Analog0 = EnsureMapRange (asin (Wiimote.gx / var.Norm), var.Range, -var.Range, -1, 1)
PPJoy.Analog1 = EnsureMapRange (asin (Wiimote.gy / var.Norm), var.Range, -var.Range, -1, 1)

debug = PPJoy.Analog0 + " " + PPJoy.Analog1
Back to top
View user's profile Send private message Visit poster's website
kunalkunal2



Joined: 13 Dec 2006
Posts: 279

Digg It
PostPosted: Tue Mar 13, 2007 12:21 am    Post subject:

almostconnected wrote:
I made this one for Star Fox 64. It also works surprisingly well for Mario 64. Point the Wiimote up so that the D-Pad is on the top and facing you. You may need to calculate dead zone.

Code:
var.Range = 30 // max degrees rotated from center position
var.Norm  = sqrt (Wiimote.gx*Wiimote.gx + Wiimote.gy*Wiimote.gy + Wiimote.gz*Wiimote.gz)

PPJoy.Analog0 = EnsureMapRange (asin (Wiimote.gx / var.Norm), var.Range, -var.Range, -1, 1)
PPJoy.Analog1 = EnsureMapRange (asin (Wiimote.gy / var.Norm), var.Range, -var.Range, -1, 1)

debug = PPJoy.Analog0 + " " + PPJoy.Analog1

Yea, I like that code. Though the thing is that it is harder to control because there is nothing on the bottom of the wiimote that will give gravity, like in the arcades.
_________________
Check out my collection of my wii script's
freewebs.com/kunalkunal2
Back to top
View user's profile Send private message
almostconnected



Joined: 15 Feb 2007
Posts: 13
Location: Florida

Digg It
PostPosted: Tue Mar 13, 2007 10:22 pm    Post subject:

kunalkunal2 wrote:
...
Yea, I like that code. Though the thing is that it is harder to control because there is nothing on the bottom of the wiimote that will give gravity, like in the arcades.


Yeah, I prefer using the nunchuk's analog stick, but this is a good alternative for people who don't have one. It helps to keep the bottom of the wiimote on a rubbery surface like a mouse pad. You can also hold the Wiimote with two hands (light saber style) which also gives you thumb access to the 1 and 2 buttons.
Back to top
View user's profile Send private message Visit poster's website
Endrick



Joined: 30 Mar 2007
Posts: 7

Digg It
PostPosted: Mon Apr 02, 2007 2:39 am    Post subject:

I've been working on this for a few days off and on, as set up this rocks as a flight sim stick.

Use PPJoy

Set up analog0 and analog1 as x and y
set up analog2 as a throttle
set up analog5 as rudder pedals

The wiimote is your joystick, hold it upright at a slight forward angle, it'll be reading center when LED 1 and 2 Are on.

Hold the nunchuk sideways in your left hand, your thumb should rest on the c and z buttons or joystick. This is your throttle, tilting it away from you 90 degrees is max throttle, tilting it level (or further toward you) is min throttle.

Since you're holding the nunchuk sideways, the nunchuk's joystick is your rudder control. Left (back) and right (forward).

Set up the buttons how you like.




Code:


// 3 Joysticks of freedom created by Endrick
// This started as the Generic Joystick Driver by vkapadia

// This utility works with the nunchuk, the chuck joystick, and the wiimote to
// provide up to 6 analog axes and 13 useable buttons. to PPJoy About the
// only things missing are IR and Accel functions.  This is set up as a
// decent starting point for all sorts of uses.  Please feel free to use,
// correct, update, change, obliterate, or abuse this script for any
// purpose you wish to put it to.

// The axis are set up to output to PPJoy as such:
// Analog 0 and 1 are for the wiimote tilt regardless of mode
// Analog 2 and 3 are for the nunchuk tilt
// Analog 4 and 5 are for the nunchuk joystick
// Any changes manual changes to this can be found near the bottom of
// the script.

// If the wiimote and chuck are outputting center (including dead zone) then
// All 4 LEDs will be lit. The first 2 LEDs represent the x, and y or z axis
// depending on which mode you're using. The second 2 LEDs represent x and z
// axis on the nunchuk

// The buttons are set up to output to PPJoy as such:

PPJoy.Digital1 = wiimote.Up
PPJoy.Digital2 = wiimote.Down
PPJoy.Digital3 = wiimote.Left
PPJoy.Digital4 = wiimote.Right
PPJoy.Digital5 = Wiimote.A
PPJoy.Digital6 = Wiimote.B
PPJoy.Digital7 = Wiimote.Minus
PPJoy.Digital8 = Wiimote.Plus
PPJoy.Digital9 = Wiimote.Home
PPJoy.Digital10 = wiimote.One
PPJoy.Digital11 = wiimote.Two

PPJoy.Digital12 = Wiimote.Nunchuk.CButton
PPJoy.Digital13 = Wiimote.Nunchuk.ZButton

// *************************************************************
// *** Wiimote Mode Select ***

// These are the 4 modes I have set up:

// 0 = off, does not use forces from the wiimote
// 1 = normal mode, hold the wiimote with the D pad facing the screen
// 2 = steering mode, hold the wiimote with the D pad by your left
//     hand and steer like excite truck
// 3 = joystick mode, hold the wiimote upright like a joystick

var.wiimote.mode = 3  //set to 0, 1, 2 or 3

// ************************************************************
// *** Trim values ***
// This is the wiimote and chuck trimming area. Probably not needed. When
// the wiimote and chuck are leveled these will be near 0 anyway.  Any variance
// will be kicked out by the deadzone.  Y is set at -8 for stick mode so that
// the stick will be held at a slightly forward angle at 0 making it easy.
// to use the D pad as a hat switch.

// trim for wiimote
var.xtrim = 0 // set from -10 to 10
var.ytrim = -8 // set from -10 to 10
var.ztrim = 0 // set from -10 to 10

// trim for nunchuck
var.chuck.xtrim = 0 // set from -10 to 10
var.chuck.ztrim = 0 // set from -10 to 10
//***********************************************************
// *** Dead zone settings ***
// These can be adjusted from 0 to 25, 4 seemed to work well for me.
// Note: output starts at the deadzone value, so the deadzone value
// is the lowest value that will be seen by PPjoy. If it is set too high
// you lose any fine control.  The joystick on the chuck doesn't really
// need a dead zone so none was set.

var.deadzone = 4  // set from 2 to 10
var.chuck.deadzone = 4 // set from 2 to 10

//***********************************************************
// *** Max/Min zone settings for wiimote ***
// The value of the raw wiimote setting will be capped at these levels.
// 25 / -25 is the max / min value of laying the wiimote on its side,
// front, or bottom.

var.xMax = 17  // Maximum X value, set from -25 to 25
var.xMin = -17 // Minimum X value, set from -25 to 25

var.yMax = 17  // Maximum Y value, set from -25 to 25
var.yMin = -17 // Minimum Y value, set from -25 to 25

var.zMax = 25  // Maximum Z value, set from -25 to 25
var.zMin = -25 // Minimum Z value, set from -25 to 25

// Max/Min zone setting for nunchuk
var.chuck.xMax = 23  // Maximum X value for chuck, set from -25 to 25
var.chuck.xMin = 0 // Minimum X value for chuck, set from -25 to 25

var.chuck.zMax = 25  // Maximum Z for chuck, set from -25 to 25
var.chuck.zMin = -25 // Minimum Z for chuck, set from -25 to 25
//***********************************************************
//Main code below

// sets the trim values

var.xRot = Wiimote.RawForceX + var.xtrim
var.yRot = Wiimote.Rawforcey + var.ytrim
var.zRot = Wiimote.RawForceZ + var.ztrim
var.chuck.xRot = Wiimote.Nunchuk.RawForceX  + var.chuck.xtrim * 2
var.chuck.zRot = Wiimote.Nunchuk.RawForceZ  + var.chuck.ztrim * 2

// sets the dead zone for the wiimote
// if the current reading, including trim is less than the deadzone
// then it will return a 0 value to ppjoy

if abs(var.xRot)< var.deadzone
   var.xRotDead = 0.00
else
    var.xRotDead = var.xRot
endif

if abs(var.yRot)< var.deadzone
   var.yRotDead = 0.00
else
    var.yRotDead = var.yRot
endif

if abs(var.zRot)< var.deadzone
   var.zRotDead = 0.00
else
    var.zRotDead = var.zRot
endif

if abs(var.zRot)< var.deadzone
   var.zRotDead = 0.00
else
    var.zRotDead = var.zRot
endif

// sets the dead zone for the nunchuck

if abs(var.chuck.xRot)< var.chuck.deadzone * 2
   var.chuck.xRotDead = 0.00
   wiimote.led3 = 1
else
    var.chuck.xRotDead = var.chuck.xRot
    wiimote.led3 = 0
endif

if abs(var.chuck.zRot)< var.chuck.deadzone * 2
   var.chuck.zRotDead = 0.00
   wiimote.led4 = 1
else
    var.chuck.zRotDead = var.chuck.zRot
    wiimote.led4 = 0
endif

if var.xRotdead > var.xMax
   var.xRotDead = var.xMax
endif
if var.xRotdead < var.xMin
   var.xRotDead = var.xMin
endif

if var.yRotdead > var.yMax
   var.yRotDead = var.yMax
endif
if var.yRotdead < var.yMin
   var.yRotDead = var.yMin
endif

if var.zRotdead > var.zMax
   var.zRotDead = var.zMax
endif
if var.zRotdead < var.zMin
   var.zRotDead = var.zMin
endif

if var.chuck.xRotdead > var.chuck.xMax * 2
   var.chuck.xRotDead = var.chuck.xMax * 2
endif
if var.chuck.xRotdead < var.chuck.xMin * 2
   var.chuck.xRotDead = var.chuck.xMin * 2
endif

if var.chuck.zRotdead > var.chuck.zMax * 2
   var.chuck.zRotDead = var.chuck.zMax * 2
endif
if var.chuck.zRotdead < var.chuck.zMin * 2
   var.chuck.zRotDead = var.chuck.zMin * 2
endif


// Wiimote value is divided by 25 to create -1/1 variance
// each set is a different mode setting

if var.wiimote.mode = 1
PPJoy.Analog0 = -var.xRotDead / 25
PPJoy.Analog1 = var.zRotDead / 25
    If var.xRotDead = 0.00
       wiimote.led1 = 1
       else
       wiimote.led1 = 0
    endif
    If var.zRotDead = 0.00
       wiimote.led2 = 1
       else
       wiimote.led2 = 0
    endif
endif

if var.wiimote.mode = 2
PPJoy.Analog1 = var.xRotDead / 25
PPJoy.Analog0 = var.zRotDead / 25
    If var.xRotDead = 0.00
       wiimote.led1 = 1
       else
       wiimote.led1 = 0
    endif
    If var.zRotDead = 0.00
       wiimote.led2 = 1
       else
       wiimote.led2 = 0
    endif
endif

if var.wiimote.mode = 3
PPJoy.Analog0 = -var.xRotDead / 25
PPJoy.Analog1 = -var.yRotDead / 25
    If var.xRotDead = 0.00
       wiimote.led1 = 1
       else
       wiimote.led1 = 0
    endif
    If var.yRotDead = 0.00
       wiimote.led2 = 1
       else
       wiimote.led2 = 0
    endif
endif

// Nunchuk value is divided by 50 to create -1/1 variance
PPJoy.Analog2 = -var.chuck.xRotDead / 50
PPJoy.Analog3 = var.chuck.zRotDead / 50

// Nunchuk's Joystick
PPJoy.Analog4 = MapRange(Wiimote.Nunchuk.JoyX, -1,1, -1,1)
PPJoy.Analog5 = - MapRange(Wiimote.Nunchuk.JoyY, -1,1, -1,1)

// Debug window output
debug = "wiimote X= " + var.xRotDead + " y= " + var.yRotDead + " z= " + var.zRotDead + " |  chuck X= " + var.chuck.xRotDead / 2 + " Z= " + var.chuck.zRotDead / 2


[/code]
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    WiiLi.org Forum Index -> Wii Scripts All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group