[AD] [4.4] Added detection of Windows 8 (and partially supported detection of Windows 8.1)

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Here is a patch for 4.4 (it should also work on 4.2 after the patch from http://sourceforge.net/mailarchive/message.php?msg_id=27203573 is applied) that adds detection of Windows 8 to
sys_directx_init().

Detection of Windows 8.1 has also been added but is only partially supported. According to Microsoft's documentation of the GetVersion() function ( http://msdn.microsoft.com/en-us/library/windows/desktop/ms724439%28v=vs.85%29.aspx and http://msdn.microsoft.com/en-us/library/windows/desktop/ms724834%28v=vs.85%29.aspx for the values it returns), the application needs to be manifested for Windows 8.1, otherwise GetVersion() will return the Windows 8 version-value instead of the Windows 8.1 version-value. I'm not familiar with manifesting applications for Windows 8.1 (and I'm not sure if it can even be done with some of the older supported compilers) (see http://msdn.microsoft.com/en-us/library/windows/desktop/dn481241%28v=vs.85%29.aspx). My guess is that for statically linked apps, it will be up to the developer to manifest their app, but I'm not sure what will need to be done for apps linked to the DLL-version of Allegro. Would the DLL need to be manifested, or just the app that uses the DLL? If so, how would this be integrated into the build-process?

The alternative is to make use of the Version Helper functions ( http://msdn.microsoft.com/en-us/library/windows/desktop/dn424972%28v=vs.85%29.aspx ), but these only report versions of Windows equal to XP or greater, and I'm not even sure if they are available in the libraries that came with older compilers, or for that matter, if using them will break compatibility with pre-XP versions of Windows).

I have continued to make use of the GetVersion() function in my patch because this is the simplest way of changing things. If I wanted to make use of the Version Helper functions, this would require a bit of a rewrite and I'd have to use a hybrid of GetVersion() and the version helper functions (and possibly GetVersionEx() too (see http://msdn.microsoft.com/en-us/library/windows/desktop/ms724451%28v=vs.85%29.aspx )) in order to make the function compatible with all supported Windows versions.

Here is a summary of the changes:

system.h
+ Added #defines for OSTYPE_WIN8 (for Windows 8.0 and Windows Server 2012) and OSTYPE_WIN8DOT1
(for Windows 8.0 and Windows Server 2012 R2)
wsystem.c
+ Made it detect Windows 8 (and 8.1 if application is manifested for Windows 8.1).

Note that this patch remains completely untested. Also,
wsystem.c violates the coding standard by sometimes using tabs when three spaces should be used instead. I have chosen not to fix this in order to keep my patch as minimalistic as possible.

AE.

--- system.old.h	2014-01-30 07:30:27.177353000 +0100
+++ system.h	2014-01-30 07:30:27.157353000 +0100
@@ -48,6 +48,8 @@ AL_ARRAY(char, allegro_error);
 #define OSTYPE_WIN2003     AL_ID('W','2','K','3')
 #define OSTYPE_WINVISTA    AL_ID('W','V','S','T')
 #define OSTYPE_WIN7        AL_ID('W','I','N','7')
+#define OSTYPE_WIN8        AL_ID('W','8','.','0')
+#define OSTYPE_WIN8DOT1    AL_ID('W','8','.','1')
 #define OSTYPE_OS2         AL_ID('O','S','2',' ')
 #define OSTYPE_WARP        AL_ID('W','A','R','P')
 #define OSTYPE_DOSEMU      AL_ID('D','E','M','U')

--- wsystem.old.c	2014-01-30 07:30:27.207353000 +0100
+++ wsystem.c	2014-01-30 07:30:27.187353000 +0100
@@ -154,9 +154,15 @@ static int sys_directx_init(void)
       /* Since doesn't exist os_version == 7 or greater yet,
          these will be detected as Vista instead of NT. */
       if (os_version >= 6) {
-         /* If in the future a os_revision == 2 or greater comes,
-            it will be detected as Windows 7 instead of Vista. */
-         if (os_revision >= 1)
+         /* If in the future a os_revision == 4 or greater comes,
+            it will be detected as Windows 8.1 instead of Vista. */
+         if (os_revision >= 3)
+	    /* Note that the application needs to be manifested for Windows 8.1,
+	       otherwise os_revision will be 2 under Windows 8.1. */
+	    os_type = OSTYPE_WIN8DOT1;
+         else if (os_revision == 2)
+	    os_type = OSTYPE_WIN8;
+         else if (os_revision == 1)
 	    os_type = OSTYPE_WIN7;
          else
 	    os_type = OSTYPE_WINVISTA;



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/