bool CryVR_WiimoteManagerPlugin::SetAccelThreshold( int ii, float angle ) { threshold = ii; angle_threshold = angle; if ( init && found > 0 ) { int i = 0; for ( ; i < MAX_WIIMOTES; ++i ) { wiiuse_set_accel_threshold( wiimotes[i], ii ); wiiuse_set_nunchuk_accel_threshold( wiimotes[i], ii ); wiiuse_set_orient_threshold( wiimotes[i], angle_threshold ); wiiuse_set_nunchuk_orient_threshold( wiimotes[i], angle_threshold ); } return true; } return false; }
/** * Set how many degrees an angle must change to generate an event for the nunchuk. * @param id id of the wiimote concerned * @param thresh minimum angle detected by an event */ JNIEXPORT void JNICALL Java_wiiusej_WiiUseApi_setNunchukOrientationThreshold (JNIEnv *env, jobject obj, jint id, jfloat thresh) { wiiuse_set_nunchuk_orient_threshold(wiiuse_get_by_id(wiimotes, nbMaxWiimotes, id), thresh); }
virtual void ProcessEvent(EFlowEvent event, SActivationInfo *pActInfo) { int found =-1; int connected; switch (event) { case eFE_Initialize:{ //Sleep(3000); wiimotes = wiiuse_init(1); found = wiiuse_find(wiimotes, 1, 5); if (found!=0) handle_ctrl_status(wiimotes[0]); connected = wiiuse_connect(wiimotes, 1); if (connected) CryLogAlways("Connected to %i wiimotes (of %i found).\n", connected, found); else CryLogAlways("Failed to connect to any wiimote.\n"); wiiuse_set_leds(wiimotes[0], WIIMOTE_LED_1); wiiuse_motion_sensing(wiimotes[0], 1); wiiuse_set_ir(wiimotes[0], 1); //trop rapide ! } case eFE_Activate: { //Sleep(3000); //wiimotes = wiiuse_init(1); //found = wiiuse_find(wiimotes, 1, 5); //if (found==0) CryLogAlways("No wiimotes found.\n"); /* connected = wiiuse_connect(wiimotes, 1); if (connected) CryLogAlways("Connected to %i wiimotes (of %i found).\n", connected, found); else CryLogAlways("Failed to connect to any wiimote.\n"); wiiuse_set_leds(wiimotes[0], WIIMOTE_LED_1); wiiuse_motion_sensing(wiimotes[0], 1); wiiuse_set_ir(wiimotes[0], 1); //WIIUSE_USING_EXP(wiimotes[0]); //WIIUSE_U //wiimotes[0]->exp.type = EXP_NUNCHUK; */ pActInfo->pGraph->SetRegularlyUpdated(pActInfo->myID,true); } break; case eFE_Update: { //int connected = wiiuse_connect(wiimotes, 1); wiiuse_poll(wiimotes, 1); wiimote* wm = wiimotes[0]; //Ne change rien ! juste qu'on a un retour d'IR //handle_ctrl_status(wiimotes[0]); CryLogAlways("attachment: %i",wm->exp.type); /* Gestion des evts */ // A commenter switch (wiimotes[0]->event) { case WIIUSE_EVENT: /* a generic event occured */ handle_event(wiimotes[0]); break; case WIIUSE_STATUS: /* a status event occured */ handle_ctrl_status(wiimotes[0]); break; case WIIUSE_DISCONNECT: case WIIUSE_UNEXPECTED_DISCONNECT: /* the wiimote disconnected */ handle_disconnect(wiimotes[0]); break; case WIIUSE_READ_DATA: /* * Data we requested to read was returned. * Take a look at wiimotes[i]->read_req * for the data. */ break; case WIIUSE_NUNCHUK_INSERTED: /* * a nunchuk was inserted * This is a good place to set any nunchuk specific * threshold values. By default they are the same * as the wiimote. */ //struct nunchuk_t* nc = (nunchuk_t*)&wiimotes[0]->exp.nunchuk; wiiuse_set_nunchuk_orient_threshold(wiimotes[0], 90.0f); wiiuse_set_nunchuk_accel_threshold(wiimotes[0], 100); CryLogAlways("Nunchuk inserted.\n"); break; case WIIUSE_CLASSIC_CTRL_INSERTED: CryLogAlways("Classic controller inserted.\n"); break; case WIIUSE_GUITAR_HERO_3_CTRL_INSERTED: /* some expansion was inserted */ handle_ctrl_status(wiimotes[0]); //printf("Guitar Hero 3 controller inserted.\n"); break; case WIIUSE_NUNCHUK_REMOVED: case WIIUSE_CLASSIC_CTRL_REMOVED: case WIIUSE_GUITAR_HERO_3_CTRL_REMOVED: /* some expansion was removed */ handle_ctrl_status(wiimotes[0]); //printf("An expansion was removed.\n"); break; default: break; } //if (wiiuse_poll(wiimotes, 1)) { //int i = 0; if (IS_PRESSED(wiimotes[0], WIIMOTE_BUTTON_A)) ActivateOutput(pActInfo, WIIMOTE_A,true); else ActivateOutput(pActInfo, WIIMOTE_A,false); if (IS_PRESSED(wiimotes[0], WIIMOTE_BUTTON_B)) ActivateOutput(pActInfo, WIIMOTE_B,true); else ActivateOutput(pActInfo, WIIMOTE_B,false); if (IS_PRESSED(wiimotes[0], WIIMOTE_BUTTON_UP)) ActivateOutput(pActInfo, WIIMOTE_UP,true); else ActivateOutput(pActInfo, WIIMOTE_UP,false); if (IS_PRESSED(wiimotes[0], WIIMOTE_BUTTON_DOWN)) ActivateOutput(pActInfo, WIIMOTE_DOWN,true); else ActivateOutput(pActInfo, WIIMOTE_DOWN,false); if (IS_PRESSED(wiimotes[0], WIIMOTE_BUTTON_LEFT)) ActivateOutput(pActInfo, WIIMOTE_LEFT,true); else ActivateOutput(pActInfo, WIIMOTE_LEFT,false); if (IS_PRESSED(wiimotes[0], WIIMOTE_BUTTON_RIGHT)) ActivateOutput(pActInfo, WIIMOTE_RIGHT,true); else ActivateOutput(pActInfo, WIIMOTE_RIGHT,false); if (IS_PRESSED(wiimotes[0], WIIMOTE_BUTTON_MINUS)) ActivateOutput(pActInfo, WIIMOTE_MINUS,true); else ActivateOutput(pActInfo, WIIMOTE_MINUS,false); if (IS_PRESSED(wiimotes[0], WIIMOTE_BUTTON_PLUS)) ActivateOutput(pActInfo, WIIMOTE_PLUS,true); else ActivateOutput(pActInfo, WIIMOTE_PLUS,false); if (IS_PRESSED(wiimotes[0], WIIMOTE_BUTTON_ONE)) ActivateOutput(pActInfo, WIIMOTE_ONE,true); else ActivateOutput(pActInfo, WIIMOTE_ONE,false); if (IS_PRESSED(wiimotes[0], WIIMOTE_BUTTON_TWO)) ActivateOutput(pActInfo, WIIMOTE_TWO,true); else ActivateOutput(pActInfo, WIIMOTE_TWO,false); if (IS_PRESSED(wiimotes[0], WIIMOTE_BUTTON_HOME)) ActivateOutput(pActInfo, WIIMOTE_HOME,true); else ActivateOutput(pActInfo, WIIMOTE_HOME,false); if (WIIUSE_USING_ACC(wiimotes[0])) { Vec3 output = Vec3(wiimotes[0]->orient.roll,wiimotes[0]->orient.pitch,wiimotes[0]->orient.yaw); ActivateOutput(pActInfo, WIIMOTE_RPY,output); } if (WIIUSE_USING_IR(wiimotes[0])) { Vec3 output = Vec3((float)wiimotes[0]->ir.x,(float)wiimotes[0]->ir.y,(float)wiimotes[0]->ir.z); ActivateOutput(pActInfo, WIIMOTE_IR,output); } /* nunchuk */ //Toujours faux ! if (wm->exp.type == EXP_NUNCHUK) { //nunchuk_t* pt = wm->exp.nunchuk; //REssort 0 a chaque fois !!!! struct nunchuk_t* nc = (nunchuk_t*)&wm->exp.nunchuk; CryLogAlways("nun gravity x EXPANSION : %f",nc->gforce.x); if (IS_PRESSED(nc, NUNCHUK_BUTTON_C)) ActivateOutput(pActInfo, NUNCHUK_C,true); else ActivateOutput(pActInfo, NUNCHUK_C,false); if (IS_PRESSED(nc, NUNCHUK_BUTTON_Z)) ActivateOutput(pActInfo, NUNCHUK_Z,true); else ActivateOutput(pActInfo, NUNCHUK_Z,false); Vec3 output = Vec3(nc->orient.a_roll,nc->orient.a_pitch,nc->orient.yaw); ActivateOutput(pActInfo, NUNCHUK_RPY,output); Vec3 output2 = Vec3(nc->js.ang,nc->js.mag,0); ActivateOutput(pActInfo, NUNCHUK_JOYSTICK,output2); } /* switch (wiimotes[0]->event) { //case WIIUSE_EVENT: //{ //} //break; case WIIUSE_STATUS: handle_ctrl_status(wiimotes[0]); break; case WIIUSE_DISCONNECT: case WIIUSE_UNEXPECTED_DISCONNECT: handle_disconnect(wiimotes[0]); break; default: break; } */ //} //} } } }