From c001f08c1e5b1f6e7ac9eafbdaff69e76333c46e Mon Sep 17 00:00:00 2001 From: npwoods Date: Thu, 18 Jul 2019 22:21:25 -0400 Subject: Making video_manager::effective_frameskip() public and exposing via LUA --- src/frontend/mame/luaengine.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/frontend/mame/luaengine.cpp') diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp index fb42192da11..87d0e1ae34b 100644 --- a/src/frontend/mame/luaengine.cpp +++ b/src/frontend/mame/luaengine.cpp @@ -1849,6 +1849,7 @@ void lua_engine::initialize() "skip_this_frame", &video_manager::skip_this_frame, "speed_factor", &video_manager::speed_factor, "speed_percent", &video_manager::speed_percent, + "effective_frameskip", &video_manager::effective_frameskip, "frame_update", &video_manager::frame_update, "size", [](video_manager &vm) { s32 width, height; -- cgit v1.2.3-70-g09d2 From 3aa9ee49927cd39b1dd7c06eaa1f4851ebf69b08 Mon Sep 17 00:00:00 2001 From: npwoods Date: Fri, 19 Jul 2019 07:47:24 -0400 Subject: Moving paste() from mame_ui_manager class to natural_keyboard class, exposing to LUA --- src/emu/natkeyboard.cpp | 21 +++++++++++++++++++++ src/emu/natkeyboard.h | 1 + src/frontend/mame/luaengine.cpp | 1 + src/frontend/mame/ui/ui.cpp | 23 +---------------------- src/frontend/mame/ui/ui.h | 1 - 5 files changed, 24 insertions(+), 23 deletions(-) (limited to 'src/frontend/mame/luaengine.cpp') diff --git a/src/emu/natkeyboard.cpp b/src/emu/natkeyboard.cpp index 9a50109eb6f..3851d98719e 100644 --- a/src/emu/natkeyboard.cpp +++ b/src/emu/natkeyboard.cpp @@ -564,6 +564,27 @@ void natural_keyboard::post_coded(const char *text, size_t length, const attotim } +//------------------------------------------------- +// paste - does a paste from the keyboard +//------------------------------------------------- + +void natural_keyboard::paste() +{ + // retrieve the clipboard text + char *text = osd_get_clipboard_text(); + + // was a result returned? + if (text != nullptr) + { + // post the text + post_utf8(text); + + // free the string + free(text); + } +} + + //------------------------------------------------- // build_codes - given an input port table, create // an input code table useful for mapping unicode diff --git a/src/emu/natkeyboard.h b/src/emu/natkeyboard.h index aa29bf4503c..b90eeb9d88e 100644 --- a/src/emu/natkeyboard.h +++ b/src/emu/natkeyboard.h @@ -54,6 +54,7 @@ public: void post(const char32_t *text, size_t length = 0, const attotime &rate = attotime::zero); void post_utf8(const char *text, size_t length = 0, const attotime &rate = attotime::zero); void post_coded(const char *text, size_t length = 0, const attotime &rate = attotime::zero); + void paste(); // debugging void dump(std::ostream &str) const; diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp index fb42192da11..1ded924ccfa 100644 --- a/src/frontend/mame/luaengine.cpp +++ b/src/frontend/mame/luaengine.cpp @@ -766,6 +766,7 @@ void lua_engine::initialize() emu["romname"] = [this](){ return machine().basename(); }; emu["softname"] = [this]() { return machine().options().software_name(); }; emu["keypost"] = [this](const char *keys){ machine().ioport().natkeyboard().post_utf8(keys); }; + emu["paste"] = [this](){ machine().ioport().natkeyboard().paste(); }; emu["time"] = [this](){ return machine().time().as_double(); }; emu["start"] = [this](const char *driver) { int i = driver_list::find(driver); diff --git a/src/frontend/mame/ui/ui.cpp b/src/frontend/mame/ui/ui.cpp index 62b84281b02..867a7b8bbf8 100644 --- a/src/frontend/mame/ui/ui.cpp +++ b/src/frontend/mame/ui/ui.cpp @@ -904,27 +904,6 @@ bool mame_ui_manager::can_paste() } -//------------------------------------------------- -// paste - does a paste from the keyboard -//------------------------------------------------- - -void mame_ui_manager::paste() -{ - // retrieve the clipboard text - char *text = osd_get_clipboard_text(); - - // was a result returned? - if (text != nullptr) - { - // post the text - machine().ioport().natkeyboard().post_utf8(text); - - // free the string - free(text); - } -} - - //------------------------------------------------- // draw_fps_counter //------------------------------------------------- @@ -1105,7 +1084,7 @@ uint32_t mame_ui_manager::handler_ingame(render_container &container) { // paste command if (machine().ui_input().pressed(IPT_UI_PASTE)) - paste(); + machine().ioport().natkeyboard().paste(); } image_handler_ingame(); diff --git a/src/frontend/mame/ui/ui.h b/src/frontend/mame/ui/ui.h index 64189344dcb..e54adc80f06 100644 --- a/src/frontend/mame/ui/ui.h +++ b/src/frontend/mame/ui/ui.h @@ -223,7 +223,6 @@ public: void show_mouse(bool status); virtual bool is_menu_active() override; bool can_paste(); - void paste(); void image_handler_ingame(); void increase_frameskip(); void decrease_frameskip(); -- cgit v1.2.3-70-g09d2 From 4c2c3e52ee3a125a50908a4991fabf4adf114493 Mon Sep 17 00:00:00 2001 From: npwoods Date: Sat, 20 Jul 2019 14:49:15 -0400 Subject: Exposed natual_keyboard object to LUA (#5364) --- src/emu/natkeyboard.cpp | 14 ++++++++++++++ src/emu/natkeyboard.h | 2 ++ src/frontend/mame/luaengine.cpp | 19 ++++++++++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-) (limited to 'src/frontend/mame/luaengine.cpp') diff --git a/src/emu/natkeyboard.cpp b/src/emu/natkeyboard.cpp index 3851d98719e..17782815d22 100644 --- a/src/emu/natkeyboard.cpp +++ b/src/emu/natkeyboard.cpp @@ -486,6 +486,13 @@ void natural_keyboard::post_utf8(const char *text, size_t length, const attotime } +void natural_keyboard::post_utf8(const std::string &text, const attotime &rate) +{ + if (!text.empty()) + post_utf8(text.c_str(), text.size(), rate); +} + + //------------------------------------------------- // post_coded - post a coded string //------------------------------------------------- @@ -564,6 +571,13 @@ void natural_keyboard::post_coded(const char *text, size_t length, const attotim } +void natural_keyboard::post_coded(const std::string &text, const attotime &rate) +{ + if (!text.empty()) + post_coded(text.c_str(), text.size(), rate); +} + + //------------------------------------------------- // paste - does a paste from the keyboard //------------------------------------------------- diff --git a/src/emu/natkeyboard.h b/src/emu/natkeyboard.h index b90eeb9d88e..fa3df156285 100644 --- a/src/emu/natkeyboard.h +++ b/src/emu/natkeyboard.h @@ -53,7 +53,9 @@ public: void post(char32_t ch); void post(const char32_t *text, size_t length = 0, const attotime &rate = attotime::zero); void post_utf8(const char *text, size_t length = 0, const attotime &rate = attotime::zero); + void post_utf8(const std::string &text, const attotime &rate = attotime::zero); void post_coded(const char *text, size_t length = 0, const attotime &rate = attotime::zero); + void post_coded(const std::string &text, const attotime &rate = attotime::zero); void paste(); // debugging diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp index 808d4314342..ea5f783c70d 100644 --- a/src/frontend/mame/luaengine.cpp +++ b/src/frontend/mame/luaengine.cpp @@ -766,7 +766,6 @@ void lua_engine::initialize() emu["romname"] = [this](){ return machine().basename(); }; emu["softname"] = [this]() { return machine().options().software_name(); }; emu["keypost"] = [this](const char *keys){ machine().ioport().natkeyboard().post_utf8(keys); }; - emu["paste"] = [this](){ machine().ioport().natkeyboard().paste(); }; emu["time"] = [this](){ return machine().time().as_double(); }; emu["start"] = [this](const char *driver) { int i = driver_list::find(driver); @@ -1672,6 +1671,7 @@ void lua_engine::initialize() sol().registry().new_usertype("ioport", "new", sol::no_constructor, "count_players", &ioport_manager::count_players, + "natkeyboard", &ioport_manager::natkeyboard, "ports", sol::property([this](ioport_manager &im) { sol::table port_table = sol().create_table(); for (auto &port : im.ports()) @@ -1679,6 +1679,23 @@ void lua_engine::initialize() return port_table; })); +/* natkeyboard library + * + * manager:machine():ioport():natkeyboard() + * + * natkeyboard.empty - is the natural keyboard buffer empty? + * natkeyboard.in_use - is the natural keyboard in use? + * natkeyboard:paste() - paste clipboard data + * natkeyboard:post() - post data to natural keyboard + * natkeyboard:post_coded() - post data to natural keyboard + */ + + sol().registry().new_usertype("natkeyboard", "new", sol::no_constructor, + "empty", sol::property(&natural_keyboard::empty), + "in_use", sol::property(&natural_keyboard::in_use, &natural_keyboard::set_in_use), + "paste", &natural_keyboard::paste, + "post", [](natural_keyboard &nat, const std::string &text) { nat.post_utf8(text); }, + "post_coded", [](natural_keyboard &nat, const std::string &text) { nat.post_coded(text); }); /* ioport_port library * -- cgit v1.2.3-70-g09d2