1 |
show_debug_message("***** Event = " + ds_map_find_value(async_load, "event_type")); |
2 |
switch (ds_map_find_value(async_load, "event_type")) |
3 |
{ |
4 |
case "gamepad discovered": |
5 |
var pad = ds_map_find_value(async_load, "pad_index"); |
6 |
if (is_connecting_controller == 1) |
7 |
exit; |
8 |
if (gamepad_is_connected(pad)) |
9 |
{ |
10 |
gamepad_id = pad; |
11 |
if (scr_is_switch_os() && is_connecting_controller < 2) |
12 |
{ |
13 |
is_connecting_controller = 1; |
14 |
if (switch_controller_support_show() == 0) |
15 |
{ |
16 |
gamepad_active = 1; |
17 |
alarm[0] = 1; |
18 |
gamepad_id = switch_controller_support_get_selected_id(); |
19 |
} |
20 |
else |
21 |
{ |
22 |
gamepad_active = 0; |
23 |
alarm[0] = 1; |
24 |
global.gamepad_type = "N/A"; |
25 |
exit; |
26 |
} |
27 |
} |
28 |
alarm[0] = 1; |
29 |
gamepad_active = 1; |
30 |
var gamepad_description = gamepad_get_description(gamepad_id); |
31 |
show_debug_message("***** Connected controller: " + gamepad_type + " | " + gamepad_description); |
32 |
if (gamepad_get_guid(gamepad_id) == "4c05e60c000000000000504944564944") |
33 |
{ |
34 |
show_debug_message("***** Remap controller: " + gamepad_description + " to " + "DualSense Wireless Controller"); |
35 |
var mapping = "a:b1,b:b2,x:b0,y:b3,back:b8,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a5,lefttrigger:a3,righttrigger:a4,"; |
36 |
gamepad_test_mapping(gamepad_id, "4c05e60c000000000000504944564944," + gamepad_description + "," + mapping); |
37 |
gamepad_description = "DualSense Wireless Controller"; |
38 |
} |
39 |
gamepad_type = gamepad_description; |
40 |
if (gamepad_type != global.gamepad_type) |
41 |
{ |
42 |
global.gamepad_type = gamepad_type; |
43 |
scr_controls_defaultscr_controls_defaultfunction scr_controls_default()
{
global.button0 = gp_face1;
global.button1 = gp_face2;
global.button2 = gp_face4;
if (os_type == os_ps4 || os_type == os_ps5)
{
var os_map = os_get_info();
var ps4_confirm_button = undefined;
if (os_map != -1)
{
var mapsize = ds_map_size(os_map);
var key = ds_map_find_first(os_map);
for (var i = 0; i < (mapsize - 1); i++)
{
if (key == "enter_button_assign")
ps4_confirm_button = ds_map_find_value(os_map, key);
else
key = ds_map_find_next(os_map, key);
}
ds_map_destroy(os_map);
}
if (ps4_confirm_button == 0)
{
global.button0 = gp_face2;
global.button1 = gp_face1;
}
else
{
global.button0 = gp_face1;
global.button1 = gp_face2;
}
global.button2 = gp_face4;
}
else if (scr_is_switch_os())
{
global.button0 = gp_face2;
global.button1 = gp_face1;
global.button2 = gp_face4;
}
global.default_button0 = global.button0;
global.default_button1 = global.button1;
global.default_button2 = global.button2;
global.input_k[0] = vk_down;
global.input_k[1] = vk_right;
global.input_k[2] = vk_up;
global.input_k[3] = vk_left;
global.input_k[4] = ord("Z");
global.input_k[5] = ord("X");
global.input_k[6] = ord("C");
global.input_k[7] = vk_enter;
global.input_k[8] = vk_shift;
global.input_k[9] = vk_control;
global.input_g[0] = gp_padd;
global.input_g[1] = gp_padr;
global.input_g[2] = gp_padu;
global.input_g[3] = gp_padl;
global.input_g[4] = global.button0;
global.input_g[5] = global.button1;
global.input_g[6] = global.button2;
global.input_g[7] = 999;
global.input_g[8] = 999;
global.input_g[9] = 999;
if (!i_ex(obj_gamecontroller))
instance_create(0, 0, obj_gamecontroller);
with (obj_gamecontroller)
gamepad_shoulderlb_reassign = 0;
} (); |
44 |
if (_load_enabled) |
45 |
{ |
46 |
if (ossafe_file_exists("config_" + string(global.filechoice) + ".ini")) |
47 |
{ |
48 |
ossafe_ini_open("config_" + string(global.filechoice) + ".ini"); |
49 |
for (var i = 0; i < 10; i++) |
50 |
{ |
51 |
readval = ini_read_real("KEYBOARD_CONTROLS", string(i), -1); |
52 |
if (readval != -1) |
53 |
global.input_k[i] = readval; |
54 |
} |
55 |
for (var i = 0; i < 10; i++) |
56 |
{ |
57 |
readval = ini_read_real("GAMEPAD_CONTROLS", string(i), -1); |
58 |
if (readval != -1) |
59 |
global.input_g[i] = readval; |
60 |
} |
61 |
var readval = ini_read_real("SHOULDERLB_REASSIGN", "SHOULDERLB_REASSIGN", gamepad_shoulderlb_reassign); |
62 |
if (readval != -1) |
63 |
gamepad_shoulderlb_reassign = readval; |
64 |
global.button0 = global.input_g[4]; |
65 |
global.button1 = global.input_g[5]; |
66 |
global.button2 = global.input_g[6]; |
67 |
ossafe_ini_close(); |
68 |
} |
69 |
} |
70 |
} |
71 |
with (obj_event_manager) |
72 |
load_trophies(pad); |
73 |
} |
74 |
break; |
75 |
case "gamepad lost": |
76 |
var pad = ds_map_find_value(async_load, "pad_index"); |
77 |
if (pad != gamepad_id) |
78 |
exit; |
79 |
if (is_connecting_controller > 0) |
80 |
exit; |
81 |
gamepad_active = 0; |
82 |
if (scr_is_switch_os()) |
83 |
{ |
84 |
if (switch_controller_support_show() == 0) |
85 |
{ |
86 |
gamepad_active = 1; |
87 |
gamepad_id = switch_controller_support_get_selected_id(); |
88 |
is_connecting_controller = 2; |
89 |
alarm[0] = 2; |
90 |
} |
91 |
} |
92 |
global.gamepad_type = "N/A"; |
93 |
break; |
94 |
} |