diff --git a/manual.lyx b/manual.lyx index 78c75735..f22834aa 100644 --- a/manual.lyx +++ b/manual.lyx @@ -4039,6 +4039,20 @@ Called each time bsnes asks for input. Note: There is no way to modify the value to be sent. \end_layout +\begin_layout Itemize +Not called if callback on_snoop2 is defined. +\end_layout + +\begin_layout Subsubsection +Callback: on_snoop2(number port, number controller, number index, number + value) +\end_layout + +\begin_layout Standard +Like on_snoop, but reserves port 0 for system, having first user port be + port 1. +\end_layout + \begin_layout Subsubsection Callback: on_keyhook(string keyname, table state) \end_layout diff --git a/manual.txt b/manual.txt index c9c22a52..90748a70 100644 --- a/manual.txt +++ b/manual.txt @@ -2052,31 +2052,39 @@ autofire have been taken into account). Might be useful when translating movies to format suitable for console verification. Note: There is no way to modify the value to be sent. -8.12.18 Callback: on_keyhook(string keyname, table state) +• Not called if callback on_snoop2 is defined. + +8.12.18 Callback: on_snoop2(number port, number controller, + number index, number value) + +Like on_snoop, but reserves port 0 for system, having first user +port be port 1. + +8.12.19 Callback: on_keyhook(string keyname, table state) Sent when key that has keyhook events requested changes state. Keyname is name of the key (group) and state is the state (same kind as table values in input.raw). -8.12.19 Callback: on_idle() +8.12.20 Callback: on_idle() Called when requested by set_idle_timeout(), the timeout has expired and emulator is waiting. -8.12.20 Callback: on_timer() +8.12.21 Callback: on_timer() Called when requested by set_idle_timeout() and the timeout has expired (regardless if emulator is waiting). -8.12.21 Callback: on_set_rewind(UNSAFEREWIND r) +8.12.22 Callback: on_set_rewind(UNSAFEREWIND r) Called when unsafe rewind object has been constructed. -8.12.22 Callback: on_pre_rewind() +8.12.23 Callback: on_pre_rewind() Called just before unsafe rewind is about to occur. -8.12.23 Callback: on_post_rewind() +8.12.24 Callback: on_post_rewind() Called just after unsafe rewind has occured. diff --git a/src/lua/lua.cpp b/src/lua/lua.cpp index 6d8a3bf2..75944ad2 100644 --- a/src/lua/lua.cpp +++ b/src/lua/lua.cpp @@ -488,9 +488,17 @@ void lua_callback_do_input(controller_frame& data, bool subframe) throw() void lua_callback_snoop_input(uint32_t port, uint32_t controller, uint32_t index, short value) throw() { - if(!callback_exists("on_snoop")) + if(!callback_exists("on_snoop2")) { + if(!callback_exists("on_snoop")) + return; + lua_pushnumber(L, port); + lua_pushnumber(L, controller); + lua_pushnumber(L, index); + lua_pushnumber(L, value); + run_lua_cb(4); return; - lua_pushnumber(L, port); + } + lua_pushnumber(L, port + 1); lua_pushnumber(L, controller); lua_pushnumber(L, index); lua_pushnumber(L, value);