Fix profile input from keyboard
This commit is contained in:
parent
6283bae8ad
commit
e88c24f098
8 changed files with 66 additions and 46 deletions
31
Ryujinx.Profiler/NPadDebug.cs
Normal file
31
Ryujinx.Profiler/NPadDebug.cs
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using OpenTK.Input;
|
||||||
|
|
||||||
|
namespace Ryujinx.Profiler
|
||||||
|
{
|
||||||
|
public struct NpadDebugButtons
|
||||||
|
{
|
||||||
|
public Key ToggleProfiler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class NpadDebug
|
||||||
|
{
|
||||||
|
public NpadDebugButtons Buttons;
|
||||||
|
|
||||||
|
private KeyboardState _prevKeyboard;
|
||||||
|
|
||||||
|
public NpadDebug(NpadDebugButtons buttons)
|
||||||
|
{
|
||||||
|
Buttons = buttons;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool TogglePressed(KeyboardState keyboard) => !keyboard[Buttons.ToggleProfiler] && _prevKeyboard[Buttons.ToggleProfiler];
|
||||||
|
|
||||||
|
public void SetPrevKeyboardState(KeyboardState keyboard)
|
||||||
|
{
|
||||||
|
_prevKeyboard = keyboard;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,8 +7,9 @@ namespace Ryujinx.Profiler
|
||||||
{
|
{
|
||||||
public static class Profile
|
public static class Profile
|
||||||
{
|
{
|
||||||
public static float UpdateRate => _settings.UpdateRate;
|
public static float UpdateRate => _settings.UpdateRate;
|
||||||
public static long HistoryLength => _settings.History;
|
public static long HistoryLength => _settings.History;
|
||||||
|
public static NpadDebug Controls => _settings.Controls;
|
||||||
|
|
||||||
private static InternalProfile _profileInstance;
|
private static InternalProfile _profileInstance;
|
||||||
private static ProfilerSettings _settings;
|
private static ProfilerSettings _settings;
|
||||||
|
@ -27,6 +28,7 @@ namespace Ryujinx.Profiler
|
||||||
UpdateRate = (config.UpdateRate <= 0) ? -1 : 1.0f / config.UpdateRate,
|
UpdateRate = (config.UpdateRate <= 0) ? -1 : 1.0f / config.UpdateRate,
|
||||||
History = (long)(config.History * PerformanceCounter.TicksPerSecond),
|
History = (long)(config.History * PerformanceCounter.TicksPerSecond),
|
||||||
MaxLevel = config.MaxLevel,
|
MaxLevel = config.MaxLevel,
|
||||||
|
Controls = config.Controls,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
{
|
{
|
||||||
"$schema": "./_schema.json",
|
|
||||||
|
|
||||||
// Enable profiling (Only available on a profiling enabled build)
|
// Enable profiling (Only available on a profiling enabled build)
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
|
|
||||||
|
@ -8,11 +6,20 @@
|
||||||
"dump_path": "",
|
"dump_path": "",
|
||||||
|
|
||||||
// Update rate for profiler UI, in hertz. -1 updates every time a frame is issued
|
// Update rate for profiler UI, in hertz. -1 updates every time a frame is issued
|
||||||
"update_rate": 4,
|
"update_rate": 4.0,
|
||||||
|
|
||||||
// Set how long to keep profiling data in seconds, reduce if profiling is taking too much RAM
|
// Set how long to keep profiling data in seconds, reduce if profiling is taking too much RAM
|
||||||
"history": 5,
|
"history": 5.0,
|
||||||
|
|
||||||
// Set the maximum profiling level. Higher values may cause a heavy load on your system but will allow you to profile in more detail
|
// Set the maximum profiling level. Higher values may cause a heavy load on your system but will allow you to profile in more detail
|
||||||
"max_level": 0
|
"max_level": 0,
|
||||||
|
|
||||||
|
// Keyboard Controls
|
||||||
|
// https://github.com/opentk/opentk/blob/master/src/OpenTK/Input/Key.cs
|
||||||
|
"controls": {
|
||||||
|
"buttons": {
|
||||||
|
// Show/Hide the profiler
|
||||||
|
"toggle_profiler": "F2"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -17,6 +17,8 @@ namespace Ryujinx.Profiler
|
||||||
public int MaxLevel { get; private set; }
|
public int MaxLevel { get; private set; }
|
||||||
public float History { get; private set; }
|
public float History { get; private set; }
|
||||||
|
|
||||||
|
public NpadDebug Controls { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads a configuration file from disk
|
/// Loads a configuration file from disk
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -15,5 +15,8 @@ namespace Ryujinx.Profiler
|
||||||
|
|
||||||
// 19531225 = 5 seconds in ticks
|
// 19531225 = 5 seconds in ticks
|
||||||
public long History { get; set; } = 19531225;
|
public long History { get; set; } = 19531225;
|
||||||
|
|
||||||
|
// Controls
|
||||||
|
public NpadDebug Controls;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
using OpenTK.Input;
|
||||||
using Ryujinx.Common;
|
using Ryujinx.Common;
|
||||||
|
|
||||||
namespace Ryujinx.Profiler.UI
|
namespace Ryujinx.Profiler.UI
|
||||||
|
@ -46,6 +47,16 @@ namespace Ryujinx.Profiler.UI
|
||||||
_window = null;
|
_window = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Conditional("USE_PROFILING")]
|
||||||
|
public void UpdateKeyInput(KeyboardState keyboard)
|
||||||
|
{
|
||||||
|
if (Profile.Controls.TogglePressed(keyboard))
|
||||||
|
{
|
||||||
|
ToggleVisible();
|
||||||
|
}
|
||||||
|
Profile.Controls.SetPrevKeyboardState(keyboard);
|
||||||
|
}
|
||||||
|
|
||||||
private void ProfileLoop()
|
private void ProfileLoop()
|
||||||
{
|
{
|
||||||
using (_window = new ProfileWindow())
|
using (_window = new ProfileWindow())
|
||||||
|
|
|
@ -152,15 +152,9 @@ namespace Ryujinx
|
||||||
if (_keyboard.HasValue)
|
if (_keyboard.HasValue)
|
||||||
{
|
{
|
||||||
KeyboardState keyboard = _keyboard.Value;
|
KeyboardState keyboard = _keyboard.Value;
|
||||||
|
|
||||||
#if USE_PROFILING
|
// Profiler input, lets the profiler get access to the main windows keyboard state
|
||||||
// Debug
|
_profileWindow.UpdateKeyInput(keyboard);
|
||||||
if (Config.NPadDebug.TogglePressed(keyboard))
|
|
||||||
{
|
|
||||||
_profileWindow.ToggleVisible();
|
|
||||||
}
|
|
||||||
Config.NPadDebug.SetPrevKeyboardState(keyboard);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Normal Input
|
// Normal Input
|
||||||
currentButton = Configuration.Instance.KeyboardControls.GetButtons(keyboard);
|
currentButton = Configuration.Instance.KeyboardControls.GetButtons(keyboard);
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using OpenTK.Input;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ui
|
|
||||||
{
|
|
||||||
public struct NPadDebugButtons
|
|
||||||
{
|
|
||||||
public int ToggleProfiler;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class NPadDebug
|
|
||||||
{
|
|
||||||
public NPadDebugButtons Buttons;
|
|
||||||
private KeyboardState prevKeyboard;
|
|
||||||
|
|
||||||
public NPadDebug(NPadDebugButtons buttons)
|
|
||||||
{
|
|
||||||
Buttons = buttons;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool TogglePressed(KeyboardState keyboard) => !keyboard[(Key) Buttons.ToggleProfiler] && prevKeyboard[(Key) Buttons.ToggleProfiler];
|
|
||||||
|
|
||||||
public void SetPrevKeyboardState(KeyboardState keyboard)
|
|
||||||
{
|
|
||||||
prevKeyboard = keyboard;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue