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 

Wii mote and Nunchuck Scripts

 
Post new topic   Reply to topic    WiiLi.org Forum Index -> Wii Remote and Nunchuck
View previous topic :: View next topic  
Author Message
chubbedup



Joined: 25 Dec 2006
Posts: 1

Digg It
PostPosted: Mon Dec 25, 2006 11:51 pm    Post subject: Wii mote and Nunchuck Scripts

hey i'm new to glovepie, and i need a good script for the wii mote+nunchuck. I'm planning on using the wii mote to play first person shooters like half-life 2 or halo. I want the Wii mote to be the mouse, but still be able to use all the buttons. It also needs to use IR, as i have one of the wireless wii sensor bars. I want the nunchuck analog stick to be the wasd keys, and if u can get the the c button and trigger on the nunchuck to be some random letter on the keyboard i could map a command to in a game. Can anyone one help me?
Back to top
View user's profile Send private message
TweaK



Joined: 24 Dec 2006
Posts: 57

Digg It
PostPosted: Tue Dec 26, 2006 12:04 am    Post subject:

You're making pretty specific demands. If this isn't out yet already, you're going to have to program it yourself probably.
Back to top
View user's profile Send private message
Marco Ceppi



Joined: 21 Dec 2006
Posts: 51

Digg It
PostPosted: Tue Dec 26, 2006 12:12 am    Post subject:

I would love to post my script I just finished an IR version for HL2 all buttons mapped. I've got a video of my playing, images of button maps, and the glovepie code. However it thinks I'm posting URLs Even when I try my hardest to mask them.


Sorry.
Back to top
View user's profile Send private message Visit poster's website AIM Address
Marco Ceppi



Joined: 21 Dec 2006
Posts: 51

Digg It
PostPosted: Tue Dec 26, 2006 12:24 am    Post subject:

I'm finishing up my script, still some buggies in it, but here it is:

Code:
/**************************************************
 *                       HL2.pie
 *                     ----------
 *     BY:  Marco Ceppi <marco at ilmbsr dot com>
 *    FOR:  GlovePIE 0.28+
 *   DATE:  Thursday Dec. 21, 2006
 * RIGHTS:  Released under GNU License. Feel free
 *          to edit and use to your liking. For all
 *          to enjoy. Marco Ceppi.
 *
 **************************************************/

// Make sure the debug window reads 0,28,0
var.dummy = wiimote.rawforcex

// Get Nunchuk axis locations. Range is -0.99 to 0.99
// Multiply by 100 to get whole numbers. (-99 to 99)
var.xNunchuk = Wiimote.Nunchuk.JoyX * 100
var.yNunchuk = Wiimote.Nunchuk.JoyY * 100
// X/Y offsets. If it's too sensative then make the numbers larger.
var.xOff = 5
var.yOff = 5
// Acceleration ammount for Nunchuk Reload (default = 17.0)
var.nunchukAccX = 19.0
// Blink rate for battery check.
var.Blink = 500ms
// Mouse IR Offsets
var.xtrim = 2
var.ytrim = -28
var.ztrim = 4
var.deadzone = 5

//var.sensor = true

//Simple debugs.
//debug = 'N:' + Wiimote.Nunchuk.JoyX + 'N:' + Wiimote.Nunchuk.JoyY + 'X:' + var.xRot + ', ' + 'Y:' + var.yRot + ', ' + 'Z:' + var.zRot

if var.xNunchuk > var.xOff and var.yNunchuk > var.yOff then
   key.w = false
   key.a = false
   key.s = true
   key.d = true
   debug = 'SE'
else if var.xNunchuk > var.xOff and var.yNunchuk < -var.yOff then
   key.w = true
   key.a = false
   key.s = false
   key.d = true
   debug = 'NE'
else if var.xNunchuk < -var.xOff and var.yNunchuk < -var.yOff then
   key.w = true
   key.a = true
   key.s = false
   key.d = false
   debug = 'NW'
else if var.xNunchuk < -var.xOff and var.yNunchuk > var.yOff then
   key.w = false
   key.a = true
   key.s = true
   key.d = false
   debug = 'SW'
else if var.xNunchuk > var.xOff then
   key.w = false
   key.a = false
   key.s = false
   key.d = true
   debug = 'Right'
else if var.xNunchuk < -var.xOff then
   key.w = false
   key.a = true
   key.s = false
   key.d = false
   debug = 'Left'
else if var.yNunchuk < -var.yOff then
   key.w = true
   key.a = false
   key.s = false
   key.d = false
   debug = 'Up'
else if var.yNunchuk > var.yOff then
   key.w = false
   key.a = false
   key.s = true
   key.d = false
   debug = 'Down'
else if var.xNunchuk > -var.xOff and < var.xOff and var.yNunchuk < var.yOff and > -var.yOff then
   key.w = false
   key.a = false
   key.s = false
   key.d = false
   debug = 'Khai sucks'
else
   key.w = false
   key.a = false
   key.s = false
   key.d = false
   debug = 'Khai sucks'
endif

//
// Game buttons.
//
// Wiimote
key.Shift = Wiimote.Up
mouse.WheelUp = Wiimote.Left
mouse.WheelDown = Wiimote.Right
key.e = Wiimote.Down

mouse.LeftButton = Wiimote.B
Wiimote.Rumble = Wiimote.B
mouse.RightButton = Wiimote.A

key.q = Wiimote.Minus
key.escape = Wiimote.Home
key.f = Wiimote.Plus

key.One = Wiimote.One
// Wiimote.Two handles Battery.


//
// Nunchuk
//
key.space = Wiimote.Nunchuk.ZButton
key.Ctrl = Wiimote.Nunchuk.CButton

