Skip to content

Commit 1dd11d6

Browse files
committed
Controller Support
1 parent 223dab4 commit 1dd11d6

File tree

1 file changed

+127
-6
lines changed

1 file changed

+127
-6
lines changed

HideMinimap/MinimapVehicleController.cs

Lines changed: 127 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ public enum signalTypes
2323
hazard
2424
};
2525
public static Keys CurrentWindowKey,PassengerWindowKey,DriverRearWindowKey,PassengerRearWindowKey,AllWindowsKey,HoodKey,TrunkKey,InteriorLightKey,ToggleRadioWheelKey,ToggleMobileRadioKey,ToggleMinimapKey,OpenDoorKey,SeatbeltKey,ShuffleSeatKey,LeftSignalKey, RightSignalKey, HazardsKey, RedLaserKey, GreenLaserKey, DropWeaponKey;
26+
public static int vehMinimapButton, vehRadioWheelButton, HazardsButton, LeftSignalButton, RightSignalButton, SeatbeltButton, InteriorLightButton, CurrentWindowButton, PassengerWindowButton, DriverRearWindowButton, PassengerRearWindowButton,AllWindowsButton,HoodButton,TrunkButton,OpenDoorButton,ShuffleSeatButton,MinimapButton,MobileRadioButton,RadioWheelButton,RedLaserButton,GreenLaserButton,DropWeaponButton;
2627
private readonly IniFile settingsINI;
2728
public static bool LightOff = true;
2829
public static bool MMoriginalEnabled, MMbigMapEnabled, MMzoomoutEnabled, MMfullEnabled, MMhiddenEnabled, enableVehicleControls, enableMinimapControls, enableMobileRadio, enablePhoneColor = true;
2930
public static bool leftSignalActive, rightSignalActive, hazardsActive, radioWheelDisabled, mobileRadio, beltedUp, isCurrentlyShuffling, window0down, window1down, window2down, window3down, AWindowDown, hoodOpen, trunkOpen, door0Open, door1Open, door2Open, door3Open, initialized = false;
3031
public static mapStates mapState = mapStates.original;
3132
public static int phoneColorIndex, MMsafetyVal = 0;
33+
public static int[] ControlsToDisable = {15,47,52,58,85,115,174,261,14,46,54,74,101,103,104,119,175,262,344,355,356,27,42,172,19,20,43,48,173,18,21,70,73,105,114,120,132,136,137,141,154,176,258,264,337,345,353,354,357,45,57,80,140,177,263,23,49,53,56,75,144,145,0,244,28,36,86,113,350,351,352,7,26,29,50,79,93,121};
3234
//LASER COMPONENT HASHES
3335
public static WeaponComponentHash laserhash = (WeaponComponentHash)2455710022; //COMPONENT_AT_AR_LASER
3436
public static WeaponComponentHash redlaserhash = (WeaponComponentHash)1073457922; //COMPONENT_AT_AR_LASER_RED
@@ -69,6 +71,96 @@ private void OnTick(object sender, EventArgs e){
6971
}
7072
if (beltedUp){Function.Call(Hash.DISABLE_CONTROL_ACTION, 0, 75, true);}
7173
if (radioWheelDisabled){Function.Call(Hash.DISABLE_CONTROL_ACTION, 0, 85, true);}
74+
//CONTROLLER SUPPORT
75+
if (Game.Player.Character.CurrentVehicle != null && enableVehicleControls && !Function.Call<bool>(Hash.IS_USING_KEYBOARD_AND_MOUSE, 0)){//if In car, car controls enabled AND using controller
76+
if (Function.Call<bool>(Hash.IS_CONTROL_PRESSED,2, 203))//if holding X on controller
77+
{
78+
DisableFuckingEverything();
79+
80+
if (Function.Call<bool>(Hash.IS_CONTROL_JUST_PRESSED, 2, AllWindowsButton))
81+
{
82+
ToggleAllWindows(Game.Player.Character.CurrentVehicle);
83+
}
84+
else if (Function.Call<bool>(Hash.IS_CONTROL_JUST_PRESSED, 2, InteriorLightButton))
85+
{
86+
ToggleInteriorLight(Game.Player.Character.CurrentVehicle, LightOff);
87+
}
88+
else if (Function.Call<bool>(Hash.IS_CONTROL_JUST_PRESSED, 2, CurrentWindowButton))
89+
{
90+
ToggleCurrentWindow(Game.Player.Character.CurrentVehicle);
91+
}
92+
else if (Function.Call<bool>(Hash.IS_CONTROL_JUST_PRESSED, 2, PassengerWindowButton))
93+
{
94+
DriverWindowAccess(Game.Player.Character.CurrentVehicle, 1);
95+
}
96+
else if (Function.Call<bool>(Hash.IS_CONTROL_JUST_PRESSED, 2, SeatbeltButton))
97+
{
98+
TogglePlayerSeatbelt(Game.Player.Character.CurrentVehicle);
99+
}
100+
else if (Function.Call<bool>(Hash.IS_CONTROL_JUST_PRESSED, 2, TrunkButton))
101+
{
102+
ToggleTrunk(Game.Player.Character.CurrentVehicle);
103+
}
104+
else if (Function.Call<bool>(Hash.IS_CONTROL_JUST_PRESSED, 2, HoodButton))
105+
{
106+
ToggleHood(Game.Player.Character.CurrentVehicle);
107+
}
108+
else if (Function.Call<bool>(Hash.IS_CONTROL_JUST_PRESSED, 2, vehMinimapButton))
109+
{
110+
if (enableMinimapControls && MMsafetyVal > 1) { CycleMinimapState(); }
111+
}
112+
else if (Function.Call<bool>(Hash.IS_CONTROL_JUST_PRESSED, 2, OpenDoorButton))
113+
{
114+
OpenLocalDoor(Game.Player.Character.CurrentVehicle);
115+
}
116+
else if (Function.Call<bool>(Hash.IS_CONTROL_JUST_PRESSED, 2, ShuffleSeatButton))
117+
{
118+
ShuffleToNextSeat(Game.Player.Character.CurrentVehicle);
119+
}
120+
else if (Function.Call<bool>(Hash.IS_CONTROL_JUST_PRESSED, 2, DriverRearWindowButton))
121+
{
122+
DriverWindowAccess(Game.Player.Character.CurrentVehicle, 2);
123+
}
124+
else if (Function.Call<bool>(Hash.IS_CONTROL_JUST_PRESSED, 2, PassengerRearWindowButton))
125+
{
126+
DriverWindowAccess(Game.Player.Character.CurrentVehicle, 3);
127+
}
128+
else if (Function.Call<bool>(Hash.IS_CONTROL_JUST_PRESSED, 2, vehRadioWheelButton))
129+
{
130+
if (enableMobileRadio) { ToggleRadioWheel(); }
131+
}
132+
133+
}
134+
} else if (!Function.Call<bool>(Hash.IS_USING_KEYBOARD_AND_MOUSE, 0))//Player is on foot
135+
{
136+
if (Function.Call<bool>(Hash.IS_CONTROL_PRESSED, 2, 205))//if holding LB on controller
137+
{
138+
if (Function.Call<bool>(Hash.IS_CONTROL_JUST_PRESSED, 2, MinimapButton))
139+
{
140+
if (enableMinimapControls && MMsafetyVal > 1) { CycleMinimapState(); }
141+
}
142+
else if (Function.Call<bool>(Hash.IS_CONTROL_JUST_PRESSED, 2, MobileRadioButton))
143+
{
144+
if (enableMobileRadio) { TogglePlayerMobileRadio(); }
145+
}
146+
else if (Function.Call<bool>(Hash.IS_CONTROL_JUST_PRESSED, 2, RadioWheelButton))
147+
{
148+
if (enableMobileRadio) { ToggleRadioWheel(); }
149+
}
150+
else if (Function.Call<bool>(Hash.IS_CONTROL_JUST_PRESSED, 2, RedLaserButton))
151+
{
152+
ToggleLaser(true);
153+
}
154+
else if (Function.Call<bool>(Hash.IS_CONTROL_JUST_PRESSED, 2, GreenLaserButton))
155+
{
156+
ToggleLaser(false);
157+
}
158+
else if (Function.Call<bool>(Hash.IS_CONTROL_JUST_PRESSED, 2, DropWeaponButton))
159+
{
160+
DropWeapon();
161+
}
162+
}
163+
}
72164
}
73165
void OnKeyDown(object sender, KeyEventArgs e){//ANY TIME
74166
switch (e.KeyCode){
@@ -81,12 +173,6 @@ void OnKeyDown(object sender, KeyEventArgs e){//ANY TIME
81173
case var value when value == ToggleMinimapKey:
82174
if (enableMinimapControls && MMsafetyVal > 1) { CycleMinimapState(); }
83175
break;
84-
case var value when value == OpenDoorKey:
85-
if (enableVehicleControls) { OpenLocalDoor(Game.Player.Character.CurrentVehicle); }
86-
break;
87-
case var value when value == ShuffleSeatKey:
88-
if (enableVehicleControls) { ShuffleToNextSeat(Game.Player.Character.CurrentVehicle); }
89-
break;
90176
case var value when value == RedLaserKey:
91177
ToggleLaser(true);
92178
break;
@@ -141,6 +227,12 @@ void OnKeyDown(object sender, KeyEventArgs e){//ANY TIME
141227
case var value when value == TrunkKey:
142228
ToggleTrunk(Game.Player.Character.CurrentVehicle);
143229
break;
230+
case var value when value == OpenDoorKey:
231+
OpenLocalDoor(Game.Player.Character.CurrentVehicle);
232+
break;
233+
case var value when value == ShuffleSeatKey:
234+
ShuffleToNextSeat(Game.Player.Character.CurrentVehicle);
235+
break;
144236
}
145237
}
146238
}
@@ -175,6 +267,28 @@ public static void LoadExternalSettings(IniFile settingsINI){
175267
RedLaserKey = settingsINI.Read<Keys>("RedLaserKey", "KEYBINDS", Keys.OemSemicolon);
176268
GreenLaserKey = settingsINI.Read<Keys>("GreenLaserKey", "KEYBINDS", Keys.OemQuotes);
177269
DropWeaponKey = settingsINI.Read<Keys>("DropWeaponKey", "KEYBINDS", Keys.L);
270+
vehMinimapButton = settingsINI.Read<int>("vehMinimapButton", "CONTROLLER_VEHICLE", 217);//BACK BY DEFAULT
271+
vehRadioWheelButton = settingsINI.Read<int>("vehRadioWheelButton", "CONTROLLER_VEHICLE", 9999);//NONE BY DEFAULT
272+
HazardsButton = settingsINI.Read<int>("HazardsButton", "CONTROLLER_VEHICLE", 9999);//NONE BY DEFAULT
273+
LeftSignalButton = settingsINI.Read<int>("LeftSignalButton", "CONTROLLER_VEHICLE", 9999);//NONE BY DEFAULT
274+
RightSignalButton = settingsINI.Read<int>("RightSignalButton", "CONTROLLER_VEHICLE", 9999);//NONE BY DEFAULT
275+
SeatbeltButton = settingsINI.Read<int>("SeatbeltButton", "CONTROLLER_VEHICLE", 191);//A BY DEFAULT
276+
InteriorLightButton = settingsINI.Read<int>("InteriorLightButton", "CONTROLLER_VEHICLE", 188);//DPAD UP BY DEFAULT
277+
CurrentWindowButton = settingsINI.Read<int>("CurrentWindowButton", "CONTROLLER_VEHICLE", 189);//DPAD LEFT BY DEFAULT
278+
PassengerWindowButton = settingsINI.Read<int>("PassengerWindowButton", "CONTROLLER_VEHICLE", 190);//DPAD RIGHT BY DEFAULT
279+
DriverRearWindowButton = settingsINI.Read<int>("DriverRearWindowButton", "CONTROLLER_VEHICLE", 9999);//NONE BY DEFAULT
280+
PassengerRearWindowButton = settingsINI.Read<int>("PassengerRearWindowButton", "CONTROLLER_VEHICLE", 9999);//NONE BY DEFAULT
281+
AllWindowsButton = settingsINI.Read<int>("AllWindowsButton", "CONTROLLER_VEHICLE", 187);//DPAD DOWN BY DEFAULT
282+
HoodButton = settingsINI.Read<int>("HoodButton", "CONTROLLER_VEHICLE", 192);//Y BY DEFAULT
283+
TrunkButton = settingsINI.Read<int>("TrunkButton", "CONTROLLER_VEHICLE", 194);//B BY DEFAULT
284+
OpenDoorButton = settingsINI.Read<int>("OpenDoorButton", "CONTROLLER_VEHICLE", 209);//L3 BY DEFAULT
285+
ShuffleSeatButton = settingsINI.Read<int>("ShuffleSeatButton", "CONTROLLER_VEHICLE", 210);//R3 BY DEFAULT
286+
MinimapButton = settingsINI.Read<int>("MinimapButton", "CONTROLLER_ON_FOOT", 217);//BACK BY DEFAULT
287+
MobileRadioButton = settingsINI.Read<int>("MobileRadioButton", "CONTROLLER_ON_FOOT", 189);//DPAD LEFT BY DEFAULT
288+
RadioWheelButton = settingsINI.Read<int>("RadioWheelButton", "CONTROLLER_ON_FOOT", 190);//DPAD RIGHT BY DEFAULT
289+
RedLaserButton = settingsINI.Read<int>("RedLaserButton", "CONTROLLER_ON_FOOT", 191);//A BY DEFAULT
290+
GreenLaserButton = settingsINI.Read<int>("GreenLaserButton", "CONTROLLER_ON_FOOT", 194);//B BY DEFAULT
291+
DropWeaponButton = settingsINI.Read<int>("DropWeaponButton", "CONTROLLER_ON_FOOT", 203);//X BY DEFAULT
178292
}
179293
#region MINIMAP FUNCTIONS
180294
public static void MinimapSafetyCheck(){
@@ -561,5 +675,12 @@ public static void DropWeapon()
561675
}
562676
}
563677
#endregion
678+
public static void DisableFuckingEverything()
679+
{
680+
for (int i = 0; i < ControlsToDisable.Length; i++)
681+
{
682+
Function.Call(Hash.DISABLE_CONTROL_ACTION, 0, ControlsToDisable[i], 0);
683+
}
684+
}
564685
}
565686
}

0 commit comments

Comments
 (0)