Issues with wiiuse events January 30, 2011 04:57PM | Registered: 13 years ago Posts: 6 |
#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; }
Re: Issues with wiiuse events January 30, 2011 07:02PM | Registered: 13 years ago Posts: 6 |
Re: Issues with wiiuse events January 31, 2011 01:05AM | Registered: 14 years ago Posts: 379 |
Re: Issues with wiiuse events January 31, 2011 07:00PM | Registered: 13 years ago Posts: 6 |
Re: Issues with wiiuse events February 02, 2011 04:43AM | Registered: 13 years ago Posts: 6 |
Re: Issues with wiiuse events February 02, 2011 12:19PM | Registered: 14 years ago Posts: 379 |
Re: Issues with wiiuse events February 03, 2011 04:56PM | Registered: 13 years ago Posts: 6 |
Re: Issues with wiiuse events February 04, 2011 06:19AM | Registered: 13 years ago Posts: 6 |