Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gamepad gyro and flick stick support #1800

Merged
merged 49 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
27a28ed
Remove obsolete camera update check
ceski-1 Jul 18, 2024
2fb5163
Use `MIN_F` constant
ceski-1 Jul 20, 2024
2571b99
Rename "swap" to "southpaw"
ceski-1 Jul 20, 2024
e6b31c2
Reorganize gamepad settings and menu items
ceski-1 Jul 21, 2024
682e224
Update defaults
ceski-1 Jul 22, 2024
799b256
Use consistent gamepad naming
ceski-1 Jul 21, 2024
0f3ee43
Simplify `deltatics` calculation
ceski-1 Jul 22, 2024
41eba20
Simplify `I_CalcGamepadAxes()`
ceski-1 Jul 22, 2024
7b99e07
Track axis update time
ceski-1 Jul 22, 2024
a001bf3
Use axis update time for `CalcExtraScale()`
ceski-1 Jul 22, 2024
4fbb5e8
Extra sensitivity improvements, refactoring
ceski-1 Jul 22, 2024
0c19455
Add flick stick feature
ceski-1 Jul 23, 2024
5d3e3d6
Flush gamepad events on reset
ceski-1 Jul 23, 2024
9300334
Add separate touchpad touch and press inputs
ceski-1 Jul 24, 2024
050cbca
Add `joy_flick_mode`
ceski-1 Jul 25, 2024
b9a857f
Add `joy_flick_rotation_speed`
ceski-1 Jul 25, 2024
6c11ab2
Enable float data type for events
ceski-1 Jul 30, 2024
71d5e8a
Add gyro support
ceski-1 Jul 31, 2024
344b363
Update README.md
ceski-1 Jul 31, 2024
437fc73
Add option to disable analog sticks
ceski-1 Jul 31, 2024
b746c08
Don't scale flick stick by regular stick sensitivity
ceski-1 Jul 31, 2024
4c8cbef
Add local space turn/lean options
ceski-1 Jul 31, 2024
e265d1a
Add player space turn/lean options
ceski-1 Aug 1, 2024
8f10931
Add calibration option
ceski-1 Aug 1, 2024
6829b28
Remove "clear calibration" menu item
ceski-1 Aug 2, 2024
96f2c78
Fix DisableItem and DisableItemFunc checks
ceski-1 Aug 2, 2024
6b99e4d
Add back gyro "tightening" menu item
ceski-1 Aug 2, 2024
b83ac0c
Add gyro "steadying" menu item to combine smoothing and tightening
ceski-1 Aug 2, 2024
29b4e68
Combine gyro space/enable into one setting
ceski-1 Aug 2, 2024
f8b1f7a
Load gyro calibration once
ceski-1 Aug 2, 2024
e0b1102
Lower max steadying and use 0.1 increments
ceski-1 Aug 2, 2024
6b34f2b
Cosmetic changes
ceski-1 Aug 3, 2024
6ac57ca
Use degrees/second for analog stick speed
ceski-1 Aug 3, 2024
3172e91
Disable menu items if joy_enable is set to 0
ceski-1 Aug 3, 2024
aa4b4e2
Show raw value dot on thermos for deadzone and steadying
ceski-1 Aug 3, 2024
501ea08
Fix opening/closing a gamepad multiple times
ceski-1 Aug 6, 2024
9e71905
Enable/disable menu items when gamepad is opened/closed
ceski-1 Aug 6, 2024
e047b91
Cosmetic change
ceski-1 Aug 6, 2024
a4602da
Use button names that match gamepad platform
ceski-1 Aug 6, 2024
e377d31
Improve touchpad key binding response
ceski-1 Aug 7, 2024
1386327
Use sensor state for gyro data instead of events
ceski-1 Aug 7, 2024
9b422c2
Allow more actions to confirm/cancel "restore defaults"
ceski-1 Aug 7, 2024
b1edde3
Let MENU_BACKSPACE back out of menu item selection
ceski-1 Aug 7, 2024
b43ccb7
Reduce scope for `motion`
ceski-1 Aug 7, 2024
a2b856b
Reduce scope for `flick`
ceski-1 Aug 7, 2024
9e56b36
Cosmetic changes
ceski-1 Aug 7, 2024
9bd092e
Change menu item dots to meters with color
ceski-1 Aug 7, 2024
4e0826e
Add "invert" gyro button action
ceski-1 Aug 8, 2024
be7c025
Use separate gyro space/enable (again)
ceski-1 Aug 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ If you turn the [Doom logo upside down](https://www.reddit.com/r/Doom/comments/8
* Support for voxels in KVX format.
* 3D audio, supporting stereo and up to 7.1 surround sound with an optional HRTF mode, as well as PC speaker emulation.
* Several music backends: native MIDI, FluidSynth with a bundled soundfont, built-in OPL3 emulator. Digital music and sound formats supported by libsndfile, module music supported by libxmp.
* Modern gamepad support.
* Modern gamepad support, including gyro controls and the flick stick control scheme.
* Mouselook.
* Autoload directories.
* Savegame backward compatibility up to `MBF.EXE`.
Expand Down Expand Up @@ -163,6 +163,13 @@ Copyright:
© 2023 liPillON.
License: [GPL-2.0+](https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)

Files: `src/i_flickstick.*, src/i_gyro.*`
Copyright:
© 2018-2021 Julian "Jibb" Smart;
© 2021-2024 Nicolas Lessard;
© 2024 ceski.
License: [MIT](https://opensource.org/licenses/MIT)

Files: `src/nano_bsp.*`
Copyright: © 2023 Andrew Apted.
License: [MIT](https://opensource.org/licenses/MIT)
Expand Down
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ set(WOOF_SOURCES
hu_stuff.c hu_stuff.h
i_3dsound.c
i_endoom.c i_endoom.h
i_flickstick.c i_flickstick.h
i_gamepad.c i_gamepad.h
i_glob.c i_glob.h
i_gyro.c i_gyro.h
i_input.c i_input.h
i_main.c
i_mbfsound.c
Expand Down Expand Up @@ -67,6 +69,7 @@ set(WOOF_SOURCES
m_random.c m_random.h
mn_snapshot.c mn_snapshot.h
m_swap.h
m_vector.h
memio.c memio.h
midifallback.c midifallback.h
midifile.c midifile.h
Expand Down
8 changes: 4 additions & 4 deletions src/am_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ static void AM_changeWindowLoc(void)
//
void AM_initVariables(void)
{
static event_t st_notify = { ev_keyup, AM_MSGENTERED };
static event_t st_notify = {.type = ev_keyup, .data1.i = AM_MSGENTERED};

automapactive = true;

Expand Down Expand Up @@ -691,7 +691,7 @@ static void AM_LevelInit(void)
//
void AM_Stop (void)
{
static event_t st_notify = { 0, ev_keyup, AM_MSGEXITED };
static event_t st_notify = {.type = 0, .data1.i = ev_keyup, .data2.i = AM_MSGEXITED};

memset(buttons_state, 0, sizeof(buttons_state));

Expand Down Expand Up @@ -829,7 +829,7 @@ boolean AM_Responder
rc = false;
else if (M_InputActivated(input_map_zoomout))
{
if (ev->type == ev_mouseb_down && M_IsMouseWheel(ev->data1))
if (ev->type == ev_mouseb_down && M_IsMouseWheel(ev->data1.i))
{
mousewheelzoom = true;
mtof_zoommul = m_zoomout_mouse;
Expand All @@ -840,7 +840,7 @@ boolean AM_Responder
}
else if (M_InputActivated(input_map_zoomin))
{
if (ev->type == ev_mouseb_down && M_IsMouseWheel(ev->data1))
if (ev->type == ev_mouseb_down && M_IsMouseWheel(ev->data1.i))
{
mousewheelzoom = true;
mtof_zoommul = m_zoomin_mouse;
Expand Down
19 changes: 14 additions & 5 deletions src/d_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#ifndef __D_EVENT__
#define __D_EVENT__

#include "doomtype.h"

//
// Event handling.
//
Expand All @@ -38,20 +40,27 @@ typedef enum evtype_e
ev_joyb_up,
ev_joystick,
ev_joystick_state,
ev_gyro,

// Quit event. Triggered when the user clicks the "close" button
// to terminate the application.
ev_quit,
} evtype_t;

typedef union evdata_u
{
int32_t i;
float f;
} evdata_t;

// Event structure.
typedef struct event_s
{
evtype_t type;
int data1; // keys / mouse/joystick buttons / left axis x
int data2; // mouse/mouse clicks / left axis y
int data3; // mouse / right axis x
int data4; // right axis y
evtype_t type;
evdata_t data1; // keys / mouse/joystick buttons / left axis x
evdata_t data2; // mouse/mouse clicks / left axis y
evdata_t data3; // mouse / right axis x
evdata_t data4; // right axis y
} event_t;

#define EV_RESIZE_VIEWPORT 1
Expand Down
22 changes: 14 additions & 8 deletions src/d_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "g_game.h"
#include "hu_stuff.h"
#include "i_endoom.h"
#include "i_gamepad.h"
#include "i_glob.h"
#include "i_input.h"
#include "i_printf.h"
Expand Down Expand Up @@ -203,7 +204,16 @@ void D_PostEvent(event_t *ev)
if (uncapped && raw_input)
{
G_MovementResponder(ev);
G_PrepControllerTiccmd();
G_PrepGamepadTiccmd();
return;
}
break;

case ev_gyro:
if (uncapped && raw_input)
{
G_MovementResponder(ev);
G_PrepGyroTiccmd();
return;
}
break;
Expand Down Expand Up @@ -236,8 +246,6 @@ void D_ProcessEvents (void)
// draw current display, possibly wiping it from the previous
//

boolean input_ready;

// wipegamestate can be set to -1 to force a wipe on the next draw
gamestate_t wipegamestate = GS_DEMOSCREEN;
static int screen_melt = wipe_Melt;
Expand Down Expand Up @@ -265,14 +273,12 @@ void D_Display (void)
if (nodrawers) // for comparative timing / profiling
return;

input_ready = (!menuactive && gamestate == GS_LEVEL && !paused);

if (uncapped)
{
// [AM] Figure out how far into the current tic we're in as a fixed_t.
fractionaltic = I_GetFracTime();

if (input_ready && raw_input)
if (!menuactive && gamestate == GS_LEVEL && !paused && raw_input)
{
I_StartDisplay();
}
Expand Down Expand Up @@ -2471,7 +2477,7 @@ void D_DoomMain(void)

I_Printf(VB_INFO, "I_Init: Setting up machine state.");
I_InitTimer();
I_InitController();
I_InitGamepad();
I_InitSound();
I_InitMusic();

Expand All @@ -2487,7 +2493,7 @@ void D_DoomMain(void)
G_UpdateSideMove();
G_UpdateAngleFunctions();
G_UpdateLocalViewFunction();
G_UpdateControllerVariables();
G_UpdateGamepadVariables();
G_UpdateMouseVariables();
R_UpdateViewAngleFunction();

Expand Down
2 changes: 0 additions & 2 deletions src/d_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ boolean D_CheckEndDoom(void);
// Called by IO functions when input is detected.
void D_PostEvent(struct event_s *ev);

extern boolean input_ready;

void D_BindMiscVariables(void);

//
Expand Down
75 changes: 37 additions & 38 deletions src/doomkeys.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,39 +155,40 @@ enum

enum
{
CONTROLLER_A,
CONTROLLER_B,
CONTROLLER_X,
CONTROLLER_Y,
CONTROLLER_BACK,
CONTROLLER_GUIDE,
CONTROLLER_START,
CONTROLLER_LEFT_STICK,
CONTROLLER_RIGHT_STICK,
CONTROLLER_LEFT_SHOULDER,
CONTROLLER_RIGHT_SHOULDER,
CONTROLLER_DPAD_UP,
CONTROLLER_DPAD_DOWN,
CONTROLLER_DPAD_LEFT,
CONTROLLER_DPAD_RIGHT,
CONTROLLER_MISC1,
CONTROLLER_PADDLE1,
CONTROLLER_PADDLE2,
CONTROLLER_PADDLE3,
CONTROLLER_PADDLE4,
CONTROLLER_TOUCHPAD,
CONTROLLER_LEFT_TRIGGER,
CONTROLLER_RIGHT_TRIGGER,
CONTROLLER_LEFT_STICK_UP,
CONTROLLER_LEFT_STICK_DOWN,
CONTROLLER_LEFT_STICK_LEFT,
CONTROLLER_LEFT_STICK_RIGHT,
CONTROLLER_RIGHT_STICK_UP,
CONTROLLER_RIGHT_STICK_DOWN,
CONTROLLER_RIGHT_STICK_LEFT,
CONTROLLER_RIGHT_STICK_RIGHT,

NUM_CONTROLLER_BUTTONS
GAMEPAD_A,
GAMEPAD_B,
GAMEPAD_X,
GAMEPAD_Y,
GAMEPAD_BACK,
GAMEPAD_GUIDE,
GAMEPAD_START,
GAMEPAD_LEFT_STICK,
GAMEPAD_RIGHT_STICK,
GAMEPAD_LEFT_SHOULDER,
GAMEPAD_RIGHT_SHOULDER,
GAMEPAD_DPAD_UP,
GAMEPAD_DPAD_DOWN,
GAMEPAD_DPAD_LEFT,
GAMEPAD_DPAD_RIGHT,
GAMEPAD_MISC1,
GAMEPAD_PADDLE1,
GAMEPAD_PADDLE2,
GAMEPAD_PADDLE3,
GAMEPAD_PADDLE4,
GAMEPAD_TOUCHPAD_PRESS,
GAMEPAD_TOUCHPAD_TOUCH,
GAMEPAD_LEFT_TRIGGER,
GAMEPAD_RIGHT_TRIGGER,
GAMEPAD_LEFT_STICK_UP,
GAMEPAD_LEFT_STICK_DOWN,
GAMEPAD_LEFT_STICK_LEFT,
GAMEPAD_LEFT_STICK_RIGHT,
GAMEPAD_RIGHT_STICK_UP,
GAMEPAD_RIGHT_STICK_DOWN,
GAMEPAD_RIGHT_STICK_LEFT,
GAMEPAD_RIGHT_STICK_RIGHT,

NUM_GAMEPAD_BUTTONS
};

enum
Expand Down Expand Up @@ -225,12 +226,10 @@ enum

enum
{
LAYOUT_DEFAULT,
LAYOUT_SWAP,
LAYOUT_LEGACY,
LAYOUT_LEGACY_SWAP,
GYRO_TURN,
GYRO_LOOK,

NUM_LAYOUTS
NUM_GYRO_AXES
};

#endif // __DOOMKEYS__
Loading
Loading