fixed some Windows 8 (non ModernUI mode) issues:

- made DX10 RenderSystem available
- fixed adapter enumeration in DX10 and DX11 RenderSystems
- fixed GamePad initialization error handling on Windows 8 when XInput 1.3 is not installed
This commit is contained in:
Glatzemann 2012-11-12 19:10:28 +00:00 committed by Konstantin Koch
parent 968ee33394
commit 6e01932070
10 changed files with 116 additions and 85 deletions

View File

@ -32,8 +32,20 @@ namespace ANX.InputDevices.Windows.XInput
public GamePad() public GamePad()
{ {
controller = new Controller[4]; controller = new Controller[4];
for (int index = 0; index < controller.Length; index++) for (int index = 0; index < controller.Length; index++)
controller[index] = new Controller((UserIndex)index); {
controller[index] = new Controller((UserIndex)index);
try
{
bool isConnected = controller[index].IsConnected;
}
catch (System.DllNotFoundException ex)
{
controller[index] = null;
Logger.Warning("couldn't initialize GamePad " + index + " because " + ex.Message);
}
}
} }
#endregion #endregion
@ -41,7 +53,7 @@ namespace ANX.InputDevices.Windows.XInput
public GamePadCapabilities GetCapabilities(PlayerIndex playerIndex) public GamePadCapabilities GetCapabilities(PlayerIndex playerIndex)
{ {
var gamepad = controller[(int)playerIndex]; var gamepad = controller[(int)playerIndex];
if (gamepad.IsConnected == false) if (gamepad == null || gamepad.IsConnected == false)
return emptyCaps; return emptyCaps;
try try
@ -95,11 +107,14 @@ namespace ANX.InputDevices.Windows.XInput
public GamePadState GetState(PlayerIndex playerIndex, GamePadDeadZone deadZoneMode) public GamePadState GetState(PlayerIndex playerIndex, GamePadDeadZone deadZoneMode)
{ {
bool isConnected = controller[(int)playerIndex].IsConnected; var controller = this.controller[(int)playerIndex];
if (controller == null) return new GamePadState();
bool isConnected = controller.IsConnected;
if (isConnected == false) if (isConnected == false)
return emptyState; return emptyState;
State nativeState = controller[(int)playerIndex].GetState(); State nativeState = controller.GetState();
Vector2 leftThumb = ApplyDeadZone(nativeState.Gamepad.LeftThumbX, nativeState.Gamepad.LeftThumbY, Vector2 leftThumb = ApplyDeadZone(nativeState.Gamepad.LeftThumbX, nativeState.Gamepad.LeftThumbY,
LeftThumbDeadZoneSquare, deadZoneMode); LeftThumbDeadZoneSquare, deadZoneMode);
Vector2 rightThumb = ApplyDeadZone(nativeState.Gamepad.RightThumbX, nativeState.Gamepad.RightThumbY, Vector2 rightThumb = ApplyDeadZone(nativeState.Gamepad.RightThumbX, nativeState.Gamepad.RightThumbY,
@ -117,7 +132,7 @@ namespace ANX.InputDevices.Windows.XInput
#region SetVibration #region SetVibration
public bool SetVibration(PlayerIndex playerIndex, float leftMotor, float rightMotor) public bool SetVibration(PlayerIndex playerIndex, float leftMotor, float rightMotor)
{ {
if (controller[(int)playerIndex].IsConnected == false) if (controller[(int)playerIndex] == null || controller[(int)playerIndex].IsConnected == false)
return false; return false;
var vib = new Vibration() var vib = new Vibration()

View File

@ -20,7 +20,7 @@
<OutputPath>..\..\bin\Debug\</OutputPath> <OutputPath>..\..\bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;XNAEXT DX10</DefineConstants> <DefineConstants>TRACE;DEBUG;XNAEXT DX10</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>0</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>

View File

@ -172,47 +172,50 @@ namespace ANX.RenderSystem.Windows.DX10
{ {
PreventSystemChange(); PreventSystemChange();
var factory = new Factory();
var adapterList = new List<GraphicsAdapter>(); var adapterList = new List<GraphicsAdapter>();
var resultingModes = new List<DisplayMode>(); var resultingModes = new List<DisplayMode>();
for (int i = 0; i < factory.GetAdapterCount(); i++) using (Factory factory = new Factory())
{ {
using (Adapter adapter = factory.GetAdapter(i)) for (int i = 0; i < factory.GetAdapterCount(); i++)
{ {
var ga = new GraphicsAdapter(); using (Adapter adapter = factory.GetAdapter(i))
//ga.CurrentDisplayMode = ; {
//ga.Description = ; var ga = new GraphicsAdapter();
ga.DeviceId = adapter.Description.DeviceId; //ga.CurrentDisplayMode = ;
ga.DeviceName = adapter.Description.Description; //ga.Description = ;
ga.IsDefaultAdapter = i == 0; //TODO: how to set default adapter? ga.DeviceId = adapter.Description.DeviceId;
//ga.IsWideScreen = ; ga.DeviceName = adapter.Description.Description;
//ga.MonitorHandle = ; ga.IsDefaultAdapter = i == 0; //TODO: how to set default adapter?
ga.Revision = adapter.Description.Revision; //ga.IsWideScreen = ;
ga.SubSystemId = adapter.Description.SubsystemId; //ga.MonitorHandle = ;
//ga.SupportedDisplayModes = ; ga.Revision = adapter.Description.Revision;
ga.VendorId = adapter.Description.VendorId; ga.SubSystemId = adapter.Description.SubsystemId;
//ga.SupportedDisplayModes = ;
ga.VendorId = adapter.Description.VendorId;
using (Output adapterOutput = adapter.Outputs[0]) resultingModes.Clear();
{
var modeList = adapterOutput.GetDisplayModeList(Format.R8G8B8A8_UNorm,
DisplayModeEnumerationFlags.Interlaced);
foreach (ModeDescription modeDescription in modeList)
{
var displayMode = new DisplayMode(modeDescription.Width, modeDescription.Height,
DxFormatConverter.Translate(modeDescription.Format));
resultingModes.Add(displayMode);
}
}
ga.SupportedDisplayModes = new DisplayModeCollection(resultingModes); if (adapter.Outputs.Length >= 1)
{
using (Output adapterOutput = adapter.Outputs[0])
{
var modeList = adapterOutput.GetDisplayModeList(Format.R8G8B8A8_UNorm, DisplayModeEnumerationFlags.Interlaced);
adapterList.Add(ga); foreach (ModeDescription modeDescription in modeList)
} {
} var displayMode = new DisplayMode(modeDescription.Width, modeDescription.Height, DxFormatConverter.Translate(modeDescription.Format));
resultingModes.Add(displayMode);
}
}
}
factory.Dispose(); ga.SupportedDisplayModes = new DisplayModeCollection(resultingModes);
adapterList.Add(ga);
}
}
}
return new ReadOnlyCollection<GraphicsAdapter>(adapterList); return new ReadOnlyCollection<GraphicsAdapter>(adapterList);
} }

View File

@ -32,7 +32,7 @@ using System.Runtime.InteropServices;
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben: // übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.7.24.*")] [assembly: AssemblyVersion("0.7.25.*")]
[assembly: AssemblyFileVersion("0.7.24.0")] [assembly: AssemblyFileVersion("0.7.25.0")]
[assembly: InternalsVisibleTo("ANX.Framework.ContentPipeline")] [assembly: InternalsVisibleTo("ANX.Framework.ContentPipeline")]

View File

@ -17,6 +17,7 @@ namespace ANX.RenderSystem.Windows.DX10
{ {
PlatformName.WindowsVista, PlatformName.WindowsVista,
PlatformName.Windows7, PlatformName.Windows7,
PlatformName.Windows8,
}; };
} }
} }

View File

@ -165,48 +165,50 @@ namespace ANX.RenderSystem.Windows.DX11
{ {
PreventSystemChange(); PreventSystemChange();
var factory = new Factory();
var adapterList = new List<GraphicsAdapter>(); var adapterList = new List<GraphicsAdapter>();
var resultingModes = new List<DisplayMode>(); var resultingModes = new List<DisplayMode>();
for (int i = 0; i < factory.GetAdapterCount(); i++) using (Factory factory = new Factory())
{ {
using (Adapter adapter = factory.GetAdapter(i)) for (int i = 0; i < factory.GetAdapterCount(); i++)
{ {
GraphicsAdapter ga = new GraphicsAdapter(); using (Adapter adapter = factory.GetAdapter(i))
//ga.CurrentDisplayMode = ;
//ga.Description = ;
ga.DeviceId = adapter.Description.DeviceId;
ga.DeviceName = adapter.Description.Description;
ga.IsDefaultAdapter = i == 0; //TODO: how to set default adapter?
//ga.IsWideScreen = ;
//ga.MonitorHandle = ;
ga.Revision = adapter.Description.Revision;
ga.SubSystemId = adapter.Description.SubsystemId;
//ga.SupportedDisplayModes = ;
ga.VendorId = adapter.Description.VendorId;
foreach (Output adapterOutput in adapter.Outputs)
{ {
foreach (ModeDescription modeDescription in adapterOutput.GetDisplayModeList(Format.R8G8B8A8_UNorm, GraphicsAdapter ga = new GraphicsAdapter();
DisplayModeEnumerationFlags.Interlaced)) //ga.CurrentDisplayMode = ;
//ga.Description = ;
ga.DeviceId = adapter.Description.DeviceId;
ga.DeviceName = adapter.Description.Description;
ga.IsDefaultAdapter = i == 0; //TODO: how to set default adapter?
//ga.IsWideScreen = ;
//ga.MonitorHandle = ;
ga.Revision = adapter.Description.Revision;
ga.SubSystemId = adapter.Description.SubsystemId;
//ga.SupportedDisplayModes = ;
ga.VendorId = adapter.Description.VendorId;
resultingModes.Clear();
if (adapter.Outputs.Length >= 1)
{ {
var displayMode = new DisplayMode(modeDescription.Width, modeDescription.Height, using (Output adapterOutput = adapter.Outputs[0])
DxFormatConverter.Translate(modeDescription.Format)); {
resultingModes.Add(displayMode); var modeList = adapterOutput.GetDisplayModeList(Format.R8G8B8A8_UNorm, DisplayModeEnumerationFlags.Interlaced);
foreach (ModeDescription modeDescription in modeList)
{
var displayMode = new DisplayMode(modeDescription.Width, modeDescription.Height, DxFormatConverter.Translate(modeDescription.Format));
resultingModes.Add(displayMode);
}
}
} }
break; //TODO: for the moment only adapter output 0 is interesting... ga.SupportedDisplayModes = new DisplayModeCollection(resultingModes);
adapterList.Add(ga);
} }
}
ga.SupportedDisplayModes = new DisplayModeCollection(resultingModes); }
adapterList.Add(ga);
}
}
factory.Dispose();
return new System.Collections.ObjectModel.ReadOnlyCollection<GraphicsAdapter>(adapterList); return new System.Collections.ObjectModel.ReadOnlyCollection<GraphicsAdapter>(adapterList);
} }

View File

@ -1,4 +1,5 @@
#region Using Statements #region Using Statements
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using ANX.Framework.Graphics; using ANX.Framework.Graphics;
@ -66,7 +67,15 @@ namespace ANX.RenderSystem.Windows.DX11
: this(managedEffect) : this(managedEffect)
{ {
var device = ((GraphicsDeviceDX)graphicsDevice.NativeDevice).NativeDevice.Device; var device = ((GraphicsDeviceDX)graphicsDevice.NativeDevice).NativeDevice.Device;
NativeEffect = new Dx11.Effect(device, GetByteCode(effectStream));
try
{
NativeEffect = new Dx11.Effect(device, GetByteCode(effectStream));
}
catch (Exception ex)
{
System.Diagnostics.Debugger.Break();
}
} }
#endregion #endregion

View File

@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Buildnummer // Buildnummer
// Revision // Revision
// //
[assembly: AssemblyVersion("0.7.16.*")] [assembly: AssemblyVersion("0.7.17.*")]
[assembly: AssemblyFileVersion("0.7.16.0")] [assembly: AssemblyFileVersion("0.7.17.0")]

View File

@ -71,9 +71,9 @@
<Project>{068eb2e9-963c-4e1b-8831-e25011f11ffe}</Project> <Project>{068eb2e9-963c-4e1b-8831-e25011f11ffe}</Project>
<Name>ANX.PlatformSystem.Windows</Name> <Name>ANX.PlatformSystem.Windows</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\RenderSystems\ANX.RenderSystem.Windows.DX11\ANX.RenderSystem.Windows.DX11.csproj"> <ProjectReference Include="..\..\RenderSystems\ANX.RenderSystem.Windows.DX10\ANX.RenderSystem.Windows.DX10.csproj">
<Project>{b30de9c2-0926-46b6-8351-9af276c472d5}</Project> <Project>{5be49183-2f6f-4527-ac90-d816911fcf90}</Project>
<Name>ANX.RenderSystem.Windows.DX11</Name> <Name>ANX.RenderSystem.Windows.DX10</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\SoundSystems\ANX.SoundSystem.Windows.XAudio\ANX.SoundSystem.Windows.XAudio.csproj"> <ProjectReference Include="..\..\SoundSystems\ANX.SoundSystem.Windows.XAudio\ANX.SoundSystem.Windows.XAudio.csproj">
<Project>{6a582788-c4d2-410c-96cd-177f75712d65}</Project> <Project>{6a582788-c4d2-410c-96cd-177f75712d65}</Project>

View File

@ -84,11 +84,12 @@ namespace ANX.SoundSystem.Windows.XAudio
distanceScale = 1f; distanceScale = 1f;
dopplerScale = 1f; dopplerScale = 1f;
speedOfSound = 343.5f; speedOfSound = 343.5f;
try try
{ {
device = new XAudio2(); device = new XAudio2(XAudio2Flags.DebugEngine, ProcessorSpecifier.AnyProcessor);
} }
catch (Exception) catch (Exception ex)
{ {
device = null; device = null;
//TODO: error handling //TODO: error handling