Trying to get the keyboard working. The keys are already being detected correctly, but there’s still a part missing.

This commit is contained in:
Dante Leoncini 2026-05-02 20:37:16 -03:00
parent 52d43468b3
commit e0107274a5
2 changed files with 81 additions and 10 deletions

View file

@ -38,6 +38,10 @@
#include "Text.h" #include "Text.h"
#include "Timer.h" #include "Timer.h"
//debug
//#include <e32cons.h>
//LOCAL_D CConsoleBase* console;
psGlobalType psGlobal; psGlobalType psGlobal;
uint32 gGameState = 0; uint32 gGameState = 0;
@ -143,15 +147,16 @@ void CapturePad(int padID) {
RsPadButtonStatus bs; RsPadButtonStatus bs;
bs.padID = padID; bs.padID = padID;
RsPadEventHandler(rsPADBUTTONUP, (void *)&bs); /*RsPadEventHandler(rsPADBUTTONUP, (void *)&bs);{
{
if (CPad::m_bMapPadOneToPadTwo) if (CPad::m_bMapPadOneToPadTwo)
bs.padID = 1; bs.padID = 1;
RsPadEventHandler(rsPADBUTTONUP, (void *)&bs); RsPadEventHandler(rsPADBUTTONUP, (void *)&bs);
RsPadEventHandler(rsPADBUTTONDOWN, (void *)&bs); RsPadEventHandler(rsPADBUTTONDOWN, (void *)&bs);
} }*/
// solo avisar que hubo input
RsPadEventHandler(rsPADBUTTONDOWN, &bs);
CPad *pad = CPad::GetPad(0); CPad *pad = CPad::GetPad(0);
pad->PCTempJoyState.LeftStickX = (int32)(virtualLeftStickX * 128.0f); pad->PCTempJoyState.LeftStickX = (int32)(virtualLeftStickX * 128.0f);
@ -312,6 +317,7 @@ public:
TRACE("gGameState = GS_PLAYING_GAME;"); TRACE("gGameState = GS_PLAYING_GAME;");
break; break;
case GS_PLAYING_GAME: case GS_PLAYING_GAME:
CapturePad(0);
// float ms = (float)CTimer::GetCurrentTimeInCycles() / (float)tickPeriod; //(float)CTimer::GetCyclesPerMillisecond(); // float ms = (float)CTimer::GetCurrentTimeInCycles() / (float)tickPeriod; //(float)CTimer::GetCyclesPerMillisecond();
// if ( RwInitialised ) // if ( RwInitialised )
// { // {
@ -334,11 +340,17 @@ public:
iPeriodic->Start(aInterval, aInterval, TCallBack(CCContainer::LoopCallBack, this)); iPeriodic->Start(aInterval, aInterval, TCallBack(CCContainer::LoopCallBack, this));
} }
void ConstructL(const TRect& aRect, CAknAppUi* aAppUi) { void ConstructL(const TRect& aRect, CAknAppUi* aAppUi) {
/*console = Console::NewL(_L("RE3 Debug"), TSize(KConsFullScreen, KConsFullScreen));
console->Printf(_L("Console iniciada\n"));*/
iAppUi = aAppUi; iAppUi = aAppUi;
CreateWindowL(); CreateWindowL();
iAppUi->SetOrientationL(CAknAppUiBase::EAppUiOrientationLandscape); iAppUi->SetOrientationL(CAknAppUiBase::EAppUiOrientationLandscape);
SetExtentToWholeScreen(); SetExtentToWholeScreen();
SetFocus(ETrue);
#ifdef RW_GL3 #ifdef RW_GL3
Window().EnableAdvancedPointers(); Window().EnableAdvancedPointers();
#endif #endif
@ -538,6 +550,63 @@ public:
CCoeControl::HandlePointerEventL(aPointerEvent); CCoeControl::HandlePointerEventL(aPointerEvent);
} }
TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType){
bool pressed = (aType == EEventKeyDown);
TUint scan = aKeyEvent.iScanCode;
/*if(console){
console->Printf(_L("Scan: %d Type: %d\n"), aKeyEvent.iScanCode, aType);
}*/
switch(scan)
{
// Flechas (DPAD)
case 16: // arriba
virtualButtons[JOY_DPAD_UP] = pressed;
break;
case 17: // abajo
virtualButtons[JOY_DPAD_DOWN] = pressed;
break;
case 14: // izquierda
virtualButtons[JOY_DPAD_LEFT] = pressed;
break;
case 15: // derecha
virtualButtons[JOY_DPAD_RIGHT] = pressed;
break;
// OK → X (PlayStation)
case 167: // OK
case 3: // Enter (algunos devices)
virtualButtons[JOY_X] = pressed;
break;
// Softkeys
/*case 164: // softkey izquierdo
virtualButtons[JOY_SELECT] = pressed;
break;*/
case 165: // softkey derecho
virtualButtons[JOY_START] = pressed;
break;
// Num keypad → botones
case 49: virtualButtons[JOY_X] = pressed; break; // 1
case 50: virtualButtons[JOY_B] = pressed; break; // 2 (circulo)
case 51: virtualButtons[JOY_Y] = pressed; break; // 3 (triangulo)
case 52: virtualButtons[JOY_A] = pressed; break; // 4 (cuadrado)
// Gatillos
case 53: virtualButtons[JOY_LB] = pressed; break; // 5
case 54: virtualButtons[JOY_RB] = pressed; break; // 6
case 55: virtualButtons[JOY_LB] = pressed; break; // 7
case 56: virtualButtons[JOY_RB] = pressed; break; // 8
default:
return EKeyWasNotConsumed;
}
return EKeyWasConsumed;
}
}; };
class RE3AppUi : public CAknAppUi { class RE3AppUi : public CAknAppUi {

View file

@ -310,7 +310,7 @@ flushGlRenderState(void)
void void
setAlphaBlend(bool32 enable) setAlphaBlend(bool32 enable)
{ {
if(rwStateCache.blendEnable != enable){ if(rwStateCache.blendEnable != enable){
rwStateCache.blendEnable = enable; rwStateCache.blendEnable = enable;
setGlRenderState(RWGL_BLEND, enable); setGlRenderState(RWGL_BLEND, enable);
@ -926,6 +926,10 @@ setWorldMatrix(Matrix *mat)
int32 int32
setLights(WorldLights *lightData) setLights(WorldLights *lightData)
{ {
//sin luces. menos codigo
glDisable(GL_LIGHTING);
return 0;
int i, n; int i, n;
Light *l; Light *l;
int32 bits = 0; int32 bits = 0;
@ -988,9 +992,7 @@ setLights(WorldLights *lightData)
out: out:
if(n > 0 || lightData->numAmbients > 0) if(n > 0 || lightData->numAmbients > 0)
//pruebo a ver que tal sin luz glEnable(GL_LIGHTING);
//glEnable(GL_LIGHTING);
glDisable(GL_LIGHTING);
else else
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
@ -1017,7 +1019,6 @@ setViewMatrix(float32 *mat)
sceneDirty = 1; sceneDirty = 1;
} }
void void
setMaterial(const RGBA &color, const SurfaceProperties &surfaceprops, float extraSurfProp) setMaterial(const RGBA &color, const SurfaceProperties &surfaceprops, float extraSurfProp)
{ {
@ -1066,6 +1067,7 @@ flushCache(void)
uniformStateDirty[RWGL_FOGSTART] || uniformStateDirty[RWGL_FOGSTART] ||
uniformStateDirty[RWGL_FOGEND] || uniformStateDirty[RWGL_FOGEND] ||
uniformStateDirty[RWGL_FOGCOLOR]){ uniformStateDirty[RWGL_FOGCOLOR]){
glDisable(GL_FOG);
if (rwStateCache.fogEnable) { if (rwStateCache.fogEnable) {
glEnable(GL_FOG); glEnable(GL_FOG);
glFogf(GL_FOG_MODE, GL_LINEAR); glFogf(GL_FOG_MODE, GL_LINEAR);