Welcome! Log In Create A New Profile

Advanced

Wii IR/Cursor Display

Posted by Heion 
Wii IR/Cursor Display
June 15, 2009 12:48AM
Hello,
I was wondering what method the all of you use to get and draw the wii's IR Location/Cursor.
Currently I'm using
WPAD_IR(WPAD_CHAN_0, &ir1);
GRRLIB_DrawImg(ir1.sx, ir1.sy, pointer_png, 0, 1, 1, 0xFFFFFFFF);
But this method doesn't seem very accurate, it gets stuck at the top and left sides of the screen n' such.
So what is the best way to do this?
Re: Wii IR/Cursor Display
June 15, 2009 01:04AM
Having Similar Issues Myself ,

2 Ideas :

1: - changing position
f32 irx;
f32 iry;

GRRLIB_DrawImg(ir1.sx - irx, ir1.sy - iry, pointer_png, 0, 1, 1, 0xFFFFFFFF);

if(wpaddown & WPAD_BUTTON_MINUS) 
{
      irx -=5;
      iry -=5;
}

Note: Untested

or change sx and sy to x and y ...
GRRLIB_DrawImg(ir1.x - irx, ir1.y - iry, pointer_png, 0, 1, 1, 0xFFFFFFFF);

Also Untested



Edited 1 time(s). Last edit at 06/15/2009 01:04AM by speewave.
Re: Wii IR/Cursor Display
June 15, 2009 06:24PM
i tested the code, and actually changing ir1.sx and ir1.sy to ir1.x and ir1.y works best....
Re: Wii IR/Cursor Display
June 15, 2009 09:14PM
Take a look of the sources of my lib, there is a function to draw a cursor here :)

You need to calculate some offset in order to have the cursor right in front of the Wiimote pointer.



Edited 1 time(s). Last edit at 06/15/2009 09:15PM by Minishlink.
Re: Wii IR/Cursor Display
June 16, 2009 01:27AM
Also, the pointer doesn't get "stuck" - what is happening is that once you move the pointer offscreen new ir coordinates are no longer fed into the ir variables (simply because they are no longer changing).

Thus, the pointer image keeps getting drawn in the same place, the point where you went off the screen. If you compare this with the behaviour of the cursor of the System Menu's cursor, you'll see that it is exactly the same, except the pointer image is erased if you move offscreen.

Therefore, erase the image whenever the ir is not within the 640 by 480 area of the screen and you'll fix the problem.

Any issues with the pointer being able to move more to one edge of the screen than the other are also illusory: if you draw an image from the ir coordinates, then the 0,0 point of the image is placed at those coordinates. Therefore, the actual location of the wiimote's pointer will be at the top left of whatever image you use. Offsetting the coordinates as people have suggested works, though you should use -48x and -48y if you want to be accurate. There are better ways to do this as well, I think.
Re: Wii IR/Cursor Display
June 16, 2009 04:52AM
note to the above: check the "valid" member of the IR structure to see if it's offscreen
Re: Wii IR/Cursor Display
June 17, 2009 10:31PM
Alright, think I've pretty much got everything going. thanks everyone, much appreciated ^^
Re: Wii IR/Cursor Display
June 17, 2009 11:53PM
Or if you are not happy with the simple pointer emulation, read the raw data and process it yourself.
Sorry, only registered users may post in this forum.

Click here to login