Exemplo n.º 1
0
void SwitchPanel::checkInputs()
{
	static unsigned char inBuffer[5];


	if (!handle)
	{
		return;
	}

	VESSEL *vessel = oapiGetFocusInterface(); // Get current vessel


	int bytesRead = hid_read(handle, inBuffer, sizeof(inBuffer));
	if (vessel!=NULL) // check if pointer is valid
	{

		//0x04 >> gear up
		//0x08 >> gear down

		if (bytesRead==3)
		{
			char keyByte = inBuffer[2];
			if (keyByte & 0x04) 
			{
				// gear up
				setGear(vessel, true);
			}

			if (keyByte & 0x08) 
			{
				// gear down
				setGear(vessel, false);
			}


		}
	}


}
Exemplo n.º 2
0
void Vehicle::setInput(const VehicleInput & input)
{
	setSteering(input.controls[VehicleInput::STEER]);
	setThrottle(input.controls[VehicleInput::THROTTLE]);
	setBrake(input.controls[VehicleInput::BRAKE]);
	setHandBrake(input.controls[VehicleInput::HBRAKE]);
	setClutch(1 - input.controls[VehicleInput::CLUTCH]);
	setNOS(input.controls[VehicleInput::NOS]);

	setGear(transmission.getGear() + input.shiftgear);
	autoshift = (input.logic & VehicleInput::AUTOSHIFT);
	autoclutch = (input.logic & VehicleInput::AUTOCLUTCH);
	setABS(input.logic & VehicleInput::ABS);
	setTCS(input.logic & VehicleInput::TCS);
	if (input.logic & VehicleInput::STARTENG)
		startEngine();
	if (input.logic & VehicleInput::RECOVER)
		rolloverRecover();
}
Exemplo n.º 3
0
void Vehicle::updateTransmission(btScalar dt)
{
	btScalar clutch_rpm = transmission.getClutchRPM();

	if (autoshift)
	{
		int gear = getNextGear(clutch_rpm);
		setGear(gear);
	}

	remaining_shift_time -= dt;
	if (remaining_shift_time < 0)
	{
		remaining_shift_time = 0;
	}

	if (!shifted && remaining_shift_time <= transmission.getShiftTime() * 0.5f)
	{
		transmission.shift(shift_gear);
		shifted = true;
	}

	if (autoclutch)
	{
		if (!engine.getCombustion())
		{
		    engine.start();
		}

		btScalar throttle = engine.getThrottle();
		throttle = autoClutchThrottle(clutch_rpm, throttle, dt);
		engine.setThrottle(throttle);

		btScalar new_clutch = autoClutch(clutch_rpm, last_clutch, dt);
		clutch.setPosition(new_clutch);
	}
	last_clutch = clutch.getPosition();
}