Skip to content

Commit

Permalink
Merge pull request #81 from a1xd/log-unhandled-ex
Browse files Browse the repository at this point in the history
add handler for unhandled exceptions
  • Loading branch information
a1xd authored Mar 11, 2021
2 parents 59e86a6 + 66f1f4c commit 11b62cf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion common/rawaccel-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#define RA_VER_MAJOR 1
#define RA_VER_MINOR 4
#define RA_VER_PATCH 2
#define RA_VER_PATCH 3

#define RA_OS "Win7+"

Expand Down
15 changes: 9 additions & 6 deletions grapher/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,16 @@ public RawAcceleration()

protected override void WndProc(ref Message m)
{
if (m.Msg == 0x00ff) // WM_INPUT
if (!(AccelGUI is null))
{
AccelGUI.MouseWatcher.ReadMouseMove(m);
}
else if (m.Msg == 0x00fe) // WM_INPUT_DEVICE_CHANGE
{
AccelGUI.UpdateInputManagers();
if (m.Msg == 0x00ff) // WM_INPUT
{
AccelGUI.MouseWatcher.ReadMouseMove(m);
}
else if (m.Msg == 0x00fe) // WM_INPUT_DEVICE_CHANGE
{
AccelGUI.UpdateInputManagers();
}
}

base.WndProc(ref m);
Expand Down
13 changes: 11 additions & 2 deletions grapher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,20 @@ static void Main()
return;
}

AppDomain.CurrentDomain.UnhandledException += GlobalUnhandledExceptionHandler;

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new RawAcceleration());

GC.KeepAlive(mutex);

GC.KeepAlive(mutex);
}

static void GlobalUnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs e)
{
var ex = (Exception)e.ExceptionObject;
System.IO.File.WriteAllText("error.log", ex.ToString());
MessageBox.Show(ex.Message, "Error");
}
}
}

0 comments on commit 11b62cf

Please sign in to comment.