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

@ -33,7 +33,19 @@ namespace ANX.InputDevices.Windows.XInput
{
controller = new Controller[4];
for (int index = 0; index < controller.Length; 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
@ -41,7 +53,7 @@ namespace ANX.InputDevices.Windows.XInput
public GamePadCapabilities GetCapabilities(PlayerIndex playerIndex)
{
var gamepad = controller[(int)playerIndex];
if (gamepad.IsConnected == false)
if (gamepad == null || gamepad.IsConnected == false)
return emptyCaps;
try
@ -95,11 +107,14 @@ namespace ANX.InputDevices.Windows.XInput
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)
return emptyState;
State nativeState = controller[(int)playerIndex].GetState();
State nativeState = controller.GetState();
Vector2 leftThumb = ApplyDeadZone(nativeState.Gamepad.LeftThumbX, nativeState.Gamepad.LeftThumbY,
LeftThumbDeadZoneSquare, deadZoneMode);
Vector2 rightThumb = ApplyDeadZone(nativeState.Gamepad.RightThumbX, nativeState.Gamepad.RightThumbY,
@ -117,7 +132,7 @@ namespace ANX.InputDevices.Windows.XInput
#region SetVibration
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;
var vib = new Vibration()

View File

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

View File

@ -172,11 +172,11 @@ namespace ANX.RenderSystem.Windows.DX10
{
PreventSystemChange();
var factory = new Factory();
var adapterList = new List<GraphicsAdapter>();
var resultingModes = new List<DisplayMode>();
using (Factory factory = new Factory())
{
for (int i = 0; i < factory.GetAdapterCount(); i++)
{
using (Adapter adapter = factory.GetAdapter(i))
@ -194,25 +194,28 @@ namespace ANX.RenderSystem.Windows.DX10
//ga.SupportedDisplayModes = ;
ga.VendorId = adapter.Description.VendorId;
resultingModes.Clear();
if (adapter.Outputs.Length >= 1)
{
using (Output adapterOutput = adapter.Outputs[0])
{
var modeList = adapterOutput.GetDisplayModeList(Format.R8G8B8A8_UNorm,
DisplayModeEnumerationFlags.Interlaced);
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));
var displayMode = new DisplayMode(modeDescription.Width, modeDescription.Height, DxFormatConverter.Translate(modeDescription.Format));
resultingModes.Add(displayMode);
}
}
}
ga.SupportedDisplayModes = new DisplayModeCollection(resultingModes);
adapterList.Add(ga);
}
}
factory.Dispose();
}
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
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.7.24.*")]
[assembly: AssemblyFileVersion("0.7.24.0")]
[assembly: AssemblyVersion("0.7.25.*")]
[assembly: AssemblyFileVersion("0.7.25.0")]
[assembly: InternalsVisibleTo("ANX.Framework.ContentPipeline")]

View File

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

View File

@ -165,11 +165,11 @@ namespace ANX.RenderSystem.Windows.DX11
{
PreventSystemChange();
var factory = new Factory();
var adapterList = new List<GraphicsAdapter>();
var resultingModes = new List<DisplayMode>();
using (Factory factory = new Factory())
{
for (int i = 0; i < factory.GetAdapterCount(); i++)
{
using (Adapter adapter = factory.GetAdapter(i))
@ -187,17 +187,20 @@ namespace ANX.RenderSystem.Windows.DX11
//ga.SupportedDisplayModes = ;
ga.VendorId = adapter.Description.VendorId;
foreach (Output adapterOutput in adapter.Outputs)
resultingModes.Clear();
if (adapter.Outputs.Length >= 1)
{
foreach (ModeDescription modeDescription in adapterOutput.GetDisplayModeList(Format.R8G8B8A8_UNorm,
DisplayModeEnumerationFlags.Interlaced))
using (Output adapterOutput = adapter.Outputs[0])
{
var displayMode = new DisplayMode(modeDescription.Width, modeDescription.Height,
DxFormatConverter.Translate(modeDescription.Format));
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);
@ -205,8 +208,7 @@ namespace ANX.RenderSystem.Windows.DX11
adapterList.Add(ga);
}
}
factory.Dispose();
}
return new System.Collections.ObjectModel.ReadOnlyCollection<GraphicsAdapter>(adapterList);
}

View File

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

View File

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

View File

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

View File

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