# MBDyn (C) is a multibody analysis code. 
# http://www.mbdyn.org
# 
# Copyright (C) 1996-2017
# 
# Pierangelo Masarati	<masarati@aero.polimi.it>
# Paolo Mantegazza	<mantegazza@aero.polimi.it>
# 
# Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
# via La Masa, 34 - 20156 Milano, Italy
# http://www.aero.polimi.it
# 
# Changing this copyright notice is forbidden.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation (version 2 of the License).
# 
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
# 

begin: data;
	problem: initial value;
end: data;

begin: initial value;
	initial time: 0.;
	final time: forever;
	time step: 1.e-2;

	real time: posix,
		mode, period, time step, 10e6,
		allow nonroot; # nanoseconds

	# output: iterations;
end: initial value;

include: "hid.set";
include: "hid_ms_sidewinder.set";

begin: control data;
	abstract nodes: JOYSTICK_N_LC + JOYSTICK_N_BUTTONS;
	file drivers: 1;
	genels: JOYSTICK_N_LC + JOYSTICK_N_BUTTONS;
	forces: JOYSTICK_N_LC + JOYSTICK_N_BUTTONS;
end: control data;

module load: "libmodule-hid";

set: const integer JOYSTICK_1 = 999;

set: const integer TRIM_L = 5;
set: const integer TRIM_F = 6;

begin: nodes;
	abstract: JOYSTICK_AILERONS;
	abstract: JOYSTICK_ELEVATOR;
	abstract: JOYSTICK_RUDDER;
	abstract: JOYSTICK_THROTTLE;
	abstract: TRIM_L;
	abstract: TRIM_F;

	abstract: JOYSTICK_TRIGGER;
	abstract: JOYSTICK_BUTTON_2;
	abstract: JOYSTICK_BUTTON_3;
	abstract: JOYSTICK_BUTTON_4;
	abstract: JOYSTICK_BUTTON_5;
	abstract: JOYSTICK_BUTTON_6;
	abstract: JOYSTICK_BUTTON_7;
	abstract: JOYSTICK_BUTTON_8;
end: nodes;

begin: drivers;
	file: JOYSTICK_1, joystick,
		# help;
		"/dev/input/js0",			# joystick device
		JOYSTICK_N_BUTTONS,			# number of buttons
		JOYSTICK_N_LC;				# number of linear controls
		# scale, 1., 2., 3., 4., 5., 6.;	# scale factor for linear controls
		# 8, 6; # Fabio's
		# 26, 8; # Andrea's
		# 12, 7; # Mine
end: drivers;

begin: elements;
	genel: JOYSTICK_AILERONS, spring support, JOYSTICK_AILERONS, abstract, algebraic, linear elastic, 1.;
	genel: JOYSTICK_ELEVATOR, spring support, JOYSTICK_ELEVATOR, abstract, algebraic, linear elastic, 1.;
	genel: JOYSTICK_RUDDER, spring support, JOYSTICK_RUDDER, abstract, algebraic, linear elastic, 1.;
	genel: JOYSTICK_THROTTLE, spring support, JOYSTICK_THROTTLE, abstract, algebraic, linear elastic, 1.;
	genel: TRIM_L, spring support, TRIM_L, abstract, algebraic, linear elastic, 1.;
	genel: TRIM_F, spring support, TRIM_F, abstract, algebraic, linear elastic, 1.;

	genel: JOYSTICK_TRIGGER, spring support, JOYSTICK_TRIGGER, abstract, algebraic, linear elastic, 1.;
	genel: JOYSTICK_BUTTON_2, spring support, JOYSTICK_BUTTON_2, abstract, algebraic, linear elastic, 1.;
	genel: JOYSTICK_BUTTON_3, spring support, JOYSTICK_BUTTON_3, abstract, algebraic, linear elastic, 1.;
	genel: JOYSTICK_BUTTON_4, spring support, JOYSTICK_BUTTON_4, abstract, algebraic, linear elastic, 1.;
	genel: JOYSTICK_BUTTON_5, spring support, JOYSTICK_BUTTON_5, abstract, algebraic, linear elastic, 1.;
	genel: JOYSTICK_BUTTON_6, spring support, JOYSTICK_BUTTON_6, abstract, algebraic, linear elastic, 1.;
	genel: JOYSTICK_BUTTON_7, spring support, JOYSTICK_BUTTON_7, abstract, algebraic, linear elastic, 1.;
	genel: JOYSTICK_BUTTON_8, spring support, JOYSTICK_BUTTON_8, abstract, algebraic, linear elastic, 1.;

	force: JOYSTICK_AILERONS, abstract, JOYSTICK_AILERONS, abstract, file, JOYSTICK_1, JOYSTICK_AILERONS;
	force: JOYSTICK_ELEVATOR, abstract, JOYSTICK_ELEVATOR, abstract, file, JOYSTICK_1, JOYSTICK_ELEVATOR;
	force: JOYSTICK_RUDDER, abstract, JOYSTICK_RUDDER, abstract, file, JOYSTICK_1, JOYSTICK_RUDDER;
	force: JOYSTICK_THROTTLE, abstract, JOYSTICK_THROTTLE, abstract, file, JOYSTICK_1, JOYSTICK_THROTTLE;
	force: TRIM_L, abstract, TRIM_L, abstract, file, JOYSTICK_1, TRIM_L;
	force: TRIM_F, abstract, TRIM_F, abstract, file, JOYSTICK_1, TRIM_F;

	force: JOYSTICK_TRIGGER, abstract, JOYSTICK_TRIGGER, abstract, file, JOYSTICK_1, JOYSTICK_TRIGGER;
	force: JOYSTICK_BUTTON_2, abstract, JOYSTICK_BUTTON_2, abstract, file, JOYSTICK_1, JOYSTICK_BUTTON_2;
	force: JOYSTICK_BUTTON_3, abstract, JOYSTICK_BUTTON_3, abstract, file, JOYSTICK_1, JOYSTICK_BUTTON_3;
	force: JOYSTICK_BUTTON_4, abstract, JOYSTICK_BUTTON_4, abstract, file, JOYSTICK_1, JOYSTICK_BUTTON_4;
	force: JOYSTICK_BUTTON_5, abstract, JOYSTICK_BUTTON_5, abstract, file, JOYSTICK_1, JOYSTICK_BUTTON_5;
	force: JOYSTICK_BUTTON_6, abstract, JOYSTICK_BUTTON_6, abstract, file, JOYSTICK_1, JOYSTICK_BUTTON_6;
	force: JOYSTICK_BUTTON_7, abstract, JOYSTICK_BUTTON_7, abstract, file, JOYSTICK_1, JOYSTICK_BUTTON_7;
	force: JOYSTICK_BUTTON_8, abstract, JOYSTICK_BUTTON_8, abstract, file, JOYSTICK_1, JOYSTICK_BUTTON_8;
end: elements;

