joy: refactor generic joy_masks array indices and macros
This commit is contained in:
@@ -52,27 +52,31 @@
|
||||
#define JOY_ERR_NO_DEVICE 4 /* Device (hardware) not found */
|
||||
|
||||
/* Argument for the joy_read function */
|
||||
#define JOY_1 0
|
||||
#define JOY_2 1
|
||||
#define JOY_1 0
|
||||
#define JOY_2 1
|
||||
|
||||
/* The following codes are *indices* into the joy_masks array */
|
||||
#define JOY_UP 0
|
||||
#define JOY_DOWN 1
|
||||
#define JOY_LEFT 2
|
||||
#define JOY_RIGHT 3
|
||||
#define JOY_FIRE 4
|
||||
#define JOY_FIRE2 5 /* Second fire button if available */
|
||||
#define JOY_UP_IDX 0
|
||||
#define JOY_DOWN_IDX 1
|
||||
#define JOY_LEFT_IDX 2
|
||||
#define JOY_RIGHT_IDX 3
|
||||
#define JOY_BTN_1_IDX 4 /* Universally available */
|
||||
#define JOY_BTN_2_IDX 5 /* Second fire button if available */
|
||||
#define JOY_BTN_3_IDX 6 /* Third fire button if available */
|
||||
#define JOY_BTN_4_IDX 7 /* Fourth fire button if available */
|
||||
|
||||
/* Array of masks used to check the return value of joy_read for a state */
|
||||
extern const unsigned char joy_masks[8];
|
||||
|
||||
/* Macros that evaluate the return code of joy_read */
|
||||
#define JOY_BTN_UP(v) ((v) & joy_masks[JOY_UP])
|
||||
#define JOY_BTN_DOWN(v) ((v) & joy_masks[JOY_DOWN])
|
||||
#define JOY_BTN_LEFT(v) ((v) & joy_masks[JOY_LEFT])
|
||||
#define JOY_BTN_RIGHT(v) ((v) & joy_masks[JOY_RIGHT])
|
||||
#define JOY_BTN_FIRE(v) ((v) & joy_masks[JOY_FIRE])
|
||||
#define JOY_BTN_FIRE2(v) ((v) & joy_masks[JOY_FIRE2])
|
||||
#define JOY_UP(v) ((v) & joy_masks[JOY_UP_IDX])
|
||||
#define JOY_DOWN(v) ((v) & joy_masks[JOY_DOWN_IDX])
|
||||
#define JOY_LEFT(v) ((v) & joy_masks[JOY_LEFT_IDX])
|
||||
#define JOY_RIGHT(v) ((v) & joy_masks[JOY_RIGHT_IDX])
|
||||
#define JOY_BTN_1(v) ((v) & joy_masks[JOY_BTN_1_IDX])
|
||||
#define JOY_BTN_2(v) ((v) & joy_masks[JOY_BTN_2_IDX])
|
||||
#define JOY_BTN_3(v) ((v) & joy_masks[JOY_BTN_3_IDX])
|
||||
#define JOY_BTN_4(v) ((v) & joy_masks[JOY_BTN_4_IDX])
|
||||
|
||||
/* The name of the standard joystick driver for a platform */
|
||||
extern const char joy_stddrv[];
|
||||
|
||||
Reference in New Issue
Block a user