Hello everyone!
I just subsribed to this list. I hope that someone can help me with my
problem.
First, here are some code snippets:
// File: Input.h
class Input
{
bool Create(void);
void Destroy(void);
void UpdateBuffer(long lScan, long lCode);
//…
};
// File: Input.cpp
#include “SDL.h”
#include “Input.h”
bool Input::Create(void)
{
//…
SDL_EnableUNICODE(1);
if (SDL_EnableUNICODE(-1) == 0)
return false;
return true;
}
void Input::Destroy(void)
{
SDL_EnableUNICODE(0);
}
void UpdateBuffer(long lScan, long lCode);
{
// Here I want to do sth. with the lCode parameter. But its always 0!
}
// File: Engine.h
class Engine
{
Input *pkInput;
bool Create(void);
void Destroy(void);
bool Update(void);
//…
};
// File: Engine.cpp
#include “Input.h”
bool Engine::Create(void)
{
if (SDL_Init(SDL_NO_PARACHUTE) < 0)
return false;
pkInput = new Input();
if (!pkInput)
return false;
if (!pkInput->Create())
{
delete pkInput;
return false;
}
//…
return true;
}
void Engine::Destroy(void)
{
if (pkInput)
{
pkInput->Destroy();
delete pkInput;
pkInput = NULL;
}
SDL_Quit();
}
bool Engine::Update(void)
{
SDL_Event kEvent;
while (SDL_PollEvent(&kEvent))
{
switch(kEvent.type)
{
//…
case SDL_KEYDOWN:
{
if (!pkInput)
break;
// Post only Messages for ASCII compliant characters
if ((kEvent.key.keysym.unicode & 0xFF80) == 0 ) // Ascii printable Character
pkInput->UpdateBuffer(
kEvent.key.keysym.sym,
kEvent.key.keysym.unicode & 0x7F
);
break;
}
//…
} // switch(kEvent.type)
}// while SDL_PollEvent
} // Engine::Update
Ok, now here 's what i don’t understand. Using the above code,
Input::UpdateBuffer
receives alway 0 as value of its lChar Parameter. But if I move the
SDL_EnableUNICODE calls
into the Engine::Create and Engine::Destroy methods, it receives the
translated character code.
I don’t understand this. Anybody an Idea? I’m programming under Windows XP
using Microsoft
Visual C++ 6.0 with the latest Service Pack (5, i guess) and SDL 1.2.3.
Well, any hint will be greatly appreciated!
Thanks and best regards,
Oliver Fladda