mirror of
https://gitlab.com/shinovon/re3-symbian.git
synced 2026-05-22 17:47:20 +03:00
Implement simple keyboard controls
This commit is contained in:
parent
7e7188abbd
commit
8e714d416d
1 changed files with 90 additions and 2 deletions
|
|
@ -13,6 +13,7 @@
|
||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <versioninfo.h>
|
#include <versioninfo.h>
|
||||||
|
#include <aknwseventobserver.h>
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "rwcore.h"
|
#include "rwcore.h"
|
||||||
|
|
@ -241,7 +242,74 @@ RwBool IsForegroundApp() {
|
||||||
return foreground;
|
return foreground;
|
||||||
}
|
}
|
||||||
|
|
||||||
class CCContainer : public CCoeControl {
|
static int MapScanCode(TInt aScanCode, TInt aModifiers) {
|
||||||
|
switch (aScanCode) {
|
||||||
|
|
||||||
|
case EStdKeyLeftArrow:
|
||||||
|
if (aModifiers & EModifierRotateBy90) {
|
||||||
|
return JOY_DPAD_UP;
|
||||||
|
}
|
||||||
|
if (aModifiers & EModifierRotateBy180) {
|
||||||
|
return JOY_DPAD_RIGHT;
|
||||||
|
}
|
||||||
|
if (aModifiers & EModifierRotateBy270) {
|
||||||
|
return JOY_DPAD_DOWN;
|
||||||
|
}
|
||||||
|
return JOY_DPAD_LEFT;
|
||||||
|
case EStdKeyRightArrow:
|
||||||
|
if (aModifiers & EModifierRotateBy90) {
|
||||||
|
return JOY_DPAD_DOWN;
|
||||||
|
}
|
||||||
|
if (aModifiers & EModifierRotateBy180) {
|
||||||
|
return JOY_DPAD_LEFT;
|
||||||
|
}
|
||||||
|
if (aModifiers & EModifierRotateBy270) {
|
||||||
|
return JOY_DPAD_UP;
|
||||||
|
}
|
||||||
|
return JOY_DPAD_RIGHT;
|
||||||
|
case EStdKeyUpArrow:
|
||||||
|
if (aModifiers & EModifierRotateBy90) {
|
||||||
|
return JOY_DPAD_RIGHT;
|
||||||
|
}
|
||||||
|
if (aModifiers & EModifierRotateBy180) {
|
||||||
|
return JOY_DPAD_DOWN;
|
||||||
|
}
|
||||||
|
if (aModifiers & EModifierRotateBy270) {
|
||||||
|
return JOY_DPAD_LEFT;
|
||||||
|
}
|
||||||
|
return JOY_DPAD_UP;
|
||||||
|
case EStdKeyDownArrow:
|
||||||
|
if (aModifiers & EModifierRotateBy90) {
|
||||||
|
return JOY_DPAD_LEFT;
|
||||||
|
}
|
||||||
|
if (aModifiers & EModifierRotateBy180) {
|
||||||
|
return JOY_DPAD_UP;
|
||||||
|
}
|
||||||
|
if (aModifiers & EModifierRotateBy270) {
|
||||||
|
return JOY_DPAD_RIGHT;
|
||||||
|
}
|
||||||
|
return JOY_DPAD_DOWN;
|
||||||
|
case 'z':
|
||||||
|
case 'Z':
|
||||||
|
return JOY_B;
|
||||||
|
case 'x':
|
||||||
|
case 'X':
|
||||||
|
return JOY_X;
|
||||||
|
case 'c':
|
||||||
|
case 'C':
|
||||||
|
return JOY_A;
|
||||||
|
case EStdKeySpace:
|
||||||
|
case ' ':
|
||||||
|
return JOY_START;
|
||||||
|
case EStdKeyEnter:
|
||||||
|
case EStdKeyNkpEnter:
|
||||||
|
case EStdKeyDevice3:
|
||||||
|
return JOY_Y;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
class CCContainer : public CCoeControl, MAknWsEventObserver {
|
||||||
public:
|
public:
|
||||||
CAknAppUi* iAppUi;
|
CAknAppUi* iAppUi;
|
||||||
CPeriodic* iPeriodic;
|
CPeriodic* iPeriodic;
|
||||||
|
|
@ -333,6 +401,11 @@ public:
|
||||||
|
|
||||||
void ConstructL(const TRect& aRect, CAknAppUi* aAppUi) {
|
void ConstructL(const TRect& aRect, CAknAppUi* aAppUi) {
|
||||||
iAppUi = aAppUi;
|
iAppUi = aAppUi;
|
||||||
|
|
||||||
|
CAknWsEventMonitor* monitor = iAppUi->EventMonitor();
|
||||||
|
monitor->AddObserverL(this);
|
||||||
|
monitor->Enable();
|
||||||
|
|
||||||
CreateWindowL();
|
CreateWindowL();
|
||||||
iAppUi->SetOrientationL(CAknAppUiBase::EAppUiOrientationLandscape);
|
iAppUi->SetOrientationL(CAknAppUiBase::EAppUiOrientationLandscape);
|
||||||
SetExtentToWholeScreen();
|
SetExtentToWholeScreen();
|
||||||
|
|
@ -406,7 +479,7 @@ public:
|
||||||
PsGlobal.lastMousePos.x = PsGlobal.lastMousePos.y = 0.0f;
|
PsGlobal.lastMousePos.x = PsGlobal.lastMousePos.y = 0.0f;
|
||||||
RsGlobal.ps = &PsGlobal;
|
RsGlobal.ps = &PsGlobal;
|
||||||
|
|
||||||
ControlsManager.InitDefaultControlConfigJoyPad(15);
|
ControlsManager.InitDefaultControlConfigJoyPad(16);
|
||||||
ControlsManager.InitDefaultControlConfigMouse(MousePointerStateHelper.GetMouseSetUp());
|
ControlsManager.InitDefaultControlConfigMouse(MousePointerStateHelper.GetMouseSetUp());
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
@ -521,6 +594,21 @@ public:
|
||||||
|
|
||||||
CCoeControl::HandlePointerEventL(aPointerEvent);
|
CCoeControl::HandlePointerEventL(aPointerEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HandleWsEventL(const TWsEvent &aEvent, CCoeControl *aDestination) {
|
||||||
|
if (!IsForegroundApp() || iAppUi->IsDisplayingDialog()) return;
|
||||||
|
switch (aEvent.Type()) {
|
||||||
|
case EEventKeyDown:
|
||||||
|
case EEventKeyUp: {
|
||||||
|
TInt k = MapScanCode(aEvent.Key()->iScanCode, aEvent.Key()->iModifiers);
|
||||||
|
if (k == -1) break;
|
||||||
|
virtualButtons[k] = aEvent.Type() == EEventKeyDown;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class RE3AppUi : public CAknAppUi {
|
class RE3AppUi : public CAknAppUi {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue