Datasheet
HANDLING INPUT FROM THE KEYPAD 49
in microseconds. The resolution of this timer is 1 ms on phone hardware,
but defaults to 5 ms on the Windows emulator, although it can be changed
by modifying the TimerResolution variable in the epoc.ini emula-
tor file. However, on Windows, there is no real-time guarantee as there is
on the smartphone hardware, because the timings are subject to whatever
else is running on Windows.
2.4 Handling Input from the Keypad
Handling user input made by pressing keys on the phone’s keypad is
quite straightforward in the Symbian OS application framework. The
application UI class should call CCoeAppUI::AddToStackL() when
it creates an application view to ensure that keypad input is passed
automatically to the current view. The key events can be inspected by
overriding CCoeControl::OfferKeyEventL().
Note that only input from the numerical keypad and multi-way con-
troller is passed into CCoeControl::OfferKeyEventL(). Input from
the user’s interaction with the menu bar, toolbar, or softkeys, is passed
separately to the HandleCommandL() method of the application UI
class for S60. In UIQ, the application view handles in-command input.
This is because a command can be located on a softkey, in a toolbar, or
in a menu, depending on the interaction style of the phone. To allow for
this flexibility, commands are defined in a more abstract way, rather than
being explicitly coded as particular GUI elements, such as menu items.
For either UI platform, the input event is handled according to the
associated command, which is specified in the application’s resource
file. The
Skeleton
example demonstrates basic menu input handling
in CSkeletonAppUi::HandleCommandL() for S60 and CSkele-
tonUIQView::HandleCommandL() for UIQ.
In the
Skeleton
example, the handling of the user input is decoupled
from the actual event, by storing it in a bitmask (iKeyState)whenitis
received, and handling it when the game loop next runs by inspecting
iKeyState. This approach is shown in the simplified example code, for
S60, below.
TKeyResponse CSkeletonAppView::OfferKeyEventL(const TKeyEvent&
aKeyEvent, TEventCode aType)
{
TKeyResponse response = EKeyWasConsumed;
TUint input = 0x00000000;
switch (aKeyEvent.iScanCode)
{
case EStdKeyUpArrow: // 4-way controller up
input = KControllerUp; // 0x00000001;
break;
case EStdKeyDownArrow: // 4-way controller down










