Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lostastro committed Feb 16, 2021
1 parent 7644a1a commit f7cef6b
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 33 deletions.
28 changes: 16 additions & 12 deletions scripts/ICUI/ICUI.gml
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ function ICUI_device_select_swapping() {
__INPUTCANDY.ui.device_select.swapping=false;
audio_play_sound(a_ICUI_pageflip,100,0);
break;
default:
default: // Swap device
var device_in_use_by=none;
for ( var i=0; i<__INPUTCANDY.max_players; i++ ) {
if ( __INPUTCANDY.players[i].device == __INPUTCANDY.ui.device_select.swapping_select and i != __INPUTCANDY.ui.device_select.influencing )
Expand All @@ -1212,6 +1212,7 @@ function ICUI_device_select_swapping() {
__INPUTCANDY.players[__INPUTCANDY.ui.device_select.influencing].device=__INPUTCANDY.ui.device_select.swapping_select;
}
__INPUTCANDY.ui.device_select.swapping=false;
__ICI.UpdateActiveSetup(true);
audio_play_sound(a_ICUI_tone,100,0);
break;
}
Expand All @@ -1232,12 +1233,13 @@ function ICUI_Draw_input_binding() {
__INPUTCANDY.ui.input_binding.mode=false;
return;
} else if (array_length(__INPUTCANDY.settings) == 0 and __INPUTCANDY.ui.input_binding.keyboard_mouse) {
__INPUTCANDY.settings[0]=__ICI.New_ICSettings();
__INPUTCANDY.settings[0].deviceInfo=__ICI.New_ICDevice();
__INPUTCANDY.settings[0].index=0;
__INPUTCANDY.settings[0].deviceInfo.desc="Keyboard and Mouse";
__INPUTCANDY.settings[0].deviceInfo.type=ICDeviceType_keyboard_mouse;
__INPUTCANDY.players[__INPUTCANDY.ui.device_select.influencing].settings = 0;
__INPUTCANDY.settings[0]=__ICI.New_ICSettings();
__INPUTCANDY.settings[0].deviceInfo=__ICI.New_ICDevice();
__INPUTCANDY.settings[0].index=0;
__INPUTCANDY.settings[0].deviceInfo.desc="Keyboard and Mouse";
__INPUTCANDY.settings[0].deviceInfo.type=ICDeviceType_keyboard_mouse;
__INPUTCANDY.players[__INPUTCANDY.ui.device_select.influencing].settings = 0;
__ICI.UpdateActiveSetup(true);
}
} else if ( array_length(__INPUTCANDY.settings) == 0 ) {
__INPUTCANDY.settings[0]=__ICI.New_ICSettings();
Expand All @@ -1246,6 +1248,7 @@ function ICUI_Draw_input_binding() {
__INPUTCANDY.players[__INPUTCANDY.ui.device_select.influencing].settings = 0;
__INPUTCANDY.settings[0].deadzone1=gamepad_get_axis_deadzone(__INPUTCANDY.settings[0].deviceInfo.slot_id);
__INPUTCANDY.settings[0].deadzone2=gamepad_get_button_threshold(__INPUTCANDY.settings[0].deviceInfo.slot_id);
__ICI.UpdateActiveSetup(true);
} else __INPUTCANDY.ui.input_binding.loading=true;
}

Expand Down Expand Up @@ -1423,9 +1426,7 @@ function ICUI_Draw_input_binding() {
ICUI_slider( __INPUTCANDY.ui.input_binding.influencing == mi_dz2,
__INPUTCANDY.settings[__INPUTCANDY.players[__INPUTCANDY.ui.device_select.influencing].settings].deadzone2,
0.05, dz2.x+dz2.w/2,dz2.y,dz2.w/2,dz2.h );
}


}

