Skip to content

Commit 12e663a

Browse files
committed
controller can only select key configs of its own type
1 parent 8f1c37f commit 12e663a

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

current-scripts/Demos/useful-scripts/scripts/menu_base_functions/menu_base_functions.gml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,24 +85,36 @@ function handle_spinner_change(_item, _delta) {
8585
/// @param {number} delta
8686
function handle_key_config_select(_item, _delta) {
8787
var _num_values = KEYBOARD_MAX_BINDINGS_PER_CONTROL + GAMEPAD_MAX_BINDINGS_PER_CONTROL;
88-
_item.current_binding_index = wrap(_item.current_binding_index+_delta, 0, _num_values);
89-
90-
if (!_item.silent_on_change && audio_exists(cursor_change_sfx)) {
88+
var _last_pressed = control_state.control_any_pressed();
89+
var _binding_info;
90+
var _original_value = _item.current_binding_index;
91+
92+
do {
93+
_item.current_binding_index = wrap(_item.current_binding_index+_delta, 0, _num_values);
94+
_binding_info = _item.get_binding_info();
95+
} until (_item.current_binding_index == _original_value || _last_pressed.control_type == _binding_info.control_type)
96+
97+
if (_item.current_binding_index != _original_value && !_item.silent_on_change && audio_exists(cursor_change_sfx)) {
9198
audio_play_sound(cursor_change_sfx, 1, false);
9299
}
93100
}
94101

95102
/// @func handle_key_config_confirm(item)
96103
/// @param {MenuKeyConfig} item
97104
function handle_key_config_confirm(_item) {
105+
var _last_pressed = control_state.control_any_pressed();
106+
98107
if (discovery_mode == MENU_DISCOVERY_MODE.NONE) {
99108
// Not selected
100-
_item.current_binding_index = 0;
109+
if (_last_pressed.control_type == CONTROL_TYPE.GAMEPAD) {
110+
_item.current_binding_index = KEYBOARD_MAX_BINDINGS_PER_CONTROL;
111+
} else {
112+
_item.current_binding_index = 0;
113+
}
101114
discovery_mode = MENU_DISCOVERY_MODE.SELECTING;
102115
self.active_key_config = _item;
103116
} else if (discovery_mode == MENU_DISCOVERY_MODE.SELECTING) {
104117
// Selecting
105-
var _last_pressed = control_state.control_any_pressed();
106118
var _binding_info = _item.get_binding_info();
107119

108120
if (_last_pressed.control_type != _binding_info.control_type) return;

current-scripts/Demos/useful-scripts/useful-scripts.yyp

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)