Skip to content
This repository was archived by the owner on Feb 1, 2026. It is now read-only.
/ Input Public archive

Commit 0d60f37

Browse files
committed
Merge branch 'dev'
2 parents 4a15d87 + eeb9106 commit 0d60f37

40 files changed

+2268
-214
lines changed

datafiles/sdl2.txt

Lines changed: 888 additions & 0 deletions
Large diffs are not rendered by default.

input.yyp

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

objects/obj_example/Create_0.gml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ enum VERB
99
PAUSE,
1010
}
1111

12+
rebinding = false;
13+
1214
input_cursor_verbs(VERB.LEFT, VERB.RIGHT, VERB.UP, VERB.DOWN, 5);
1315
input_cursor_move(room_width/2, room_height/2);
1416

@@ -21,7 +23,7 @@ input_default_key(vk_backspace, VERB.CANCEL );
2123
input_default_key(vk_escape , VERB.PAUSE );
2224
input_default_key(vk_enter , VERB.PAUSE, 1);
2325

24-
input_default_mouse_button(mb_left, VERB.CONFIRM, 1)
26+
input_default_mouse_button(mb_left, VERB.CONFIRM, 1);
2527

2628
input_default_gamepad_axis(gp_axislh , true , VERB.LEFT );
2729
input_default_gamepad_axis(gp_axislh , false, VERB.RIGHT);

objects/obj_example/Draw_0.gml

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,35 @@
1-
var _string = "Left = " + string(input_value(VERB.LEFT )) + "\n";
2-
_string += "Right = " + string(input_value(VERB.RIGHT )) + "\n";
3-
_string += "Up = " + string(input_value(VERB.UP )) + "\n";
4-
_string += "Down = " + string(input_value(VERB.DOWN )) + "\n";
5-
_string += "Confirm = " + string(input_value(VERB.CONFIRM)) + "\n";
6-
_string += "Cancel = " + string(input_value(VERB.CANCEL )) + "\n";
7-
_string += "Pause = " + string(input_value(VERB.PAUSE )) + "\n";
8-
1+
var _string = "Left = " + string(input_value(VERB.LEFT )) + " " + string(input_binding_get(VERB.LEFT )) + "\n";
2+
_string += "Right = " + string(input_value(VERB.RIGHT )) + " " + string(input_binding_get(VERB.RIGHT )) + "\n";
3+
_string += "Up = " + string(input_value(VERB.UP )) + " " + string(input_binding_get(VERB.UP )) + "\n";
4+
_string += "Down = " + string(input_value(VERB.DOWN )) + " " + string(input_binding_get(VERB.DOWN )) + "\n";
5+
_string += "Confirm = " + string(input_value(VERB.CONFIRM)) + " " + string(input_binding_get(VERB.CONFIRM)) + "\n";
6+
_string += "Cancel = " + string(input_value(VERB.CANCEL )) + " " + string(input_binding_get(VERB.CANCEL )) + "\n";
7+
_string += "Pause = " + string(input_value(VERB.PAUSE )) + " " + string(input_binding_get(VERB.PAUSE )) + "\n";
8+
_string += "Recent (all) = " + string(input_check_press_most_recent()) + "\n";
9+
_string += "Recent (4dir) = " + string(input_check_press_most_recent([VERB.LEFT, VERB.RIGHT, VERB.UP, VERB.DOWN])) + "\n";
10+
11+
//var _gamepad = input_player_gamepad_get(0);
12+
//var _i = 0;
13+
//repeat(30)
14+
//{
15+
// if (gamepad_button_check(_gamepad, _i))
16+
// {
17+
// _string += "b" + string(_i) + "\n";
18+
// }
19+
//
20+
// ++_i;
21+
//}
22+
//
23+
//var _i = 0;
24+
//repeat(10)
25+
//{
26+
// _string += "a" + string(_i) + " = " + string(gamepad_axis_value(_gamepad, _i)) + "\n";
27+
// ++_i;
28+
//}
29+
//
30+
//_string += "a4106 = " + string(gamepad_axis_value(_gamepad, 4106)) + "\n";
31+
//_string += "a4107 = " + string(gamepad_axis_value(_gamepad, 4107)) + "\n";
32+
933
draw_text(10, 10, _string);
1034

