Skip to content

Commit 3accbc2

Browse files
committed
fix steam deck detection
1 parent cdf1ea8 commit 3accbc2

File tree

7 files changed

+23
-18
lines changed

7 files changed

+23
-18
lines changed
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
control_manager_functions();
22

33
players = ds_list_create();
4-
num_players = 0;
5-
6-
self.init_steam_deck_info();
4+
num_players = 0;

current-scripts/Demos/useful-scripts/objects/obj_control_manager_demo/Draw_0.gml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@ draw_text(16, 16, "Control Manager Demo");
44

55
draw_text(640, 96, "Gamepads Supported: " + (gamepad_is_supported() ? "Yes" : "No"));
66
draw_text(640, 128, "Gamepads Detected: " + string(num_controllers_connected));
7-
draw_text(640, 192, "Current Slot: " + string(current_gamepad_index + 1) + "/" + string(device_count));
7+
draw_text(640, 192, "Current Slot: " + string(current_gamepad_index) + "/" + string(device_count - 1));
88
draw_text(640, 224, "Gamepad Connected: " + (gamepad_connected[current_gamepad_index] ? "Yes" : "No"));
99
draw_text(640, 256, "GUID: " + gamepad_get_guid(current_gamepad_index));
1010
draw_text(640, 286, "Description: " + gamepad_get_description(current_gamepad_index));
1111

12+
if (os_type == os_linux) {
13+
draw_text(640, 320, "Is On Steam Deck: " + (inst_control_manager.is_on_steam_deck() ? "Yes" : "No"));
14+
draw_text(640, 352, "Steam Deck Gamepad Index: " + string(inst_control_manager.get_steam_deck_gamepad_index()));
15+
}
16+
17+
1218
for (var i=0; i<num_controls; i++) {
1319
var _pressed = my_player.get_control_state(i, CONTROL_STATE.HELD);
1420
var _text_colour = _pressed ? c_lime : c_white;

current-scripts/Demos/useful-scripts/objects/obj_init/Alarm_0.gml

Lines changed: 0 additions & 1 deletion
This file was deleted.

current-scripts/Demos/useful-scripts/objects/obj_init/Create_0.gml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
start_timer = time_source_create(time_source_game, 1, time_source_units_frames, function() {
2+
inst_control_manager.init_steam_deck_info();
3+
4+
with (obj_persistent_controller) {
5+
current_gamepad_index = inst_control_manager.is_on_steam_deck()
6+
? inst_control_manager.get_steam_deck_gamepad_index()
7+
: 0;
8+
9+
my_player.set_gamepad_slot(current_gamepad_index);
10+
}
11+
time_source_destroy(start_timer);
212
room_goto(room_title);
313
});
414

current-scripts/Demos/useful-scripts/objects/obj_init/obj_init.yy

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

current-scripts/Demos/useful-scripts/objects/obj_persistent_controller/Create_0.gml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,4 @@ my_player.set_binding(CONTROL_TYPE.GAMEPAD, CONTROL_SOURCE.GAMEPAD, CONTROLS.MEN
4646
my_player.set_binding(CONTROL_TYPE.GAMEPAD, CONTROL_SOURCE.GAMEPAD, CONTROLS.MENU_RIGHT, 0, gp_padr);
4747
my_player.set_binding(CONTROL_TYPE.GAMEPAD, CONTROL_SOURCE.GAMEPAD, CONTROLS.MENU_CONFIRM, 0, gp_face1);
4848
my_player.set_binding(CONTROL_TYPE.GAMEPAD, CONTROL_SOURCE.GAMEPAD, CONTROLS.MENU_CANCEL, 0, gp_face2);
49-
my_player.set_binding(CONTROL_TYPE.GAMEPAD, CONTROL_SOURCE.GAMEPAD, CONTROLS.DELETE_BINDING, 0, gp_face3);
50-
51-
current_gamepad_index = inst_control_manager.is_on_steam_deck()
52-
? inst_control_manager.get_steam_deck_gamepad_index()
53-
: 0;
54-
55-
my_player.set_gamepad_slot(current_gamepad_index);
49+
my_player.set_binding(CONTROL_TYPE.GAMEPAD, CONTROL_SOURCE.GAMEPAD, CONTROLS.DELETE_BINDING, 0, gp_face3);

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,15 @@ function get_os_browser_string(_os_browser) {
8787
function get_steam_deck_info() {
8888
var _result = {
8989
is_on_steam_deck: false,
90-
gamepad_index: -1,
90+
gamepad_index: 0,
9191
}
9292

93-
// Check all gamepad slots for "Valve Streaming Controller"
93+
// Check all gamepad slots for "Steam Virtual Gamepad"
9494
var _num_devices = gamepad_get_device_count();
9595
for (var i = 0; i < _num_devices; i++;) {
9696
if (gamepad_is_connected(i)) {
9797
var _description = gamepad_get_description(i);
98-
if (string_pos("Valve Streaming Gamepad", _description) != 0) {
98+
if (string_pos("Steam Virtual Gamepad", _description) != 0) {
9999
_result.gamepad_index = i;
100100
}
101101
}
@@ -113,8 +113,7 @@ function get_steam_deck_info() {
113113
// Vendor should be "AMD"
114114
// Version should contain "Mesa"
115115
// Renderer should be "AMD Custom GPU 0405"
116-
if ( _result.gamepad_index >= 0
117-
&& string_pos("AMD", _vendor) != 0
116+
if (string_pos("AMD", _vendor) != 0
118117
&& string_pos("Mesa", _version) != 0
119118
&& string_pos("AMD Custom GPU 0405", _renderer) != 0) {
120119
_result.is_on_steam_deck = true;

0 commit comments

Comments
 (0)