forked from nkast/MonoGame
-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Oculus native backend * build oculus * Oculus template * update readme
- Loading branch information
Showing
30 changed files
with
4,217 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.9.34723.18 | ||
MinimumVisualStudioVersion = 17.9.34723.18 | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Framework", "Framework", "{A5A52329-49D0-4CE0-BA3E-DBD2BA90988F}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Platforms", "Platforms", "{9E8F9D1A-DEF1-4FA1-8DE9-0A82B7BC99D9}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xna.Framework", "src\Xna.Framework\Xna.Framework.csproj", "{741B4B1E-89E4-434C-8867-6129838AFD51}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xna.Framework.Content", "src\Xna.Framework.Content\Xna.Framework.Content.csproj", "{1DC4C439-A8A6-4A11-AB3B-A88DCBA05449}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xna.Framework.Graphics", "src\Xna.Framework.Graphics\Xna.Framework.Graphics.csproj", "{4B8D3F73-BBD2-4057-B86B-8B73B957DC0F}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xna.Framework.Audio", "src\Xna.Framework.Audio\Xna.Framework.Audio.csproj", "{3F81F76D-F0F3-44FE-A256-40AF153C33F7}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xna.Framework.Media", "src\Xna.Framework.Media\Xna.Framework.Media.csproj", "{6E0E6284-13FF-4DC7-8FC2-B6D756EAF1FD}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xna.Framework.Input", "src\Xna.Framework.Input\Xna.Framework.Input.csproj", "{8FB8B257-C091-4C41-B221-75C37B68CD8F}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xna.Framework.Game", "src\Xna.Framework.Game\Xna.Framework.Game.csproj", "{90BBD6EF-F386-4F47-88CD-BF386C7D1705}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xna.Framework.Devices", "src\Xna.Framework.Devices\Xna.Framework.Devices.csproj", "{6B3E56F7-C567-463C-9746-0244FD959322}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xna.Framework.Storage", "src\Xna.Framework.Storage\Xna.Framework.Storage.csproj", "{7AE82BAB-5F52-427A-8F6F-DA829261FF9C}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xna.Framework.XR", "src\Xna.Framework.XR\Xna.Framework.XR.csproj", "{6D0D985D-B256-4208-9E78-77897D461698}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kni.Platform.Oculus.GL", "Platforms\Kni.Platform.Oculus.GL.csproj", "{3472997A-CD26-4D0D-B64A-795F913E6777}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{741B4B1E-89E4-434C-8867-6129838AFD51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{741B4B1E-89E4-434C-8867-6129838AFD51}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{741B4B1E-89E4-434C-8867-6129838AFD51}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{741B4B1E-89E4-434C-8867-6129838AFD51}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{1DC4C439-A8A6-4A11-AB3B-A88DCBA05449}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{1DC4C439-A8A6-4A11-AB3B-A88DCBA05449}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{1DC4C439-A8A6-4A11-AB3B-A88DCBA05449}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{1DC4C439-A8A6-4A11-AB3B-A88DCBA05449}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{4B8D3F73-BBD2-4057-B86B-8B73B957DC0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{4B8D3F73-BBD2-4057-B86B-8B73B957DC0F}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{4B8D3F73-BBD2-4057-B86B-8B73B957DC0F}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{4B8D3F73-BBD2-4057-B86B-8B73B957DC0F}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{3F81F76D-F0F3-44FE-A256-40AF153C33F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{3F81F76D-F0F3-44FE-A256-40AF153C33F7}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{3F81F76D-F0F3-44FE-A256-40AF153C33F7}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{3F81F76D-F0F3-44FE-A256-40AF153C33F7}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{6E0E6284-13FF-4DC7-8FC2-B6D756EAF1FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{6E0E6284-13FF-4DC7-8FC2-B6D756EAF1FD}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{6E0E6284-13FF-4DC7-8FC2-B6D756EAF1FD}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{6E0E6284-13FF-4DC7-8FC2-B6D756EAF1FD}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{8FB8B257-C091-4C41-B221-75C37B68CD8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{8FB8B257-C091-4C41-B221-75C37B68CD8F}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{8FB8B257-C091-4C41-B221-75C37B68CD8F}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{8FB8B257-C091-4C41-B221-75C37B68CD8F}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{90BBD6EF-F386-4F47-88CD-BF386C7D1705}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{90BBD6EF-F386-4F47-88CD-BF386C7D1705}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{90BBD6EF-F386-4F47-88CD-BF386C7D1705}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{90BBD6EF-F386-4F47-88CD-BF386C7D1705}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{6B3E56F7-C567-463C-9746-0244FD959322}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{6B3E56F7-C567-463C-9746-0244FD959322}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{6B3E56F7-C567-463C-9746-0244FD959322}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{6B3E56F7-C567-463C-9746-0244FD959322}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{7AE82BAB-5F52-427A-8F6F-DA829261FF9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{7AE82BAB-5F52-427A-8F6F-DA829261FF9C}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{7AE82BAB-5F52-427A-8F6F-DA829261FF9C}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{7AE82BAB-5F52-427A-8F6F-DA829261FF9C}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{6D0D985D-B256-4208-9E78-77897D461698}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{6D0D985D-B256-4208-9E78-77897D461698}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{6D0D985D-B256-4208-9E78-77897D461698}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{6D0D985D-B256-4208-9E78-77897D461698}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{3472997A-CD26-4D0D-B64A-795F913E6777}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{3472997A-CD26-4D0D-B64A-795F913E6777}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{3472997A-CD26-4D0D-B64A-795F913E6777}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{3472997A-CD26-4D0D-B64A-795F913E6777}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(NestedProjects) = preSolution | ||
{741B4B1E-89E4-434C-8867-6129838AFD51} = {A5A52329-49D0-4CE0-BA3E-DBD2BA90988F} | ||
{1DC4C439-A8A6-4A11-AB3B-A88DCBA05449} = {A5A52329-49D0-4CE0-BA3E-DBD2BA90988F} | ||
{4B8D3F73-BBD2-4057-B86B-8B73B957DC0F} = {A5A52329-49D0-4CE0-BA3E-DBD2BA90988F} | ||
{3F81F76D-F0F3-44FE-A256-40AF153C33F7} = {A5A52329-49D0-4CE0-BA3E-DBD2BA90988F} | ||
{6E0E6284-13FF-4DC7-8FC2-B6D756EAF1FD} = {A5A52329-49D0-4CE0-BA3E-DBD2BA90988F} | ||
{8FB8B257-C091-4C41-B221-75C37B68CD8F} = {A5A52329-49D0-4CE0-BA3E-DBD2BA90988F} | ||
{90BBD6EF-F386-4F47-88CD-BF386C7D1705} = {A5A52329-49D0-4CE0-BA3E-DBD2BA90988F} | ||
{6B3E56F7-C567-463C-9746-0244FD959322} = {A5A52329-49D0-4CE0-BA3E-DBD2BA90988F} | ||
{7AE82BAB-5F52-427A-8F6F-DA829261FF9C} = {A5A52329-49D0-4CE0-BA3E-DBD2BA90988F} | ||
{6D0D985D-B256-4208-9E78-77897D461698} = {A5A52329-49D0-4CE0-BA3E-DBD2BA90988F} | ||
{3472997A-CD26-4D0D-B64A-795F913E6777} = {9E8F9D1A-DEF1-4FA1-8DE9-0A82B7BC99D9} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
using System; | ||
using System.Linq; | ||
using Android.App; | ||
using Android.Content.Res; | ||
using Android.OS; | ||
using Android.Views; | ||
|
||
namespace Microsoft.Xna.Framework | ||
{ | ||
/// <summary> | ||
/// Properties that change from how XNA works by default | ||
/// </summary> | ||
public class AndroidCompatibility | ||
{ | ||
private static AndroidCompatibility _current; | ||
|
||
/// <summary> | ||
/// Because the Kindle Fire devices default orientation is fliped by 180 degrees from all the other android devices | ||
/// on the market we need to do some special processing to make sure that LandscapeLeft is the correct way round. | ||
/// This list contains all the Build.Model strings of the effected devices, it should be added to if and when | ||
/// more devices exhibit the same issues. | ||
/// </summary> | ||
private readonly string[] Kindles = new[] { "KFTT", "KFJWI", "KFJWA", "KFSOWI", "KFTHWA", "KFTHWI", "KFAPWA", "KFAPWI" }; | ||
|
||
public bool FlipLandscape { get; private set; } | ||
|
||
[CLSCompliant(false)] | ||
public Orientation NaturalOrientation { get; private set; } | ||
|
||
|
||
[CLSCompliant(false)] | ||
public static AndroidCompatibility Current | ||
{ | ||
get | ||
{ | ||
if (_current != null) | ||
return _current; | ||
else | ||
throw new InvalidOperationException("Not initialized."); | ||
} | ||
} | ||
|
||
internal static void Initialize(Activity activity) | ||
{ | ||
if (_current == null) | ||
_current = new AndroidCompatibility(activity); | ||
} | ||
|
||
private AndroidCompatibility(Activity activity) | ||
{ | ||
FlipLandscape = Kindles.Contains(Build.Model); | ||
NaturalOrientation = GetDeviceNaturalOrientation(activity); | ||
} | ||
|
||
private Orientation GetDeviceNaturalOrientation(Activity activity) | ||
{ | ||
var orientation = activity.Resources.Configuration.Orientation; | ||
SurfaceOrientation rotation = activity.WindowManager.DefaultDisplay.Rotation; | ||
|
||
// check if MainActivity setup is correct. | ||
var screenOrientation = activity.RequestedOrientation; | ||
if (screenOrientation != Android.Content.PM.ScreenOrientation.Landscape) | ||
throw new InvalidOperationException("Invalid orientation. Set ScreenOrientation in MainActivity to Landscape."); | ||
|
||
if (((rotation == SurfaceOrientation.Rotation0 || rotation == SurfaceOrientation.Rotation180) && | ||
orientation == Orientation.Landscape) | ||
|| ((rotation == SurfaceOrientation.Rotation90 || rotation == SurfaceOrientation.Rotation270) && | ||
orientation == Orientation.Portrait)) | ||
{ | ||
return Orientation.Landscape; | ||
} | ||
else | ||
{ | ||
return Orientation.Portrait; | ||
} | ||
} | ||
|
||
internal DisplayOrientation GetAbsoluteOrientation(int degrees) | ||
{ | ||
// Orientation is reported by the device in degrees compared to the natural orientation | ||
// Some tablets have a natural landscape orientation, which we need to account for | ||
if (NaturalOrientation == Orientation.Landscape) | ||
degrees += 270; | ||
|
||
// Round orientation into one of 8 positions, either 0, 45, 90, 135, 180, 225, 270, 315. | ||
degrees = ( ((degrees + 22) / 45) * 45) % 360; | ||
|
||
// Surprisingly 90 degree is landscape right, except on Kindle devices | ||
var disporientation = DisplayOrientation.Unknown; | ||
switch (degrees) | ||
{ | ||
case 90: disporientation = FlipLandscape ? DisplayOrientation.LandscapeLeft : DisplayOrientation.LandscapeRight; | ||
break; | ||
case 270: disporientation = FlipLandscape ? DisplayOrientation.LandscapeRight : DisplayOrientation.LandscapeLeft; | ||
break; | ||
case 0: disporientation = DisplayOrientation.Portrait; | ||
break; | ||
case 180: disporientation = DisplayOrientation.PortraitDown; | ||
break; | ||
default: | ||
disporientation = DisplayOrientation.Unknown; | ||
break; | ||
} | ||
|
||
return disporientation; | ||
} | ||
|
||
/// <summary> | ||
/// Get the absolute orientation of the device, accounting for platform differences. | ||
/// </summary> | ||
/// <returns></returns> | ||
[CLSCompliant(false)] | ||
public DisplayOrientation GetAbsoluteOrientation(Activity activity) | ||
{ | ||
var orientation = activity.WindowManager.DefaultDisplay.Rotation; | ||
|
||
// Landscape degrees (provided by the OrientationListener) are swapped by default | ||
// Since we use the code used by OrientationListener, we have to swap manually | ||
int degrees; | ||
switch (orientation) | ||
{ | ||
case SurfaceOrientation.Rotation90: | ||
degrees = 270; | ||
break; | ||
case SurfaceOrientation.Rotation180: | ||
degrees = 180; | ||
break; | ||
case SurfaceOrientation.Rotation270: | ||
degrees = 90; | ||
break; | ||
default: | ||
degrees = 0; | ||
break; | ||
} | ||
|
||
return GetAbsoluteOrientation(degrees); | ||
} | ||
} | ||
} |
Oops, something went wrong.