1135
var _i = 0;

objects/obj_example/Step_1.gml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
input_tick();
2-
input_hotswap_tick();
2+
input_hotswap_tick();
3+
4+
if (input_check_p(VERB.PAUSE)) rebinding = true;
5+
if (rebinding)
6+
{
7+
if (input_rebind_tick(VERB.UP) != 0) rebinding = false;
8+
}
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
#macro INPUT_MAX_PLAYERS 4 //Maximum number of players that the game supports
2-
#macro INPUT_MAX_ALTERNATE_BINDINGS 2 //Maximum number of alternate bindings per verb per input source
3-
#macro INPUT_DEFAULT_MIN_THRESHOLD 0.3 //Default minimum threshold for gamepad axes. This value is used for detecting gamepad input in input_hotswap_tick() so make sure you set it above 0.0
4-
#macro INPUT_DEFAULT_MAX_THRESHOLD 1.0 //Default maximum threshold for gamepad axes
5-
#macro INPUT_BUFFERED_REALTIME false //Set to true to use milliseconds instead of frames for input_check_*() functions
6-
#macro INPUT_HOTSWAP_DELAY 33 //Number of milliseconds between source swaps. This should be longer than a single frame (>17 ms)
1+
#macro INPUT_MAX_PLAYERS 4 //Maximum number of players that the game supports
2+
#macro INPUT_MAX_ALTERNATE_BINDINGS 2 //Maximum number of alternate bindings per verb per input source
3+
#macro INPUT_DEFAULT_MIN_THRESHOLD 0.3 //Default minimum threshold for gamepad axes. This value is used for detecting gamepad input in input_hotswap_tick() so make sure you set it above 0.0
4+
#macro INPUT_DEFAULT_MAX_THRESHOLD 1.0 //Default maximum threshold for gamepad axes
5+
#macro INPUT_BUFFERED_REALTIME false //Set to true to use milliseconds instead of frames for input_check_*() functions
6+
#macro INPUT_HOTSWAP_DELAY 33 //Number of milliseconds between source swaps. This should be longer than a single frame (>17 ms)
7+
#macro INPUT_HOTSWAP_ON_MOUSE_MOVEMENT true //Whether to trigger a hotswap when the mouse is moved
8+
#macro INPUT_HOTSWAP_ON_GAMEPAD_AXIS true //Whether to trigger a hotswap when a gamepad axis is moved
9+
#macro INPUT_SDL2_DATABASE_FILENAME "sdl2.txt" //Name of the SDL2 database to read gamepad remapping definitions from. Use an empty string to not load any definitions
10+
#macro INPUT_SDL2_GP_SELECT_NAME "back" //SDL2 binding name for gp_select (GameMaker's documentation says "guide" but most SDL2 definitions use "back")

