void State::Manager::Run(State& entranceState) { SDL_setenv("UBUNTU_PLATFORM_API_BACKEND", "touch_mirclient", 1); accel = ua_sensors_accelerometer_new(); ua_sensors_accelerometer_set_reading_cb(accel, tilt_cb, 0); ua_sensors_accelerometer_enable(accel); current = &entranceState; current->Enter(); //clock_t ticks = clock(); while (!quit) { PollEvent(); Tilt(); if (next) EnterNextState(); CallLoopFunction(); if (param.framerate != 0) { /**clock_t nticks = clock(); int32_t sleeptime = (CLOCKS_PER_SEC/param.framerate - (nticks-ticks)) / 1000; if (sleeptime > 0) SDL_Delay(sleeptime);*/ SDL_Delay(1); //ticks = nticks; } } current->Exit(); previous = current; current = NULL; }
void CineCameraClass::CameraAim(int& dx, int& dy) { XMFLOAT2 d; d.x = (float)dx; d.y = (float)dy; Pan(d.x / 8.0f); Tilt(d.y / 8.0f); }
Camera::Camera(int pinServoPan, int pinServoTilt,int camID) { Camera::numCam++; cameraID = camID; _pinServoPan = pinServoPan; _pinServoTilt = pinServoTilt; _servoPan.attach(_pinServoPan); _servoTilt.attach(_pinServoTilt); Pan(100); // Stopping Pan Tilt(45); // Centering Tilt }
void FWiimoteInputDevice::handle_event(struct wiimote_t* wm, int id) { UE_LOG(LogWiimote, Log, TEXT("\n\n--- EVENT [id %i] ---"), wm->unid); CurrentStates[0] = IS_PRESSED(wm, WIIMOTE_BUTTON_A) || IS_HELD(wm, WIIMOTE_BUTTON_A); CurrentStates[1] = IS_PRESSED(wm, WIIMOTE_BUTTON_B) || IS_HELD(wm, WIIMOTE_BUTTON_B); CurrentStates[2] = IS_PRESSED(wm, WIIMOTE_BUTTON_ONE) || IS_HELD(wm, WIIMOTE_BUTTON_ONE); CurrentStates[3] = IS_PRESSED(wm, WIIMOTE_BUTTON_TWO) || IS_HELD(wm, WIIMOTE_BUTTON_TWO); CurrentStates[4] = IS_PRESSED(wm, WIIMOTE_BUTTON_PLUS) || IS_HELD(wm, WIIMOTE_BUTTON_PLUS); CurrentStates[5] = IS_PRESSED(wm, WIIMOTE_BUTTON_MINUS) || IS_HELD(wm, WIIMOTE_BUTTON_MINUS); CurrentStates[6] = IS_PRESSED(wm, WIIMOTE_BUTTON_UP) || IS_HELD(wm, WIIMOTE_BUTTON_UP); CurrentStates[7] = IS_PRESSED(wm, WIIMOTE_BUTTON_DOWN) || IS_HELD(wm, WIIMOTE_BUTTON_DOWN); CurrentStates[8] = IS_PRESSED(wm, WIIMOTE_BUTTON_LEFT) || IS_HELD(wm, WIIMOTE_BUTTON_LEFT); CurrentStates[9] = IS_PRESSED(wm, WIIMOTE_BUTTON_RIGHT) || IS_HELD(wm, WIIMOTE_BUTTON_RIGHT); if (IS_PRESSED(wm, WIIMOTE_BUTTON_HOME)) { UE_LOG(LogWiimote, Log, TEXT("HOME pressed")); } /* show events specific to supported expansions */ if (wm->exp.type == EXP_NUNCHUK || wm->exp.type == EXP_MOTION_PLUS_NUNCHUK) { /* nunchuk */ struct nunchuk_t* nc = (nunchuk_t*)&wm->exp.nunchuk; const float DEADZONE = 0.6f; CurrentStates[10] = IS_PRESSED(nc, NUNCHUK_BUTTON_C) || IS_HELD(wm, NUNCHUK_BUTTON_C); CurrentStates[11] = IS_PRESSED(nc, NUNCHUK_BUTTON_Z) || IS_HELD(wm, NUNCHUK_BUTTON_Z); CurrentStates[12] = nc->js.y > DEADZONE; CurrentStates[13] = nc->js.y < -DEADZONE; CurrentStates[14] = nc->js.x < -DEADZONE; CurrentStates[15] = nc->js.x > DEADZONE; UE_LOG(LogWiimote, Log, TEXT("nunchuk roll = %f"), nc->orient.roll); UE_LOG(LogWiimote, Log, TEXT("nunchuk pitch = %f"), nc->orient.pitch); UE_LOG(LogWiimote, Log, TEXT("nunchuk yaw = %f"), nc->orient.yaw); UE_LOG(LogWiimote, Log, TEXT("nunchuk joystick angle: %f"), nc->js.ang); UE_LOG(LogWiimote, Log, TEXT("nunchuk joystick magnitude: %f"), nc->js.mag); UE_LOG(LogWiimote, Log, TEXT("nunchuk joystick vals: %f, %f"), nc->js.x, nc->js.y); UE_LOG(LogWiimote, Log, TEXT("nunchuk joystick calibration (min, center, max): x: %i, %i, %i y: %i, %i, %i"), nc->js.min.x, nc->js.center.x, nc->js.max.x, nc->js.min.y, nc->js.center.y, nc->js.max.y); } /* * If IR tracking is enabled then print the coordinates * on the virtual screen that the wiimote is pointing to. * * Also make sure that we see at least 1 dot. */ if (WIIUSE_USING_IR(wm)) { /* go through each of the 4 possible IR sources */ for (int i = 0; i < 4; ++i) { /* check if the source is visible */ if (wm->ir.dot[i].visible) { UE_LOG(LogWiimote, Log, TEXT("IR source %i: (%u, %u)"), i, wm->ir.dot[i].x, wm->ir.dot[i].y); } } UE_LOG(LogWiimote, Log, TEXT("IR cursor: (%u, %u)"), wm->ir.x, wm->ir.y); UE_LOG(LogWiimote, Log, TEXT("IR z distance: %f"), wm->ir.z); } // Update motion controls. FVector Tilt(0, 0, 0); FVector RotationRate(0, 0, 0); FVector Gravity(0, 0, 0); FVector Acceleration(0, 0, 0); /* if the accelerometer is turned on then print angles */ if (WIIUSE_USING_ACC(wm)) { Tilt.X = -wm->orient.pitch; Tilt.Y = wm->orient.yaw; Tilt.Z = wm->orient.roll; Acceleration.X = wm->accel.x; Acceleration.Y = wm->accel.y; Acceleration.Z = wm->accel.z; } if (wm->exp.type == EXP_MOTION_PLUS || wm->exp.type == EXP_MOTION_PLUS_NUNCHUK) { RotationRate.X = -wm->exp.mp.angle_rate_gyro.pitch; RotationRate.Y = wm->exp.mp.angle_rate_gyro.yaw; RotationRate.Z = wm->exp.mp.angle_rate_gyro.roll; } Gravity.X = wm->gforce.x; Gravity.Y = wm->gforce.y; Gravity.Z = wm->gforce.z; MessageHandler->OnMotionDetected(Tilt, RotationRate, Gravity, Acceleration, id); }
void CineCameraClass::TiltUp() { Tilt(-1.0f); }
void CineCameraClass::TiltDown() { Tilt(1.0f); }