From 8e714d416d2f54ff8f53828b69fc99906fcf8fc2 Mon Sep 17 00:00:00 2001 From: Shinovon Date: Sun, 3 May 2026 02:32:10 +0500 Subject: [PATCH] Implement simple keyboard controls --- src/skel/symbian/symbian.cpp | 92 +++++++++++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 2 deletions(-) diff --git a/src/skel/symbian/symbian.cpp b/src/skel/symbian/symbian.cpp index 38e47d7..531dddd 100644 --- a/src/skel/symbian/symbian.cpp +++ b/src/skel/symbian/symbian.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include "common.h" #include "rwcore.h" @@ -241,7 +242,74 @@ RwBool IsForegroundApp() { 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: CAknAppUi* iAppUi; CPeriodic* iPeriodic; @@ -333,6 +401,11 @@ public: void ConstructL(const TRect& aRect, CAknAppUi* aAppUi) { iAppUi = aAppUi; + + CAknWsEventMonitor* monitor = iAppUi->EventMonitor(); + monitor->AddObserverL(this); + monitor->Enable(); + CreateWindowL(); iAppUi->SetOrientationL(CAknAppUiBase::EAppUiOrientationLandscape); SetExtentToWholeScreen(); @@ -406,7 +479,7 @@ public: PsGlobal.lastMousePos.x = PsGlobal.lastMousePos.y = 0.0f; RsGlobal.ps = &PsGlobal; - ControlsManager.InitDefaultControlConfigJoyPad(15); + ControlsManager.InitDefaultControlConfigJoyPad(16); ControlsManager.InitDefaultControlConfigMouse(MousePointerStateHelper.GetMouseSetUp()); { @@ -521,6 +594,21 @@ public: 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 {