dxx-rebirth/common/include/joy.h

64 lines
1.5 KiB
C
Raw Normal View History

2014-06-01 17:55:23 +00:00
/*
* This file is part of the DXX-Rebirth project <http://www.dxx-rebirth.com/>.
* It is copyright by its individual contributors, as recorded in the
* project's Git history. See COPYING.txt at the top level for license
* terms and a link to the Git history.
*/
2006-03-20 17:12:09 +00:00
/*
*
* Header for joystick functions
*
*/
#pragma once
2006-03-20 17:12:09 +00:00
#include "dxxsconf.h"
#if MAX_JOYSTICKS
2006-03-20 17:12:09 +00:00
#include "pstypes.h"
2012-07-01 02:54:33 +00:00
#include "maths.h"
2013-06-30 02:22:56 +00:00
#include <SDL.h>
2006-03-20 17:12:09 +00:00
#ifdef __cplusplus
struct d_event;
#define JOY_MAX_AXES (MAX_AXES_PER_JOYSTICK * MAX_JOYSTICKS)
#define JOY_MAX_BUTTONS (MAX_BUTTONS_PER_JOYSTICK * MAX_JOYSTICKS)
2006-03-20 17:12:09 +00:00
struct d_event_joystick_axis_value
{
unsigned axis;
int value;
};
extern void joy_init();
2006-03-20 17:12:09 +00:00
extern void joy_close();
const d_event_joystick_axis_value &event_joystick_get_axis(const d_event &event);
2006-03-20 17:12:09 +00:00
extern void joy_flush();
2014-10-04 21:47:13 +00:00
extern int event_joystick_get_button(const d_event &event);
#endif
#else
#define joy_init()
#define joy_flush()
#define joy_close()
#endif
#if MAX_BUTTONS_PER_JOYSTICK
extern void joy_button_handler(SDL_JoyButtonEvent *jbe);
#else
#define joy_button_handler(jbe) static_cast<void>(static_cast<SDL_JoyButtonEvent *const &>(jbe))
#endif
2006-03-20 17:12:09 +00:00
#if MAX_HATS_PER_JOYSTICK
extern void joy_hat_handler(SDL_JoyHatEvent *jhe);
#else
#define joy_hat_handler(jhe) static_cast<void>(static_cast<SDL_JoyHatEvent *const &>(jhe))
#endif
#if MAX_AXES_PER_JOYSTICK
extern int joy_axis_handler(SDL_JoyAxisEvent *jae);
#else
#define joy_axis_handler(jae) (static_cast<void>(static_cast<SDL_JoyAxisEvent *const &>(jae)), 1)
#endif