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 

Download Windows driver here.
Goto page Previous  1, 2, 3 ... 10, 11, 12 ... 22, 23, 24  Next
 
Post new topic   Reply to topic    WiiLi.org Forum Index -> Wii Remote and Nunchuck
View previous topic :: View next topic  
Author Message
Jephthah



Joined: 29 Nov 2006
Posts: 16

Digg It
PostPosted: Mon Dec 04, 2006 8:20 am    Post subject: On-The-Fly Calibration

EDIT - Typo resulting from the forum posting format fixed

Here's a modification of one of the scripts from here.
Tilt up/down/left/right while holding the trigger is mouse control.
A is left-click
DOWN is right-click
The innovation in this script is twofold:
1. It uses a var*var*var/precision control for speed, meaning that there are no thresholds, the more you tilt the controller, the more the mouse moves, and the faster it moves, the faster it accelerates.
2. You can calibrate the rest position, at which the mouse is stationary, and you can make the motions of the mouse more or less precise, without doing any actual coding. Great of all of you out there who have never done a bit of programming.
To calibrate:
Press the Home button. All four LED's should come on, letting you know that the remote is in "calibration mode." From there.
1: make the vertical motion more precise
2: make the vertical motion less precise
+: make the horizontal motion more precise
-: make the horizontal motion less precise
A: Calibrate the remote's default position. Whatever position the remote is in when A is pressed in calibration mode becomes the stationary position for the mouse.
To exit calibration mode, press Home again, and it should go back to 1 led
Two questions/pondering points on which I'd like info...
1. Does anyone know the acceleration equation for MS basic mouse drivers? If we could use this equation for our cursor movement, it would be entirely intuitive, in terms of speed, to anyone who had ever used Windows.
2. While loops seem to make the code execute waaay too quickly, and the minimum movement in mouse.x and mouse.y appears to be one pixel in the current screen resolution. I'm trying to encase the two buttons for left/right click INSIDE my mode1...that way, you could have several different button maps, each corresponding to an led configuration when it's active...but...
if I use if statements, the buttons aren't held down, rather, as the interpreter reaches code that is outside of the block in which the button assignment is made, they are let up, resulting in the mouse buttons being clicked repeatedly. If I use while statements, the cursor control code is too fast, and precision, it seems, is impossible. I've tried introducing waits...but even 1ms makes mouse movement incredibly choppy, at least on my machine. Ideas?

Enjoy!
Jephthah

Code:

/**
Threshold-free Variable Resolution Tilt Configuration for Wiimote Mouse Control.
**/
//Debug variable Display Information
//debug = wiimote.RawForceX+","+wiimote.rawforcey+","+wiimote.rawforcez

//Set the default  calibration
if var.offsets=0
var.xoff=-10
var.yoff=34
var.zoff=-11
var.offsets=1
endif

//code to change the modes
var.modechanged=0
if wiimote.home then
if var.mode==1 && var.modechanged==0 then
var.mode=2
var.modechanged=1
wiimote.leds=15
endif
if var.mode==2&& var.modechanged==0 then
var.mode=1
var.modechanged=1
wiimote.leds=1
endif
wait 200 ms
endif



//Default Resolutions
if var.xres==0 then
   var.xres=350000
   var.yres=250000
endif

//Initialize into mode 1
if var.mode==0
   var.mode=1
   wiimote.leds=1
endif

//button control
Mouse.LeftButton = Wiimote.A
Mouse.RightButton = Wiimote.Down
//cursor control
      if wiimote.B
         var.x = wiimote.RawForceX - var.xoff //trim to 0
         var.y = Wiimote.RawForceY - var.yoff // trim to 0
         var.z = Wiimote.RawForceZ - var.zoff //trim to 0

         mouse.x=mouse.x - var.x*var.x*var.x /var.xres
         mouse.y=mouse.y - var.z*var.z*var.z /var.yres
   endif

endif

//calibration code
if var.mode=2
//Increase Y Precision
   if wiimote.one then
      var.yres=var.yres+100
   endif
