SADX Input Mod - Fixed XInput & DInput!

Discussion in 'Engineering & Reverse Engineering' started by SF94, Jan 1, 2015.

  1. SF94

    SF94

    Previously Morph Tech Member
    773
    0
    16
    Utah
    SA1/2 hax
    This mod fixes issues with XInput controllers (camera problems, adds rumble) and some DirectInput controllers. It uses SDL2 to allow simultaneous usage of XInput and DirectInput controllers, and increases the maximum number of controllers from 4 (sometimes 8 depending on where you look in SADX's code) to 8.

    Requirements:

    What it does:
    • Configurable deadzones per stick
    • Configurable rumble intensity
    • XInput rumble
    • Per-Controller rumble
    • Fixes right analog stick (first person camera bug) for XInput and some DirectInput controllers
    • Extended buttons - LB is Dreamcast C, RB is Z, and Back is D.

    What it doesn't:
    • Configurable controls.

    Configuration:
    To configure deadzones and the like, create a text file called "config.ini" in the mod's folder (as in, mods/input-mod, where input-mod.dll is). As for the contents, here's an example of the deadzones I use for my DualShock 4.

    Code (Text):
    1.  
    2. [Controller 1]
    3. DeadzoneL = 4096
    4. DeadzoneR = 4096
    5.  
    The deadzone can be anywhere from 0 to 32767.

    You can also enable or disable radial input using the following parameters. By default, it's enabled for the left stick and disabled for the right stick.

    Code (Text):
    1.  
    2. RadialL = (0/1, 1 by default)
    3. RadialR = (0/1, 0 by default)
    4.  
    And for reference, these are the default XInput deadzones.
    • 7849 for the left stick
    • 8689 for the right stick
    • 30 for the triggers

    Other configuration fields:
    • RumbleFactor - Rumble intensity factor; floating point. 1.0 by default. This value can be as low as 0.0 and as high as you want, but it might cause issues with really high values.
    • Debug - (0/1) Enables display of ingame debug information about your controller when you press L1/LB.

    To change the controller you're configuring for, simply change the number after "Controller" in the first example (e.g [Controller 1] -> [Controller 2]). You can configure up to 8 controllers.

    Download:

    p.s xinput sucks, signed gerbilsoft-senpai
     
  2. Tweedle

    Tweedle

    Member Member
    Happy new year, This looks very helpful, I'll try it out later!
     
  3. IndyTheGreat

    IndyTheGreat

    Member Member
    53
    0
    6
    Fixed Water (SADX PC)
    You CAN use the triggers in the Steam release though... just go into the config and move the camera controls from the bumpers to the triggers.
     
  4. SF94

    SF94

    Previously Morph Tech Member
    773
    0
    16
    Utah
    SA1/2 hax
    I suppose you're right. Last time I had tried, it didn't work, but that could have actually been DS4Windows doing its occasional "who needs button presses!" thing. I've still got the D-Pad and not-as-overbearing rumble though (which is still subject to adjustment) =P

    Edit: see below
     
  5. SF94

    SF94

    Previously Morph Tech Member
    773
    0
    16
    Utah
    SA1/2 hax
    Updated it the day after I released it. Fantastic :v:

    I modified this to link with XInput 1.3 specifically which is available in the DirectX End-User Runtime. I also fixed an oversight which would cause it to crash on Windows XP.

    That's about it, really.
     
  6. SF94

    SF94

    Previously Morph Tech Member
    773
    0
    16
    Utah
    SA1/2 hax
    Bug fix!

    With the help of some testers in #x-hax: fixed an integer rollover which--even though it shouldn't have, and I did many tests to ensure it didn't--caused the axes to reverse direction under certain conditions (third party controllers).
     
  7. Conzuh

    Conzuh

    help Member
    71
    0
    6
    Redbubble memery
    I just wanted to say thank you, Morph. I can't believe we've gone this long with only a hodgepodge of a hack to get 360 controllers semi-working.

    You're doing SEGA's work.
     
  8. ShadowBlitz

    ShadowBlitz

    Member Member
    12
    0
    1
    This mod is pretty awesome. Makes it a lot more natural to use a 360 controller. I'm assuming this probably works with Xbone's controller as well, but I don't feel like using that until I can get a wireless adapter for it.
     
  9. SF94

    SF94

    Previously Morph Tech Member
    773
    0
    16
    Utah
    SA1/2 hax
    Thanks guys!

    If you end up trying it out, let me know if that controller works, ShadowBlitz.
     
  10. ShadowBlitz

    ShadowBlitz

    Member Member
    12
    0
    1
    I gave it a try and it definitely does work fine with a One controller. No obvious issues for sure.
     
  11. SF94

    SF94

    Previously Morph Tech Member
    773
    0
    16
    Utah
    SA1/2 hax
    Quick update. I've disabled the debug display by request (which would normally appear when LB/L1 is pressed); compatibility doesn't seem to be an issue at this point anyway. The functionality is otherwise the same.

    This brings the version number to 1.3. You can grab it from the first post, or from GitHub. If you have problems with your controller, you can use the previous version (1.2) from GitHub as well, and the debug information will be available again. Alternatively, you can compile your own Debug build, but that's not the most user friendly option given that I haven't provided instructions, I suppose =P
     
  12. SF94

    SF94

    Previously Morph Tech Member
    773
    0
    16
    Utah
    SA1/2 hax
    Here's another rather minor update.

    I may or may not have been handling button presses incorrectly, so I've made it pretty much exactly the same as found in the original (albeit disassembled) code. I've also updated the mod loader to v3.2, which is now a hard requirement. You'll have to update it before you can use the latest mod.

    I've also disabled per-controller rumble until I can figure out how to detect if a player is currently AI controlled.

    This brings the version number to 1.4. As always, you can grab the latest version from the first post or the GitHub release page. Let me know if I broke anything.
     
  13. CheatFreak

    CheatFreak

    Everything or Nothing. Member
    56
    0
    0
    Michigan
    BetterSADX Patch
    I don't seem to be getting any rumble on my Logitech F710 Xinput controller- the rumble works fine in any other game- is the rumble disabled entirely as of now?
    Also- Xinput Button Prompts for english speakers! (DL: https://u.teknik.io/MSktVp.zip)
    [​IMG]
    Ignore that some of the buttons are incorrect in that image- they are actually correct in the download
     
  14. Ch1pper

    Ch1pper

    Fighting the Battle of Who Could Care Less Member
    647
    0
    16
    Life.
    I'd love to try that out, but after clicking the link I'm getting multiple "Warning: mysql_connect(): No connection could be made because the target machine actively refused it."
     
  15. CheatFreak

    CheatFreak

    Everything or Nothing. Member
    56
    0
    0
    Michigan
    BetterSADX Patch
    If you were talking about my button prompts- I think it's because teknik was down earlier- it's back up now.
     
  16. Ch1pper

    Ch1pper

    Fighting the Battle of Who Could Care Less Member
    647
    0
    16
    Life.
    Yes, sorry, I was responding to you. I downloaded it this morning and, after some fiddling around with having the correct exe just now, I got it working fine. I don't have the 360 version to compare to, but at a quick glance of the character instructions it works as expected. At any rate it certainly gets the job done, so nice job!
     
  17. SF94

    SF94

    Previously Morph Tech Member
    773
    0
    16
    Utah
    SA1/2 hax
    Been sitting on this update for a while now!

    Version 1.5 now uses a scaled optionally-radial deadzone. This means that when an axis exceeds a deadzone, the value of the axis is a scaled value of 1 to axis max instead of deadzone + 1 to axis max (which is just a hard cutoff). That also means if you have normalization enabled (making it radial, I think? Unless I've got my terminology wrong, which I wouldn't doubt), by exceeding the deadzone on one axis, you inherently exceed it on the other; e.g pressing forward to exceed the vertical deadzone also "exceeds" the horizontal deadzone. It gives you a more Dreamcast-esque full range of motion, is enabled on the left stick by default, and disabled for the right stick since camera movement is so sensitive. If you're a sonic-the-car-driving wuss don't like the full range of motion, you can disable it in your xinput ini using the following parameters:

    Code (Text):
    1.  
    2. NormalizeL = (0/1, 1 by default)
    3. NormalizeR = (0/1, 0 by default)
    4.  
    To clarify, disabling it gives you a more Gamecube-esque range of motion, and enabling it gives you the full Dreamcast range of motion.
    Download on the first page or github blah blah blah.

    Edit: Oh, and configurable controls might be coming next update.
     
  18. LimitCrown

    LimitCrown

    Member Member
    I'm encountering a few problems with the latest version of this mod. It seems that button configuration is messed up. For example, the left stick button is the start button, the camera automatically rotates, the X button is mapped to down on the d-pad, the R button is mapped to up, and a few others. The trigger buttons can't be used to adjust the camera, too.
     
  19. SF94

    SF94

    Previously Morph Tech Member
    773
    0
    16
    Utah
    SA1/2 hax
    Then it's not even working. Make sure your mod loader is the latest, is actually installed (does the mod manager have an "install" button?), and that you have the redists linked in the first post installed.
     
  20. LimitCrown

    LimitCrown

    Member Member
    Oh. It seems that I had the previous version of the SADX Mod Manager. Sorry about that. It was my mistake.