scripts/input_assignment_tick/input_assignment_tick.gml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -126,22 +126,22 @@ function __input_assignment_tick_input(_player_index)
126126
{
127127
if (gamepad_is_connected(_g) && __input_source_is_available(INPUT_SOURCE.GAMEPAD, _g))
128128
{
129-
if (gamepad_button_check_pressed(_g, gp_face1)
130-
|| gamepad_button_check_pressed(_g, gp_face2)
131-
|| gamepad_button_check_pressed(_g, gp_face3)
132-
|| gamepad_button_check_pressed(_g, gp_face4)
133-
|| gamepad_button_check_pressed(_g, gp_padu)
134-
|| gamepad_button_check_pressed(_g, gp_padd)
135-
|| gamepad_button_check_pressed(_g, gp_padl)
136-
|| gamepad_button_check_pressed(_g, gp_padr)
137-
|| gamepad_button_check_pressed(_g, gp_shoulderl)
138-
|| gamepad_button_check_pressed(_g, gp_shoulderr)
139-
|| gamepad_button_check_pressed(_g, gp_shoulderlb)
140-
|| gamepad_button_check_pressed(_g, gp_shoulderrb)
141-
|| gamepad_button_check_pressed(_g, gp_start)
142-
|| gamepad_button_check_pressed(_g, gp_select)
143-
|| gamepad_button_check_pressed(_g, gp_stickl)
144-
|| gamepad_button_check_pressed(_g, gp_stickr))
129+
if (input_gamepad_check_press(_g, gp_face1)
130+
|| input_gamepad_check_press(_g, gp_face2)
131+
|| input_gamepad_check_press(_g, gp_face3)
132+
|| input_gamepad_check_press(_g, gp_face4)
133+
|| input_gamepad_check_press(_g, gp_padu)
134+
|| input_gamepad_check_press(_g, gp_padd)
135+
|| input_gamepad_check_press(_g, gp_padl)
136+
|| input_gamepad_check_press(_g, gp_padr)
137+
|| input_gamepad_check_press(_g, gp_shoulderl)
138+
|| input_gamepad_check_press(_g, gp_shoulderr)
139+
|| input_gamepad_check_press(_g, gp_shoulderlb)
140+
|| input_gamepad_check_press(_g, gp_shoulderrb)
141+
|| input_gamepad_check_press(_g, gp_start)
142+
|| input_gamepad_check_press(_g, gp_select)
143+
|| input_gamepad_check_press(_g, gp_stickl)
144+
|| input_gamepad_check_press(_g, gp_stickr))
145145
{
146146
return { source : INPUT_SOURCE.GAMEPAD, gamepad : _g };
147147
}

scripts/input_async_system_event/input_async_system_event.gml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,28 @@ function input_async_system_event()
22
{
33
var _any_changed = false;
44

5-
if (async_load[? "event_type"] == "gamepad lost")
5+
if (async_load[? "event_type"] == "gamepad discovered")
66
{
7+
//Create a new gamepad handler to manage remapping
8+
var _gamepad = async_load[? "pad_index"];
9+
global.__input_gamepads[@ _gamepad] = new __input_class_gamepad(_gamepad);
10+
}
11+
else if (async_load[? "event_type"] == "gamepad lost")
12+
{
13+
//Remove our gamepad handler
14+
var _gamepad = async_load[? "pad_index"];
15+
global.__input_gamepads[@ _gamepad] = undefined;
16+
17+
//Also report gamepad changes for any active players
718
var _i = 0;
819
repeat(INPUT_MAX_PLAYERS)
920
{
1021
with(global.__input_players[_i])
1122
{
12-
if (gamepad == async_load[? "pad_index"] && (source == INPUT_SOURCE.GAMEPAD))
23+
if ((gamepad == _gamepad) && (source == INPUT_SOURCE.GAMEPAD))
1324
{
1425
__input_trace("Player ", _i, " gamepad disconnected");
26+
1527
source = INPUT_SOURCE.NONE;
1628
_any_changed = true;
1729
}

scripts/input_bindings_copy/input_bindings_copy.gml

Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -3,80 +3,80 @@
33

44
function input_bindings_copy(_player_index_s, _player_index_d)
55
{
6-
if (is_struct(_player_index_s))
7-
{
8-
var _player_s = _player_index_s;
9-
}
10-
else
11-
{
12-
var _player_s = global.__input_players[_player_index_s];
13-
14-
if (_player_index_s < 0)
15-
{
16-
__input_error("Invalid source player index provided (", _player_index_s, ")");
17-
return undefined;
18-
}
19-
20-
if (_player_index_s >= INPUT_MAX_PLAYERS)
21-
{
22-
__input_error("Source player index too large (", _player_index_s, " vs. ", INPUT_MAX_PLAYERS, ")\nIncrease INPUT_MAX_PLAYERS to support more players");
23-
return undefined;
24-
}
25-
}
26-
27-
if (is_struct(_player_index_d))
28-
{
29-
var _player_d = _player_index_d;
30-
}
31-
else
32-
{
33-
var _player_d = global.__input_players[_player_index_d];
34-
35-
if (_player_index_d < 0)
36-
{
37-
__input_error("Invalid destination player index provided (", _player_index_d, ")");
38-
return undefined;
39-
}
40-
41-
if (_player_index_d >= INPUT_MAX_PLAYERS)
42-
{
43-
__input_error("Destination player index too large (", _player_index_d, " vs. ", INPUT_MAX_PLAYERS, ")\nIncrease INPUT_MAX_PLAYERS to support more players");
44-
return undefined;
45-
}
46-
}
47-
6+
if (is_struct(_player_index_s))
7+
{
8+
var _player_s = _player_index_s;
9+
}
10+
else
11+
{
12+
var _player_s = global.__input_players[_player_index_s];
13+
14+
if (_player_index_s < 0)
15+
{
16+
__input_error("Invalid source player index provided (", _player_index_s, ")");
17+
return undefined;
18+
}
19+
20+
if (_player_index_s >= INPUT_MAX_PLAYERS)
21+
{
22+
__input_error("Source player index too large (", _player_index_s, " vs. ", INPUT_MAX_PLAYERS, ")\nIncrease INPUT_MAX_PLAYERS to support more players");
23+
return undefined;
24+
}
25+
}
26+
27+
if (is_struct(_player_index_d))
28+
{
29+
var _player_d = _player_index_d;
30+
}
31+
else
32+
{
33+
var _player_d = global.__input_players[_player_index_d];
34+
35+
if (_player_index_d < 0)
36+
{
37+
__input_error("Invalid destination player index provided (", _player_index_d, ")");
38+
return undefined;
39+
}
40+
41+
if (_player_index_d >= INPUT_MAX_PLAYERS)
42+
{
43+
__input_error("Destination player index too large (", _player_index_d, " vs. ", INPUT_MAX_PLAYERS, ")\nIncrease INPUT_MAX_PLAYERS to support more players");
44+
return undefined;
45+
}
46+
}
47+
4848
with(_player_d)
4949
{
5050
sources = array_create(INPUT_SOURCE.__SIZE, undefined);
5151

52-
var _source = 0;
53-
repeat(INPUT_SOURCE.__SIZE)
54-
{
55-
var _source_verb_struct = variable_struct_get(_player_s.config, global.__input_source_names[_source]);
56-
if (is_struct(_source_verb_struct))
57-
{
58-
var _verb_names = variable_struct_get_names(_source_verb_struct);
59-
var _v = 0;
60-
repeat(array_length(_verb_names))
61-
{
62-
var _verb = _verb_names[_v];
63-
var _alternate_array = variable_struct_get(_source_verb_struct, _verb);
64-
if (is_array(_alternate_array))
65-
{
66-
var _alternate = 0;
67-
repeat(array_length(_alternate_array))
68-
{
69-
var _binding = _alternate_array[_alternate];
70-
if (is_struct(_binding)) set_binding(_source, _verb, _alternate, __input_binding_duplicate(_binding));
71-
++_alternate;
72-
}
73-
}
74-
75-
++_v;
76-
}
77-
}
78-
79-
++_source;
80-
}
52+
var _source = 0;
53+
repeat(INPUT_SOURCE.__SIZE)
54+
{
55+
var _source_verb_struct = variable_struct_get(_player_s.config, global.__input_source_names[_source]);
56+
if (is_struct(_source_verb_struct))
57+
{
58+
var _verb_names = variable_struct_get_names(_source_verb_struct);
59+
var _v = 0;
60+
repeat(array_length(_verb_names))
61+
{
62+
var _verb = _verb_names[_v];
63+
var _alternate_array = variable_struct_get(_source_verb_struct, _verb);
64+
if (is_array(_alternate_array))
65+
{
66+
var _alternate = 0;
67+
repeat(array_length(_alternate_array))
68+
{
69+
var _binding = _alternate_array[_alternate];
70+
if (is_struct(_binding)) set_binding(_source, _verb, _alternate, __input_binding_duplicate(_binding));
71+
++_alternate;
72+
}
73+
}
74+
75+
++_v;
76+
}
77+
}
78+
79+
++_source;
80+
}
8181
}
8282
}

0 commit comments

Comments
 (0)