//Decrease Y Precision
   if wiimote.two then
      var.yres=var.yres-100
   endif
//Increase X Precision
   if wiimote.Plus then
      var.xres=var.xres+100
   endif
//Decrease X Precision
   if wiimote.minus then
      var.xres= var.xres-100
   endif
//Set Stationary Mouse
   if wiimote.a then
   var.xoff=wiimote.rawforcex
   var.yoff=wiimote.rawforcey
   var.zoff=wiimote.rawforcez
   endif
endif


Last edited by Jephthah on Mon Dec 04, 2006 9:53 am; edited 1 time in total
Back to top
View user's profile Send private message
Kasten



Joined: 03 Dec 2006
Posts: 14

Digg It
PostPosted: Mon Dec 04, 2006 9:44 am    Post subject:

Here is my code that i made to play FPSs. I've been playing half life 2 with it works great. Don't forget to follow the offset configuration before playing a game.
Code:

/* NOTE for this code to work right with the wiimote please
   read the following                                      */

// When configuring the offsets please put the wiimote flat and do not move it.
// These are offsets change them so that your debug output reads 0,28,0
// The debug output is at the top of this window.
// Ex if you get -7,33,-6 then change the offsets to 7,-5,6
var.xOffset = 0
var.yOffset = 0
var.zOffset = 0


// Change this if you would like your mouse to go faster
var.speed = 1

// change these to a higher number if your hands are not steady or lower if they are
var.xCutoff = 4
var.zCutoff = 4


var.xRot = Wiimote.RawForceX + var.xOffset
var.yRot = Wiimote.RawForceY + var.yOffset
var.zRot = Wiimote.RawForceZ + var.zOffset

debug = 'X:' + var.xRot + ', ' + 'Y:' + var.yRot + ', ' + 'Z:' + var.zRot

// This is the code that moves your mouse
if var.xRot > var.xCutoff then mouse.x = mouse.x - .001 * var.speed * (var.xRot - var.xCutoff)
if var.xRot < -var.xCutoff then mouse.x = mouse.x - .001 * var.speed * (var.xRot + var.xCutoff)
if var.zRot > var.zCutoff then mouse.y = mouse.y - .001 * var.speed * (var.zRot - var.zCutoff)
if var.zRot < -var.zCutoff then mouse.y = mouse.y - .001 * var.speed * (var.zRot + var.zCutoff)

/* The following is for turning wii button presses into keyboard presses and mouse clicks */
// WASD for fsp games
w = Wiimote.Up
s = Wiimote.Down
a = Wiimote.Left
d = Wiimote.Right

// Press 1 on the wiimote to press e on the keyboard
e = Wiimote.One
// Press 2 on the wiimote to press control on the keyboard
control = Wiimote.Two

// B for left click and A for right click
mouse.LeftButton = Wiimote.B
mouse.RightButton = Wiimote.A

// Plus and Minus on the wiimote to use the scroll wheel
// get for scrolling though weapens in fsp games
mouse.WheelUp = Wiimote.Plus
mouse.WheelDown = Wiimote.Minus


// Rumbles wiimote when shift is pressed on your keyboard
Wiimote.Rumble = Shift

// Have some fun and press 1, 2, 3, and/of 4 to little up the lights on the wiimote
Wiimote.Led1 = four
Wiimote.Led2 = three
Wiimote.Led3 = two
Wiimote.Led4 = one

// If you move your controler up and down quickly then it will press space
// Great for jumping on games
if var.yRot >= 100 then space = true else space = false


Remember if your configuration is way off for the mouse and can't stop the program press control + shift + P +I + E


Edit: forgot to put the offsets in the code to 0 i had to put 7,-5,6 for my wiimote.


Last edited by Kasten on Mon Dec 04, 2006 9:51 am; edited 1 time in total
Back to top
View user's profile Send private message
Jephthah



Joined: 29 Nov 2006
Posts: 16

Digg It
PostPosted: Mon Dec 04, 2006 9:48 am    Post subject:

