Remove direct emulation thread references from keyboard.cpp
This commit is contained in:
parent
77abaa2d98
commit
c3b1031498
3 changed files with 19 additions and 10 deletions
|
@ -17,6 +17,8 @@ UI services.
|
|||
|
||||
class emulator_instance;
|
||||
class dumper_factory_base;
|
||||
namespace keyboard { class modifier_set; }
|
||||
namespace keyboard { class key_key; }
|
||||
|
||||
struct project_author_info
|
||||
{
|
||||
|
@ -108,5 +110,10 @@ void UI_start_dump(emulator_instance& inst, dumper_factory_base& factory, const
|
|||
* End dumping.
|
||||
*/
|
||||
void UI_end_dump(emulator_instance& inst, dumper_factory_base& factory);
|
||||
/**
|
||||
* Send a keypress event.
|
||||
*/
|
||||
void UI_do_keypress(emulator_instance& inst, const keyboard::modifier_set& mods, keyboard::key_key& key,
|
||||
bool polarity);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "core/project.hpp"
|
||||
#include "core/queue.hpp"
|
||||
#include "core/ui-services.hpp"
|
||||
#include "library/keyboard.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -201,3 +202,12 @@ void UI_end_dump(emulator_instance& inst, dumper_factory_base& factory)
|
|||
delete in;
|
||||
});
|
||||
}
|
||||
|
||||
void UI_do_keypress(emulator_instance& inst, const keyboard::modifier_set& mods, keyboard::key_key& key,
|
||||
bool polarity)
|
||||
{
|
||||
auto _key = &key;
|
||||
inst.iqueue->run_async([mods, _key, polarity]() {
|
||||
_key->set_state(mods, polarity ? 1 : 0);
|
||||
}, [](std::exception& e) {});
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "core/instance.hpp"
|
||||
#include "core/queue.hpp"
|
||||
#include "core/window.hpp"
|
||||
#include "core/ui-services.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
|
@ -265,15 +266,6 @@ namespace
|
|||
std::map<int, keyboard::key_key*> key_map;
|
||||
std::map<std::string, int> keys_allocated;
|
||||
std::set<int> keys_held;
|
||||
|
||||
//Request keypress event to happen.
|
||||
void do_keypress(keyboard::modifier_set mods, keyboard::key_key& key, bool polarity)
|
||||
{
|
||||
auto _key = &key;
|
||||
lsnes_instance.iqueue->run_async([mods, _key, polarity]() {
|
||||
_key->set_state(mods, polarity ? 1 : 0);
|
||||
}, [](std::exception& e) {});
|
||||
}
|
||||
}
|
||||
|
||||
std::string map_keycode_to_key(int kcode)
|
||||
|
@ -323,7 +315,7 @@ void handle_wx_keyboard(wxKeyEvent& e, bool polarity)
|
|||
k++;
|
||||
}
|
||||
if(grp)
|
||||
do_keypress(mset, *grp, polarity);
|
||||
UI_do_keypress(lsnes_instance, mset, *grp, polarity);
|
||||
e.Skip();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue