HeapsIO / heaps

Heaps : Haxe Game Framework
http://heaps.io
MIT License
3.21k stars 341 forks source link

DualShock 4 RT and LT triggered on load for HLDX build #854

Closed parkersprouse closed 4 years ago

parkersprouse commented 4 years ago

I noticed a weird interaction when building my project on Windows for HashLink with the -lib hldx DirectX library and using a DualShock 4 gamepad. As soon as the project loads up, both the RT and LT buttons of my gamepad are automatically triggered. This does not happen if I build for OpenGL (-lib hlsdl) and it does not happen for either library if I use an Xbox 360 gamepad. It's also worth noting that it doesn't happen on the JavaScript output target.

I do use the Steam drivers when I'm playing Steam games, but I didn't have Steam running at the time so I'm not sure if the drivers were active (not sure how those are handled). I don't use DS4Windows, but I do use InputMapper to map my DS4 to a 360 controller for games that don't support DS4 natively, and when I was running InputMapper, the bug didn't happen.

This printed RT and LT to the console once as soon as the game launched:

override function update(dt : Float) {
  if (pad.isPressed(Pad.DEFAULT_CONFIG.RT)) {
    trace('RT');
  }
  if (pad.isPressed(Pad.DEFAULT_CONFIG.LT)) {
    trace('LT');
  }
}

However, there's inconsistent output when isDown is used instead. I got the printout between one and three times between runs.

override function update(dt : Float) {
  if (pad.isDown(Pad.DEFAULT_CONFIG.RT)) {
    trace('RT');
  }
  if (pad.isDown(Pad.DEFAULT_CONFIG.LT)) {
    trace('LT');
  }
}

Here's my whole file that I found the bug with:

import hxd.Pad;

class Main extends hxd.App {
  var pad : hxd.Pad;

  static function main() {
    new Main();
  }

  override function init() {
    pad = Pad.createDummy();
    Pad.wait((p) -> pad = p);
  }

  override function update(dt : Float) {
    if (pad.isDown(Pad.DEFAULT_CONFIG.RT)) {
      trace('RT');
    }
    if (pad.isDown(Pad.DEFAULT_CONFIG.LT)) {
      trace('LT');
    }
  }
}

Here's my whole project folder just in case: Heaps_Gamepad_Bug.zip

And my dependencies: dep

parkersprouse commented 4 years ago

Some more info:

I checked the pad.values indexes to see if the triggers had any values at load at the recommendation of @Yanrishatum:

Index 18: 0.499992370489052
Index 19: 0.499992370489052

After a few runs, it looks like it starts at 0 for 4 frames, then becomes ~0.5 for 2 frames, then goes back to 0.

ncannasse commented 4 years ago

I don't think there's much we can do about it since the values come directly from DirectX driver. You might want to confirm that by recompiling the DirectX.hdll from Hashlink sources with some additional printf for debugging.

Le dim. 12 juil. 2020 à 18:29, Parker Sprouse notifications@github.com a écrit :

Some more info:

I checked the pad.values indexes to see if the triggers had any values at load:

Index 18: 0.499992370489052 Index 19: 0.499992370489052

After a few runs, it looks like it starts at 0 for 4 frames, then becomes ~0.5 for 2 frames, then goes back to 0.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/HeapsIO/heaps/issues/854#issuecomment-657245406, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHZXQFCMIV2SIIJMQJOSKDR3HQHVANCNFSM4OXP35DA .