OptimumCoder wrote:
ScorpionLance wrote:
I'll admit i'm a complete n00b when it comes to programming so thats why i'm on here asking for help. I got the code running and the wiimote is working just like blackfrog did his video on. The thing i'm wondering is if the UDLR pad can be made to repeat. I'm wanting to use it for a FPS game and i'm hoping i can map the Up Down Left Right to W,S,A,D so i can move around. If you can post a code that will do that i'll refer to that person as my personal god. Thanks a bunch!!!


I posted something earlier yesterday about this. It's good for scrolling in firefox but I haven't tested it in any games.

http://www.wiili.org/forum/download-windows-driver-here-t294-s30.html#2433

You can change the Key.Up to Key.W and so on to set the WASD keys.


It appears that the solution strobes the keys, which, while useful, is not the same thing as holding them down. Ie...holding the B button in old-school mario does not make him spit repeated fireballs...strobing it does...(crappy example, but hey, its 4:45 am here...) Any ideas on how to get true button-pressed behavior? this may not be possible with GlovePie as it stands now. I know that to accomplish this Java uses two signals, a KeyPressed() event and a KeyReleased() event. whereas strobing as you've accomplished with this is accomplished via a third KeyTyped() event which repeats the signal when the button is held down.
Back to top
View user's profile Send private message
Kasten



Joined: 03 Dec 2006
Posts: 14

Digg It
PostPosted: Mon Dec 04, 2006 10:17 am    Post subject:

Jephthah i can't seem to get your code to work. My mouse will just jump up the upper left side of the screen and will flip out if i tilt the controller.


Edit: I think i was trying it change the collaboration by pressing the home button but it didn't work. I don't have the means of trying it again right now for my friend has the wii and not me. Sad
Back to top
View user's profile Send private message
Jephthah



Joined: 29 Nov 2006
Posts: 16

Digg It
PostPosted: Mon Dec 04, 2006 11:07 am    Post subject:

There was an error in my post before....a variable-hat-3 (variable to the third power) was rendered as variable-3 because of the forum's tags. This messed things up when you copied and pasted. I edited it, and it SHOULD work now....if not, post again and I'll take another look at it.
Also, HOME by itself doesn't calibrate.
HOME puts it in calibration mode (lights up all the leds)...A calibrates when its in this mode, and HOME again takes it out of the mode.
Can anyone get the code to work besides me? Or are other people having the same difficulty?
Back to top
View user's profile Send private message
CarlKenner
Site Admin


Joined: 29 Nov 2006
Posts: 614

Digg It
PostPosted: Mon Dec 04, 2006 1:12 pm    Post subject:

GlovePIE currently doesn't support key repeat. Sorry.

You can look at NewSamples\MouseParty.PIE for an example of mouse pointer acceleration. This is also a very cool script if you have multiple mice and you want multiple mouse pointers.

By the way, if you want the Wiimote to be an EXTRA mouse pointer, in addition to the regular mouse pointer, that is also possible.

For the real acceleration used in windows search the web for "windows xp mouse ballistics".

I am aware of the stopping and then running again bug, and it will be fixed in the next version. But the next version currently has other bugs stopping me from releasing it.

Cliff, from the MacOS thread, partly knows how to read the nunchuk, classic controller and the IR sensors. But I haven't been able to get his method to work yet.
Back to top
View user's profile Send private message Send e-mail
Kasten



Joined: 03 Dec 2006
Posts: 14

Digg It
PostPosted: Mon Dec 04, 2006 3:45 pm    Post subject:

Wow that would be crazy nice if you could at lest get your PIE program to get a some raw data from the ir and/or nunchuk. Still can't be leave you made the software for this without the a wiimote. I'm a programmer my self so if you need me to test something or help you with the coding the wiimode with PIE I'll try my best Carl. I never programmed a HID or a driver but i'm not a noob to coding.
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 Remote and Nunchuck All times are GMT
Goto page Previous  1, 2, 3 ... 10, 11, 12 ... 22, 23, 24  Next
Page 11 of 24

 
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