Game Development Reference
In-Depth Information
Function
Description
GyroscopeStart and
GyroscopeStop
These two functions start and stop the hardware generating
gyroscope input data.
GyroscopeGetX ,
GyroscopeGetY , and
GyroscopeGetZ
Returns the current gyroscope data values for the X, Y, and
Z axes. The values are returned as float values in radians
per second.
The API detailed earlier provides the bare minimum functionality required to
provide gyroscope support and has deliberately been kept simple in order to
demonstrate the process of building an extension more clearly.
Declaring the extension API
The first step in creating an extension is to specify the functions it will contain,
which we will do using an S4E file . This file is used to define the API of our
extension and is best illustrated by an example. If you want to follow along, create
a new directory called Gyroscope and create a file called Gyroscope.s4e inside it
with the following contents:
include:
#include <s3eTypes.h>
functions:
bool GyroscopeSupported() false
void GyroscopeStart() void
void GyroscopeStop() void
float GyroscopeGetX() 0.0f
float GyroscopeGetY() 0.0f
float GyroscopeGetZ() 0.0f
The example starts with the line include: , which is then followed by any number of
C preprocessor commands, include files, structure definitions, and class definitions
that will become part of the extension's main header file. In our case we are just
including the s3eTypes.h file; but if we needed to pass lots of data between
the extension and the calling code, we might want to add structures or classes,
enumerations, and definitions here too.
Next we have the functions: section of the file, which is little more than a list of the
functions that our extension will contain and can be called from within a Marmalade
project that makes use of the extension.
Search WWH ::




Custom Search