Evdev joystick plugin
[lsnes.git] / lua / movie.cpp
blobaf1b19b8bd88dc43318d986a333de09e1e0a9ff2
1 #include "lua-int.hpp"
2 #include "movie.hpp"
3 #include "moviedata.hpp"
5 namespace
7 function_ptr_luafun mcurframe("movie.currentframe", [](lua_State* LS, const std::string& fname) -> int {
8 auto& m = get_movie();
9 lua_pushnumber(LS, m.get_current_frame());
10 return 1;
11 });
13 function_ptr_luafun mfc("movie.framecount", [](lua_State* LS, const std::string& fname) -> int {
14 auto& m = get_movie();
15 lua_pushnumber(LS, m.get_frame_count());
16 return 1;
17 });
19 function_ptr_luafun mro("movie.readonly", [](lua_State* LS, const std::string& fname) -> int {
20 auto& m = get_movie();
21 lua_pushboolean(LS, m.readonly_mode() ? 1 : 0);
22 return 1;
23 });
25 function_ptr_luafun mrw("movie.readwrite", [](lua_State* LS, const std::string& fname) -> int {
26 auto& m = get_movie();
27 m.readonly_mode(false);
28 return 0;
29 });
31 function_ptr_luafun mfs("movie.frame_subframes", [](lua_State* LS, const std::string& fname) -> int {
32 uint64_t frame = get_numeric_argument<uint64_t>(LS, 1, "movie.frame_subframes");
33 auto& m = get_movie();
34 lua_pushnumber(LS, m.frame_subframes(frame));
35 return 1;
36 });
38 function_ptr_luafun mrs("movie.read_subframes", [](lua_State* LS, const std::string& fname) -> int {
39 uint64_t frame = get_numeric_argument<uint64_t>(LS, 1, "movie.frame_subframes");
40 uint64_t subframe = get_numeric_argument<uint64_t>(LS, 2, "movie.frame_subframes");
41 auto& m = get_movie();
42 controls_t r = m.read_subframe(frame, subframe);
43 lua_newtable(LS);
44 for(size_t i = 0; i < TOTAL_CONTROLS; i++) {
45 lua_pushnumber(LS, i);
46 lua_pushnumber(LS, r(i));
47 lua_settable(LS, -3);
49 return 1;
50 });