Added love.focus callback

This commit is contained in:
Bart van Strien
2010-08-03 13:51:19 +02:00
parent 93910940da
commit 5235ceac53
7 changed files with 990 additions and 957 deletions
+1
View File
@@ -8,6 +8,7 @@ LOVE 0.7.0
* Added Font:getWrap.
* Added identity field to love.conf.
* Added love.quit callback.
* Added love.focus callback.
* Added extra meter parameter to love.physics.newWorld.
* Added love.graphics.setIcon.
* Enabled love.filesystem.FileData.
+1
View File
@@ -66,6 +66,7 @@ namespace event
{"mr", Event::TYPE_MOUSE_RELEASED},
{"jp", Event::TYPE_JOYSTICK_PRESSED},
{"jr", Event::TYPE_JOYSTICK_RELEASED},
{"f", Event::TYPE_FOCUS},
{"q", Event::TYPE_QUIT},
};
+7
View File
@@ -44,6 +44,7 @@ namespace event
TYPE_MOUSE_RELEASED,
TYPE_JOYSTICK_RELEASED,
TYPE_JOYSTICK_PRESSED,
TYPE_FOCUS,
TYPE_QUIT,
TYPE_MAX_ENUM = 32
};
@@ -73,6 +74,12 @@ namespace event
love::keyboard::Keyboard::Key k;
unsigned short u;
} keyboard;
struct
{
Type type;
bool f;
} focus;
};
virtual ~Event();
+10
View File
@@ -96,6 +96,12 @@ namespace sdl
m.joystick.button = e.jbutton.button;
m.joystick.index = e.jbutton.which;
return true;
case SDL_ACTIVEEVENT:
if (e.active.state & SDL_APPINPUTFOCUS) {
m.type = Event::TYPE_FOCUS;
m.focus.f = e.active.gain;
return true;
} else break;
case SDL_QUIT:
m.type = Event::TYPE_QUIT;
return true;
@@ -127,6 +133,10 @@ namespace sdl
e.jbutton.which = m.joystick.index;
e.jbutton.button = m.joystick.button;
return true;
case Event::TYPE_FOCUS:
e.type = SDL_ACTIVEEVENT;
e.active.state = SDL_APPINPUTFOCUS;
e.active.gain = m.focus.f;
case Event::TYPE_QUIT:
e.type = SDL_QUIT;
return true;
+6
View File
@@ -64,6 +64,9 @@ namespace sdl
msg.joystick.index = luaL_checkint(L, 2);
msg.joystick.button = luaL_checkint(L, 3);
return true;
case Event::TYPE_FOCUS:
msg.focus.f = lua_toboolean(L, 2);
return true;
case Event::TYPE_QUIT:
return true;
default:
@@ -108,6 +111,9 @@ namespace sdl
lua_pushinteger(L, msg.joystick.index);
lua_pushinteger(L, msg.joystick.button);
return 3;
case Event::TYPE_FOCUS:
lua_pushboolean(L, msg.focus.f);
return 2;
case Event::TYPE_QUIT:
return 1;
default:
+3
View File
@@ -170,6 +170,9 @@ function love.createhandlers()
jr = function (j,b)
if love.joystickreleased then love.joystickreleased(j,b) end
end,
f = function (f)
if love.focus then love.focus(f) end
end,
q = function ()
return
end,
+947 -942
View File
File diff suppressed because it is too large Load Diff