mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-05 19:31:04 +00:00
Simulate all keys being released when when game loses focus (#13336)
This commit is contained in:
parent
fe75ec8d0d
commit
e139749b5c
3 changed files with 44 additions and 8 deletions
|
@ -124,6 +124,13 @@ public:
|
|||
push_back(key);
|
||||
}
|
||||
|
||||
void append(const KeyList &other)
|
||||
{
|
||||
for (const KeyPress &key : other) {
|
||||
set(key);
|
||||
}
|
||||
}
|
||||
|
||||
bool operator[](const KeyPress &key) const { return find(key) != end(); }
|
||||
};
|
||||
|
||||
|
@ -178,6 +185,12 @@ public:
|
|||
mouse_wheel = 0;
|
||||
}
|
||||
|
||||
void releaseAllKeys()
|
||||
{
|
||||
keyWasReleased.append(keyIsDown);
|
||||
keyIsDown.clear();
|
||||
}
|
||||
|
||||
void clearWasKeyPressed()
|
||||
{
|
||||
keyWasPressed.clear();
|
||||
|
@ -263,6 +276,7 @@ public:
|
|||
virtual void step(float dtime) {}
|
||||
|
||||
virtual void clear() {}
|
||||
virtual void releaseAllKeys() {}
|
||||
|
||||
JoystickController joystick;
|
||||
KeyCache keycache;
|
||||
|
@ -395,6 +409,12 @@ public:
|
|||
m_receiver->clearInput();
|
||||
}
|
||||
|
||||
void releaseAllKeys()
|
||||
{
|
||||
joystick.releaseAllKeys();
|
||||
m_receiver->releaseAllKeys();
|
||||
}
|
||||
|
||||
private:
|
||||
MyEventReceiver *m_receiver = nullptr;
|
||||
v2s32 m_mousepos;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue