Game Development Reference
In-Depth Information
Creating a Windows extension
Since we won't actually be supporting gyroscope input on Windows, our API only
needs to return false in the GyroscopeSupported function and the functions for
accessing current gyroscope values should always return a 0 value. Obviously the
start and stop functions need to do absolutely nothing!
We've already created the S4E file, so now we'll put it to use. Open Windows
Explorer, navigate to the Gyroscope directory, and then right-click on the
Gyroscope.s4e file. Select the menu option Build Windows Extension , which
will run a Python script that generates a number of new files and directories.
In the main Gyroscope directory three new files are created:
Gyroscope_build.mkf is the MKF file for the extension that allows us
to specify additional generic or platform-dependant source files that are
needed for building it
Gyroscope.mkf is the MKF file any Marmalade project that makes
use of our extension will need to include as a subproject to access the
extension functions
Gyroscope_windows.mkb is the MKB file that creates a Visual Studio
project that we can use to compile the extension code
There are four subdirectories created as well. We can safely ignore the stamp
directory, which contains a file used internally by the EDK build scripts to track
changes to the extension API. We can also ignore the files in the interface
directory, which are autogenerated and should not be altered.
The h directory contains a single file, Gyroscope.h , which again we should not
modify, as any changes we make will be overwritten by the extension creation
scripts. This file is very useful, however, as it is the file we will include in our
project sources to access the functions in the extension.
Finally there is the source directory that in turn contains three more subdirectories.
The generic subdirectory contains source files that will define the default behavior
of the extension if platform-specific source files are not provided. The h directory
also contains files that are used across all platforms for building the extension code.
While we can make changes to these files, it is unlikely we will ever need to.
This leaves us with the windows subdirectory that contains a single file called
Gyroscope_platform.cpp . This file contains stubs for each of our extension functions
that were generated from the data provided in the functions list of the S4E file.
 
Search WWH ::




Custom Search