two Keyboard keys press
two Keyboard keys press
how I can make so that instructions of one uses a keyboard key A that this being press, continues to be executed one another keyboard key B after to have been press? I tested the function event.KeyInput.PressDown in many ways , but it stops the execution of the instructions of the keyboard key A.[/b]
It should be this way if I'm not mistakened:
Code: Select all
if (event.EventType == EET_KEY_INPUT_EVENT && event.KeyInput.Event == KEY_KEY_A && event.KeyInput.Event == KEY_KEY_B)
{
//whatever you want to happen goes here
}
Please. You're giving Guest a bad name.It should be this way if I'm not mistakened:
That expression can never work. A single variable can never have two values at the same time.
Irado: bitplane is right. That thread explains how you can go from events (which are keypresses/releases, i.o.w. changes) to keystates.
I search the keystates in the irrlicht but i don't find.
I am trying to use the class, but this saying the error message:
base operand of '->' has non-pointer type 'CIrrLichtEvent'
in the line:
recebe->Init();
this is the class. --------------------------------------------------------------
class CIrrLichtEvent : public IEventReceiver
{
public:
bool m_key_buf[256];
bool m_key_buf_old[256];
public:
CIrrLichtEvent();
virtual ~CIrrLichtEvent();
void Init()
{
bool keys[irr::KEY_KEY_CODES_COUNT] ;
//initialization
for(int x=0; x<irr::KEY_KEY_CODES_COUNT; x++) keys[x] = false;
memset(m_key_buf, 0, 256);
memset(m_key_buf_old, 0, 256);
}
virtual bool OnEvent(SEvent event)
{
if (event.EventType)
{
if (EET_KEY_INPUT_EVENT)
{
m_key_buf_old[event.KeyInput.Key] = m_key_buf[event.KeyInput.Key];
m_key_buf[event.KeyInput.Key] = event.KeyInput.PressedDown;
}
}
return true;
}
bool IsKeyDown(int index)
{
return m_key_buf[index];
}
bool IsKeyUpDown(int index)
{
return (m_key_buf[index] && !m_key_buf_old[index]);
}
bool IsKeyDownUp(int index)
{
return (!m_key_buf[index] && m_key_buf_old[index]);
}
};
int main()
{ //main
CIrrLichtEvent recebe;
recebe->Init();
IrrlichtDevice *device = createDevice(video::EDT_OPENGL, core::dimension2d<s32>(640, 480),
16, false, false, false, &recebe );
I am trying to use the class, but this saying the error message:
base operand of '->' has non-pointer type 'CIrrLichtEvent'
in the line:
recebe->Init();
this is the class. --------------------------------------------------------------
class CIrrLichtEvent : public IEventReceiver
{
public:
bool m_key_buf[256];
bool m_key_buf_old[256];
public:
CIrrLichtEvent();
virtual ~CIrrLichtEvent();
void Init()
{
bool keys[irr::KEY_KEY_CODES_COUNT] ;
//initialization
for(int x=0; x<irr::KEY_KEY_CODES_COUNT; x++) keys[x] = false;
memset(m_key_buf, 0, 256);
memset(m_key_buf_old, 0, 256);
}
virtual bool OnEvent(SEvent event)
{
if (event.EventType)
{
if (EET_KEY_INPUT_EVENT)
{
m_key_buf_old[event.KeyInput.Key] = m_key_buf[event.KeyInput.Key];
m_key_buf[event.KeyInput.Key] = event.KeyInput.PressedDown;
}
}
return true;
}
bool IsKeyDown(int index)
{
return m_key_buf[index];
}
bool IsKeyUpDown(int index)
{
return (m_key_buf[index] && !m_key_buf_old[index]);
}
bool IsKeyDownUp(int index)
{
return (!m_key_buf[index] && m_key_buf_old[index]);
}
};
int main()
{ //main
CIrrLichtEvent recebe;
recebe->Init();
IrrlichtDevice *device = createDevice(video::EDT_OPENGL, core::dimension2d<s32>(640, 480),
16, false, false, false, &recebe );
Those two functions don't work as they should.
They are only supposed to be true when the key is toggled, but the old status is not reset except when the key is toggled.
One way to fix that is to modify them by copying the new key state to the old key state before returning the result of the comparison.
Or you can look at some improved code on this thread:
http://irrlicht.sourceforge.net/phpBB2/ ... php?t=6159
They are only supposed to be true when the key is toggled, but the old status is not reset except when the key is toggled.
One way to fix that is to modify them by copying the new key state to the old key state before returning the result of the comparison.
Or you can look at some improved code on this thread:
http://irrlicht.sourceforge.net/phpBB2/ ... php?t=6159