X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Flibgame%2Fjoystick.h;h=e43844edd8b8e63b8d9a10752205162e463b8cd5;hp=a826efff8213b4bad23fd16568fcd5fbff29d39f;hb=b641818c787e48bbf03ce2a0cd5b542c4c21e523;hpb=e0e2697df0d0da483a91b1248c120aef6b3caf9b diff --git a/src/libgame/joystick.h b/src/libgame/joystick.h index a826efff..e43844ed 100644 --- a/src/libgame/joystick.h +++ b/src/libgame/joystick.h @@ -1,15 +1,13 @@ -/*********************************************************** -* Artsoft Retro-Game Library * -*----------------------------------------------------------* -* (c) 1995-2002 Artsoft Entertainment * -* Holger Schemel * -* Detmolder Strasse 189 * -* 33604 Bielefeld * -* Germany * -* e-mail: info@artsoft.org * -*----------------------------------------------------------* -* joystick.h * -***********************************************************/ +// ============================================================================ +// Artsoft Retro-Game Library +// ---------------------------------------------------------------------------- +// (c) 1995-2014 by Artsoft Entertainment +// Holger Schemel +// info@artsoft.org +// https://www.artsoft.org/ +// ---------------------------------------------------------------------------- +// joystick.h +// ============================================================================ #ifndef JOYSTICK_H #define JOYSTICK_H @@ -19,8 +17,12 @@ #define JOYSTICK_NOT_AVAILABLE 0 #define JOYSTICK_AVAILABLE (1 << 0) #define JOYSTICK_ACTIVE (1 << 1) +#define JOYSTICK_CONFIGURED (1 << 2) +#define JOYSTICK_NOT_CONFIGURED (1 << 3) #define JOYSTICK_ACTIVATED (JOYSTICK_AVAILABLE | JOYSTICK_ACTIVE) +#define MAX_JOYSTICK_NAME_LEN 40 + #if defined(PLATFORM_FREEBSD) #define DEV_JOYSTICK_0 "/dev/joy0" #define DEV_JOYSTICK_1 "/dev/joy1" @@ -33,24 +35,17 @@ #define DEV_JOYSTICK_3 "/dev/js3" #endif -/* get these values from the program 'js' from the joystick package, */ -/* set JOYSTICK_PERCENT to a threshold appropriate for your joystick */ +// get these values from the program 'js' from the joystick package, +// set JOYSTICK_PERCENT to a threshold appropriate for your joystick + +#define JOYSTICK_MAX_AXIS_POS 32767 -#ifdef TARGET_SDL -#define JOYSTICK_XLEFT -32767 +#define JOYSTICK_XLEFT -JOYSTICK_MAX_AXIS_POS #define JOYSTICK_XMIDDLE 0 -#define JOYSTICK_XRIGHT 32767 -#define JOYSTICK_YUPPER -32767 +#define JOYSTICK_XRIGHT +JOYSTICK_MAX_AXIS_POS +#define JOYSTICK_YUPPER -JOYSTICK_MAX_AXIS_POS #define JOYSTICK_YMIDDLE 0 -#define JOYSTICK_YLOWER 32767 -#else -#define JOYSTICK_XLEFT 1 -#define JOYSTICK_XMIDDLE 128 -#define JOYSTICK_XRIGHT 255 -#define JOYSTICK_YUPPER 1 -#define JOYSTICK_YMIDDLE 128 -#define JOYSTICK_YLOWER 255 -#endif +#define JOYSTICK_YLOWER +JOYSTICK_MAX_AXIS_POS #define JOYSTICK_PERCENT 25 @@ -59,32 +54,33 @@ #define JOY_RIGHT MV_RIGHT #define JOY_UP MV_UP #define JOY_DOWN MV_DOWN -#define JOY_BUTTON_1 (1 << 4) -#define JOY_BUTTON_2 (1 << 5) -#define JOY_BUTTON (JOY_BUTTON_1 | JOY_BUTTON_2) +#define JOY_BUTTON_1 KEY_BUTTON_1 +#define JOY_BUTTON_2 KEY_BUTTON_2 +#define JOY_BUTTON_SNAP KEY_BUTTON_SNAP +#define JOY_BUTTON_DROP KEY_BUTTON_DROP +#define JOY_MOTION KEY_MOTION +#define JOY_BUTTON KEY_BUTTON +#define JOY_ACTION KEY_ACTION #define JOY_BUTTON_NOT_PRESSED 0 #define JOY_BUTTON_PRESSED 1 #define JOY_BUTTON_NEW_PRESSED 2 #define JOY_BUTTON_NEW_RELEASED 3 -#if defined(PLATFORM_UNIX) -void UnixInitJoysticks(void); -boolean UnixReadJoystick(int, int *, int *, boolean *, boolean *); -#endif - char *getJoyNameFromJoySymbol(int); int getJoySymbolFromJoyName(char *); int getJoystickNrFromDeviceName(char *); char *getDeviceNameFromJoystickNr(int); +char *getFormattedJoystickName(const char *); void CheckJoystickData(void); int Joystick(int); +int JoystickExt(int, boolean); int JoystickButton(int); int AnyJoystick(void); int AnyJoystickButton(void); -void DeactivateJoystickForCalibration(); -void ActivateJoystickIfAvailable(); +void DeactivateJoystick(void); +void ActivateJoystick(void); -#endif /* JOYSTICK_H */ +#endif // JOYSTICK_H