Commit graph

63 commits

Author SHA1 Message Date
Tylor 6fee36638d Feat: Pitch unlocker 2022-08-21 16:16:40 -05:00
Kp 6863dd3581 Reduce lifetime of joy_axis
It is only needed for the duration of kconfig_end_loop.  Move it from
the global Controls to local scope.
2022-02-27 14:23:53 +00:00
Kp 197a9cbd98 Move joystick interpretation to happen after the event loop
If two or more events are delivered in the same loop, the previous
implementation would count joystick motion multiple times.  Fix this by
moving the joystick interpretation to occur once, after all the events
have been processed.
2022-02-27 14:23:53 +00:00
Kp 1843ed752c Fix Windows build of kconfig.h
fbd05a1592 changed joy.h to include only fwd-event.h, but not event.h.
event.h included maths.h, which kconfig.h was relying on.  Add an
inclusion of maths.h into kconfig.h to define `fix`.

Fixes: fbd05a1592 ("optimize include files (include what you use)")
2021-04-04 22:01:25 +00:00
Kp 6af56a27f2 Remove outdated joystick preprocessor guards
Testing for buttons||hats||axes is equivalent to testing for
joysticks!=0, since SConstruct forces joysticks=0 when
buttons == 0 && hats == 0 && axes == 0.  Remove tests of
buttons||hats||axes when those occur inside a test for joysticks!=0.
2020-07-16 02:31:04 +00:00
Kp 5735175999 Merge 'refs/pull/516/head' into master 2020-07-09 02:47:18 +00:00
Kp 569802e00f Convert kconfig array lookups to require correct enumerated type
This ensures that an array is indexed by the appropriate type.  Indexing
a mouse array with a joystick index is undefined behavior, and with this
change, such undefined behavior is now a compilation error.
2020-07-05 23:34:33 +00:00
Martin Fiedler 853a0c41e1 added joystick binding for showing ingame menu
A new configurable joystick button binding is
introduced that opens the ingame menu, i.e. the
menu that appears when pressing the Escape key.

Fortunately, there was still enough space left
in the button binding maps for both games. The
configuration screen, however, needed to be
extended by a row to make room for the new
binding on d2x.

One known issue: When using an old player
configuration file, the menu button bindings
are initially set to J1 B1, because the unused
slots in DefaultKeySettings used to be
initialized that way. There's not much we can
do about that; the player needs to remove
these bogus assignments by hand. We can (and
do) prevent that from happening again, though,
by initializing new player files with correct
unmapped buttons.
2020-06-29 23:16:04 +02:00
Kp b08620292d Fix input handling in automap
The automap code keeps a mostly-private secondary copy of control_info.
The change to reset control_info before the event loop reset the main
copy of control_info for the automap, not the copy that the automap
actually used.  Fix this by passing the desired control_info to relevant
functions instead of always using the global variable Controls.

Fixes: c621a970c6 ("Reset kconfig counters once, before the event loop")
2020-05-28 03:21:22 +00:00
Kp c621a970c6 Reset kconfig counters once, before the event loop 2020-05-27 03:07:17 +00:00
Kp 8839f538e0 Refer to <array> directly, not through "compiler-array.h" 2020-05-02 21:18:42 +00:00
Kp 3170b11997 Modernize typedefs for std::array types
Use `using x = y;` instead of `typedef y x;`.
2020-05-02 21:18:42 +00:00
Kp 53761500f1 Qualify uses of std::array 2020-05-02 21:18:42 +00:00
Kp 5fa8c06914 Add experimental support for autosaves
Set autosave interval to 10 minutes, unless specified in the player's
configuration file.  Players can change the autosave to 0 minutes to
disable it.
2020-04-19 20:47:07 +00:00
daivuk 74ef8b02e6 Added axis buttons
Each axis can act as two buttons in both ways.
For example, a player might map slide left and slide right to J1 -A1 and J1 +A1 as button presses instead of the slide L/R axis.

This is mostly to fix XBox 360 Controller Left and Right triggers. But it can work on every axis if the player wishes to bind them.
2019-09-01 13:11:14 -04:00
Kp 22fe81666a Unify some control_info fields 2018-01-29 01:56:40 +00:00
Kp 7311712399 Compile out joystick key settings when DXX_MAX_JOYSTICKS=0 2017-12-05 05:29:55 +00:00
Kp 88832e3679 Use constexpr integral_constant for various magic numbers 2017-10-14 17:10:30 +00:00
Kp 9421c31b5a Replace "compiler-type_traits.h" with <type_traits>
Delete stub "compiler-type_traits.h" header.  Redirect all uses to the
standard <type_traits> header.

