Welcome! Log In Create A New Profile

Advanced

Issues with wiiuse events

Posted by saurabh29789 
Issues with wiiuse events
January 30, 2011 04:57PM
I just started using the wiiuse library. The program is successfully able to find and connect the remote but no matter what I do, it generates only the WIIUSE_NONE event. When I press a button or tilt the remote, I expect WIIUSE_EVENT to be emitted but this doesn't happen. What could be the problem ?

Also, I tried IR Tracking and set the Virtual Screen Resolution to 560x420, but I get very large values for the x and y members of the dot[] array. Why does that happen?
Here's the code:
#include < stdio.h >
#include < stdlib.h >
#include "unistd.h"
#include "wiiuse.h"

#define NUMBER_OF_REMOTES 1

void handle_event(struct wiimote_t* rm) {
    if(IS_PRESSED(rm, WIIMOTE_BUTTON_UP)){
        printf("\n - IR Activated - \n");
        wiiuse_set_ir(rm, 1);
    }
    else if(IS_PRESSED(rm, WIIMOTE_BUTTON_DOWN)){
        printf("\n - IR Deactivated - \n");
        wiiuse_set_ir(rm, 0);
    }

    if(WIIUSE_USING_IR(rm)){
        for(int i=0; i<4; i++){
            if( rm->ir.dot.visible){
                printf("Source:%d (%u, %u)\n",i, rm->ir.dot.x, rm->ir.dot.y);
            }
        }
    }
}

void handle_disconnect(struct wiimote_t* rm){
    printf("\n - DISCONNECTED %d - \n", rm->unid);
}

int main(){
    wiimote** remotes = wiiuse_init(NUMBER_OF_REMOTES);

    printf("Found %d remotes\n", wiiuse_find(remotes, NUMBER_OF_REMOTES, 3));
    int conn  = wiiuse_connect(remotes, NUMBER_OF_REMOTES);
    if(!conn){
        printf("Failed to connect remotes\n");
        return 0;
    }
    printf("Connected %d remotes\n", conn);
    wiiuse_rumble(remotes[0], 1);
    sleep(1);
    wiiuse_rumble(remotes[0], 0);

    while(1){
        int detected=0;
        if(detected = wiiuse_poll(remotes, NUMBER_OF_REMOTES)){
            for(int i=0; i < detected; i++){
                switch(remotes->event){
                    case WIIUSE_EVENT:                  printf("\n - WIIUSE _ EVENT - \n");
                                                        handle_event(remotes);
                                                        break;
                    case WIIUSE_DISCONNECT:
                    case WIIUSE_UNEXPECTED_DISCONNECT:  handle_disconnect(remotes);
                                                        break;

                    case WIIUSE_NONE:                   printf("\n - WIIUSE_NONE - \n");
                                                        break;
                    default:                            printf("\n - UNHANDLED EVENT - \n");
                                                        break;

                }
            }
        }
    }
    wiiuse_cleanup(remotes, NUMBER_OF_REMOTES);
    return 0;
}





PS: I'm using Linux (ubuntu 10.10).



Edited 2 time(s). Last edit at 01/30/2011 05:19PM by saurabh29789.
Re: Issues with wiiuse events
January 30, 2011 07:02PM
Any solutions ????
Re: Issues with wiiuse events
January 31, 2011 01:05AM
I think I know what's missing, after taking a quick look at your code. But you expected an answer within 2 hours. So I'll let you wait a bit longer.
Re: Issues with wiiuse events
January 31, 2011 07:00PM
I suppose you can answer me now. I've waited for a day here and have been stuck on these for 2 days. I had tried everything I could before posting in the forum.



Edited 1 time(s). Last edit at 01/31/2011 07:32PM by saurabh29789.
Re: Issues with wiiuse events
February 02, 2011 04:43AM
Anybody? I'm really stuck with this problem for quite long now and I need it working asap.
Re: Issues with wiiuse events
February 02, 2011 12:19PM
At first I was thinking you didn't set the report mode, but you are. After pressing a button.

Do you know for sure the wiimote you have really works with libwiiuse? 3th party wiimotes have lots of problems with libwiiuse. And make sure you use the latest version with libwiiuse, and try a 'test tool' first.

I tried this tool:
[code.google.com]
To see if my wiimote was working correctly with libwiiuse. And at first it didn't because my bluetooth stack was rubish and outdated.
Re: Issues with wiiuse events
February 03, 2011 04:56PM
My wiimote is from Nintendo itself.
I am having problems installing Netbeans. I tried installing in twice. Both the times, it came up with some strange problem and I had to install ubuntu again.

Is there anything else I can try?

PS: The remote works fine with the wmgui tool and the demo application that came with wiiuse.
Re: Issues with wiiuse events
February 04, 2011 06:19AM
I have been able to get the job done using the cwiid library.
Sorry, only registered users may post in this forum.

Click here to login