You are not logged in.

#1 2009-06-04 00:03:43

Physx
Member

[RESOLVED] WiiMote IR

Hi, Could anybody please link me to / show me an example of a clean fully working wiimote movement code please? Iv been trying to figure out whats going on in other sources but they are far to messy and i can never get my motion sensing to work, iv been trying for 6hrs+ and its got to the point where im geting rather annoyed

Thank You

Offline

 

#2 2009-06-04 00:08:56

Crayon
Bad Mother Fucker

Re: [RESOLVED] WiiMote IR

Hi, is that what you are looking for: http://wiibrew.org/wiki/How_to_use_the_Wiimote ???

Offline

 

#3 2009-06-04 14:11:43

Physx
Member

Re: [RESOLVED] WiiMote IR

This helped me alot, thank you smile

Offline

 

#4 2009-06-04 21:28:26

Physx
Member

Re: [RESOLVED] WiiMote IR

i appear to have another problem. When printing the X and Y coordinates, 0,0 appears to be somewhere in the centre of the screen and not in the top left hand corner. When i move my pointer off (Down and Right from the centre-ish) screen the numbers carry on going all the way to 640 x 480.

Any idea why its doing this? i assume its going to effect my button pressing when hovering over button coords that arnt real

Here is the code iv used for displaying the coordinates onscreen. I Took this code from Demo2. When i added this code to the Shapes Demo Case in Demo2 i got the same results.

GRRLIB_Printf(200, 320, tex_console, 0xFFFFFFFF, 1, "X = %i. Y = %i", (int)ir1.x - 24, (int)ir1.y - 22);

Removing The Pointer Offsets (-24 and -22) dont help fix my problem either

Thanks

Last edited by Physx (2009-06-04 21:37:40)

Offline

 

#5 2009-06-04 21:51:41

Crayon
Bad Mother Fucker

Re: [RESOLVED] WiiMote IR

Check the code from lesson1: http://code.google.com/p/grrlib/source/ … rce/main.c

Getting the values from Wii Remote 1:

Code:

WPAD_IR(WPAD_CHAN_0, &ir1);

Printing the values:

Code:

                GRRLIB_Printf(left, top+250, tex_BMfont1, GRRLIB_WHITE, 1, "IR X VALUE: %d", (int)ir1.x);
                GRRLIB_Printf(left, top+300, tex_BMfont3, GRRLIB_WHITE, 1, "IR Y VALUE: %d", (int)ir1.y);

Try this in case...

Code:

WPAD_SetVRes(0, 640, 480);

Offline

 

#6 2009-06-04 21:57:50

Physx
Member

Re: [RESOLVED] WiiMote IR

yep, i have all thoes values in my code, i have drawn u a picture in paint to try and show you whats happening

changing from int to doubles (%i to %d) didnt help

http://i43.tinypic.com/o6jokp.png


i have these lines of code that involve using IR -

ir_t ir1;                // Initialize IR
WPAD_Init();            // Initialize WPAD
WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);        // Get Data For IR
WPAD_SetVRes(0, 640, 480);        // Set WiiMote Res
WPAD_IR(WPAD_CHAN_0, &ir1);        // Get WiiMote Data
GRRLIB_Printf(200, 320, tex_console, 0xFFFFFFFF, 1, "X = %D. Y = %D", (int)ir1.x, (int)ir1.y);

Iv also uploaded the edited Demo2 .dol to show you what the problem is. Switch to the Shape demo and then try and move the pointer to the top left corner.... you should notice that the X and Y output values dont work properly. Thats if you have time to check ofcourse.

http://rapidshare.com/files/240854553/boot.rar.html

EDIT - im on 480p Widescreen settings if that makes any difference (Which it doesnt, i still get the same problem with 576i, 480i and 4:3.)

Please help sad i basically cant finish what im working on without a fix for this

Thanks

Last edited by Physx (2009-06-05 13:51:30)

Offline

 

#7 2009-06-05 17:36:41

Physx
Member

Re: [RESOLVED] WiiMote IR

Hello, it appears that the problem was any line of code that had ir1 in it instead of just ir; Hours and hours messing about all because of this simple number.

I Took this code from the X O Learn From Code Edition..... Yeah i learnt alot... just use ir NOT ir1.

God i feel like a muppet

Thanks

Offline

 

#8 2009-06-05 18:36:47

Crayon
Bad Mother Fucker

Re: [RESOLVED] WiiMote IR

I just noticed that I'm using ir too in my code:

Code:

    WPADData *WPadData0 = WPAD_Data(WPAD_CHAN_0);

    if(WPadData0->ir.valid)
    {
        Hand[0].SetLeft(WPadData0->ir.x);
        Hand[0].SetTop(WPadData0->ir.y);
        Hand[0].SetAngle(WPadData0->orient.roll);
        Hand[0].SetVisible(true);
    }
    else
    {   // Hide cursor
        Hand[0].SetVisible(false);
    }

Offline

 

Board footer

Powered by FluxBB