Game Development Reference
In-Depth Information
if ( ! discover() )
return;
jni_send_message("Connecting to %d wiimote(s)", nmotes);
int connected = wiic_connect(wiimotes, nmotes);
if ( !connected) {
jni_send_error(110, "Connect: Failed to connect to any wiimote.");
return ;
}
// LOGD("Connected to %i wiimotes (of %i found).\n", connected, nmotes);
jni_send_message("Connected to %i wiimotes (of %i found).\n", connected, nmotes);
// turn on 1st led
wiic_set_leds(wiimotes[0], WIIMOTE_LED_1);
// rumble for 1 sec
wiic_rumble(wiimotes[0], 1);
usleep(1000000);
wiic_rumble(wiimotes[0], 0);
/*
* This is the main loop
*/
while (!sig_exit)
{
process_signals();
if (wiic_poll(wiimotes, connected)) {
/*
* This happens if something happened on any wiimote. So go through each
* one and check if anything happened.
*/
for (i = 0; i < MAX_WIIMOTES; ++i) {
// LOGD("Wii Event %d ", wiimotes[i]->event);
switch (wiimotes[i]->event) {
case WIIC_EVENT:
// a generic event occured
handle_event(wiimotes[i]);
break;
case WIIC_STATUS:
// a status event occured
handle_ctrl_status(wiimotes[i]);
break;
case WIIC_DISCONNECT:
case WIIC_UNEXPECTED_DISCONNECT:
// the wiimote disconnected
handle_disconnect(wiimotes[i]);
break;
Search WWH ::




Custom Search