git grep -wlz 'compiler-type_traits.h' -- '*.cpp' '*.h' | xargs -0 perl -p -i <<EOF
    BEGIN {
	    $i = 0;
    }
    if (($i == 1 && $_ eq "\n") || ($i < 2 && /^#include "/)) {
	    # First blank line or first user-include after a system-include.
	    # Print, then never again for this file.
	    print "#include <type_traits>\n";
	    $i = 2;
    } elsif ($i == 0) {
	    $i = 1 if (/^#include </);
    } elsif ($_ eq "#include \"compiler-type_traits.h\"\n") {
	    # Remove this line if found.
	    $_ = '';
    }
    # Reset state machine when moving to next file.
    $i = 0 if eof;
EOF
2017-06-25 20:46:03 +00:00
Kp adcf02e454 Expand tt:: indirection to std::
All supported compilers have an acceptable <type_traits>.  Commit
4cb3d46148 ("Move <type_traits> test to Cxx11RequiredFeature") made
<type_traits> support mandatory in August and no one has objected.
Remove the indirection and use namespace std directly for type_traits
members.
2017-06-25 20:46:03 +00:00
Kp 806c76ce02 Fix label truncation when strlen(hats) + 1 < strlen(buttons)
Hat labels reserve an extra character for the arrow, which partially
masked this error.  When used buttons requires more characters than (1
+ used hats), the buffer had insufficient space and the label was
truncated.
2017-05-13 04:19:39 +00:00
Kp 10aa2e5106 Move some kconfig symbols into namespace dsx 2016-12-22 05:21:16 +00:00
Kp 4894117d70 Rename MAX_HATS_PER_JOYSTICK to DXX_MAX_HATS_PER_JOYSTICK
Rename symbol MAX_HATS_PER_JOYSTICK to DXX_MAX_HATS_PER_JOYSTICK
to show that it is a DXX symbol, not one inherited from a library.

git grep -lzw MAX_HATS_PER_JOYSTICK -- SConstruct '*.h' '*.cpp' | xargs -0 sed -i -e 's/\<MAX_HATS_PER_JOYSTICK\>/DXX_&/g'
2016-09-25 04:52:49 +00:00
Kp 94937de128 Rename MAX_BUTTONS_PER_JOYSTICK to DXX_MAX_BUTTONS_PER_JOYSTICK
Rename symbol MAX_BUTTONS_PER_JOYSTICK to DXX_MAX_BUTTONS_PER_JOYSTICK
to show that it is a DXX symbol, not one inherited from a library.

git grep -lzw MAX_BUTTONS_PER_JOYSTICK -- SConstruct '*.h' '*.cpp' | xargs -0 sed -i -e 's/\<MAX_BUTTONS_PER_JOYSTICK\>/DXX_&/g'
2016-09-25 04:52:49 +00:00
Kp 7d38a9f0be Rename MAX_AXES_PER_JOYSTICK to DXX_MAX_AXES_PER_JOYSTICK
Rename symbol MAX_AXES_PER_JOYSTICK to DXX_MAX_AXES_PER_JOYSTICK to show
that it is a DXX symbol, not one inherited from a library.

git grep -lzw MAX_AXES_PER_JOYSTICK -- SConstruct '*.h' '*.cpp' | xargs -0 sed -i -e 's/\<MAX_AXES_PER_JOYSTICK\>/DXX_&/g'
2016-09-25 04:52:49 +00:00
Kp f24e9f836c Rename MAX_JOYSTICKS to DXX_MAX_JOYSTICKS
Rename symbol MAX_JOYSTICKS to DXX_MAX_JOYSTICKS to show that it is a DXX
symbol, not one inherited from a library.

git grep -lzw MAX_JOYSTICKS -- SConstruct '*.h' '*.cpp' | xargs -0 sed -i -e 's/\<MAX_JOYSTICKS\>/DXX_&/g'
2016-09-25 04:52:48 +00:00
Kp 44592ddc31 Flatten kconfig type hierarchy 2016-07-14 01:59:05 +00:00
Kp dbe4918f27 Use inline namespace dcx for common/arch/sdl 2015-12-05 22:57:24 +00:00
Kp 6111e5adbf Allow configuring max joysticks at build time 2015-11-01 21:15:40 +00:00
Kp 545b71c1cc Use enum class for kconfig subtype 2015-11-01 21:15:38 +00:00
Kp d971cf7702 Wrap game-specific types in game-specific preprocessor guards
These types are not used in common code, and in some cases would provoke
a -Wodr warning if they were used.
2015-09-26 21:17:12 +00:00
zico d3660207d2 Added Mouse Overrun Buffer option as proposed by kp 2015-09-24 16:31:10 +02:00
Kp 0c106b67f2 Make convert_raw_joy_axis static 2015-06-23 03:04:47 +00:00
Kp 29aa820dc0 Only respawn when the player presses fire
Only respawn when the player presses a fire key/button (primary,
secondary, or flare).  Only clear primary, second, flare, and bomb when
respawning.  This allows dead players to use the automap or change their
camera views.

This is a necessary step to flushing only the firing inputs on respawn,
as requested by Mako88 in
<https://github.com/dxx-rebirth/dxx-rebirth/issues/104>.  Currently,
inputs are flushed again by the activation of the game window, so
respawn still flushes all inputs.

	#1  0x00005555555cee19 in game_flush_inputs () at similar/main/game.cpp:374
	#2  game_handler (event=...) at similar/main/game.cpp:1114
	#3  0x0000555555576113 in window_send_event (wind=..., event=...) at common/arch/sdl/window.cpp:208
	#4  0x000055555557627b in WINDOW_SEND_EVENT (file=0x5555556dc126 "common/arch/sdl/window.cpp", e=0x5555556dc141 "EVENT_WINDOW_ACTIVATED", line=179, event=..., w=...) at common/include/window.h:111
	#5  window_set_visible (w=..., visible=visible@entry=1) at common/arch/sdl/window.cpp:179
	#6  0x00005555555e90f5 in window_set_visible (visible=1, wind=<optimized out>) at common/include/window.h:90
	#7  DoPlayerDead () at similar/main/gameseq.cpp:1479
	#8  0x000055555563ed65 in dead_player_frame () at similar/main/object.cpp:1486
	#9  0x00005555555cf4df in GameProcessFrame () at similar/main/game.cpp:1329
	#10 game_handler (event=...) at similar/main/game.cpp:1157
2015-06-20 16:16:43 +00:00
John Ackerman fe71a94d53 Implement Nonlinear Joystick Settings
[Kp: fix whitespace; squash fixes into main]
Requested-by: Mako88 <https://github.com/dxx-rebirth/dxx-rebirth/pull/84>
2015-06-11 01:41:26 +00:00
Kp 808d5c1cf2 Switch joystick_text_length to integral_constant 2015-04-19 04:18:52 +00:00
Kp cd6be09547 Reduce kconfig.h includes 2015-04-19 04:18:51 +00:00
Kp 90fbebf8fd Convert most global arrays to array<> 2015-04-02 02:36:52 +00:00
Kp a8f853aa7a Pass d_event arg by const& 2014-10-04 22:36:13 +00:00
Kp 3e8ec8932f Use array<> for player_config 2014-08-26 02:59:01 +00:00
zico ad7cb106bc Changed custom D1X license to GPLv3 2014-06-01 19:55:23 +02:00
Kp 094dfbf3d4 Reduce header inclusions 2013-12-31 03:22:03 +00:00
Kp 1e8036bd24 Split compiler.h for PCH compatibility 2013-12-21 05:12:38 +00:00
Kp 2bd302cddd Move Controls ubyte values into substructure 2013-12-13 03:47:57 +00:00
Kp 141ead1830 Move ramped controls into template structure 2013-12-07 21:13:37 +00:00
Kp 9de54cfa74 Switch to C++ linkage
import fileinput
guard = 0
cxxguard = '#ifdef __cplusplus\n'
for line in fileinput.input(inplace=True):
	if line == cxxguard:
		guard = 1
		continue
	if guard:
		if line == 'extern "C" {\n':
			guard = 2
			continue
		if line == '}\n':
			guard = 0
			continue
		if guard == 2:
			assert(line == '#endif\n')
			guard = 0
			print cxxguard,
			continue
	print line,
2013-12-06 03:35:32 +00:00
Kp 74ac85076f Store joystick button text in one allocation 2013-12-01 22:42:47 +00:00
Kp 5354d05fbf Store joystick axis text in one allocation 2013-12-01 22:42:47 +00:00
Kp 6becfdacca Remove NUM_DXX_REBIRTH_CONTROLS 2013-11-18 00:54:59 +00:00
Kp a842b31a20 Remove NUM_MOUSE_CONTROLS 2013-11-18 00:54:59 +00:00