Merge branch 'rr1-maint'

Conflicts:
	src/lua/input.cpp
This commit is contained in:
Ilari Liusvaara 2012-03-10 08:20:59 +02:00
commit b3d3bc5afa
6 changed files with 163 additions and 5 deletions

View file

@ -1 +1 @@
1-Δ4ε1
1-Δ5

View file

@ -2184,6 +2184,16 @@ There are two special bit positions, true and false, standing for always
set bit and always clear bit.
\end_layout
\begin_layout Subsubsection
bit.value([number bit1[, number bit2,...]])
\end_layout
\begin_layout Standard
Returns bitwise OR of 1 left shifted by bit1 places, 1 left shifted by bit2
places and so on.
As special value, nil argument is no-op.
\end_layout
\begin_layout Subsection
Table gui:
\end_layout
@ -2482,7 +2492,7 @@ Returns a new palette (initially all transparent).
\end_layout
\begin_layout Subsubsection
gui.bitmap_new(number w, number h, boolean direct)
gui.bitmap_new(number w, number h, boolean direct[, bool icolor])
\end_layout
\begin_layout Standard
@ -2503,6 +2513,10 @@ h: The height of new bitmap
direct: If true, the returned bitmap is dbitmap, otherwise bitmap.
\end_layout
\begin_layout Itemize
icolor: Initital fill color (defaults to 0 on BITMAP, -1 on DBITMAP)
\end_layout
\begin_layout Subsubsection
gui.bitmap_load(string file)
\end_layout
@ -2770,6 +2784,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
@ -5852,5 +5891,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

View file

@ -1060,6 +1060,12 @@ Notes:
• There are two special bit positions, true and false, standing
for always set bit and always clear bit.
8.2.11 bit.value([number bit1[, number bit2,...]])
Returns bitwise OR of 1 left shifted by bit1 places, 1 left
shifted by bit2 places and so on. As special value, nil argument
is no-op.
8.3 Table gui:
Most of these functions can only be called in on_paint and
@ -1217,7 +1223,8 @@ Draw a bitmap on screen. Parameters:
Returns a new palette (initially all transparent). Can be used
anywhere.
8.3.15 gui.bitmap_new(number w, number h, boolean direct)
8.3.15 gui.bitmap_new(number w, number h, boolean direct[, bool
icolor])
Returns a new bitmap/dbitmap. Can be used anywhere. Parameters:
@ -1228,6 +1235,9 @@ Returns a new bitmap/dbitmap. Can be used anywhere. Parameters:
• direct: If true, the returned bitmap is dbitmap, otherwise
bitmap.
• icolor: Initital fill color (defaults to 0 on BITMAP, -1 on
DBITMAP)
8.3.16 gui.bitmap_load(string file)
Returns loaded bitmap/dbitmap (if bitmap, the second return value
@ -2875,3 +2885,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.

View file

@ -102,7 +102,7 @@ namespace
}
};
function_ptr_luafun lua_print("bit.extract", [](lua_State* LS, const std::string& fname) -> int {
function_ptr_luafun lua_bextract("bit.extract", [](lua_State* LS, const std::string& fname) -> int {
uint64_t num = get_numeric_argument<uint64_t>(LS, 1, fname.c_str());
uint64_t ret = 0;
for(size_t i = 0;; i++) {
@ -119,6 +119,20 @@ namespace
return 1;
});
function_ptr_luafun lua_bvalue("bit.value", [](lua_State* LS, const std::string& fname) -> int {
uint64_t ret = 0;
for(size_t i = 0;; i++) {
if(lua_isnumber(LS, i + 1)) {
uint8_t bit = get_numeric_argument<uint8_t>(LS, i + 1, fname.c_str());
ret |= (1ULL << bit);
} else if(lua_isnil(LS, i + 1)) {
} else
break;
}
lua_pushnumber(LS, ret);
return 1;
});
lua_symmetric_bitwise<combine_none, BITWISE_MASK> bit_none("bit.none");
lua_symmetric_bitwise<combine_none, BITWISE_MASK> bit_bnot("bit.bnot");
lua_symmetric_bitwise<combine_any, 0> bit_any("bit.any");

View file

@ -1,5 +1,7 @@
#include "core/keymapper.hpp"
#include "lua/internal.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;

View file

@ -65,7 +65,7 @@ int main(int argc, char** argv)
std::cout << "Console: " << name_romtype(rtype) << std::endl;
std::cout << "Region: " << name_region(reg) << std::endl;
std::cout << "Port #1: " << name_porttype(m.port1) << std::endl;
std::cout << "Port #2: " << name_porttype(m.port1) << std::endl;
std::cout << "Port #2: " << name_porttype(m.port2) << std::endl;
std::cout << "Used emulator core: " << escape_string(m.coreversion) << std::endl;
if(m.gamename != "")
std::cout << "Game name: " << escape_string(m.gamename) << std::endl;