From b37b7c29e3de879f5b83bc9ed73bef39e20d18ff Mon Sep 17 00:00:00 2001 From: Gautier Hattenberger Date: Thu, 2 Oct 2008 15:48:22 +0000 Subject: [PATCH] joystick driver with sample main code (based on martin's driver) --- sw/ground_segment/joystick/Makefile | 39 +++ sw/ground_segment/joystick/README | 27 ++ sw/ground_segment/joystick/main_stick.c | 89 +++++++ sw/ground_segment/joystick/usb_stick.c | 338 ++++++++++++++++++++++++ sw/ground_segment/joystick/usb_stick.h | 64 +++++ 5 files changed, 557 insertions(+) create mode 100644 sw/ground_segment/joystick/Makefile create mode 100644 sw/ground_segment/joystick/README create mode 100644 sw/ground_segment/joystick/main_stick.c create mode 100644 sw/ground_segment/joystick/usb_stick.c create mode 100644 sw/ground_segment/joystick/usb_stick.h diff --git a/sw/ground_segment/joystick/Makefile b/sw/ground_segment/joystick/Makefile new file mode 100644 index 0000000000..f182a1162e --- /dev/null +++ b/sw/ground_segment/joystick/Makefile @@ -0,0 +1,39 @@ +# +# $Id$ +# Copyright (C) 2004 Pascal Brisset, Antoine Drouin +# +# This file is part of paparazzi. +# +# paparazzi 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; either version 2, or (at your option) +# any later version. +# +# paparazzi 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 paparazzi; see the file COPYING. If not, write to +# the Free Software Foundation, 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. +# + +# Quiet compilation +Q=@ + +all: main_stick ctrlstick ffjoystick + +main_stick: main_stick.c usb_stick.c + gcc -g -O2 -Wall `pkg-config glib-2.0 --cflags` -o $@ $^ `pkg-config glib-2.0 --libs` `pcre-config --libs` -lglibivy + +ctrlstick: ctrlstick.c + gcc -g -O2 -Wall `pkg-config glib-2.0 --cflags` -o $@ $^ `pkg-config glib-2.0 --libs` `pcre-config --libs` -lglibivy + +ffjoystick: ffjoystick.c + gcc -g -O2 -Wall `pkg-config glib-2.0 --cflags` -o $@ $^ `pkg-config glib-2.0 --libs` `pcre-config --libs` -lglibivy -lm + +clean: + rm -f *.opt *.out *~ core *.o *.bak .depend *.cm* main_stick ctrlstick ffjoystick + diff --git a/sw/ground_segment/joystick/README b/sw/ground_segment/joystick/README new file mode 100644 index 0000000000..6c6fb0bde1 --- /dev/null +++ b/sw/ground_segment/joystick/README @@ -0,0 +1,27 @@ +# +# $Id$ +# Copyright (C) 2003 Pascal Brisset Antoine Drouin +# +# This file is part of paparazzi. +# +# paparazzi 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; either version 2, or (at your option) +# any later version. +# +# paparazzi 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 paparazzi; see the file COPYING. If not, write to +# the Free Software Foundation, 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. +# + + +Tools for controling an aircraft with a ground joystick + + + diff --git a/sw/ground_segment/joystick/main_stick.c b/sw/ground_segment/joystick/main_stick.c new file mode 100644 index 0000000000..4066c4ee4e --- /dev/null +++ b/sw/ground_segment/joystick/main_stick.c @@ -0,0 +1,89 @@ +/* + * main_stick + * + * send joystick control to paparazzi through ivy + * + * based on Force Feedback: Constant Force Stress Test + * Copyright (C) 2001 Oliver Hamann + * + * 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; either version 2 of the License, or + * (at your option) any later version. + * + * 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 + */ + +#include "usb_stick.h" + +#include +#include +#include +#include +#include +#include + +#define TIMEOUT_PERIOD 100 + +#define DEFAULT_AC_ID 1 + +/* Options */ +char * device_name = NULL; +int aircraft_id = DEFAULT_AC_ID; + +void parse_args(int argc, char * argv[]) +{ + int i; + + for (i = 1; i < argc; i++) { + if (!strcmp(argv[i],"-d") && i [