Move DirectX wrappers to new project

This commit is contained in:
YoshiRulz 2020-10-05 03:58:34 +10:00 committed by James Groom
parent 69a05641e7
commit 7f5e777f75
22 changed files with 87 additions and 51 deletions

View File

@ -45,6 +45,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BizHawk.Emulation.Cores", "
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BizHawk.Bizware.BizwareGL", "src\BizHawk.Bizware.BizwareGL\BizHawk.Bizware.BizwareGL.csproj", "{9F84A0B2-861E-4EF4-B89B-5E2A3F38A465}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BizHawk.Bizware.DirectX", "src\BizHawk.Bizware.DirectX\BizHawk.Bizware.DirectX.csproj", "{A914D063-9E4B-4086-B156-7B3F39E33DB2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BizHawk.BizInvoke", "src\BizHawk.BizInvoke\BizHawk.BizInvoke.csproj", "{E5D76DC1-84A8-47AF-BE25-E76F06D2FBBC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BizHawk.WinForms.Controls", "src\BizHawk.WinForms.Controls\BizHawk.WinForms.Controls.csproj", "{B5A2214B-3CB0-48C4-8DB1-98B38D48AC4A}"
@ -95,6 +97,10 @@ Global
{9F84A0B2-861E-4EF4-B89B-5E2A3F38A465}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9F84A0B2-861E-4EF4-B89B-5E2A3F38A465}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9F84A0B2-861E-4EF4-B89B-5E2A3F38A465}.Release|Any CPU.Build.0 = Release|Any CPU
{A914D063-9E4B-4086-B156-7B3F39E33DB2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A914D063-9E4B-4086-B156-7B3F39E33DB2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A914D063-9E4B-4086-B156-7B3F39E33DB2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A914D063-9E4B-4086-B156-7B3F39E33DB2}.Release|Any CPU.Build.0 = Release|Any CPU
{E5D76DC1-84A8-47AF-BE25-E76F06D2FBBC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E5D76DC1-84A8-47AF-BE25-E76F06D2FBBC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E5D76DC1-84A8-47AF-BE25-E76F06D2FBBC}.Release|Any CPU.ActiveCfg = Release|Any CPU

View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
</PropertyGroup>
<Import Project="../MainSlnCommon.props" />
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="System.Windows.Forms" />
<Reference Include="SlimDX" HintPath="$(ProjectDir)../../References/x64/SlimDX.dll" Private="true" />
<ProjectReference Include="$(ProjectDir)../BizHawk.Client.Common/BizHawk.Client.Common.csproj" />
</ItemGroup>
</Project>

View File

@ -6,9 +6,9 @@ using System.Linq;
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk
namespace BizHawk.Bizware.DirectX
{
internal sealed class DirectInputAdapter : HostInputAdapter
public sealed class DirectInputAdapter : HostInputAdapter
{
private Config? _config;
@ -57,32 +57,4 @@ namespace BizHawk.Client.EmuHawk
public void UpdateConfig(Config config) => _config = config;
}
internal sealed class OpenTKInputAdapter : HostInputAdapter
{
public void DeInitAll() {}
public void FirstInitAll(IntPtr mainFormHandle)
{
OTK_Keyboard.Initialize();
OTK_GamePad.Initialize();
}
public void ReInitGamepads(IntPtr mainFormHandle) {}
public void PreprocessHostGamepads() => OTK_GamePad.UpdateAll();
public void ProcessHostGamepads(Action<string?, bool, ClientInputFocus> handleButton, Action<string?, int> handleAxis)
{
foreach (var pad in OTK_GamePad.EnumerateDevices())
{
foreach (var but in pad.buttonObjects) handleButton(pad.InputNamePrefix + but.ButtonName, but.ButtonAction(), ClientInputFocus.Pad);
foreach (var (axisID, f) in pad.GetAxes()) handleAxis($"{pad.InputNamePrefix}{axisID} Axis", (int) f);
}
}
public IEnumerable<KeyEvent> ProcessHostKeyboards() => OTK_Keyboard.Update();
public void UpdateConfig(Config config) {}
}
}

