Skip to content

Commit f41418e

Browse files
Improved Controller Support.
Add modifier button to enable mod controls.
1 parent 57dad72 commit f41418e

File tree

2 files changed

+35
-15
lines changed

2 files changed

+35
-15
lines changed

EVLC_Settings.ini

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
See docs/ControllerButtonList for valid controller binds.
2+
13
[Emergency Vehicles]
24
Siren_Toggle_Key=Tab
35
Siren_Toggle_Button=ScriptPadDown
@@ -17,4 +19,7 @@ Right_Indicator_Key=Right
1719
Right_Indicator_Button=ScriptPadRight
1820

1921
Hazard_Lights_Key=Down
20-
Hazard_Lights_Button=ScriptRB
22+
Hazard_Lights_Button=ScriptRB
23+
24+
[Mod Settings]
25+
Modifier_Button=ScriptLB

main.cs

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class Main : Script
1616
bool hazards;
1717

1818
Keys sirenToggleKey, beamToggleKey, interiorLightToggleKey, leftIndicatorKey, rightIndicatorKey, hazardsKey;
19-
GTA.Control sirenToggleButton, beamToggleButton, leftIndicatorButton, rightIndicatorButton, hazardsButton;
19+
GTA.Control sirenToggleButton, beamToggleButton, leftIndicatorButton, rightIndicatorButton, hazardsButton, modifierButton;
2020

2121
public Main()
2222
{
@@ -40,22 +40,23 @@ public Main()
4040
leftIndicatorButton = config.GetValue<GTA.Control>("Indicators", "Left_Indicator_Button", GTA.Control.ScriptPadLeft);
4141
rightIndicatorButton = config.GetValue<GTA.Control>("Indicators", "Right_Indicator_Button", GTA.Control.ScriptPadRight);
4242
hazardsButton = config.GetValue<GTA.Control>("Indicators", "Hazard_Lights_Button", GTA.Control.ScriptRB);
43+
modifierButton = config.GetValue<GTA.Control>("Mod Settings", "Modifier_Button", GTA.Control.ScriptLB);
4344
#endregion
4445
}
4546

4647
private void OnTick(object sender, EventArgs e)
4748
{
4849
string modName = "Enhanced Vehicle Lighting Controls";
49-
string version = "PreRelease v0.3.0";
50+
string version = "PreRelease v0.4.0";
5051
string developer = "MccDev260";
5152

5253
if (firstTime)
5354
{
54-
Notification.Show(NotificationIcon.Blocked, modName, developer, version + " " + "loaded!!", false, true);
55+
Notification.Show(NotificationIcon.Blocked, modName, developer, $"{version} loaded!!", false, true);
5556
firstTime = false;
5657
}
5758

58-
if (Game.LastInputMethod == InputMethod.GamePad && playerCharacter.CurrentVehicle != null)
59+
if (Game.LastInputMethod == InputMethod.GamePad)
5960
GamePad();
6061
}
6162

@@ -86,20 +87,34 @@ private void OnKeyDown(object sender, KeyEventArgs e)
8687

8788
private void GamePad()
8889
{
89-
if (Game.IsControlJustReleased(sirenToggleButton))
90-
ToggleSiren();
90+
if (Game.IsControlPressed(modifierButton) && playerCharacter.CurrentVehicle != null)
91+
{
92+
// Disable all player controls except for some driving functions.
93+
Game.DisableAllControlsThisFrame();
94+
Game.EnableControlThisFrame(GTA.Control.VehicleAccelerate);
95+
Game.EnableControlThisFrame(GTA.Control.VehicleBrake);
96+
Game.EnableControlThisFrame(GTA.Control.VehicleHorn);
97+
Game.EnableControlThisFrame(GTA.Control.VehicleLookBehind);
98+
99+
if (Game.IsControlJustReleased(sirenToggleButton))
100+
ToggleSiren();
91101

92-
if (Game.IsControlJustReleased(beamToggleButton))
93-
ToggleFullBeams();
102+
if (Game.IsControlJustReleased(beamToggleButton))
103+
ToggleFullBeams();
94104

95-
if (Game.IsControlJustPressed(leftIndicatorButton))
96-
ToggleLeftIndicator();
105+
if (Game.IsControlJustPressed(leftIndicatorButton))
106+
ToggleLeftIndicator();
97107

98-
if (Game.IsControlJustPressed(rightIndicatorButton))
99-
ToggleRightIndicator();
108+
if (Game.IsControlJustPressed(rightIndicatorButton))
109+
ToggleRightIndicator();
100110

101-
if (Game.IsControlJustPressed(hazardsButton))
102-
ToggleHazards();
111+
if (Game.IsControlJustPressed(hazardsButton))
112+
ToggleHazards();
113+
}
114+
else if (Game.IsControlJustReleased(modifierButton))
115+
{
116+
Game.EnableAllControlsThisFrame();
117+
}
103118
}
104119
#endregion
105120

0 commit comments

Comments
 (0)