Skip to content

Commit

Permalink
Flycast guns + gun4IR get order
Browse files Browse the repository at this point in the history
  • Loading branch information
Tartifless committed Dec 30, 2023
1 parent 203d28e commit f0df594
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 80 deletions.
70 changes: 38 additions & 32 deletions .emulationstation/es_features.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8602,6 +8602,38 @@
<sharedFeature submenu="GUNS" group="ADVANCED SETTINGS" value="gun_reload_button"/>
<sharedFeature submenu="DEVELOPER SETTINGS" group="ADVANCED SETTINGS" value="disableautoconfig"/>
</emulator>
<!-- EDUKE32 -->
<emulator name="eduke32">
<feature name="INTERNAL RESOLUTION" group="GENERAL SETTINGS" value="eduke_resolution">
<choice name="1920x1080" value="1920x1080"/>
<choice name="1680x1050" value="1680x1050"/>
<choice name="1600x900" value="1600x900"/>
<choice name="1440x900" value="1440x900"/>
<choice name="1400x1050" value="1400x1050"/>
<choice name="1366x768" value="1366x768"/>
<choice name="1360x768" value="1360x768"/>
<choice name="1280x1024" value="1280x1024"/>
<choice name="1280x960" value="1280x960"/>
<choice name="1280x800" value="1280x800"/>
<choice name="1280x768" value="1280x768"/>
<choice name="1280x720" value="1280x720"/>
<choice name="1280x600" value="1280x600"/>
<choice name="1152x864" value="1152x864"/>
<choice name="1024x768" value="1024x768"/>
<choice name="800x600" value="800x600"/>
<choice name="640x480" value="640x480"/>
</feature>
<feature name="AUTOLOAD CONTENT" group="GENERAL SETTINGS" value="autoload" description="Use this to autoload content like HD packs.">
<choice name="NO" value="0"/>
<choice name="YES" value="1"/>
</feature>
<sharedFeature submenu="VIDEO" group="ADVANCED SETTINGS" value="videomode"/>
<feature submenu="DRIVERS" name="VIDEO" group="ADVANCED SETTINGS" value="eduke_video">
<choice name="OPENGL" value="32"/>
<choice name="OPENGL POLYMER" value="polymer"/>
<choice name="SOFTWARE" value="8"/>
</feature>
</emulator>
<!-- FLYCAST -->
<emulator name="flycast">
<sharedFeature group="GENERAL SETTINGS" value="bezel"/>
Expand Down Expand Up @@ -8797,6 +8829,8 @@
<choice name="PURUPURU" value="3"/>
<choice name="MICROPHONE" value="2"/>
</feature>
<sharedFeature submenu="GUNS" group="ADVANCED SETTINGS" value="use_guns"/>
<sharedFeature submenu="GUNS" group="ADVANCED SETTINGS" value="one_gun"/>
<feature submenu="GUNS" name="SHOW CROSSHAIR" group="ADVANCED SETTINGS" value="flycast_crosshair">
<choice name="NO" value="0"/>
<choice name="YES" value="1"/>
Expand All @@ -8805,6 +8839,10 @@
<choice name="NO" value="0"/>
<choice name="YES" value="1"/>
</feature>
<feature submenu="GUNS" name="SWITCH GUN INDEX" group="ADVANCED SETTINGS" value="gun_index_revert" description="Switch this to use lightgun 1 for player 2 and lightgun 2 for player 1.">
<choice name="NO" value="0"/>
<choice name="YES" value="1"/>
</feature>
<system name="atomiswave">
<feature submenu="EMULATION" name="FREE PLAY" group="ADVANCED SETTINGS" value="flycast_freeplay" description="Modify the coin setting to Free Play.">
<choice name="YES" value="yes"/>
Expand Down Expand Up @@ -8869,38 +8907,6 @@
<choice name="100%" value="100"/>
</feature>
</emulator>
<!-- EDUKE32 -->
<emulator name="eduke32">
<feature name="INTERNAL RESOLUTION" group="GENERAL SETTINGS" value="eduke_resolution">
<choice name="1920x1080" value="1920x1080"/>
<choice name="1680x1050" value="1680x1050"/>
<choice name="1600x900" value="1600x900"/>
<choice name="1440x900" value="1440x900"/>
<choice name="1400x1050" value="1400x1050"/>
<choice name="1366x768" value="1366x768"/>
<choice name="1360x768" value="1360x768"/>
<choice name="1280x1024" value="1280x1024"/>
<choice name="1280x960" value="1280x960"/>
<choice name="1280x800" value="1280x800"/>
<choice name="1280x768" value="1280x768"/>
<choice name="1280x720" value="1280x720"/>
<choice name="1280x600" value="1280x600"/>
<choice name="1152x864" value="1152x864"/>
<choice name="1024x768" value="1024x768"/>
<choice name="800x600" value="800x600"/>
<choice name="640x480" value="640x480"/>
</feature>
<feature name="AUTOLOAD CONTENT" group="GENERAL SETTINGS" value="autoload" description="Use this to autoload content like HD packs.">
<choice name="NO" value="0"/>
<choice name="YES" value="1"/>
</feature>
<sharedFeature submenu="VIDEO" group="ADVANCED SETTINGS" value="videomode"/>
<feature submenu="DRIVERS" name="VIDEO" group="ADVANCED SETTINGS" value="eduke_video">
<choice name="OPENGL" value="32"/>
<choice name="OPENGL POLYMER" value="polymer"/>
<choice name="SOFTWARE" value="8"/>
</feature>
</emulator>
<!-- FUTURE PINBALL -->
<emulator name="fpinball">
<feature name="GAME ASPECT RATIO" group="GENERAL SETTINGS" value="ratio">
Expand Down
63 changes: 15 additions & 48 deletions emulatorLauncher/Generators/Flycast.Controllers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private void CreateControllerConfiguration(string path, string system, IniFile i

string mappingPath = Path.Combine(path, "mappings");

bool guns = SystemConfig["flycast_controller1"] == "7" || SystemConfig["flycast_controller2"] == "7";
bool guns = SystemConfig.getOptBoolean("use_guns") || SystemConfig["flycast_controller1"] == "7" || SystemConfig["flycast_controller2"] == "7";

Dictionary<string, int> double_pads = new Dictionary<string, int>();
int nsamepad = 0;
Expand Down Expand Up @@ -436,8 +436,18 @@ private void ConfigureJoystick(IniFile ini, Controller ctrl, string mappingPath,

private void ConfigureFlycastGuns(IniFile ini, string mappingPath)
{
bool multigun = SystemConfig["flycast_controller1"] == "7" && SystemConfig["flycast_controller2"] == "7";
bool guninvert = SystemConfig.isOptSet("gun_invert") && SystemConfig.getOptBoolean("gun_invert");
bool useOneGun = SystemConfig.getOptBoolean("one_gun");
bool guninvert = SystemConfig.getOptBoolean("gun_invert");
bool gunindexrevert = SystemConfig.getOptBoolean("gun_index_revert");
bool multigun = false;
if (SystemConfig["flycast_controller1"] == "7" && SystemConfig["flycast_controller2"] == "7")
multigun = true;

int gunCount = RawLightgun.GetUsableLightGunCount();
var guns = RawLightgun.GetRawLightguns();

if (gunCount > 1 && guns.Length > 1 && !useOneGun)
multigun = true;

ini.WriteValue("input", "maple_sdl_mouse", "0");

Expand All @@ -460,54 +470,11 @@ private void ConfigureFlycastGuns(IniFile ini, string mappingPath)

if (multigun)
{
RawLightgun lightgun1 = null;
RawLightgun lightgun2 = null;

int gunCount = RawLightgun.GetUsableLightGunCount();

if (gunCount <= 1) // If there's only one gun ( or just one sinden gun + one mouse ), then ignore multigun
return;

var guns = RawLightgun.GetRawLightguns();

var sindenguns = RawLightgun.GetRawLightguns()
.Where(c => c.Type == RawLighGunType.SindenLightgun)
.Take(2)
.ToArray();

var wiimoteguns = RawLightgun.GetRawLightguns()
.Where(c => c.Type == RawLighGunType.MayFlashWiimote)
.Take(2)
.ToArray();

if (sindenguns.Length > 1)
{
lightgun1 = sindenguns[0];
lightgun2 = sindenguns[1];
}
else if (sindenguns.Length > 0)
lightgun1 = sindenguns[0];

if (wiimoteguns.Length > 1)
{
if (lightgun1 == null)
{
lightgun1 = wiimoteguns[0];
lightgun2 = wiimoteguns[1];
}
}
else if (wiimoteguns.Length > 0)
{
if (lightgun1 == null)
lightgun1 = wiimoteguns[0];
else if (lightgun2 == null)
lightgun2 = wiimoteguns[1];
}

if (lightgun2 == null && gunCount > 1)
lightgun2 = guns[1];
if (lightgun1 == null && gunCount > 0)
lightgun1 = guns[0];
RawLightgun lightgun1 = gunindexrevert ? guns[1] : guns[0];
RawLightgun lightgun2 = gunindexrevert ? guns[0] : guns[1];

ini.WriteValue("input", "RawInput", "yes");
ini.WriteValue("input", "maple_raw_keyboard_" + lightgun1.DevicePath.Substring(8), "0");
Expand Down

0 comments on commit f0df594

Please sign in to comment.