Datasheet

SYSTEM EVENTS 55
step occurs is often customizable by the phone’s owner, and usually, a
screensaver is displayed, such as the time and date, which can also be
customized.
Regardless of the fact that the phone appears to be in power-saving
mode, the game loop will continue running, even when the screensaver
is showing and the backlight is off, unless the developer adds code to
explicitly stop it. To save power, it is usual practice for the game to move
into ‘attract’ mode, or to display a pause menu and stop the game loop
after user inactivity of a certain duration.
Attract mode is so called because it displays a graphics sequence which
looks something like the game running in a demo mode, showing off the
game to attract the user to play it. Attract mode also consumes power,
because it is still displaying regularly updated graphics and running a
game loop, even if the frequency of the timer is much reduced from
that of normal gameplay. Unless the phone is running on main power
(i.e., connected to its charger), it is usual to run the attract mode for
a pre-determined amount of time only, perhaps two minutes, and then
display the pause menu and halt the game loop by completely stopping
the heartbeat timer.
User inactivity can be detected by creating a class that inherits from
the CTimer active object and calling the Inactivity() method. The
object receives an event if the interval specified, passed as a parameter
to the method, elapses without user activity.
class CInactivityTimer : public CTimer
{
public:
static CInactivityTimer* NewL(CSkeletonAppView& aAppView);
void StartInactivityMonitor(TTimeIntervalSeconds aSeconds);
protected:
CInactivityTimer(CSkeletonAppView& aAppView);
virtual void RunL();
private:
CSkeletonAppView& iAppView;
TTimeIntervalSeconds iTimeout;
};
CInactivityTimer::CInactivityTimer(CSkeletonAppView& aAppView)
: CTimer(EPriorityLow), iAppView(aAppView)
{
CActiveScheduler::Add(this);
}
CInactivityTimer* CInactivityTimer::NewL(CSkeletonAppView& aAppView)
{
CInactivityTimer* me = new (ELeave) CInactivityTimer(aAppView);
CleanupStack::PushL(me);
me->ConstructL();
CleanupStack::Pop(me);
return (me);
}