DualSenseIV
Adaptive triggers, directional rumble and a siren lightbar for
Grand Theft Auto IV: The Complete Edition, on a PS5 DualSense controller.

DSX is not required. The mod reads the controller directly and presents it to
the game as an Xbox pad, over USB or Bluetooth.

Open "Weapon tuner and guide.html" in any browser for the illustrated version of
everything below, plus sliders that build the per weapon config file for you.
It works offline; nothing in it is downloaded.


-------------------------------------------------------------------------------
INSTALL
-------------------------------------------------------------------------------

1. Get the .NET Script Hook. This mod is a .NET script, so it needs
   ScriptHookDotNet, which is NOT in this zip: it is a separate project under
   its own licence, and the build has to match your game version.

       https://github.com/Tomasak/gta4_scripthookdotnet/releases

   Use v1.7.1.8, the fork that added Complete Edition (1.2.0.59) support.
   Put its ScriptHookDotNet.asi in your GTA IV folder.

2. Open your GTA IV folder. It is the one holding GTAIV.exe, next to the
   common, pc, TLAD and TBoGT folders.

3. Drag everything from this zip into that folder, except the two _optional
   and _licenses folders. Choose "merge" if Windows asks about the scripts
   folder. You should end up with:

       <game folder>\ScriptHook.dll
       <game folder>\ScriptHookDotNet.asi        (from step 1)
       <game folder>\aCompleteEditionHook.asi
       <game folder>\scripts\DualSenseIV.net.dll
       <game folder>\scripts\HidSharp.dll
       <game folder>\scripts\Nefarius.ViGEm.Client.dll

4. Install the ViGEmBus driver, once, by running
       _optional\ViGEmBus driver\ViGEmBus_Setup.exe
   Skip this if you already use DSX or DS4Windows, which install it too.

5. Turn off Steam Input for GTA IV, otherwise Steam claims the controller
   before the mod can see it. In Steam: right click the game, Properties,
   Controller, then "Disable Steam Input".

6. Start the game. A message confirms the mod loaded and whether it found the
   controller over USB or Bluetooth. Press F7 for settings.

You also need an ASI loader in the game folder. FusionFix already includes one
(dinput8.dll). If you do not use FusionFix, install Ultimate ASI Loader:
https://github.com/ThirteenAG/Ultimate-ASI-Loader  (the 32-bit build, not x64)
Never run two ASI loaders at once, for example an old dsound.dll alongside
FusionFix's dinput8.dll. Everything gets loaded twice and the game misbehaves.


-------------------------------------------------------------------------------
WHICH GAME VERSION
-------------------------------------------------------------------------------

Get the ScriptHookDotNet build that matches your game. The Complete Edition
currently sold on Steam and the Rockstar launcher is 1.2.0.59, which is what
v1.7.1.8 at the link above is built for. If your game is 1.2.0.43, the 2020
Complete Edition, you need the build for that version instead. The wrong one
loads no scripts at all and says so in ScriptHookDotNet.log.

To check your version, right click GTAIV.exe, choose Properties, then Details.


-------------------------------------------------------------------------------
WHAT IT DOES
-------------------------------------------------------------------------------

Weapon triggers
  Every weapon gets its own trigger effect, worked out from the fire rate and
  magazine size in your own game files. Pistols click once per shot, submachine
  guns rattle fast and light, the AK-47 thumps slower and harder, the belt fed
  Advanced MG buzzes, launchers pull like a bow and the minigun grinds. An empty
  magazine gives you a dead trigger until you reload.

Vehicles
  The right trigger starts weightless and grows heavier the further you press,
  resetting the moment you lift off. The brake firms up with speed. A dead
  engine locks both triggers; going airborne frees them.

Directional rumble
  The two motors are driven separately, so a shot fired from your left is felt
  on the left. Gunfire nearby that is not aimed at you gives a softer tick, and
  taking damage gives a heavier one from the attacker's side. The game's own
  rumble still comes through, mixed rather than replaced.

Sniper scope
  While scoped, the right stick looks, the left stick strafes left and right and
  zooms up and down, and walking forward is disabled. The mod holds the camera
  steady while you move, cancelling the turn the game normally applies.

Lightbar
  Left alone until the police want you, then it alternates blue and red like a
  siren, faster at higher wanted levels, and hands the colour back when you lose
  them, die or get busted.


-------------------------------------------------------------------------------
SETTINGS
-------------------------------------------------------------------------------

In game, press F7, or Create and Options together on the controller, for a
menu covering every trigger, each rumble cue with its own strength, the sniper
remap and the lights. Changes apply immediately and save themselves.

  F7   settings menu
  F9   debug overlay with live state and a meter for each motor
  F10  trigger test pulse
  F11  left motor test        F12  right motor test

Two files appear in the scripts folder on first run:

  DualSenseIV.ini
      General settings, the same ones the F7 menu writes. The menu key itself
      can be changed here with MenuKey, if F7 clashes with something.

  DualSenseIV.weapons.ini
      Per weapon trigger feel, listing every weapon found in your game with its
      slot, fire rate and magazine size. It starts empty of overrides; add a
      line to change one weapon:

          14 = effect:rattle, strength:7, rate:8, start:6

      effect     click, rattle, bow, grind, resist or none
      strength   1 for a feather, 8 for as stiff as the pad goes
      rate       shakes per second, used by rattle and grind
      start      how far down the pull it begins, 0 at the top, 9 at the bottom

      Any field you leave out keeps the built in value, so "34 = strength:4"
      lightens one gun and changes nothing else. Delete the file to reset.
      Use "Reload weapon config file" in the F7 menu to apply edits without
      restarting the game.


-------------------------------------------------------------------------------
IF SOMETHING IS WRONG
-------------------------------------------------------------------------------

Read scripts\DualSenseIV.log first. It records which controller was found, over
which connection, and any warning. Turn on Verbose logging in the F7 menu for
much more detail.

The controller does nothing in game
  ViGEmBus is not installed, or Steam Input is still on for GTA IV. The startup
  message names the problem when it is the driver.

No mod at all, no F7 menu
  Check ScriptHookDotNet.log in the game folder. "version ... is not supported"
  means you have the wrong ScriptHookDotNet for your game version; see above.

Triggers work but rumble does not follow the sides
  You are running in DSX mode. DSX cannot carry rumble, so the mod falls back to
  it whenever DSX is running. Close DSX and restart the game.

The controller is connected twice
  A pad paired over Bluetooth and plugged in at the same time shows up twice.
  Use one at a time.


-------------------------------------------------------------------------------
CREDITS AND LICENCES
-------------------------------------------------------------------------------

DualSenseIV is built on work by other people. The components bundled here are
included under their own licences; see the _licenses folder.

  ScriptHook            Aru
  ScriptHookDotNet      HazardX, with fixes by Tomasak and LMS (MIT)
                        Not bundled - download it yourself, see INSTALL
  aCompleteEditionHook  LMS
  HidSharp              James F. Bellinger (Apache 2.0)
  ViGEm.NET             Nefarius Software Solutions (MIT)
  ViGEmBus driver       Nefarius Software Solutions (BSD 3 clause)

The mod does not replace or modify any game file. It only reads
common/data/WeaponInfo.xml and the episode equivalents to learn fire rates.
