Skip to content

Commit

Permalink
Monitor: track max FFB value.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheIronWolfModding committed Sep 5, 2018
1 parent 9a59fe2 commit b354fd3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Monitor/rF2SMMonitor/rF2SMMonitor/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public partial class MainForm : Form
private const float DEGREES_IN_RADIAN = 57.2957795f;
private const int LIGHT_MODE_REFRESH_MS = 500;

public static bool useStockCarRulesPlugin = false;

System.Windows.Forms.Timer connectTimer = new System.Windows.Forms.Timer();
System.Windows.Forms.Timer disconnectTimer = new System.Windows.Forms.Timer();
bool connected = false;
Expand Down Expand Up @@ -327,7 +329,9 @@ private void MarshalDataBuffer(bool partial, byte[] sharedMemoryReadBuffer, ref
bool logTiming = true;
bool logRules = true;
bool logLightMode = false;
public static bool useStockCarRulesPlugin = false;

// Capture of the max FFB force.
double maxFFBValue = 0.0;

[StructLayout(LayoutKind.Sequential)]
public struct NativeMessage
Expand Down Expand Up @@ -441,6 +445,8 @@ private void MainForm_MouseClick(object sender, MouseEventArgs e)
this.rulesBuffer.ClearStats();

// No stats for FFB buffer (single value buffer).

this.maxFFBValue = 0.0;
}
}

Expand Down Expand Up @@ -689,8 +695,12 @@ void View_Paint(object sender, PaintEventArgs e)
var currY = 3.0f;
float yStep = SystemFonts.DefaultFont.Height;
var gameStateText = new StringBuilder();

// Capture FFB stats:
this.maxFFBValue = Math.Max(Math.Abs(this.forceFeedback.mForceValue), this.maxFFBValue);

gameStateText.Append(
$"Plugin Version: Expected: 3.1.0.0 64bit Actual: {MainForm.GetStringFromBytes(this.extended.mVersion)} {(this.extended.is64bit == 1 ? "64bit" : "32bit")} {(this.extended.mHostedPluginVars.StockCarRules_IsHosted == 1 ? "SCR Plugin Hosted" : "")} FPS: {this.fps} FFB Value: {this.forceFeedback.mForceValue:N3}");
$"Plugin Version: Expected: 3.1.0.0 64bit Actual: {MainForm.GetStringFromBytes(this.extended.mVersion)} {(this.extended.is64bit == 1 ? "64bit" : "32bit")}{(this.extended.mHostedPluginVars.StockCarRules_IsHosted == 1 ? " SCR Plugin Hosted" : "")} FPS: {this.fps} FFB Curr: {this.forceFeedback.mForceValue:N3} Max: {this.maxFFBValue:N3}");

// Draw header
g.DrawString(gameStateText.ToString(), SystemFonts.DefaultFont, brush, currX, currY);
Expand Down

0 comments on commit b354fd3

Please sign in to comment.