2013-12-07 06:55:00 +00:00
|
|
|
/*
|
2015-10-22 05:13:26 +00:00
|
|
|
* Apple // emulator for *ix
|
2013-12-07 06:55:00 +00:00
|
|
|
*
|
|
|
|
* This software package is subject to the GNU General Public License
|
2015-10-22 05:13:26 +00:00
|
|
|
* version 3 or later (your choice) as published by the Free Software
|
2013-12-07 06:55:00 +00:00
|
|
|
* Foundation.
|
|
|
|
*
|
2015-10-22 05:13:26 +00:00
|
|
|
* Copyright 2013-2015 Aaron Culliney
|
2013-12-07 06:55:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _JOYSTICK_H_
|
|
|
|
#define _JOYSTICK_H_
|
|
|
|
|
2013-12-21 23:25:02 +00:00
|
|
|
#define JOY_RANGE 0x100
|
2015-12-19 21:01:28 +00:00
|
|
|
#define HALF_JOY_RANGE (JOY_RANGE>>1)
|
|
|
|
#define QUARTER_JOY_RANGE (HALF_JOY_RANGE>>1)
|
2013-12-21 23:25:02 +00:00
|
|
|
|
2014-10-19 19:54:03 +00:00
|
|
|
extern uint16_t joy_x;
|
|
|
|
extern uint16_t joy_y;
|
|
|
|
extern uint8_t joy_button0;
|
|
|
|
extern uint8_t joy_button1;
|
|
|
|
extern uint8_t joy_button2;
|
2014-12-06 06:31:12 +00:00
|
|
|
extern bool joy_clip_to_radius;
|
2014-10-19 19:54:03 +00:00
|
|
|
|
|
|
|
#ifdef KEYPAD_JOYSTICK
|
|
|
|
extern uint8_t joy_auto_recenter;
|
|
|
|
extern short joy_step;
|
|
|
|
#endif
|
2014-05-10 20:08:44 +00:00
|
|
|
|
2014-10-25 19:51:09 +00:00
|
|
|
void c_joystick_reset(void);
|
2014-11-09 21:13:27 +00:00
|
|
|
#ifdef INTERFACE_CLASSIC
|
|
|
|
void c_calibrate_joystick(void);
|
|
|
|
#endif
|
2013-12-07 06:55:00 +00:00
|
|
|
|
2015-12-19 21:01:28 +00:00
|
|
|
// enable/disable gamepad clamping to joystick corners
|
|
|
|
void joydriver_setClampBeyondRadius(bool clamp);
|
|
|
|
|
|
|
|
// set joystick axis values
|
|
|
|
void joydriver_setAxisValue(uint8_t x, uint8_t y);
|
|
|
|
|
|
|
|
// return X axis value
|
|
|
|
uint8_t joydriver_getAxisX(void);
|
|
|
|
|
|
|
|
// return Y axis value
|
|
|
|
uint8_t joydriver_getAxisY(void);
|
|
|
|
|
|
|
|
// set button 0 pressed
|
|
|
|
void joydriver_setButton0Pressed(bool pressed);
|
|
|
|
|
|
|
|
// set button 1 pressed
|
|
|
|
void joydriver_setButton1Pressed(bool pressed);
|
|
|
|
|
2015-04-12 22:35:16 +00:00
|
|
|
#if INTERFACE_TOUCH
|
2015-04-02 02:59:38 +00:00
|
|
|
|
2015-08-01 23:46:09 +00:00
|
|
|
typedef enum touchjoy_variant_t {
|
2015-08-22 06:33:08 +00:00
|
|
|
EMULATED_NONE = 0,
|
|
|
|
EMULATED_JOYSTICK, // touch interface emulates a physical joystick device
|
|
|
|
EMULATED_KEYPAD, // touch interface generates key presses
|
2015-08-01 23:46:09 +00:00
|
|
|
} touchjoy_variant_t;
|
|
|
|
|
|
|
|
typedef enum touchjoy_button_type_t {
|
|
|
|
TOUCH_NONE = -1,
|
|
|
|
TOUCH_BUTTON0 = 0,
|
|
|
|
TOUCH_BUTTON1,
|
|
|
|
TOUCH_BOTH,
|
2015-08-16 05:02:51 +00:00
|
|
|
// --or-- an ASCII/fonttext value ...
|
2015-08-01 23:46:09 +00:00
|
|
|
} touchjoy_button_type_t;
|
2015-04-02 02:59:38 +00:00
|
|
|
|
2015-08-16 05:02:51 +00:00
|
|
|
#define ROSETTE_ROWS 3
|
|
|
|
#define ROSETTE_COLS 3
|
|
|
|
|
|
|
|
enum {
|
|
|
|
ROSETTE_NORTHWEST=0,
|
|
|
|
ROSETTE_NORTH,
|
|
|
|
ROSETTE_NORTHEAST,
|
|
|
|
ROSETTE_WEST,
|
|
|
|
ROSETTE_CENTER,
|
|
|
|
ROSETTE_EAST,
|
|
|
|
ROSETTE_SOUTHWEST,
|
|
|
|
ROSETTE_SOUTH,
|
|
|
|
ROSETTE_SOUTHEAST,
|
|
|
|
};
|
|
|
|
|
2015-04-02 02:59:38 +00:00
|
|
|
// is the touch joystick available
|
|
|
|
extern bool (*joydriver_isTouchJoystickAvailable)(void);
|
|
|
|
|
|
|
|
// enable/disable touch joystick
|
2015-04-27 01:12:56 +00:00
|
|
|
extern void (*joydriver_setTouchJoystickEnabled)(bool enabled);
|
|
|
|
|
2015-07-30 04:18:25 +00:00
|
|
|
// grant/remove ownership of touch screen
|
2015-04-27 01:12:56 +00:00
|
|
|
extern void (*joydriver_setTouchJoystickOwnsScreen)(bool pwnd);
|
2015-04-02 02:59:38 +00:00
|
|
|
|
2015-07-30 04:18:25 +00:00
|
|
|
// query touch screen ownership
|
|
|
|
extern bool (*joydriver_ownsScreen)(void);
|
|
|
|
|
2015-08-16 05:02:51 +00:00
|
|
|
/*
|
|
|
|
* set the joystick button types/visuals (scancodes are fired for EMULATED_KEYPAD variant)
|
|
|
|
*
|
|
|
|
* - for EMULATED_JOYSTICK, there is an implicit extra layer-of-indirection for the touchjoy_button_type_t, which maps
|
|
|
|
* to the open apple, closed apple, or "both" visual keys
|
|
|
|
*
|
|
|
|
* - for EMULATED_KEYPAD, the touchjoy_button_type_t is the displayed visual (as ASCII value and lookup into font
|
|
|
|
* table)
|
|
|
|
*/
|
|
|
|
extern void (*joydriver_setTouchButtonTypes)(
|
|
|
|
touchjoy_button_type_t touchDownChar, int downScancode,
|
|
|
|
touchjoy_button_type_t northChar, int northScancode,
|
|
|
|
touchjoy_button_type_t southChar, int southScancode);
|
2015-04-02 02:59:38 +00:00
|
|
|
|
2015-08-16 05:02:51 +00:00
|
|
|
// set the button tap delay (to differentiate between single tap and north/south/etc swipe)
|
2015-08-01 23:46:09 +00:00
|
|
|
extern void (*joydriver_setTapDelay)(float secs);
|
|
|
|
|
2015-08-16 05:02:51 +00:00
|
|
|
// set the sensitivity multiplier
|
2015-08-01 23:46:09 +00:00
|
|
|
extern void (*joydriver_setTouchAxisSensitivity)(float multiplier);
|
|
|
|
|
2015-08-02 18:28:48 +00:00
|
|
|
// set the touch button switch threshold
|
|
|
|
extern void (*joydriver_setButtonSwitchThreshold)(int delta);
|
|
|
|
|
2015-08-01 23:46:09 +00:00
|
|
|
// set the joystick variant
|
|
|
|
extern void (*joydriver_setTouchVariant)(touchjoy_variant_t variant);
|
|
|
|
|
|
|
|
// get the joystick variant
|
|
|
|
extern touchjoy_variant_t (*joydriver_getTouchVariant)(void);
|
|
|
|
|
2015-08-16 05:02:51 +00:00
|
|
|
// set the axis visuals (scancodes are fired for EMULATED_KEYPAD variant)
|
|
|
|
extern void (*joydriver_setTouchAxisTypes)(uint8_t rosetteChars[(ROSETTE_ROWS * ROSETTE_COLS)], int rosetteScancodes[(ROSETTE_ROWS * ROSETTE_COLS)]);
|
2015-04-02 02:59:38 +00:00
|
|
|
|
2015-08-02 18:28:48 +00:00
|
|
|
// set screen divide between axis and buttons
|
|
|
|
extern void (*joydriver_setScreenDivision)(float division);
|
|
|
|
|
|
|
|
// swap axis and buttons sides
|
|
|
|
extern void (*joydriver_setAxisOnLeft)(bool axisIsOnLeft);
|
|
|
|
|
|
|
|
// begin calibration mode
|
|
|
|
extern void (*joydriver_beginCalibration)(void);
|
|
|
|
|
|
|
|
// end calibration mode
|
|
|
|
extern void (*joydriver_endCalibration)(void);
|
|
|
|
|
2015-08-16 05:02:51 +00:00
|
|
|
// end calibration mode
|
|
|
|
extern bool (*joydriver_isCalibrating)(void);
|
|
|
|
|
2015-08-22 18:05:18 +00:00
|
|
|
// set controls visibility
|
|
|
|
extern void (*joydriver_setShowControls)(bool showControls);
|
|
|
|
|
2016-01-03 20:08:47 +00:00
|
|
|
// set azimuth visibility
|
|
|
|
extern void (*joydriver_setShowAzimuth)(bool showAzimuth);
|
|
|
|
|
2015-08-21 05:15:56 +00:00
|
|
|
// set key repeat threshold (keypad joystick)
|
|
|
|
extern void (*joydriver_setKeyRepeatThreshold)(float repeatThresholdSecs);
|
|
|
|
|
2015-04-12 22:35:16 +00:00
|
|
|
#endif // INTERFACE_TOUCH
|
2015-04-02 02:59:38 +00:00
|
|
|
|
2013-12-07 06:55:00 +00:00
|
|
|
#endif // whole file
|