if ( __INPUTCANDY.ui.input(ICUI_right) or __INPUTCANDY.ui.input(ICUI_down) ) {
audio_play_sound(a_ICUI_click,100,0);
Expand Down Expand Up @@ -1464,7 +1465,8 @@ function ICUI_Draw_input_binding() {
__INPUTCANDY.settings[next_profile].deviceInfo=__ICI.New_ICDevice();
__INPUTCANDY.settings[next_profile].deviceInfo.desc="Keyboard and Mouse";
__INPUTCANDY.settings[next_profile].deviceInfo.type=ICDeviceType_keyboard_mouse;
__INPUTCANDY.players[__INPUTCANDY.ui.device_select.influencing].settings = next_profile;
__INPUTCANDY.players[__INPUTCANDY.ui.device_select.influencing].settings = next_profile;
__ICI.UpdateActiveSetup(true);
}
} else {
__INPUTCANDY.settings[next_profile]=__ICI.New_ICSettings();
Expand All @@ -1474,6 +1476,7 @@ function ICUI_Draw_input_binding() {
__INPUTCANDY.settings[next_profile].deadzone1=gamepad_get_axis_deadzone(__INPUTCANDY.settings[next_profile].deviceInfo.slot_id);
__INPUTCANDY.settings[next_profile].deadzone2=gamepad_get_button_threshold(__INPUTCANDY.settings[next_profile].deviceInfo.slot_id);
__INPUTCANDY.players[__INPUTCANDY.ui.device_select.influencing].settings = next_profile;
__ICI.UpdateActiveSetup(true);
}
__INPUTCANDY.ui.input_binding.scrolled=0;
__INPUTCANDY.ui.input_binding.influencing=mi_scrdn;
Expand Down Expand Up @@ -2143,7 +2146,7 @@ function ICUI_DoSearch( device, next ) {
}
}
for ( var i=start; i<global.SDLDB_Entries; i++ ) {
if ( string_pos(global.SDLDB[i].brief,guid) == 1 ) {
if ( string_pos(global.SDLDB[i].vid,guid) > 0 and string_pos(global.SDLDB[i].pid,guid) > 0 ) {
__INPUTCANDY.ui.SDLDB_select.scrolled=i;
return;
}
Expand Down Expand Up @@ -2199,6 +2202,7 @@ function ICUI_Draw_SDLDB_select() {
__INPUTCANDY.players[__INPUTCANDY.ui.device_select.influencing].settings = next_profile;
__INPUTCANDY.settings[next_profile].deadzone1=gamepad_get_axis_deadzone(__INPUTCANDY.settings[next_profile].deviceInfo.slot_id);
__INPUTCANDY.settings[next_profile].deadzone2=gamepad_get_button_threshold(__INPUTCANDY.settings[next_profile].deviceInfo.slot_id);
__ICI.UpdateActiveSetup(true);
}
}

Expand Down
21 changes: 15 additions & 6 deletions scripts/InputCandy/InputCandy.gml
Original file line number Diff line number Diff line change
Expand Up @@ -1813,7 +1813,7 @@ function New_InputCandy_Private() {
if ( binding == unknown ) binding=__ICI.GetBinding( __INPUTCANDY.players[player_index].settings, action.index );
if ( binding != none ) return __ICI.MatchAction( player_index, binding.bound_action, type );
}
return ___ICI.MatchAction(player_number,action,type);
return __ICI.MatchAction(player_number,action,type);
},
GetDirectional: function ( player_index, moving, type ) {
var player_number=player_index+1;
Expand Down Expand Up @@ -2390,7 +2390,9 @@ function New_InputCandy_Private() {
for ( var i=0; i<len; i++ ){
output[i]=__INPUTCANDY.settings[i];
var blen=array_length(output[i].bindings);
for ( var j=0; j<blen; j++ ) output[i].bindings[j]=__ICI.PreSaveBinding(output[i].bindings[j]);
for ( var j=0; j<blen; j++ )
if ( output[i].bindings[j].action == none ) continue;
else output[i].bindings[j]=__ICI.PreSaveBinding(output[i].bindings[j]);
}
__INPUTCANDY.e_save_file(__INPUTCANDY.settings_filename,output);
__ICI.SaveSetups();
Expand Down Expand Up @@ -2487,11 +2489,18 @@ function New_InputCandy_Private() {
},

// Updates the active setup based on
UpdateActiveSetup: function () {
if ( __INPUTCANDY.active_setup == none ) return;
UpdateActiveSetup: function ( create_it ) {
if ( __INPUTCANDY.active_setup == none ) {
if ( create_it ) {
var index=array_length(__INPUTCANDY.setups);
__INPUTCANDY.setups[index]=__ICI.CurrentSetup();
__INPUTCANDY.active_setup=index;
}
return;
}
var k=__INPUTCANDY.active_setup;
__INPUTCANDY.setups[k]=__ICI.CaptureSetup();
__ICI.SaveSetups();
__INPUTCANDY.setups[k]=__ICI.CurrentSetup();
__ICI.SaveSettings();
},

ApplySDLMappings: function () {
Expand Down
37 changes: 22 additions & 15 deletions scripts/SDLDB/SDLDB.gml
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,22 @@ function SDLDB_Process_Step() {
/* Do nothing */
} else {
var fomo=string_lower(parts[0]);
var platform=string_replace(parts[array_length(parts)-1],"platform:","");
var vid,pid;
vid = string_copy(fomo, 9, 4);
if (os_type == os_windows) {
pid = string_copy(fomo, 14, 4);
} else if ((os_type == os_macosx) || (os_type == os_linux) || (os_type == os_ios) || (os_type == os_android)) {
pid = string_copy(fomo, 17, 4);
} else pid="";
global.SDLDB[__INPUTCANDY.SDLDB_Process_j]={
index: __INPUTCANDY.SDLDB_Process_j,
guid: fomo,
short: string_delete(fomo,1,8), // Remove the 03000000 or 05000000 from the beginning
brief: string_copy(string_delete(fomo,1,8),1,8),
vidpid: vid+pid,
name: string_lower(parts[1]),
remapping: line,
platform: string_replace(parts[array_length(parts)-1],"platform:","")
platform: platform
};
__INPUTCANDY.SDLDB_Process_j++;
__INPUTCANDY.SDLDB_Process_Completeness=0.5 + (__INPUTCANDY.SDLDB_Process_i/__INPUTCANDY.SDLDB_Process_len) * 0.5;
Expand All @@ -146,19 +154,18 @@ function SDLDB_Process_Step() {

/// Lookup functions.

function SDLDB_Lookup_VID_PID( guid ) {
var vendor,product;
if ( os_type == os_windows ) {
vendor = string_copy(guid, 1, 4);
product = string_copy(guid, 5, 4);
} else if ( (os_type == os_macosx) || (os_type == os_linux) || (os_type == os_ios) || (os_type == os_android) ) {
vendor = string_copy(guid, 9, 4);
product = string_copy(guid, 17, 4);
} else {
vendor = "";
product = "";
}
return SDLDB_Lookup_GUID( vendor+product );
function SDLDB_Lookup_VID_PID( guid_from_gamepad ) {
var vendor,product,guid=string_lower(guid_from_gamepad);
if (os_type == os_windows) {
vendor = string_copy(guid, 1, 4);
product = string_copy(guid, 5, 4);
} else if ((os_type == os_macosx) || (os_type == os_linux) || (os_type == os_ios) || (os_type == os_android)) {
vendor = string_copy(guid, 9, 4);
product = string_copy(guid, 17, 4);
} else return { index: -1, guid: "none", name: "Unknown", remapping: "", platform: "" };
guid=vendor+product;
for ( var i=0; i<global.SDLDB_Entries; i++ ) if ( string_pos(guid, global.SDLDB[i].short) == 1 ) return global.SDLDB[i];
return { index: -1, guid: "none", name: "Unknown", remapping: "", platform: "" };
}

function SDLDB_Lookup_GUID( guid ) {
Expand Down

0 comments on commit f7cef6b

Please sign in to comment.