Lua: input.controllertype()
This commit is contained in:
parent
66fca7925c
commit
b06c8cbc09
4 changed files with 121 additions and 1 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
1-Δ4ε1
|
||||
1-Δ5
|
67
manual.lyx
67
manual.lyx
|
@ -2763,6 +2763,31 @@ Set state for entiere controller.
|
|||
args is up to 12 values for indices (overriding values in bitmask if specified).
|
||||
\end_layout
|
||||
|
||||
\begin_layout Subsubsection
|
||||
input.controllertype(number controller)
|
||||
\end_layout
|
||||
|
||||
\begin_layout Standard
|
||||
Get the type of controller as string.
|
||||
Valid values are:
|
||||
\end_layout
|
||||
|
||||
\begin_layout Itemize
|
||||
gamepad
|
||||
\end_layout
|
||||
|
||||
\begin_layout Itemize
|
||||
mouse
|
||||
\end_layout
|
||||
|
||||
\begin_layout Itemize
|
||||
justifier
|
||||
\end_layout
|
||||
|
||||
\begin_layout Itemize
|
||||
superscope
|
||||
\end_layout
|
||||
|
||||
\begin_layout Subsubsection
|
||||
input.reset([number cycles])
|
||||
\end_layout
|
||||
|
@ -5845,5 +5870,47 @@ rr1-delta4epsilon1
|
|||
Don't corrupt movie if movie length is integer multiple of frames per page.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Subsection
|
||||
rr1-delta5
|
||||
\end_layout
|
||||
|
||||
\begin_layout Itemize
|
||||
New Lua hooks: on_rewind, on_frame_emulated, on_idle, on_timer
|
||||
\end_layout
|
||||
|
||||
\begin_layout Itemize
|
||||
New Lua functions: emulator_ready(), utime(), set_idle_timeout(), set_timer_time
|
||||
out(), bit.extract(), bit.value(), input.geta(), input.seta() and input.controllertyp
|
||||
e()
|
||||
\end_layout
|
||||
|
||||
\begin_layout Itemize
|
||||
Wxwidgets: Fix internal focus lost (hotkeys stop working)
|
||||
\end_layout
|
||||
|
||||
\begin_layout Itemize
|
||||
Wxwidgets: Fix broken modifiers
|
||||
\end_layout
|
||||
|
||||
\begin_layout Itemize
|
||||
on_paint has parameter now.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Itemize
|
||||
Optional initital fill for bitmaps
|
||||
\end_layout
|
||||
|
||||
\begin_layout Itemize
|
||||
Fix palette changing.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Itemize
|
||||
Optimize rendering a bit.
|
||||
\end_layout
|
||||
|
||||
\begin_layout Itemize
|
||||
Bsnes v087 support.
|
||||
\end_layout
|
||||
|
||||
\end_body
|
||||
\end_document
|
||||
|
|
24
manual.txt
24
manual.txt
|
@ -2879,3 +2879,27 @@ set-axis joystick0axis19 disabled
|
|||
• Don't corrupt movie if movie length is integer multiple of
|
||||
frames per page.
|
||||
|
||||
15.53 rr1-delta5
|
||||
|
||||
• New Lua hooks: on_rewind, on_frame_emulated, on_idle, on_timer
|
||||
|
||||
• New Lua functions: emulator_ready(), utime(),
|
||||
set_idle_timeout(), set_timer_timeout(), bit.extract(),
|
||||
bit.value(), input.geta(), input.seta()
|
||||
|
||||
• Wxwidgets: Fix internal focus lost (hotkeys stop working)
|
||||
|
||||
• Wxwidgets: Fix broken modifiers
|
||||
|
||||
• on_paint has parameter now.
|
||||
|
||||
• Optional initital fill for bitmaps
|
||||
|
||||
• Fix palette changing.
|
||||
|
||||
• Optimize rendering a bit.
|
||||
|
||||
• Bsnes v087 support.
|
||||
|
||||
•
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "core/keymapper.hpp"
|
||||
#include "core/lua-int.hpp"
|
||||
#include "core/movie.hpp"
|
||||
#include "core/moviedata.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -58,6 +60,33 @@ namespace
|
|||
return MAX_CONTROLS_PER_CONTROLLER + 1;
|
||||
});
|
||||
|
||||
function_ptr_luafun igett("input.controllertype", [](lua_State* LS, const std::string& fname) -> int {
|
||||
unsigned controller = get_numeric_argument<unsigned>(LS, 1, fname.c_str());
|
||||
auto& m = get_movie();
|
||||
controller_frame f = m.read_subframe(m.get_current_frame(), 0);
|
||||
porttype_t p = f.get_port_type(controller / MAX_CONTROLLERS_PER_PORT);
|
||||
const porttype_info& i = porttype_info::lookup(p);
|
||||
if(i.controllers <= controller % MAX_CONTROLLERS_PER_PORT)
|
||||
lua_pushnil(LS);
|
||||
else if(p == PT_NONE)
|
||||
lua_pushnil(LS);
|
||||
else if(p == PT_GAMEPAD)
|
||||
lua_pushstring(LS, "gamepad");
|
||||
else if(p == PT_MULTITAP)
|
||||
lua_pushstring(LS, "gamepad");
|
||||
else if(p == PT_MOUSE)
|
||||
lua_pushstring(LS, "mouse");
|
||||
else if(p == PT_SUPERSCOPE)
|
||||
lua_pushstring(LS, "superscope");
|
||||
else if(p == PT_JUSTIFIER)
|
||||
lua_pushstring(LS, "justifier");
|
||||
else if(p == PT_JUSTIFIERS)
|
||||
lua_pushstring(LS, "justifier");
|
||||
else
|
||||
lua_pushstring(LS, "unknown");
|
||||
return 1;
|
||||
});
|
||||
|
||||
function_ptr_luafun ireset("input.reset", [](lua_State* LS, const std::string& fname) -> int {
|
||||
if(!lua_input_controllerdata)
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue