SHWotever / SimHub

Multi sim dashboard, bass shaker driver, ....
http://www.simhubdash.com/
806 stars 98 forks source link

[Feature request] AMS2 DRS state #1196

Open lukester1975 opened 1 year ago

lukester1975 commented 1 year ago

Hello Nicolas

I guess this isn't implemented yet, but is there a plan to / could you add mapping of AMS2's mDrsState to DRSAvailable and DRSEnabled?

I guess you must have added some support since mDrsState appears in the raw game data, but DRSAvailable and DRSEnabled say not supported.

// (Type#14) DrsState Flags (to be used with 'mDrsState')
enum DrsState
{
    DRS_INSTALLED       = (1<<0),  // Vehicle has DRS capability
    DRS_ZONE_RULES      = (1<<1),  // 1 if DRS uses F1 style rules
    DRS_AVAILABLE_NEXT  = (1<<2),  // detection zone was triggered (only applies to f1 style rules)
    DRS_AVAILABLE_NOW   = (1<<3),  // detection zone was triggered and we are now in the zone (only applies to f1 style rules)
    DRS_ACTIVE          = (1<<4),  // Wing is in activated state
};

I guess DRS_AVAILABLE_NOW is preferable to DRS_AVAILABLE_NEXT for DRSAvailable...

Many thanks!

Luke.

SHWotever commented 1 year ago

Hi !

Thnaks for your message, I indeed forgot to remove the "not available" flag, but the values are properly wired already,

I'm removing the "not available" flag for the next version,

Nicolas

lukester1975 commented 1 year ago

Oh, that's interesting - I only looked at the UI property viewer as I was never seeing non-0 for DRSEnabled and DRSAvailable in AMS2.

I ended up with (JS):

if ($prop('IsInPitLane') || $prop('IsInPit')) {
  return 0;
} else if ($prop('DataCorePlugin.CurrentGame') === 'Automobilista2') {
  const drsState = $prop('GameRawData.mDrsState');

  if (drsState & 0x10) {
    return 1;
  } else if (drsState & 0x08) {
    return 2;
  }
} else {
  if ($prop('DRSEnabled')) {
    return 1;
  } else if ($prop('DRSAvailable')) {
    return 2;
  }
}

return 0;

instead of (ncalc):

if (([IsInPitLane] || [IsInPit]), 0, if ([DRSEnabled], 1, if ([DRSAvailable], 2, 0)))

which is working fine. Any chance the code is checking for DRS_ZONE_RULES and only setting DRSEnabled and DRSAvailable then? This was inside a plugin in case that makes any difference.

Thanks!