Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions code/controlconfig/controlsconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1531,6 +1531,11 @@ const char *control_config_tooltip_handler(const char *str)
return NULL;
}

bool control_config_special_mode()
{
return (Binding_mode || Search_mode);
}

void control_config_init(bool API_Access)
{
int i;
Expand Down
5 changes: 5 additions & 0 deletions code/controlconfig/controlsconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,11 @@ void control_config_common_init();
*/
void control_config_common_close();

/*!
* @brief detect whether control config is in search or binding modes
*/
bool control_config_special_mode();

/*!
* @brief init config menu
*/
Expand Down
51 changes: 43 additions & 8 deletions code/controlconfig/controlsconfigcommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2611,25 +2611,51 @@ void CC_bind::invert_toggle() {
flags ^= CCF_INVERTED;
}


static bool compare_btn(short cid, const CC_bind& A, char& A_flags, const CC_bind& B, char& B_flags)
{
auto A_btn = A.get_btn();
auto B_btn = B.get_btn();

auto current = io::joystick::getPlayerJoystick(cid);

if (current && current->isGamepad()) {
if (A_btn >= SDL_GAMEPAD_BUTTON_COUNT) {
A_btn = (A_btn - SDL_GAMEPAD_BUTTON_COUNT) + SDL_GAMEPAD_AXIS_LEFT_TRIGGER;
A_flags |= CCF_AXIS_BTN;
}

if (B_btn >= SDL_GAMEPAD_BUTTON_COUNT) {
B_btn = (B_btn - SDL_GAMEPAD_BUTTON_COUNT) + SDL_GAMEPAD_AXIS_LEFT_TRIGGER;
B_flags |= CCF_AXIS_BTN;
}
}

return (A_btn == B_btn);
}

bool CC_bind::conflicts_with(const CC_bind& B) const {
char A_flags = flags;
char B_flags = B.flags;

// Bail early if CID or btn are not the same
if ((cid != B.cid) || (btn != B.btn)) {
if ((cid != B.cid) || !compare_btn(cid, *this, A_flags, B, B_flags)) {
return false;
}

// Check if A is an Axis or Axis Button, and if B is an Axis or Axis Button
char mask = (CCF_AXIS_BTN | CCF_AXIS);
if ((flags & mask) && (B.flags & mask)) {
if ((A_flags & mask) && (B_flags & mask)) {
return true;
}

// Check if Hat
if (flags & B.flags & CCF_HAT) {
if (A_flags & B_flags & CCF_HAT) {
return true;
}

// Check if Ball
if (flags & B.flags & CCF_BALL) {
if (A_flags & B_flags & CCF_BALL) {
return true;
}

Expand All @@ -2641,7 +2667,7 @@ bool CC_bind::conflicts_with(const CC_bind& B) const {
// First off, check if A or B is NOT a button, as according to the mask. Buttons do not have a flag, so we check
// if they are any of the other input types
// Next, we return the inverse of the result. Negative of a Negative = Positive. Not Not a button = Is a button
return !((flags | B.flags) & mask);
return !((A_flags | B_flags) & mask);
}

bool CC_bind::is_inverted() const {
Expand Down Expand Up @@ -2732,10 +2758,19 @@ SCP_string CC_bind::textify() const {
case CID_JOY0:
case CID_JOY1:
case CID_JOY2:
case CID_JOY3:
Assert((btn >= 0) && (btn < JOY_TOTAL_BUTTONS));
retval = SCP_string(textify_button(btn));
case CID_JOY3: {
auto axis = joy_get_button_axis(cid, btn);

if (axis < 0) {
Assert((btn >= 0) && (btn < JOY_TOTAL_BUTTONS));
retval = SCP_string(textify_button(btn));
} else {
Assert((axis >= 0) && (axis < NUM_AXIS_TEXT));
retval = SCP_string(Axis_text[axis]);
}

break;
}

case CID_NONE:
default:
Expand Down
5 changes: 5 additions & 0 deletions code/cutscene/movie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "tracing/tracing.h"
#include "io/timer.h"
#include "io/key.h"
#include "io/gamepad.h"
#include "mod_table/mod_table.h"
#include "network/multi.h"
#include "scripting/global_hooks.h"
Expand Down Expand Up @@ -244,6 +245,10 @@ void movie_display_loop(Player* player, PlaybackState* state) {

processEvents();

if (io::gamepad::action_or_cancel()) {
state->playing = false;
}

// NOTE: This does not update mission time! If movies get enabled in places
// other than through cutscenes then some refactoring should be done
// to account for normal time progression rather than just timestamps
Expand Down
Loading
Loading