View File

@ -8,9 +8,9 @@ using BizHawk.Client.Common;
using SlimDX.DirectSound;
using SlimDX.Multimedia;
namespace BizHawk.Client.EmuHawk
namespace BizHawk.Bizware.DirectX
{
public class DirectSoundSoundOutput : ISoundOutput
public sealed class DirectSoundSoundOutput : ISoundOutput
{
private readonly IHostAudioManager _sound;
private bool _disposed;

View File

@ -4,9 +4,9 @@ using System.Windows.Forms;
using BizHawk.Bizware.BizwareGL;
using SlimDX.Direct3D9;
namespace BizHawk.Client.EmuHawk
namespace BizHawk.Bizware.DirectX
{
public class GLControlWrapperSlimDX9 : Control, IGraphicsControl
public sealed class GLControlWrapperSlimDX9 : Control, IGraphicsControl
{
public GLControlWrapperSlimDX9(IGL_SlimDX9 sdx)
{

View File

@ -6,9 +6,9 @@ using BizHawk.Common;
using SlimDX;
using SlimDX.DirectInput;
namespace BizHawk.Client.EmuHawk
namespace BizHawk.Bizware.DirectX
{
public class GamePad
internal sealed class GamePad
{
private static readonly object SyncObj = new object();
private static readonly List<GamePad> Devices = new List<GamePad>();

View File

@ -5,9 +5,9 @@ using System.Runtime.InteropServices;
using BizHawk.Common;
using SlimDX.XInput;
namespace BizHawk.Client.EmuHawk
namespace BizHawk.Bizware.DirectX
{
public class GamePad360
internal sealed class GamePad360
{
// ********************************** Static interface **********************************

View File

@ -13,9 +13,9 @@ using sdi = System.Drawing.Imaging;
using swf = System.Windows.Forms;
// todo - do a better job selecting shader model? base on caps somehow? try several and catch compilation exceptions (yuck, exceptions)
namespace BizHawk.Client.EmuHawk
namespace BizHawk.Bizware.DirectX
{
public class IGL_SlimDX9 : IGL
public sealed class IGL_SlimDX9 : IGL
{
private const int D3DERR_DEVICELOST = -2005530520;
private const int D3DERR_DEVICENOTRESET = -2005530519;

View File

@ -8,9 +8,9 @@ using BizHawk.Client.Common;
using SlimDX.DirectInput;
// this is not a very safe or pretty protocol, I'm not proud of it
namespace BizHawk.Client.EmuHawk
namespace BizHawk.Bizware.DirectX
{
public static class IPCKeyInput
internal static class IPCKeyInput
{
public static void Initialize()
{

View File

@ -6,9 +6,9 @@ using BizHawk.Client.Common;
using SlimDX;
using SlimDX.DirectInput;
namespace BizHawk.Client.EmuHawk
namespace BizHawk.Bizware.DirectX
{
public static class KeyInput
internal static class KeyInput
{
private static readonly object SyncObj = new object();
private static readonly List<KeyEvent> EventList = new List<KeyEvent>();

View File

@ -3,7 +3,7 @@ using System.Linq;
using System.Windows.Forms;
using SlimDX.DirectInput;
namespace BizHawk.Client.EmuHawk
namespace BizHawk.Bizware.DirectX
{
internal static class KeyboardMapping
{

View File

@ -1,6 +1,6 @@
namespace BizHawk.Bizware.BizwareGL
namespace BizHawk.Bizware.DirectX
{
public static class Extensions
internal static class Extensions
{
public static global::SlimDX.Matrix ToSlimDXMatrix(this OpenTK.Matrix4 m, bool transpose)
{

View File

@ -8,9 +8,9 @@ using SlimDX;
using SlimDX.Multimedia;
using SlimDX.XAudio2;
namespace BizHawk.Client.EmuHawk
namespace BizHawk.Bizware.DirectX
{
public class XAudio2SoundOutput : ISoundOutput
public sealed class XAudio2SoundOutput : ISoundOutput
{
private bool _disposed;
private readonly IHostAudioManager _sound;

View File

@ -86,10 +86,9 @@
<Reference Include="GongShell" HintPath="$(ProjectDir)../../References/GongShell.dll" Private="true" />
<Reference Include="NLua, Version=1.3.2.0, Culture=neutral, processorArchitecture=MSIL" HintPath="$(ProjectDir)../../output/dll/nlua/NLua.dll" Private="true" SpecificVersion="false" />
<PackageReference Include="OpenTK.GLControl" Version="3.0.1" PrivateAssets="all" />
<Reference Include="SlimDX" HintPath="$(ProjectDir)../../References/x64/SlimDX.dll" Private="true" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(ProjectDir)../BizHawk.Client.Common/BizHawk.Client.Common.csproj" />
<ProjectReference Include="$(ProjectDir)../BizHawk.Bizware.DirectX/BizHawk.Bizware.DirectX.csproj" />
<ProjectReference Include="$(ProjectDir)../BizHawk.WinForms.Controls/BizHawk.WinForms.Controls.csproj" />
<Compile Include="$(ProjectDir)../BizHawk.Common/OSTailoredCode.cs" />
<Compile Remove="Properties/Settings.Designer.cs" />

View File

@ -12,6 +12,7 @@ using System.Runtime.InteropServices;
using System.Windows.Forms;
using BizHawk.Bizware.BizwareGL;
using BizHawk.Bizware.DirectX;
using BizHawk.Client.Common;
using BizHawk.Client.Common.Filters;
using BizHawk.Client.Common.FilterManager;

View File

@ -1,5 +1,6 @@
using System;
using BizHawk.Bizware.BizwareGL;
using BizHawk.Bizware.DirectX;
namespace BizHawk.Client.EmuHawk
{

View File

@ -1,6 +1,7 @@
using System;
using BizHawk.Bizware.BizwareGL;
using BizHawk.Bizware.DirectX;
namespace BizHawk.Client.EmuHawk
{

View File

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Threading;
using System.Windows.Forms;
using BizHawk.Bizware.DirectX;
using BizHawk.Common;
using BizHawk.Client.Common;

View File

@ -0,0 +1,37 @@
#nullable enable
using System;
using System.Collections.Generic;
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk
{
public sealed class OpenTKInputAdapter : HostInputAdapter
{
public void DeInitAll() {}
public void FirstInitAll(IntPtr mainFormHandle)
{
OTK_Keyboard.Initialize();
OTK_GamePad.Initialize();
}
public void ReInitGamepads(IntPtr mainFormHandle) {}
public void PreprocessHostGamepads() => OTK_GamePad.UpdateAll();
public void ProcessHostGamepads(Action<string?, bool, ClientInputFocus> handleButton, Action<string?, int> handleAxis)
{
foreach (var pad in OTK_GamePad.EnumerateDevices())
{
foreach (var but in pad.buttonObjects) handleButton(pad.InputNamePrefix + but.ButtonName, but.ButtonAction(), ClientInputFocus.Pad);
foreach (var (axisID, f) in pad.GetAxes()) handleAxis($"{pad.InputNamePrefix}{axisID} Axis", (int) f);
}
}
public IEnumerable<KeyEvent> ProcessHostKeyboards() => OTK_Keyboard.Update();
public void UpdateConfig(Config config) {}
}
}

View File

@ -6,6 +6,8 @@ using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using BizHawk.Bizware.DirectX;
using Microsoft.VisualBasic.ApplicationServices;
using BizHawk.Common;

View File

@ -1,6 +1,7 @@
using System;
using System.Threading;
using BizHawk.Bizware.DirectX;
using BizHawk.Emulation.Common;
using BizHawk.Client.Common;
using BizHawk.Common;

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using BizHawk.Bizware.DirectX;
using BizHawk.Client.Common;
using BizHawk.Common;