10 #ifndef WIN32 // Goober5000
22 static int Joy_inited = 0;
24 static int joy_num_buttons = 0;
25 static int joy_num_axes = 0;
26 static int joy_num_hats = 0;
33 static int Joy_last_x_reading = 0;
34 static int Joy_last_y_reading = 0;
48 static SDL_Joystick *sdljoy;
62 SDL_JoystickClose(sdljoy);
66 SDL_QuitSubSystem (SDL_INIT_JOYSTICK);
78 joy = SDL_JoystickOpen (j);
81 nprintf ((
"JOYSTICK",
"Joystick #%d: %s\n", j -
JOYSTICKID1 + 1, SDL_JoystickName(j)));
83 for (
int i = 0;
i < SDL_JoystickNumAxes(joy);
i++)
88 SDL_JoystickClose (joy);
100 tmp = joy_buttons[btn].
state;
128 bi = &joy_buttons[btn];
161 bi = &joy_buttons[
i];
206 int x, d, dead_zone, rng;
207 float percent, sensitivity_percent, non_sensitivity_percent;
220 if (raw < -dead_zone) {
222 d = -raw - dead_zone;
224 }
else if (raw > dead_zone) {
241 percent = (
float) d / (
float) rng;
244 percent = (percent * sensitivity_percent + percent * percent * percent * percent * percent * non_sensitivity_percent);
246 x = (
int) ((
float)
F1_0 * percent);
291 Joy_last_x_reading = *
x;
294 Joy_last_y_reading = *
y;
370 if (state != joy_buttons[button].actual_state) {
379 joy_buttons[button].
state = 1;
382 if ( joy_buttons[button].state )
385 joy_buttons[button].
state = 0;
389 if (joy_buttons[button].state)
404 state = (position == SDL_HAT_DOWN) ? 1 : 0;
407 state = (position == SDL_HAT_UP) ? 1 : 0;
410 state = (position == SDL_HAT_LEFT) ? 1 : 0;
413 state = (position == SDL_HAT_RIGHT) ? 1 : 0;
419 if (state != joy_buttons[
i].actual_state) {
431 if ( joy_buttons[
i].state ) {
439 if (joy_buttons[
i].state) {
473 if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) {
474 mprintf((
"Could not initialize joystick\n"));
479 if ( (SDL_JoystickEventState(SDL_ENABLE)) != SDL_ENABLE ) {
480 mprintf((
"ERROR: Unable to initialize joystick event processing!\n"));
481 SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
485 n = SDL_NumJoysticks();
488 mprintf((
"No joysticks found\n"));
489 SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
499 if (sdljoy == NULL) {
501 SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
509 joy_num_buttons = SDL_JoystickNumButtons(sdljoy);
510 joy_num_axes = SDL_JoystickNumAxes(sdljoy);
511 joy_num_hats = SDL_JoystickNumHats(sdljoy);
513 mprintf((
"\nJoystick INITTED!\n\n" ));
515 mprintf((
" Number of axes: %i\n", joy_num_axes ));
516 mprintf((
" Number of buttons: %i\n", joy_num_buttons ));
517 mprintf((
" Number of hats: %i\n", joy_num_hats ));
518 mprintf((
" Number of trackballs: %i\n\n", SDL_JoystickNumBalls(sdljoy) ));
530 SDL_EventState( SDL_JOYAXISMOTION, SDL_IGNORE );
531 SDL_EventState( SDL_JOYBALLMOTION, SDL_IGNORE );
535 SDL_EventState( SDL_JOYBUTTONDOWN, SDL_ENABLE );
536 SDL_EventState( SDL_JOYBUTTONUP, SDL_ENABLE );
537 SDL_EventState( SDL_JOYHATMOTION, SDL_ENABLE );
555 for (i = 0; i < num_axes; i++) {
564 for (i = 0; i < num_axes; i++) {
565 if (i < joy_num_axes) {
566 axis[
i] = SDL_JoystickGetAxis(sdljoy, i) + 32768;
645 #endif // Goober5000 - #ifndef WIN32
int axis_max[JOY_NUM_AXES]
uint os_config_read_uint(const char *section, const char *name, uint default_value)
void joy_ff_afterburn_on()
int axis_center[JOY_NUM_AXES]
void joy_ff_stop_effects()
struct joy_button_info joy_button_info
void joy_ff_mission_init(vec3d v)
int joy_get_pos(int *x, int *y, int *z, int *rx)
joy_button_info joy_buttons[JOY_TOTAL_BUTTONS]
void joy_ff_afterburn_off()
void joy_get_caps(int max)
void joy_process(int time_delta)
int axis_min[JOY_NUM_AXES]
void joy_set_button_state(int button, int state)
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
void joy_ff_play_primary_shoot(int gain)
void joy_ff_fly_by(int mag)
int joystick_read_raw_axis(int num_axes, int *axis)
void joy_ff_play_dir_effect(float x, float y)
void joy_ff_play_reload_effect()
GLint GLint GLint GLint GLint x
for(int idx=0;idx< i;idx++)
void joy_ff_play_secondary_shoot(int gain)
float joy_down_time(int btn)
typedef float(SCP_EXT_CALLCONV *SCPTRACKIR_PFFLOATVOID)()
#define JOY_TOTAL_BUTTONS
int joy_get_scaled_reading(int raw, int axn)
int joy_down_count(int btn, int reset_count)
int joy_get_unscaled_reading(int raw, int axn)
void joy_ff_adjust_handling(int speed)
void joy_set_hat_state(int position)
int axis_valid[JOY_NUM_AXES]
int timer_get_milliseconds()
void joy_ff_play_vector_effect(vec3d *v, float scaler)