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

Commit 0c8fc0b

Browse files
committed
Adds camera follow and most recent press functions
1 parent 40ba6cb commit 0c8fc0b

File tree

10 files changed

+147
-9
lines changed

10 files changed

+147
-9
lines changed

input.yyp

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

objects/obj_example/Draw_0.gml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
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";
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";
810

911
//var _gamepad = input_player_gamepad_get(0);
1012
//var _i = 0;

scripts/input_check_press_most_recent/input_check.yy

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/// @param [array]
2+
/// @param [playerIndex]
3+
4+
function input_check_press_most_recent()
5+
{
6+
var _verb_names = argument[0];
7+
var _player_index = ((argument_count > 1) && (argument[1] != undefined))? argument[1] : 0;
8+
9+
if (_player_index < 0)
10+
{
11+
__input_error("Invalid player index provided (", _player_index, ")");
12+
return undefined;
13+
}
14+
15+
if (_player_index >= INPUT_MAX_PLAYERS)
16+
{
17+
__input_error("Player index too large (", _player_index, " vs. ", INPUT_MAX_PLAYERS, ")\nIncrease INPUT_MAX_PLAYERS to support more players");
18+
return undefined;
19+
}
20+
21+
var _verbs_array = global.__input_players[_player_index].verbs;
22+
if (!is_array(_verb_names)) _verb_names = variable_struct_get_names(_verbs_array);
23+
24+
var _max_time = -1;
25+
var _max_verb = undefined;
26+
var _i = 0;
27+
repeat(array_length(_verb_names))
28+
{
29+
var _verb = _verb_names[_i];
30+
var _verb_struct = variable_struct_get(_verbs_array, _verb);
31+
32+
if ((_verb_struct.press_time > _max_time) && input_check(_verb, _player_index))
33+
{
34+
_max_time = _verb_struct.press_time;
35+
_max_verb = _verb;
36+
}
37+
38+
++_i;
39+
}
40+
41+
return _max_verb;
42+
}

scripts/input_check_press_most_recent/input_check_press_most_recent.yy

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/// @param camera
2+
/// @param [playerIndex]
3+
4+
function input_cursor_follow_camera()
5+
{
6+
var _camera = argument[0];
7+
var _player_index = ((argument_count > 1) && (argument[1] != undefined))? argument[1] : 0;
8+
9+
if ((_player_index < 0) && (_player_index != all))
10+
{
11+
__input_error("Invalid player index provided (", _player_index, ")");
12+
return undefined;
13+
}
14+
15+
if (_player_index >= INPUT_MAX_PLAYERS)
16+
{
17+
__input_error("Player index too large (", _player_index, " vs. ", INPUT_MAX_PLAYERS, ")\nIncrease INPUT_MAX_PLAYERS to support more players");
18+
return undefined;
19+
}
20+
21+
if (_player_index == all)
22+
{
23+
var _i = 0;
24+
repeat(INPUT_MAX_PLAYERS)
25+
{
26+
input_cursor_follow_camera(_camera, _i);
27+
++_i;
28+
}
29+
}
30+
else
31+
{
32+
global.__input_players[_player_index].cursor.camera = _camera;
33+
}
34+
}

scripts/input_cursor_follow_camera/input_cursor_follow_camera.yy

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

scripts/input_cursor_x/input_cursor_x.gml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,15 @@ function input_cursor_x()
1616
return undefined;
1717
}
1818

19-
return global.__input_players[_player_index].cursor.x;
19+
with(global.__input_players[_player_index].cursor)
20+
{
21+
if (is_numeric(camera) && (camera >= 0))
22+
{
23+
return camera_get_view_x(camera) + x;
24+
}
25+
else
26+
{
27+
return x;
28+
}
29+
}
2030
}

scripts/input_cursor_y/input_cursor_y.gml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,15 @@ function input_cursor_y()
1616
return undefined;
1717
}
1818

19-
return global.__input_players[_player_index].cursor.y;
19+
with(global.__input_players[_player_index].cursor)
20+
{
21+
if (is_numeric(camera) && (camera >= 0))
22+
{
23+
return camera_get_view_y(camera) + y;
24+
}
25+
else
26+
{
27+
return y;
28+
}
29+
}
2030
}

scripts/input_tick/input_tick.gml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,8 @@ function __input_class_cursor() constructor
454454
x = 0;
455455
y = 0;
456456

457+
camera = undefined;
458+
457459
limit_l = undefined;
458460
limit_t = undefined;
459461
limit_r = undefined;

0 commit comments

Comments
 (0)