73 #include "generated/airframe.h"
81 #ifndef NPS_JS_AXIS_ROLL
82 #define NPS_JS_AXIS_ROLL 0
84 #ifndef NPS_JS_AXIS_PITCH
85 #define NPS_JS_AXIS_PITCH 1
87 #ifndef NPS_JS_AXIS_YAW
88 #define NPS_JS_AXIS_YAW 2
90 #ifndef NPS_JS_AXIS_THROTTLE
91 #define NPS_JS_AXIS_THROTTLE 3
94 #ifndef NPS_JS_AXIS_MODE
101 #ifndef NPS_JS_BUTTON_MODE_MANUAL
102 #define NPS_JS_BUTTON_MODE_MANUAL 1
104 #ifndef NPS_JS_BUTTON_MODE_AUTO1
105 #define NPS_JS_BUTTON_MODE_AUTO1 2
107 #ifndef NPS_JS_BUTTON_MODE_AUTO2
108 #define NPS_JS_BUTTON_MODE_AUTO2 3
111 #ifndef NPS_JS_AXIS_MODE
112 #define JS_NB_BUTTONS 3
114 #define JS_NB_BUTTONS 0
140 int device_index = atoi(device);
143 if (SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO) < 0) {
144 printf(
"Could not initialize SDL: %s.\n", SDL_GetError());
152 SDL_EventState(SDL_ACTIVEEVENT, SDL_IGNORE);
153 SDL_EventState(SDL_KEYDOWN, SDL_IGNORE);
154 SDL_EventState(SDL_KEYUP, SDL_IGNORE);
155 SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
156 SDL_EventState(SDL_MOUSEBUTTONDOWN, SDL_IGNORE);
157 SDL_EventState(SDL_MOUSEBUTTONUP, SDL_IGNORE);
158 SDL_EventState(SDL_JOYAXISMOTION, SDL_IGNORE);
159 SDL_EventState(SDL_JOYBALLMOTION, SDL_IGNORE);
160 SDL_EventState(SDL_JOYHATMOTION, SDL_IGNORE);
162 SDL_EventState(SDL_JOYBUTTONUP, SDL_IGNORE);
163 SDL_EventState(SDL_VIDEORESIZE, SDL_IGNORE);
164 SDL_EventState(SDL_VIDEOEXPOSE, SDL_IGNORE);
166 SDL_EventState(SDL_USEREVENT, SDL_IGNORE);
167 SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE);
170 if (!SDL_NumJoysticks()) {
171 printf(
"No joysticks attached! Quitting.\n");
178 printf(
"Joystick corresponding to SDL Index %d failed to open! Exiting.\n", device_index);
181 printf(
"Selected joystick does not support enough axes!\n");
182 printf(
"Number of axes required: %i\n",
JS_NB_AXIS);
183 printf(
"Number of axes available: %i\n", SDL_JoystickNumAxes(
sdl_joystick));
187 printf(
"Selected joystick does not support enough buttons!\n");
192 printf(
"Using joystick named: %s\n", SDL_JoystickName(device_index));
204 #if NPS_JS_AXIS_THROTTLE_REVERSED
209 #if NPS_JS_AXIS_ROLL_REVERSED
214 #if NPS_JS_AXIS_PITCH_REVERSED
219 #if NPS_JS_AXIS_YAW_REVERSED
225 #ifdef NPS_JS_AXIS_MODE
226 #if NPS_JS_AXIS_MODE_REVERSED
235 case SDL_JOYBUTTONDOWN: {
237 #ifndef NPS_JS_AXIS_MODE
258 printf(
"Quitting...\n");
264 printf(
"unknown SDL event!!!\n");