//
// Reload
//
if Wiimote.Nunchuk.RawAccX > var.nunchukAccX or < -var.nunchukAccX then
key.r = true
key.r = false
debug = 'VROOM!'
endif

Wiimote.leds = 0

//
// Battery Check!
//
// A full battery gives 0xC0 (192)
if Wiimote.Two == true then
   var.Batt = wiimote.Battery / 48

   if true then
      wait 5 seconds
      // it sends an instruction that tells the Wiimote to actually
      // send the report.
      Wiimote.Report15 = 0x80 | Int(wiimote.Rumble)
   endif

   // Display the battery level of your wiimote using the four LEDs on the bottom.
   // Battery level is displayed in four levels increasing to the right, like a cell
   // phone battery gauge. As the battery gets close to the next level down, the LED
   // for the current level will blink.

   debug = "Battery level: " + 100*48*var.Batt/192 + "%"
   if 0 <= var.Batt <= 0.25 then
      Wiimote.Leds = 1
      wait var.Blink
      Wiimote.Leds = 0
      wait var.Blink
   elseif 0.25 < var.Batt<=1 then
      Wiimote.Leds = 1
   elseif 1 < var.Batt<=1.25 then
      Wiimote.Leds = 3
      wait var.Blink
      Wiimote.Leds = 1
      wait var.Blink
   elseif 1.25 < var.Batt<=2 then
      Wiimote.Leds = 3
   elseif 2 < var.Batt<=2.25 then
      Wiimote.Leds = 7
      wait var.Blink
      Wiimote.Leds = 3
      wait var.Blink
   elseif 2.25 < var.Batt<=3 then
      Wiimote.Leds = 7
   elseif 3 < var.Batt<=3.25 then
      Wiimote.Leds = 15
      wait var.Blink
      Wiimote.Leds = 7
      wait var.Blink
   elseif 3.25 < var.Batt<=4 then
      Wiimote.Leds = 15
   else
      Wiimote.Leds = 0
   endif
endif

//
// Mouse IR
//
var.accx = wiimote.RawForceX + var.xtrim
var.accy = wiimote.RawForceY + var.ytrim
var.accz = wiimote.RawForceZ + var.ztrim

if wiimote.dot1vis and wiimote.dot2vis then

  if var.accy > -7 then
    var.orientation = 0
  elseif var.accy > -45 then
    if var.accx < 0 then
      var.orientation = 3
    else
      var.orientation = 1
    endif
  else
    var.orientation = 2
  endif

  if var.leftpoint = 0 then
    if var.orientation = 0 then
      if wiimote.dot1x < wiimote.dot2x then
        var.leftpoint = 1
      else
        var.leftpoint = 2
      endif
    endif
    if var.orientation = 1 then
      if wiimote.dot1y > wiimote.dot2y then
        var.leftpoint = 1
      else
        var.leftpoint = 2
      endif
    endif
    if var.orientation = 2 then
      if wiimote.dot1x > wiimote.dot2x then
        var.leftpoint = 1
      else
        var.leftpoint = 2
      endif
    endif
    if var.orientation = 3 then
      if wiimote.dot1y < wiimote.dot2y then
        var.leftpoint = 1
      else
        var.leftpoint = 2
      endif
    endif
  endif

  if var.leftpoint = 1 then
    var.fix1x = wiimote.dot1x
    var.fix1y = wiimote.dot1y
    var.fix2x = wiimote.dot2x
    var.fix2y = wiimote.dot2y
  else
    var.fix1x = wiimote.dot2x
    var.fix1y = wiimote.dot2y
    var.fix2x = wiimote.dot1x
    var.fix2y = wiimote.dot1y
  endif

  var.dx = var.fix2x - var.fix1x
  var.dy = var.fix2y - var.fix1y
  var.cx = (var.fix1x+var.fix2x)/1024.0 - 1
  var.cy = (var.fix1y+var.fix2y)/1024.0 - .75

  var.d = sqrt(var.dx*var.dx+var.dy*var.dy)

  var.dx = var.dx / var.d
  var.dy = var.dy / var.d

  var.ox = -var.dy*var.cy-var.dx*var.cx;
  var.oy = -var.dx*var.cy+var.dy*var.cx;

  var.ax = (var.ox * screen.desktopwidth) + (screen.desktopwidth / 2)
  var.ay = (-var.oy * screen.desktopwidth) + (screen.desktopheight / 2)




  var.dx = var.ax - mouse.cursorposx
  var.dy = var.ay - mouse.cursorposy

  var.d = sqrt((var.dx*var.dx)+(var.dy*var.dy))

  var.a = 180 / (200 + var.d * var.d * var.d * .001)

  if var.d <= var.deadzone then var.a = 1

  //debug = var.d + " " + var.a

  var.finalx = mouse.cursorposx * var.a + var.ax * (1 - var.a)
  var.finaly = mouse.cursorposy * var.a + var.ay * (1 - var.a)


  mouse.cursorposx = var.finalx
  mouse.cursorposy = var.finaly

else

  var.leftpoint = 0

endif



The buttons are mapped to the default HL2 configuration. The mouse is pretty sensative off the bat. In HL2 change the sensativity to the lowest (1.0) for it to somewhat work.

Here are the button maps:

http://www.grapefruitage.com/marco/wiimii/wiitrol.png

and a video:

http://archives.grapefruitage.com/player.php?id=10002


(One day! One day I'll be able to post stuff.)


Marco
Back to top
View user's profile Send private message Visit poster's website AIM Address
Display posts from previous:   
Post new topic   Reply to topic    WiiLi.org Forum Index -> Wii Remote and Nunchuck 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