Просмотр исходного кода

Merge remote-tracking branch 'upstream/next'

Joilnen Leite 13 лет назад
Родитель
Сommit
89ff6e6538

+ 7 - 7
README.md

@@ -8,17 +8,17 @@ GamePlay3D is an open-source, cross-platform 3D native C++ game framework making
 - [Forums](http://www.gameplay3d.org/forums/)
 - [Forums](http://www.gameplay3d.org/forums/)
 - [Wiki](https://github.com/blackberry/GamePlay/wiki)
 - [Wiki](https://github.com/blackberry/GamePlay/wiki)
 - [API Reference](http://www.gameplay3d.org/api.php)
 - [API Reference](http://www.gameplay3d.org/api.php)
-- [Documentation](http://www.gameplay3d.org/docs.php)
+- [Development Guide](https://github.com/blackberry/GamePlay/wiki#wiki-Development_Guide)
 
 
 ## Supported Mobile Platforms
 ## Supported Mobile Platforms
-- BlackBerry 10 and PlayBook (using [BlackBerry Native SDK](http://developer.blackberry.com/native/))
-- Apple iOS 5 (using Apple XCode 4)
-- Google Android 2.3+ (using Google Android NDK)
+- [BlackBerry 10 and PlayBook](https://github.com/blackberry/GamePlay/wiki/BlackBerry-Setup) (using BlackBerry Native SDK)
+- [Apple iOS 5](https://github.com/blackberry/GamePlay/wiki/Apple-Xcode-Setup) (using Apple XCode 4)
+- [Google Android 2.3+](https://github.com/blackberry/GamePlay/wiki/Android-NDK-Setup) (using Google Android NDK)
 
 
 ## Supported Desktop Platforms
 ## Supported Desktop Platforms
-- Microsoft Windows 7 (using Microsoft Visual Studio 2010)
-- Apple MacOS X (using Apple XCode 4)
-- Linux (using CMake)
+- [Microsoft Windows 7](https://github.com/blackberry/GamePlay/wiki/Visual-Studio-Setup) (using Microsoft Visual Studio 2010)
+- [Apple MacOS X](https://github.com/blackberry/GamePlay/wiki/Apple-Xcode-Setup) (using Apple XCode 4)
+- [Linux](https://github.com/blackberry/GamePlay/wiki/Linux-Setup) (using CMake)
 
 
 ## Roadmap for 'next' branch
 ## Roadmap for 'next' branch
 - [Version 1.7.0 Milestone](https://github.com/blackberry/GamePlay/issues?milestone=4)
 - [Version 1.7.0 Milestone](https://github.com/blackberry/GamePlay/issues?milestone=4)

+ 2 - 2
gameplay-encoder/src/FileIO.h

@@ -29,7 +29,7 @@ void fprintfElement(FILE* file, const char* elementName, const std::string& valu
 void fprintfElement(FILE* file, const char* elementName, const float values[], int length);
 void fprintfElement(FILE* file, const char* elementName, const float values[], int length);
 
 
 template <class T>
 template <class T>
-void fprintfElement(FILE* file, const char* format, const char* elementName, std::vector<T> list)
+void fprintfElement(FILE* file, const char* format, const char* elementName, std::vector<T>& list)
 {
 {
     fprintf(file, "<%s count=\"%lu\">", elementName, list.size());
     fprintf(file, "<%s count=\"%lu\">", elementName, list.size());
     typename std::vector<T>::const_iterator i;
     typename std::vector<T>::const_iterator i;
@@ -41,7 +41,7 @@ void fprintfElement(FILE* file, const char* format, const char* elementName, std
 }
 }
 
 
 template <class T>
 template <class T>
-void fprintfElement(FILE* file, const char* format, const char* elementName, std::list<T> list)
+void fprintfElement(FILE* file, const char* format, const char* elementName, std::list<T>& list)
 {
 {
     fprintf(file, "<%s count=\"%lu\">", elementName, list.size());
     fprintf(file, "<%s count=\"%lu\">", elementName, list.size());
     typename std::list<T>::const_iterator i;
     typename std::list<T>::const_iterator i;

+ 72 - 11
gameplay-encoder/src/NormalMapGenerator.cpp

@@ -60,6 +60,16 @@ void calculateNormal(
     Vector3::cross(Q, P, normal);
     Vector3::cross(Q, P, normal);
 }
 }
 
 
+float normalizedHeightPacked(float r, float g, float b)
+{
+    // This formula is intended for 24-bit packed heightmap images (that are generated
+    // with gameplay-encoder. However, it is also compatible with normal grayscale 
+    // heightmap images, with an error of approximately 0.4%. This can be seen by
+    // setting r=g=b=x and comparing the grayscale height expression to the packed
+    // height expression: the error is 2^-8 + 2^-16 which is just under 0.4%.
+    return (256.0f*r + g + 0.00390625f*b) / 65536.0f;
+}
+
 void NormalMapGenerator::generate()
 void NormalMapGenerator::generate()
 {
 {
     // Load the input heightmap
     // Load the input heightmap
@@ -76,8 +86,6 @@ void NormalMapGenerator::generate()
             return;
             return;
         }
         }
 
 
-        // TODO: Add command-line argument for high precision heightmaps
-
         _resolutionX = image->getWidth();
         _resolutionX = image->getWidth();
         _resolutionY = image->getHeight();
         _resolutionY = image->getHeight();
         int size = _resolutionX * _resolutionY;
         int size = _resolutionX * _resolutionY;
@@ -88,20 +96,20 @@ void NormalMapGenerator::generate()
             switch (image->getFormat())
             switch (image->getFormat())
             {
             {
             case Image::LUMINANCE:
             case Image::LUMINANCE:
-                heights[i] = data[i];
+                heights[i] = data[i] / 255.0f;
                 break;
                 break;
             case Image::RGB:
             case Image::RGB:
             case Image::RGBA:
             case Image::RGBA:
                 {
                 {
                     int pos = i * image->getBpp();
                     int pos = i * image->getBpp();
-                    heights[i] = (data[pos] + data[pos+1] + data[pos+2]) / 3.0f;
+                    heights[i] = normalizedHeightPacked(data[pos], data[pos+1], data[pos+2]);
                 }
                 }
                 break;
                 break;
             default:
             default:
                 heights[i] = 0.0f;
                 heights[i] = 0.0f;
                 break;
                 break;
             }
             }
-            heights[i] = (heights[i] / 255.0f) * _worldSize.y;
+            heights[i] = heights[i] * _worldSize.y;
         }
         }
         SAFE_DELETE(image);
         SAFE_DELETE(image);
     }
     }
@@ -110,16 +118,69 @@ void NormalMapGenerator::generate()
         // Load heights from RAW 8 or 16-bit file
         // Load heights from RAW 8 or 16-bit file
         if (_resolutionX <= 0 || _resolutionY <= 0)
         if (_resolutionX <= 0 || _resolutionY <= 0)
         {
         {
-            LOG(1, "Missing resolution argument - must be explicitly specified for RAW heightmap files: %s\n.", _inputFile.c_str());
+            LOG(1, "Missing resolution argument - must be explicitly specified for RAW heightmap files: %s.\n", _inputFile.c_str());
             return;
             return;
         }
         }
 
 
-        // TODO
-        heights = new float[_resolutionX * _resolutionY];
-        // TODO
+        // Read all data from file
+        FILE* fp = fopen(_inputFile.c_str(), "rb");
+        if (fp == NULL)
+        {
+            LOG(1, "Failed to open input file: %s.\n", _inputFile.c_str());
+            return;
+        }
 
 
-        LOG(1, "RAW files not yet implemented...");
-        return;
+        fseek(fp, 0, SEEK_END);
+        long fileSize = ftell(fp);
+        fseek(fp, 0, SEEK_SET);
+
+        unsigned char* data = new unsigned char[fileSize];
+        if (fread(data, 1, fileSize, fp) != (size_t)fileSize)
+        {
+            fclose(fp);
+            delete[] data;
+            LOG(1, "Failed to read bytes from input file: %s.\n", _inputFile.c_str());
+            return;
+        }
+        fclose(fp);
+
+        // Determine if the RAW file is 8-bit or 16-bit based on file size.
+        int bits = (fileSize / (_resolutionX * _resolutionY)) * 8;
+        if (bits != 8 && bits != 16)
+        {
+            LOG(1, "Invalid RAW file - must be 8-bit or 16-bit, but found neither: %s.", _inputFile.c_str());
+            delete[] data;
+            return;
+        }
+
+        int size = _resolutionX * _resolutionY;
+        heights = new float[size];
+        if (bits == 16)
+        {
+            // 16-bit (0-65535)
+            int idx;
+            for (unsigned int y = 0, i = 0; y < (unsigned int)_resolutionY; ++y)
+            {
+                for (unsigned int x = 0; x < (unsigned int)_resolutionX; ++x, ++i)
+                {
+                    idx = (y * _resolutionX + x) << 1;
+                    heights[i] = ((data[idx] | (int)data[idx+1] << 8) / 65535.0f) * _worldSize.y;
+                }
+            }
+        }
+        else
+        {
+            // 8-bit (0-255)
+            for (unsigned int y = 0, i = 0; y < (unsigned int)_resolutionY; ++y)
+            {
+                for (unsigned int x = 0; x < (unsigned int)_resolutionX; ++x, ++i)
+                {
+                    heights[i] = (data[y * _resolutionX + x] / 255.0f) * _worldSize.y;
+                }
+            }
+        }
+
+        delete[] data;
     }
     }
     else
     else
     {
     {

+ 6 - 12
gameplay-template/template.bar-descriptor.xml

@@ -24,20 +24,14 @@
          <versionNumber> element.  Must be an integer from 0 to 2^16-1 -->
          <versionNumber> element.  Must be an integer from 0 to 2^16-1 -->
     <buildId>1</buildId>
     <buildId>1</buildId>
 
 
-    <!-- A string value (such as "v1", "2.5", or "Alpha 1") that represents the version of the application, as it should be shown to users. Optional. -->
-    <!-- <versionLabel></versionLabel> -->
-
     <!-- Description, displayed in the BlackBerry Tablet OS application installer.
     <!-- Description, displayed in the BlackBerry Tablet OS application installer.
          May have multiple values for each language. See samples or xsd schema file. Optional. -->
          May have multiple values for each language. See samples or xsd schema file. Optional. -->
     <description>TEMPLATE_DESCRIPTION</description>
     <description>TEMPLATE_DESCRIPTION</description>
-    
-    <!-- Copyright information. Optional. -->
-    <!-- <copyright></copyright> -->
 
 
-    <!--  Name of author which is used for signing. Must match the developer name of your development certificate. -->
+    <!-- Name of author which is used for signing. Must match the developer name of your development certificate. -->
     <author>TEMPLATE_AUTHOR</author>
     <author>TEMPLATE_AUTHOR</author>
 
 
-    <!--  Unique author ID assigned by signing authority. Required if using debug tokens. -->
+    <!-- Unique author ID assigned by signing authority. Required if using debug tokens. -->
     <!-- <authorId>gYAAgPkLP1tZlyYP1wiMaRFFNMw</authorId> -->
     <!-- <authorId>gYAAgPkLP1tZlyYP1wiMaRFFNMw</authorId> -->
 
 
     <initialWindow>
     <initialWindow>
@@ -47,7 +41,7 @@
         <transparent>false</transparent>
         <transparent>false</transparent>
     </initialWindow>
     </initialWindow>
 
 
-    <!--  The category where the application appears. Either core.games or core.media. -->
+    <!-- The category where the application appears. Either core.games or core.media. -->
     <category>core.games</category>
     <category>core.games</category>
 
 
     <asset path="icon.png">icon.png</asset>
     <asset path="icon.png">icon.png</asset>
@@ -82,18 +76,18 @@
        <asset path="Simulator-Coverage/TEMPLATE_PROJECT" entry="true" type="Qnx/Elf">TEMPLATE_PROJECT</asset>
        <asset path="Simulator-Coverage/TEMPLATE_PROJECT" entry="true" type="Qnx/Elf">TEMPLATE_PROJECT</asset>
     </configuration>
     </configuration>
 
 
-    <!--  The icon for the application, which should be 86x86. -->
+    <!-- The icon for the application, which should be 150x150. -->
     <icon>
     <icon>
         <image>icon.png</image>
         <image>icon.png</image>
     </icon>
     </icon>
 
 
-    <!--  The splash screen that will appear when your application is launching. Should be 1024x600. -->
+    <!-- The splash screen that will appear when your application is launching. Should be 1280x768. -->
     <!-- <splashscreen></splashscreen> -->
     <!-- <splashscreen></splashscreen> -->
 
 
     <!-- Request permission to execute native code.  Required for native applications. -->
     <!-- Request permission to execute native code.  Required for native applications. -->
     <action system="true">run_native</action>
     <action system="true">run_native</action>
 
 
-    <!--  The permissions requested by your application. -->
+    <!-- The permissions requested by your application. -->
     <!--  <action>access_shared</action> -->
     <!--  <action>access_shared</action> -->
     <!--  <action>record_audio</action> -->
     <!--  <action>record_audio</action> -->
     <!--  <action>read_geolocation</action> -->
     <!--  <action>read_geolocation</action> -->

+ 12 - 3
gameplay/.cproject

@@ -23,8 +23,8 @@
 								<option id="com.qnx.qcc.option.compiler.security.311918799" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.compiler.security.311918799" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.compiler.defines.1481323494" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
 								<option id="com.qnx.qcc.option.compiler.defines.1481323494" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
 									<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
 									<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
-									<listOptionValue builtIn="false" value="__BB10__"/>
 									<listOptionValue builtIn="false" value="BT_USE_NEON"/>
 									<listOptionValue builtIn="false" value="BT_USE_NEON"/>
+									<listOptionValue builtIn="false" value="BLACKBERRY_USE_GAMEPAD"/>
 								</option>
 								</option>
 								<option id="com.qnx.qcc.option.compiler.includePath.2133604142" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
 								<option id="com.qnx.qcc.option.compiler.includePath.2133604142" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
 									<listOptionValue builtIn="false" value="&quot;../../external-deps/lua/include&quot;"/>
 									<listOptionValue builtIn="false" value="&quot;../../external-deps/lua/include&quot;"/>
@@ -43,7 +43,7 @@
 							</tool>
 							</tool>
 							<tool id="com.qnx.qcc.tool.assembler.1988140188" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
 							<tool id="com.qnx.qcc.tool.assembler.1988140188" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
 								<option id="com.qnx.qcc.option.assembler.debug.1929307156" name="Debug (-g)" superClass="com.qnx.qcc.option.assembler.debug" value="true" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.assembler.debug.1929307156" name="Debug (-g)" superClass="com.qnx.qcc.option.assembler.debug" value="true" valueType="boolean"/>
-								<option id="com.qnx.qcc.option.assembler.defines.1866459653" name="Defines (-D)" superClass="com.qnx.qcc.option.assembler.defines" valueType="definedSymbols"/>
+								<option id="com.qnx.qcc.option.assembler.defines.1866459653" name="Defines (-D)" superClass="com.qnx.qcc.option.assembler.defines"/>
 								<inputType id="com.qnx.qcc.inputType.assembler.1944074393" superClass="com.qnx.qcc.inputType.assembler"/>
 								<inputType id="com.qnx.qcc.inputType.assembler.1944074393" superClass="com.qnx.qcc.inputType.assembler"/>
 							</tool>
 							</tool>
 							<tool id="com.qnx.qcc.tool.linker.85592747" name="QCC Linker" superClass="com.qnx.qcc.tool.linker">
 							<tool id="com.qnx.qcc.tool.linker.85592747" name="QCC Linker" superClass="com.qnx.qcc.tool.linker">
@@ -88,6 +88,7 @@
 								<option id="com.qnx.qcc.option.compiler.defines.398688299" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
 								<option id="com.qnx.qcc.option.compiler.defines.398688299" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
 									<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
 									<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
 									<listOptionValue builtIn="false" value="BT_USE_NEON"/>
 									<listOptionValue builtIn="false" value="BT_USE_NEON"/>
+									<listOptionValue builtIn="false" value="BLACKBERRY_USE_GAMEPAD"/>
 								</option>
 								</option>
 								<option id="com.qnx.qcc.option.compiler.includePath.1670164593" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
 								<option id="com.qnx.qcc.option.compiler.includePath.1670164593" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
 									<listOptionValue builtIn="false" value="&quot;../../external-deps/bullet/include&quot;"/>
 									<listOptionValue builtIn="false" value="&quot;../../external-deps/bullet/include&quot;"/>
@@ -148,7 +149,8 @@
 								<option id="com.qnx.qcc.option.compiler.security.1649809766" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.compiler.security.1649809766" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.compiler.defines.276653249" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
 								<option id="com.qnx.qcc.option.compiler.defines.276653249" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
 									<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
 									<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
-									<listOptionValue builtIn="false" value="BY_USE_NEON"/>
+									<listOptionValue builtIn="false" value="BT_USE_NEON"/>
+									<listOptionValue builtIn="false" value="BLACKBERRY_USE_GAMEPAD"/>
 								</option>
 								</option>
 								<option id="com.qnx.qcc.option.compiler.includePath.1503059677" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
 								<option id="com.qnx.qcc.option.compiler.includePath.1503059677" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
 									<listOptionValue builtIn="false" value="&quot;../../external-deps/bullet/include&quot;"/>
 									<listOptionValue builtIn="false" value="&quot;../../external-deps/bullet/include&quot;"/>
@@ -213,6 +215,7 @@
 								<option id="com.qnx.qcc.option.compiler.defines.374283024" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
 								<option id="com.qnx.qcc.option.compiler.defines.374283024" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
 									<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
 									<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
 									<listOptionValue builtIn="false" value="BT_USE_NEON"/>
 									<listOptionValue builtIn="false" value="BT_USE_NEON"/>
+									<listOptionValue builtIn="false" value="BLACKBERRY_USE_GAMEPAD"/>
 								</option>
 								</option>
 								<option id="com.qnx.qcc.option.compiler.includePath.1769677874" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
 								<option id="com.qnx.qcc.option.compiler.includePath.1769677874" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
 									<listOptionValue builtIn="false" value="&quot;../../external-deps/bullet/include&quot;"/>
 									<listOptionValue builtIn="false" value="&quot;../../external-deps/bullet/include&quot;"/>
@@ -274,6 +277,8 @@
 								<option id="com.qnx.qcc.option.compiler.security.1671403331" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.compiler.security.1671403331" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.compiler.defines.1863269886" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
 								<option id="com.qnx.qcc.option.compiler.defines.1863269886" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
 									<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
 									<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
+									<listOptionValue builtIn="false" value="BT_USE_NEON"/>
+									<listOptionValue builtIn="false" value="BLACKBERRY_USE_GAMEPAD"/>
 								</option>
 								</option>
 								<option id="com.qnx.qcc.option.compiler.includePath.847642559" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
 								<option id="com.qnx.qcc.option.compiler.includePath.847642559" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
 									<listOptionValue builtIn="false" value="&quot;../../external-deps/bullet/include&quot;"/>
 									<listOptionValue builtIn="false" value="&quot;../../external-deps/bullet/include&quot;"/>
@@ -333,6 +338,8 @@
 								<option id="com.qnx.qcc.option.compiler.security.1329750381" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.compiler.security.1329750381" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.compiler.defines.1679396285" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
 								<option id="com.qnx.qcc.option.compiler.defines.1679396285" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
 									<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
 									<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
+									<listOptionValue builtIn="false" value="BT_USE_NEON"/>
+									<listOptionValue builtIn="false" value="BLACKBERRY_USE_GAMEPAD"/>
 								</option>
 								</option>
 								<option id="com.qnx.qcc.option.compiler.includePath.513622172" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
 								<option id="com.qnx.qcc.option.compiler.includePath.513622172" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
 									<listOptionValue builtIn="false" value="&quot;../../external-deps/bullet/include&quot;"/>
 									<listOptionValue builtIn="false" value="&quot;../../external-deps/bullet/include&quot;"/>
@@ -393,6 +400,8 @@
 								<option id="com.qnx.qcc.option.compiler.security.1296061040" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.compiler.security.1296061040" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.compiler.defines.1925901823" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
 								<option id="com.qnx.qcc.option.compiler.defines.1925901823" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
 									<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
 									<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
+									<listOptionValue builtIn="false" value="BT_USE_NEON"/>
+									<listOptionValue builtIn="false" value="BLACKBERRY_USE_GAMEPAD"/>
 								</option>
 								</option>
 								<option id="com.qnx.qcc.option.compiler.includePath.1685994750" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
 								<option id="com.qnx.qcc.option.compiler.includePath.1685994750" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
 									<listOptionValue builtIn="false" value="&quot;../../external-deps/bullet/include&quot;"/>
 									<listOptionValue builtIn="false" value="&quot;../../external-deps/bullet/include&quot;"/>

+ 1 - 1
gameplay/android/jni/Android.mk

@@ -170,7 +170,7 @@ LOCAL_SRC_FILES := \
     lua/lua_Game.cpp \
     lua/lua_Game.cpp \
     lua/lua_GameClearFlags.cpp \
     lua/lua_GameClearFlags.cpp \
     lua/lua_Gamepad.cpp \
     lua/lua_Gamepad.cpp \
-    lua/lua_GamepadButtonState.cpp \
+    lua/lua_GamepadButtonMapping.cpp \
     lua/lua_GamepadGamepadEvent.cpp \
     lua/lua_GamepadGamepadEvent.cpp \
     lua/lua_GameState.cpp \
     lua/lua_GameState.cpp \
     lua/lua_Gesture.cpp \
     lua/lua_Gesture.cpp \

+ 2 - 1
gameplay/res/shaders/terrain.frag

@@ -47,7 +47,8 @@ void main()
 #if (LAYER_COUNT > 0)
 #if (LAYER_COUNT > 0)
     // Set base diffuse color
     // Set base diffuse color
     vec2 uvCoord = mod(v_texCoord0 * TEXTURE_REPEAT_0, vec2(1,1));
     vec2 uvCoord = mod(v_texCoord0 * TEXTURE_REPEAT_0, vec2(1,1));
-	_baseColor = texture2D(u_samplers[TEXTURE_INDEX_0], uvCoord);
+	_baseColor.rgb = texture2D(u_samplers[TEXTURE_INDEX_0], uvCoord).rgb;
+    _baseColor.a = 1.0;
 #else
 #else
     // If no layers are defined, simple use a white color
     // If no layers are defined, simple use a white color
     _baseColor = vec4(1,1,1,1);
     _baseColor = vec4(1,1,1,1);

+ 0 - 3
gameplay/src/Button.cpp

@@ -41,9 +41,6 @@ Button* Button::create(Theme::Style* style, Properties* properties)
 
 
 bool Button::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
 bool Button::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
 {
 {
-    if (!isEnabled())
-        return false;
-
     switch (evt)
     switch (evt)
     {
     {
     case Touch::TOUCH_PRESS:
     case Touch::TOUCH_PRESS:

+ 1 - 1
gameplay/src/Button.h

@@ -77,7 +77,7 @@ protected:
      * @param evt The touch event that occurred.
      * @param evt The touch event that occurred.
      * @param x The x position of the touch in pixels. Left edge is zero.
      * @param x The x position of the touch in pixels. Left edge is zero.
      * @param y The y position of the touch in pixels. Top edge is zero.
      * @param y The y position of the touch in pixels. Top edge is zero.
-     * @param contactIndex The order of occurrence for multiple touch contacts starting at zero.
+     * @param contactIndex An integer to identify this contact point within the currently active touch set.
      *
      *
      * @return Whether the touch event was consumed by the control.
      * @return Whether the touch event was consumed by the control.
      *
      *

+ 0 - 5
gameplay/src/CheckBox.cpp

@@ -76,11 +76,6 @@ void CheckBox::addListener(Control::Listener* listener, int eventFlags)
 
 
 bool CheckBox::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
 bool CheckBox::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
 {
 {
-    if (!isEnabled())
-    {
-        return false;
-    }
-
     switch (evt)
     switch (evt)
     {
     {
     case Touch::TOUCH_RELEASE:
     case Touch::TOUCH_RELEASE:

+ 1 - 1
gameplay/src/CheckBox.h

@@ -123,7 +123,7 @@ protected:
      * @param evt The touch event that occurred.
      * @param evt The touch event that occurred.
      * @param x The x position of the touch in pixels. Left edge is zero.
      * @param x The x position of the touch in pixels. Left edge is zero.
      * @param y The y position of the touch in pixels. Top edge is zero.
      * @param y The y position of the touch in pixels. Top edge is zero.
-     * @param contactIndex The order of occurrence for multiple touch contacts starting at zero.
+     * @param contactIndex An integer to identify this contact point within the currently active touch set.
      *
      *
      * @return Whether the touch event was consumed by the control.
      * @return Whether the touch event was consumed by the control.
      *
      *

+ 4 - 4
gameplay/src/Container.cpp

@@ -608,7 +608,7 @@ bool Container::keyEvent(Keyboard::KeyEvent evt, int key)
     {
     {
         Control* control = *it;
         Control* control = *it;
         GP_ASSERT(control);
         GP_ASSERT(control);
-        if (!control->isEnabled())
+        if (!control->isEnabled() || !control->isVisible())
         {
         {
             continue;
             continue;
         }
         }
@@ -1024,7 +1024,7 @@ bool Container::mouseEventScroll(Mouse::MouseEvent evt, int x, int y, int wheelD
 
 
 bool Container::pointerEvent(bool mouse, char evt, int x, int y, int data)
 bool Container::pointerEvent(bool mouse, char evt, int x, int y, int data)
 {
 {
-    if (!isEnabled())
+    if (!isEnabled() || !isVisible())
     {
     {
         return false;
         return false;
     }
     }
@@ -1051,7 +1051,7 @@ bool Container::pointerEvent(bool mouse, char evt, int x, int y, int data)
     {
     {
         Control* control = *it;
         Control* control = *it;
         GP_ASSERT(control);
         GP_ASSERT(control);
-        if (!control->isEnabled())
+        if (!control->isEnabled() || !control->isVisible())
         {
         {
             continue;
             continue;
         }
         }
@@ -1085,7 +1085,7 @@ bool Container::pointerEvent(bool mouse, char evt, int x, int y, int data)
         }
         }
     }
     }
 
 
-    if (!isEnabled())
+    if (!isEnabled() || !isVisible())
     {
     {
         release();
         release();
         return (_consumeInputEvents | eventConsumed);
         return (_consumeInputEvents | eventConsumed);

+ 2 - 2
gameplay/src/Container.h

@@ -259,7 +259,7 @@ protected:
      * @param evt The touch event that occurred.
      * @param evt The touch event that occurred.
      * @param x The x position of the touch in pixels. Left edge is zero.
      * @param x The x position of the touch in pixels. Left edge is zero.
      * @param y The y position of the touch in pixels. Top edge is zero.
      * @param y The y position of the touch in pixels. Top edge is zero.
-     * @param contactIndex The order of occurrence for multiple touch contacts starting at zero.
+     * @param contactIndex An integer to identify this contact point within the currently active touch set.
      *
      *
      * @return Whether the touch event was consumed by a control within this container.
      * @return Whether the touch event was consumed by a control within this container.
      *
      *
@@ -340,7 +340,7 @@ protected:
      * @param evt The touch event that occurred.
      * @param evt The touch event that occurred.
      * @param x The x position of the touch in pixels. Left edge is zero.
      * @param x The x position of the touch in pixels. Left edge is zero.
      * @param y The y position of the touch in pixels. Top edge is zero.
      * @param y The y position of the touch in pixels. Top edge is zero.
-     * @param contactIndex The order of occurrence for multiple touch contacts starting at zero.
+     * @param contactIndex An integer to identify this contact point within the currently active touch set.
      *
      *
      * @return Whether the touch event was consumed by scrolling within this container.
      * @return Whether the touch event was consumed by scrolling within this container.
      *
      *

+ 0 - 8
gameplay/src/Control.cpp

@@ -760,9 +760,6 @@ void Control::addSpecificListener(Control::Listener* listener, Listener::EventTy
 
 
 bool Control::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
 bool Control::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
 {
 {
-    if (!isEnabled())
-        return false;
-
     switch (evt)
     switch (evt)
     {
     {
     case Touch::TOUCH_PRESS:
     case Touch::TOUCH_PRESS:
@@ -816,11 +813,6 @@ bool Control::keyEvent(Keyboard::KeyEvent evt, int key)
 
 
 bool Control::mouseEvent(Mouse::MouseEvent evt, int x, int y, int wheelDelta)
 bool Control::mouseEvent(Mouse::MouseEvent evt, int x, int y, int wheelDelta)
 {
 {
-    if (!isEnabled())
-    {
-        return false;
-    }
-
     // By default, mouse events are either interpreted as touch events or ignored.
     // By default, mouse events are either interpreted as touch events or ignored.
     switch (evt)
     switch (evt)
     {
     {

+ 1 - 1
gameplay/src/Control.h

@@ -805,7 +805,7 @@ protected:
      * @param evt The touch event that occurred.
      * @param evt The touch event that occurred.
      * @param x The x position of the touch in pixels. Left edge is zero.
      * @param x The x position of the touch in pixels. Left edge is zero.
      * @param y The y position of the touch in pixels. Top edge is zero.
      * @param y The y position of the touch in pixels. Top edge is zero.
-     * @param contactIndex The order of occurrence for multiple touch contacts starting at zero.
+     * @param contactIndex An integer to identify this contact point within the currently active touch set.
      *
      *
      * @return Whether the touch event was consumed by this control.
      * @return Whether the touch event was consumed by this control.
      *
      *

+ 2 - 2
gameplay/src/DebugNew.cpp

@@ -106,7 +106,7 @@ void* debugAlloc(std::size_t size, const char* file, int line)
     mem += sizeof(MemoryAllocationRecord);
     mem += sizeof(MemoryAllocationRecord);
 
 
     rec->address = (unsigned long)mem;
     rec->address = (unsigned long)mem;
-    rec->size = size;
+    rec->size = (unsigned int)size;
     rec->file = file;
     rec->file = file;
     rec->line = line;
     rec->line = line;
     rec->next = __memoryAllocations;
     rec->next = __memoryAllocations;
@@ -114,7 +114,7 @@ void* debugAlloc(std::size_t size, const char* file, int line)
 
 
     // Capture the stack frame (up to MAX_STACK_FRAMES) if we 
     // Capture the stack frame (up to MAX_STACK_FRAMES) if we 
     // are running on Windows and the user has enabled it.
     // are running on Windows and the user has enabled it.
-#if defined(WIN32)
+#if defined(WIN32) && defined(_M_IX86)
     rec->trackStackTrace = __trackStackTrace;
     rec->trackStackTrace = __trackStackTrace;
     if (rec->trackStackTrace)
     if (rec->trackStackTrace)
     {
     {

+ 3 - 3
gameplay/src/Form.cpp

@@ -590,7 +590,7 @@ bool Form::touchEventInternal(Touch::TouchEvent evt, int x, int y, unsigned int
         Form* form = __forms[i];
         Form* form = __forms[i];
         GP_ASSERT(form);
         GP_ASSERT(form);
 
 
-        if (form->isEnabled())
+        if (form->isEnabled() && form->isVisible())
         {
         {
             if (form->_node)
             if (form->_node)
             {
             {
@@ -636,7 +636,7 @@ bool Form::keyEventInternal(Keyboard::KeyEvent evt, int key)
     {
     {
         Form* form = __forms[i];
         Form* form = __forms[i];
         GP_ASSERT(form);
         GP_ASSERT(form);
-        if (form->isEnabled())
+        if (form->isEnabled() && form->isVisible())
         {
         {
             if (form->keyEvent(evt, key))
             if (form->keyEvent(evt, key))
                 return true;
                 return true;
@@ -654,7 +654,7 @@ bool Form::mouseEventInternal(Mouse::MouseEvent evt, int x, int y, int wheelDelt
         Form* form = __forms[i];
         Form* form = __forms[i];
         GP_ASSERT(form);
         GP_ASSERT(form);
 
 
-        if (form->isEnabled())
+        if (form->isEnabled() && form->isVisible())
         {
         {
             if (form->_node)
             if (form->_node)
             {
             {

+ 1 - 1
gameplay/src/Game.h

@@ -295,7 +295,7 @@ public:
      * @param evt The touch event that occurred.
      * @param evt The touch event that occurred.
      * @param x The x position of the touch in pixels. Left edge is zero.
      * @param x The x position of the touch in pixels. Left edge is zero.
      * @param y The y position of the touch in pixels. Top edge is zero.
      * @param y The y position of the touch in pixels. Top edge is zero.
-     * @param contactIndex The order of occurrence for multiple touch contacts starting at zero.
+     * @param contactIndex An integer to identify this contact point within the currently active touch set.
      *
      *
      * @see Touch::TouchEvent
      * @see Touch::TouchEvent
      */
      */

+ 9 - 4
gameplay/src/Gamepad.cpp

@@ -33,7 +33,7 @@ Gamepad::Gamepad(const char* formPath)
 }
 }
 
 
 Gamepad::Gamepad(const char* id, GamepadHandle handle, unsigned int buttonCount, unsigned int joystickCount, unsigned int triggerCount,
 Gamepad::Gamepad(const char* id, GamepadHandle handle, unsigned int buttonCount, unsigned int joystickCount, unsigned int triggerCount,
-                 unsigned int vendorId, unsigned int productId, char* vendorString, char* productString)
+                 unsigned int vendorId, unsigned int productId, const char* vendorString, const char* productString)
     : _id(id), _handle(handle), _vendorId(vendorId), _productId(productId), _vendorString(vendorString), _productString(productString),
     : _id(id), _handle(handle), _vendorId(vendorId), _productId(productId), _vendorString(vendorString), _productString(productString),
       _buttonCount(buttonCount), _joystickCount(joystickCount), _triggerCount(triggerCount), _form(NULL)
       _buttonCount(buttonCount), _joystickCount(joystickCount), _triggerCount(triggerCount), _form(NULL)
 {
 {
@@ -48,7 +48,7 @@ Gamepad::~Gamepad()
 }
 }
 
 
 Gamepad* Gamepad::add(const char* id, GamepadHandle handle, unsigned int buttonCount, unsigned int joystickCount, unsigned int triggerCount,
 Gamepad* Gamepad::add(const char* id, GamepadHandle handle, unsigned int buttonCount, unsigned int joystickCount, unsigned int triggerCount,
-    unsigned int vendorId, unsigned int productId, char* vendorString, char* productString)
+    unsigned int vendorId, unsigned int productId, const char* vendorString, const char* productString)
 {
 {
     Gamepad* gamepad = new Gamepad(id, handle, buttonCount, joystickCount, triggerCount, vendorId, productId, vendorString, productString);
     Gamepad* gamepad = new Gamepad(id, handle, buttonCount, joystickCount, triggerCount, vendorId, productId, vendorString, productString);
 
 
@@ -75,6 +75,7 @@ void Gamepad::remove(GamepadHandle handle)
         if (gamepad->_handle == handle)
         if (gamepad->_handle == handle)
         {
         {
             Game::getInstance()->gamepadEvent(DISCONNECTED_EVENT, gamepad);
             Game::getInstance()->gamepadEvent(DISCONNECTED_EVENT, gamepad);
+            SAFE_DELETE(gamepad);
             it = __gamepads.erase(it);
             it = __gamepads.erase(it);
         }
         }
         else
         else
@@ -93,6 +94,7 @@ void Gamepad::remove(Gamepad* gamepad)
         if (g == gamepad)
         if (g == gamepad)
         {
         {
             Game::getInstance()->gamepadEvent(DISCONNECTED_EVENT, g);
             Game::getInstance()->gamepadEvent(DISCONNECTED_EVENT, g);
+            SAFE_DELETE(gamepad);
             it = __gamepads.erase(it);
             it = __gamepads.erase(it);
         }
         }
         else
         else
@@ -225,9 +227,12 @@ const char* Gamepad::getProductString() const
 
 
 void Gamepad::update(float elapsedTime)
 void Gamepad::update(float elapsedTime)
 {
 {
-    if (_form && _form->isEnabled())
+    if (_form)
     {
     {
-        _form->update(elapsedTime);
+        if (_form->isEnabled())
+        {
+            _form->update(elapsedTime);
+        }
     }
     }
     else
     else
     {
     {

+ 2 - 2
gameplay/src/Gamepad.h

@@ -198,7 +198,7 @@ private:
      * @param triggerCount the number of triggers on the gamepad.
      * @param triggerCount the number of triggers on the gamepad.
      */
      */
     Gamepad(const char* id, GamepadHandle handle, unsigned int buttonCount, unsigned int joystickCount, unsigned int triggerCount,
     Gamepad(const char* id, GamepadHandle handle, unsigned int buttonCount, unsigned int joystickCount, unsigned int triggerCount,
-            unsigned int vendorId, unsigned int productId, char* vendorString, char* productString);
+            unsigned int vendorId, unsigned int productId, const char* vendorString, const char* productString);
 
 
     /**
     /**
      * Copy constructor.
      * Copy constructor.
@@ -209,7 +209,7 @@ private:
      * Used by platforms to add gamepads to the set available to games.
      * Used by platforms to add gamepads to the set available to games.
      */
      */
     static Gamepad* add(const char* id, GamepadHandle handle, unsigned int buttonCount, unsigned int joystickCount, unsigned int triggerCount,
     static Gamepad* add(const char* id, GamepadHandle handle, unsigned int buttonCount, unsigned int joystickCount, unsigned int triggerCount,
-                        unsigned int vendorId, unsigned int productId, char* vendorString, char* productString);
+                        unsigned int vendorId, unsigned int productId, const char* vendorString, const char* productString);
 
 
     /**
     /**
      * Used by Game::loadGamepads() to add virtual gamepads from a game's config file.
      * Used by Game::loadGamepads() to add virtual gamepads from a game's config file.

+ 1 - 1
gameplay/src/Joystick.h

@@ -153,7 +153,7 @@ protected:
      * @param evt The touch event that occurred.
      * @param evt The touch event that occurred.
      * @param x The x position of the touch in pixels. Left edge is zero.
      * @param x The x position of the touch in pixels. Left edge is zero.
      * @param y The y position of the touch in pixels. Top edge is zero.
      * @param y The y position of the touch in pixels. Top edge is zero.
-     * @param contactIndex The order of occurrence for multiple touch contacts starting at zero.
+     * @param contactIndex An integer to identify this contact point within the currently active touch set.
      *
      *
      * @return Whether the touch event was consumed by the control.
      * @return Whether the touch event was consumed by the control.
      *
      *

+ 1 - 1
gameplay/src/Layout.h

@@ -80,7 +80,7 @@ protected:
      * @param evt The touch event that occurred.
      * @param evt The touch event that occurred.
      * @param x The x position of the touch in pixels. Left edge is zero.
      * @param x The x position of the touch in pixels. Left edge is zero.
      * @param y The y position of the touch in pixels. Top edge is zero.
      * @param y The y position of the touch in pixels. Top edge is zero.
-     * @param contactIndex The order of occurrence for multiple touch contacts starting at zero.
+     * @param contactIndex An integer to identify this contact point within the currently active touch set.
      *
      *
      * @see Touch::TouchEvent
      * @see Touch::TouchEvent
      */
      */

+ 11 - 1
gameplay/src/Platform.h

@@ -235,7 +235,7 @@ public:
      * @param evt The touch event that occurred.
      * @param evt The touch event that occurred.
      * @param x The x position of the touch in pixels. Left edge is zero.
      * @param x The x position of the touch in pixels. Left edge is zero.
      * @param y The y position of the touch in pixels. Top edge is zero.
      * @param y The y position of the touch in pixels. Top edge is zero.
-     * @param contactIndex The order of occurrence for multiple touch contacts starting at zero.
+     * @param contactIndex An integer to identify this contact point within the currently active touch set.
      *
      *
      * @see Touch::TouchEvent
      * @see Touch::TouchEvent
      */
      */
@@ -268,6 +268,16 @@ public:
      */
      */
     static bool mouseEventInternal(Mouse::MouseEvent evt, int x, int y, int wheelDelta);
     static bool mouseEventInternal(Mouse::MouseEvent evt, int x, int y, int wheelDelta);
 
 
+    /**
+     * Gamepad callback on gamepad events. This is called only from platform when gamepad are connectd and disconnected.
+     *
+     * @param evt The mouse event that occurred.
+     * @param gamepad The gamepad that is either connected or disconnected from the platform.
+     *
+     * @see Gamepad::GamepadEvent
+     */
+    static void gamepadEventInternal(Gamepad::GamepadEvent evt, Gamepad* gamepad);
+
     /**
     /**
      * Opens an URL in an external browser, if available.
      * Opens an URL in an external browser, if available.
      *
      *

+ 4 - 0
gameplay/src/PlatformAndroid.cpp

@@ -1252,6 +1252,10 @@ bool Platform::mouseEventInternal(Mouse::MouseEvent evt, int x, int y, int wheel
     }
     }
 }
 }
 
 
+void Platform::gamepadEventInternal(Gamepad::GamepadEvent evt, Gamepad* gamepad)
+{
+}
+
 bool Platform::isGestureSupported(Gesture::GestureEvent evt)
 bool Platform::isGestureSupported(Gesture::GestureEvent evt)
 {
 {
     // Pinch currently not implemented
     // Pinch currently not implemented

+ 29 - 13
gameplay/src/PlatformBlackBerry.cpp

@@ -491,19 +491,7 @@ void gesture_callback(gesture_base_t* gesture, mtouch_event_t* event, void* para
     }
     }
 }
 }
 
 
-#ifdef __BB10__
-
-static const int __VIDs[] = {
-    0x1038,
-    0x057e,
-    0x25b6
-};
-
-static const int __PIDs[] = {
-    0x1412,
-    0x0306,
-    0x0001
-};
+#ifdef BLACKBERRY_USE_GAMEPAD
 
 
 static const char* __vendorStrings[] =
 static const char* __vendorStrings[] =
 {
 {
@@ -519,6 +507,18 @@ static const char* __productStrings[] =
     "Gametel"
     "Gametel"
 };
 };
 
 
+static const int __VIDs[] = {
+    0x1038,
+    0x057e,
+    0x25b6
+};
+
+static const int __PIDs[] = {
+    0x1412,
+    0x0306,
+    0x0001
+};
+
 static const unsigned int __knownGamepads = 3;
 static const unsigned int __knownGamepads = 3;
 
 
 void loadGamepad(GamepadHandle handle, int* buttonCount, int* joystickCount, int* productId, int* vendorId, char* id, char* productString, char* vendorString)
 void loadGamepad(GamepadHandle handle, int* buttonCount, int* joystickCount, int* productId, int* vendorId, char* id, char* productString, char* vendorString)
@@ -1521,6 +1521,22 @@ bool Platform::mouseEventInternal(Mouse::MouseEvent evt, int x, int y, int wheel
     }
     }
 }
 }
 
 
+void Platform::gamepadEventInternal(Gamepad::GamepadEvent evt, Gamepad* gamepad)
+{
+    if (evt == Gamepad::CONNECTED_EVENT)
+    {
+        Gamepad::add(gamepad->_id.c_str(), 
+                     gamepad->_handle, 
+                     gamepad->_buttonCount, gamepad->_joystickCount, gamepad->_triggerCount,
+                     gamepad->_vendorId, gamepad->_productId, 
+                     gamepad->_vendorString.c_str(), gamepad->_productString.c_str());
+    }
+    else if (evt == Gamepad::DISCONNECTED_EVENT) 
+    {
+        Gamepad::remove(gamepad);
+    }
+}
+
 bool Platform::isGestureSupported(Gesture::GestureEvent evt)
 bool Platform::isGestureSupported(Gesture::GestureEvent evt)
 {
 {
     // All are supported no need to test the bitset
     // All are supported no need to test the bitset

+ 4 - 0
gameplay/src/PlatformLinux.cpp

@@ -1118,6 +1118,10 @@ bool Platform::mouseEventInternal(Mouse::MouseEvent evt, int x, int y, int wheel
         return Game::getInstance()->getScriptController()->mouseEvent(evt, x, y, wheelDelta);
         return Game::getInstance()->getScriptController()->mouseEvent(evt, x, y, wheelDelta);
     }
     }
 }
 }
+
+void Platform::gamepadEventInternal(Gamepad::GamepadEvent evt, Gamepad* gamepad)
+{
+}
 
 
 bool Platform::isGestureSupported(Gesture::GestureEvent evt)
 bool Platform::isGestureSupported(Gesture::GestureEvent evt)
 {
 {

+ 17 - 1
gameplay/src/PlatformMacOSX.mm

@@ -882,7 +882,7 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime
 - (void) mouseDragged: (NSEvent*) event
 - (void) mouseDragged: (NSEvent*) event
 {
 {
     NSPoint point = [self convertPoint:[event locationInWindow] fromView:nil];
     NSPoint point = [self convertPoint:[event locationInWindow] fromView:nil];
-    if (__leftMouseDown)
+    if (__leftMouseDown && !__mouseCaptured)
     {
     {
         [self mouse: Mouse::MOUSE_MOVE orTouchEvent: Touch::TOUCH_MOVE x: point.x y: __height - point.y s: 0];
         [self mouse: Mouse::MOUSE_MOVE orTouchEvent: Touch::TOUCH_MOVE x: point.x y: __height - point.y s: 0];
     }
     }
@@ -1716,6 +1716,22 @@ bool Platform::mouseEventInternal(Mouse::MouseEvent evt, int x, int y, int wheel
     return result;
     return result;
 }
 }
 
 
+void Platform::gamepadEventInternal(Gamepad::GamepadEvent evt, Gamepad* gamepad)
+{
+    if (evt == Gamepad::CONNECTED_EVENT)
+    {
+        Gamepad::add(gamepad->_id.c_str(), 
+                     gamepad->_handle, 
+                     gamepad->_buttonCount, gamepad->_joystickCount, gamepad->_triggerCount,
+                     gamepad->_vendorId, gamepad->_productId, 
+                     gamepad->_vendorString.c_str(), gamepad->_productString.c_str());
+    }
+    else if (evt == Gamepad::DISCONNECTED_EVENT) 
+    {
+        Gamepad::remove(gamepad);
+    }
+}
+
 bool Platform::isGestureSupported(Gesture::GestureEvent evt)
 bool Platform::isGestureSupported(Gesture::GestureEvent evt)
 {
 {
     // Swipe unsupported as it is considered moving mouse cursor
     // Swipe unsupported as it is considered moving mouse cursor

+ 4 - 0
gameplay/src/PlatformWindows.cpp

@@ -1278,6 +1278,10 @@ bool Platform::mouseEventInternal(Mouse::MouseEvent evt, int x, int y, int wheel
     }
     }
 }
 }
 
 
+void Platform::gamepadEventInternal(Gamepad::GamepadEvent evt, Gamepad* gamepad)
+{
+}
+
 bool Platform::launchURL(const char* url)
 bool Platform::launchURL(const char* url)
 {
 {
     if (url == NULL || *url == '\0')
     if (url == NULL || *url == '\0')

+ 5 - 1
gameplay/src/PlatformiOS.mm

@@ -1388,7 +1388,11 @@ bool Platform::mouseEventInternal(Mouse::MouseEvent evt, int x, int y, int wheel
     {
     {
         return Game::getInstance()->getScriptController()->mouseEvent(evt, x, y, wheelDelta);
         return Game::getInstance()->getScriptController()->mouseEvent(evt, x, y, wheelDelta);
     }
     }
-}    
+}
+
+void Platform::gamepadEventInternal(Gamepad::GamepadEvent evt, Gamepad* gamepad)
+{
+}
 
 
 bool Platform::isGestureSupported(Gesture::GestureEvent evt)
 bool Platform::isGestureSupported(Gesture::GestureEvent evt)
 {
 {

+ 0 - 5
gameplay/src/RadioButton.cpp

@@ -91,11 +91,6 @@ void RadioButton::addListener(Control::Listener* listener, int eventFlags)
 
 
 bool RadioButton::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
 bool RadioButton::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
 {
 {
-    if (!isEnabled())
-    {
-        return false;
-    }
-
     switch (evt)
     switch (evt)
     {
     {
     case Touch::TOUCH_RELEASE:
     case Touch::TOUCH_RELEASE:

+ 1 - 1
gameplay/src/RadioButton.h

@@ -136,7 +136,7 @@ protected:
      * @param evt The touch event that occurred.
      * @param evt The touch event that occurred.
      * @param x The x position of the touch in pixels. Left edge is zero.
      * @param x The x position of the touch in pixels. Left edge is zero.
      * @param y The y position of the touch in pixels. Top edge is zero.
      * @param y The y position of the touch in pixels. Top edge is zero.
-     * @param contactIndex The order of occurrence for multiple touch contacts starting at zero.
+     * @param contactIndex An integer to identify this contact point within the currently active touch set.
      *
      *
      * @return Whether the touch event was consumed by the control.
      * @return Whether the touch event was consumed by the control.
      *
      *

+ 1 - 1
gameplay/src/ScriptController.h

@@ -811,7 +811,7 @@ private:
      * @param evt The touch event that occurred.
      * @param evt The touch event that occurred.
      * @param x The x position of the touch in pixels. Left edge is zero.
      * @param x The x position of the touch in pixels. Left edge is zero.
      * @param y The y position of the touch in pixels. Top edge is zero.
      * @param y The y position of the touch in pixels. Top edge is zero.
-     * @param contactIndex The order of occurrence for multiple touch contacts starting at zero.
+     * @param contactIndex An integer to identify this contact point within the currently active touch set.
      *
      *
      * @see Touch::TouchEvent
      * @see Touch::TouchEvent
      */
      */

+ 0 - 10
gameplay/src/Slider.cpp

@@ -135,11 +135,6 @@ void Slider::addListener(Control::Listener* listener, int eventFlags)
 
 
 bool Slider::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
 bool Slider::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
 {
 {
-    if (!isEnabled())
-    {
-        return false;
-    }
-
     switch (evt)
     switch (evt)
     {
     {
     case Touch::TOUCH_PRESS:
     case Touch::TOUCH_PRESS:
@@ -243,11 +238,6 @@ bool Slider::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contac
 
 
 bool Slider::mouseEvent(Mouse::MouseEvent evt, int x, int y, int wheelDelta)
 bool Slider::mouseEvent(Mouse::MouseEvent evt, int x, int y, int wheelDelta)
 {
 {
-    if (!isEnabled())
-    {
-        return false;
-    }
-
     switch (evt)
     switch (evt)
     {
     {
         case Mouse::MOUSE_PRESS_LEFT_BUTTON:
         case Mouse::MOUSE_PRESS_LEFT_BUTTON:

+ 1 - 1
gameplay/src/Slider.h

@@ -192,7 +192,7 @@ protected:
      * @param evt The touch event that occurred.
      * @param evt The touch event that occurred.
      * @param x The x position of the touch in pixels. Left edge is zero.
      * @param x The x position of the touch in pixels. Left edge is zero.
      * @param y The y position of the touch in pixels. Top edge is zero.
      * @param y The y position of the touch in pixels. Top edge is zero.
-     * @param contactIndex The order of occurrence for multiple touch contacts starting at zero.
+     * @param contactIndex An integer to identify this contact point within the currently active touch set.
      *
      *
      * @return Whether the touch event was consumed by the control.
      * @return Whether the touch event was consumed by the control.
      *
      *

+ 2 - 4
gameplay/src/TerrainPatch.cpp

@@ -488,11 +488,9 @@ bool TerrainPatch::updateMaterial()
         material->getParameter("u_lightColor")->bindValue(this, &TerrainPatch::getLightColor);
         material->getParameter("u_lightColor")->bindValue(this, &TerrainPatch::getLightColor);
         material->getParameter("u_lightDirection")->bindValue(this, &TerrainPatch::getLightDirection);
         material->getParameter("u_lightDirection")->bindValue(this, &TerrainPatch::getLightDirection);
         if (_layers.size() > 0)
         if (_layers.size() > 0)
-        {
             material->getParameter("u_samplers")->setValue((const Texture::Sampler**)&_samplers[0], (unsigned int)_samplers.size());
             material->getParameter("u_samplers")->setValue((const Texture::Sampler**)&_samplers[0], (unsigned int)_samplers.size());
-            if (_terrain->_normalMap)
-                material->getParameter("u_normalMap")->setValue(_terrain->_normalMap);
-        }
+        if (_terrain->_normalMap)
+            material->getParameter("u_normalMap")->setValue(_terrain->_normalMap);
 
 
         if (_terrain->isFlagSet(Terrain::DEBUG_PATCHES))
         if (_terrain->isFlagSet(Terrain::DEBUG_PATCHES))
         {
         {

+ 0 - 5
gameplay/src/TextBox.cpp

@@ -49,11 +49,6 @@ void TextBox::addListener(Control::Listener* listener, int eventFlags)
 
 
 bool TextBox::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
 bool TextBox::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
 {   
 {   
-    if (!isEnabled())
-    {
-        return false;
-    }
-
     switch (evt)
     switch (evt)
     {
     {
     case Touch::TOUCH_PRESS: 
     case Touch::TOUCH_PRESS: 

+ 1 - 1
gameplay/src/TextBox.h

@@ -102,7 +102,7 @@ protected:
      * @param evt The touch event that occurred.
      * @param evt The touch event that occurred.
      * @param x The x position of the touch in pixels. Left edge is zero.
      * @param x The x position of the touch in pixels. Left edge is zero.
      * @param y The y position of the touch in pixels. Top edge is zero.
      * @param y The y position of the touch in pixels. Top edge is zero.
-     * @param contactIndex The order of occurrence for multiple touch contacts starting at zero.
+     * @param contactIndex An integer to identify this contact point within the currently active touch set.
      *
      *
      * @return Whether the touch event was consumed by the control.
      * @return Whether the touch event was consumed by the control.
      *
      *

+ 46 - 0
gameplay/src/lua/lua_Platform.cpp

@@ -2,6 +2,7 @@
 #include "ScriptController.h"
 #include "ScriptController.h"
 #include "lua_Platform.h"
 #include "lua_Platform.h"
 #include "Platform.h"
 #include "Platform.h"
+#include "lua_GamepadGamepadEvent.h"
 #include "lua_GestureGestureEvent.h"
 #include "lua_GestureGestureEvent.h"
 #include "lua_KeyboardKeyEvent.h"
 #include "lua_KeyboardKeyEvent.h"
 #include "lua_MouseMouseEvent.h"
 #include "lua_MouseMouseEvent.h"
@@ -21,6 +22,7 @@ void luaRegister_Platform()
     {
     {
         {"canExit", lua_Platform_static_canExit},
         {"canExit", lua_Platform_static_canExit},
         {"displayKeyboard", lua_Platform_static_displayKeyboard},
         {"displayKeyboard", lua_Platform_static_displayKeyboard},
+        {"gamepadEventInternal", lua_Platform_static_gamepadEventInternal},
         {"getAbsoluteTime", lua_Platform_static_getAbsoluteTime},
         {"getAbsoluteTime", lua_Platform_static_getAbsoluteTime},
         {"getAccelerometerValues", lua_Platform_static_getAccelerometerValues},
         {"getAccelerometerValues", lua_Platform_static_getAccelerometerValues},
         {"getDisplayHeight", lua_Platform_static_getDisplayHeight},
         {"getDisplayHeight", lua_Platform_static_getDisplayHeight},
@@ -196,6 +198,50 @@ int lua_Platform_static_displayKeyboard(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Platform_static_gamepadEventInternal(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
+                (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                Gamepad::GamepadEvent param1 = (Gamepad::GamepadEvent)lua_enumFromString_GamepadGamepadEvent(luaL_checkstring(state, 1));
+
+                // Get parameter 2 off the stack.
+                bool param2Valid;
+                ScriptUtil::LuaArray<Gamepad> param2 = ScriptUtil::getObjectPointer<Gamepad>(2, "Gamepad", false, &param2Valid);
+                if (!param2Valid)
+                {
+                    lua_pushstring(state, "Failed to convert parameter 2 to type 'Gamepad'.");
+                    lua_error(state);
+                }
+
+                Platform::gamepadEventInternal(param1, param2);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Platform_static_gamepadEventInternal - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_Platform_static_getAbsoluteTime(lua_State* state)
 int lua_Platform_static_getAbsoluteTime(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.

+ 1 - 0
gameplay/src/lua/lua_Platform.h

@@ -9,6 +9,7 @@ int lua_Platform__gc(lua_State* state);
 int lua_Platform_enterMessagePump(lua_State* state);
 int lua_Platform_enterMessagePump(lua_State* state);
 int lua_Platform_static_canExit(lua_State* state);
 int lua_Platform_static_canExit(lua_State* state);
 int lua_Platform_static_displayKeyboard(lua_State* state);
 int lua_Platform_static_displayKeyboard(lua_State* state);
+int lua_Platform_static_gamepadEventInternal(lua_State* state);
 int lua_Platform_static_getAbsoluteTime(lua_State* state);
 int lua_Platform_static_getAbsoluteTime(lua_State* state);
 int lua_Platform_static_getAccelerometerValues(lua_State* state);
 int lua_Platform_static_getAccelerometerValues(lua_State* state);
 int lua_Platform_static_getDisplayHeight(lua_State* state);
 int lua_Platform_static_getDisplayHeight(lua_State* state);