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()
{
controller = new Controller[4];
for (int index = 0; index < controller.Length; index++)
controller[index] = new Controller((UserIndex)index);
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,47 +172,50 @@ namespace ANX.RenderSystem.Windows.DX10
{
PreventSystemChange();
var factory = new Factory();
var adapterList = new List<GraphicsAdapter>();
var resultingModes = new List<DisplayMode>();
for (int i = 0; i < factory.GetAdapterCount(); i++)
{
using (Adapter adapter = factory.GetAdapter(i))
{
var ga = new GraphicsAdapter();
//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;
using (Factory factory = new Factory())
{
for (int i = 0; i < factory.GetAdapterCount(); i++)
{
using (Adapter adapter = factory.GetAdapter(i))
{
var ga = new GraphicsAdapter();
//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;
using (Output adapterOutput = adapter.Outputs[0])
{
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);
}
}
resultingModes.Clear();
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);
}

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,48 +165,50 @@ namespace ANX.RenderSystem.Windows.DX11
{
PreventSystemChange();
var factory = new Factory();
var adapterList = new List<GraphicsAdapter>();
var resultingModes = new List<DisplayMode>();
for (int i = 0; i < factory.GetAdapterCount(); i++)
{
using (Adapter adapter = factory.GetAdapter(i))
{
GraphicsAdapter ga = new GraphicsAdapter();
//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)
using (Factory factory = new Factory())
{
for (int i = 0; i < factory.GetAdapterCount(); i++)
{
using (Adapter adapter = factory.GetAdapter(i))
{
foreach (ModeDescription modeDescription in adapterOutput.GetDisplayModeList(Format.R8G8B8A8_UNorm,
DisplayModeEnumerationFlags.Interlaced))
GraphicsAdapter ga = new GraphicsAdapter();
//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,
DxFormatConverter.Translate(modeDescription.Format));
resultingModes.Add(displayMode);
using (Output adapterOutput = adapter.Outputs[0])
{
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);
}

View File

@ -1,4 +1,5 @@
#region Using Statements
using System;
using System.Collections.Generic;
using System.IO;
using ANX.Framework.Graphics;
@ -66,7 +67,15 @@ namespace ANX.RenderSystem.Windows.DX11
: this(managedEffect)
{
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

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