//testing accelerometer readings. To enable the test, search below for "ACCELTEST" //Note: You'll need to look at the debug log to see the output. (For android, run PhoneLog.bat from RTBareBones/android) void App::OnAccel(VariantList *pVList) { if ( int(pVList->m_variant[0].GetFloat()) != MESSAGE_TYPE_GUI_ACCELEROMETER) return; CL_Vec3f v = pVList->m_variant[1].GetVector3(); LogMsg("Accel: %s", PrintVector3(v).c_str()); v.x = v.x * kFilteringFactor + v.x * (1.0f - kFilteringFactor); v.y = v.y * kFilteringFactor + v.y * (1.0f - kFilteringFactor); v.z = v.z * kFilteringFactor + v.z * (1.0f - kFilteringFactor); // Compute values for the three axes of the acceleromater float x = v.x - v.x; float y = v.y - v.x; float z = v.z - v.x; //Compute the intensity of the current acceleration if (sqrt(x * x + y * y + z * z) > 2.0f) { Entity *pEnt = GetEntityRoot()->GetEntityByName("jumble"); if (pEnt) { //GetAudioManager()->Play("audio/click.wav"); VariantList vList(CL_Vec2f(), pEnt); pEnt->GetFunction("OnButtonSelected")->sig_function(&vList); } LogMsg("Shake!"); } }
void ArcadeInputComponent::SetOutput(VariantList *pVList) { Entity *pEnt = pVList->Get(0).GetEntity(); assert(!m_customSignal && "We don't support setting this twice yet"); m_customSignal = &pEnt->GetFunction("OnArcadeInput")->sig_function; //get notified when this entity dies pEnt->sig_onRemoved.connect(1, boost::bind(&ArcadeInputComponent::OnCustomOutputRemoved, this, _1)); }