virtual bool control() override { if(joystickIntervalCounter++ > 40){ joystickIntervalCounter = 0; joystick.readCurrentState(); } double thrust[2]; double thrust_updown; double hyd = 0.0; thrust[0] = -joystick.getPosition(3); // right thrust[1] = -joystick.getPosition(1); // left thrust_updown = joystick.getPosition(5); //up、down ThrusterDevice* thrusterDevice[3]; for(size_t i = 0; i < thrusts.size(); ++i){ thrusterDevice[i] = thrusts[i]; if(thrusts[i]->id()){ // Set hydraulic power. if(thrust[i - 1]){ hyd = thrust[i - 1] * 0.75; }else{ hyd = 0.0; } }else{ if(thrust_updown){ hyd = thrust_updown * 0.75; }else{ hyd = 0.0; } } thrusterDevice[i]->setHydraulic(hyd); thrusterDevice[i]->notifyStateChange(); } if(light){ bool changed = false; bool lightButtonState = joystick.getButtonState(0); if(lightButtonState){ if(!prevLightButtonState){ light->on(!light->on()); changed = true; } } prevLightButtonState = lightButtonState; if(changed){ light->notifyStateChange(); } } return true; }