mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Automated formatting fix
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
@@ -36,7 +36,7 @@ namespace keyboard
|
||||
return keys.find(in, out);
|
||||
}
|
||||
|
||||
StringMap<Keyboard::Key, Keyboard::KEY_MAX_ENUM>::Entry Keyboard::keyEntries[] =
|
||||
StringMap<Keyboard::Key, Keyboard::KEY_MAX_ENUM>::Entry Keyboard::keyEntries[] =
|
||||
{
|
||||
{"backspace", Keyboard::KEY_BACKSPACE},
|
||||
{"tab", Keyboard::KEY_TAB},
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace sdl
|
||||
{
|
||||
SDLKey k;
|
||||
Uint8 * keystate = SDL_GetKeyState(0);
|
||||
|
||||
|
||||
for (Key key = *keylist; key != KEY_MAX_ENUM; key = *(++keylist))
|
||||
{
|
||||
if (keys.find(key, k) && keystate[(unsigned)k] == 1)
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
|
||||
@@ -1,106 +1,106 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#include <common/config.h>
|
||||
|
||||
#include "wrap_Keyboard.h"
|
||||
|
||||
#include "sdl/Keyboard.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace keyboard
|
||||
{
|
||||
static Keyboard * instance;
|
||||
|
||||
int w_isDown(lua_State * L)
|
||||
{
|
||||
Keyboard::Key k;
|
||||
unsigned int num = lua_gettop(L);
|
||||
Keyboard::Key * keylist = new Keyboard::Key[num+1];
|
||||
unsigned int counter = 0;
|
||||
|
||||
for (unsigned int i = 0; i < num; i++)
|
||||
{
|
||||
if(Keyboard::getConstant(luaL_checkstring(L, i+1), k))
|
||||
keylist[counter++] = k;
|
||||
}
|
||||
keylist[counter] = Keyboard::KEY_MAX_ENUM;
|
||||
|
||||
luax_pushboolean(L, instance->isDown(keylist));
|
||||
delete[] keylist;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_setKeyRepeat(lua_State * L)
|
||||
{
|
||||
if(lua_gettop(L) == 0)
|
||||
{
|
||||
// Disables key repeat.
|
||||
instance->setKeyRepeat(0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
instance->setKeyRepeat(luaL_optint(L, 1, Keyboard::DEFAULT), luaL_optint(L, 2, Keyboard::DEFAULT));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_getKeyRepeat(lua_State * L)
|
||||
{
|
||||
lua_pushnumber(L, instance->getKeyRepeatDelay());
|
||||
lua_pushnumber(L, instance->getKeyRepeatInterval());
|
||||
return 2;
|
||||
}
|
||||
|
||||
// List of functions to wrap.
|
||||
static const luaL_Reg functions[] = {
|
||||
{ "isDown", w_isDown },
|
||||
{ "setKeyRepeat", w_setKeyRepeat },
|
||||
{ "getKeyRepeat", w_getKeyRepeat },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int luaopen_love_keyboard(lua_State * L)
|
||||
{
|
||||
if(instance == 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
instance = new love::keyboard::sdl::Keyboard();
|
||||
}
|
||||
catch(Exception & e)
|
||||
{
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
}
|
||||
else
|
||||
instance->retain();
|
||||
|
||||
WrappedModule w;
|
||||
w.module = instance;
|
||||
w.name = "keyboard";
|
||||
w.flags = MODULE_T;
|
||||
w.functions = functions;
|
||||
w.types = 0;
|
||||
|
||||
return luax_register_module(L, w);
|
||||
}
|
||||
} // keyboard
|
||||
} // love
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#include <common/config.h>
|
||||
|
||||
#include "wrap_Keyboard.h"
|
||||
|
||||
#include "sdl/Keyboard.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace keyboard
|
||||
{
|
||||
static Keyboard * instance;
|
||||
|
||||
int w_isDown(lua_State * L)
|
||||
{
|
||||
Keyboard::Key k;
|
||||
unsigned int num = lua_gettop(L);
|
||||
Keyboard::Key * keylist = new Keyboard::Key[num+1];
|
||||
unsigned int counter = 0;
|
||||
|
||||
for (unsigned int i = 0; i < num; i++)
|
||||
{
|
||||
if (Keyboard::getConstant(luaL_checkstring(L, i+1), k))
|
||||
keylist[counter++] = k;
|
||||
}
|
||||
keylist[counter] = Keyboard::KEY_MAX_ENUM;
|
||||
|
||||
luax_pushboolean(L, instance->isDown(keylist));
|
||||
delete[] keylist;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_setKeyRepeat(lua_State * L)
|
||||
{
|
||||
if (lua_gettop(L) == 0)
|
||||
{
|
||||
// Disables key repeat.
|
||||
instance->setKeyRepeat(0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
instance->setKeyRepeat(luaL_optint(L, 1, Keyboard::DEFAULT), luaL_optint(L, 2, Keyboard::DEFAULT));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_getKeyRepeat(lua_State * L)
|
||||
{
|
||||
lua_pushnumber(L, instance->getKeyRepeatDelay());
|
||||
lua_pushnumber(L, instance->getKeyRepeatInterval());
|
||||
return 2;
|
||||
}
|
||||
|
||||
// List of functions to wrap.
|
||||
static const luaL_Reg functions[] = {
|
||||
{ "isDown", w_isDown },
|
||||
{ "setKeyRepeat", w_setKeyRepeat },
|
||||
{ "getKeyRepeat", w_getKeyRepeat },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int luaopen_love_keyboard(lua_State * L)
|
||||
{
|
||||
if (instance == 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
instance = new love::keyboard::sdl::Keyboard();
|
||||
}
|
||||
catch (Exception & e)
|
||||
{
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
}
|
||||
else
|
||||
instance->retain();
|
||||
|
||||
WrappedModule w;
|
||||
w.module = instance;
|
||||
w.name = "keyboard";
|
||||
w.flags = MODULE_T;
|
||||
w.functions = functions;
|
||||
w.types = 0;
|
||||
|
||||
return luax_register_module(L, w);
|
||||
}
|
||||
} // keyboard
|
||||
} // love
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_KEYBOARD_WRAP_KEYBOARD_H
|
||||
#define LOVE_KEYBOARD_WRAP_KEYBOARD_H
|
||||
|
||||
// LOVE
|
||||
#include "Keyboard.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace keyboard
|
||||
{
|
||||
int w_isDown(lua_State * L);
|
||||
int w_setKeyRepeat(lua_State * L);
|
||||
int w_getKeyRepeat(lua_State * L);
|
||||
extern "C" LOVE_EXPORT int luaopen_love_keyboard(lua_State * L);
|
||||
} // keyboard
|
||||
} // love
|
||||
|
||||
#endif // LOVE_KEYBOARD_WRAP_KEYBOARD_H
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
* appreciated but is not required.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_KEYBOARD_WRAP_KEYBOARD_H
|
||||
#define LOVE_KEYBOARD_WRAP_KEYBOARD_H
|
||||
|
||||
// LOVE
|
||||
#include "Keyboard.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace keyboard
|
||||
{
|
||||
int w_isDown(lua_State * L);
|
||||
int w_setKeyRepeat(lua_State * L);
|
||||
int w_getKeyRepeat(lua_State * L);
|
||||
extern "C" LOVE_EXPORT int luaopen_love_keyboard(lua_State * L);
|
||||
} // keyboard
|
||||
} // love
|
||||
|
||||
#endif // LOVE_KEYBOARD_WRAP_KEYBOARD_H
|
||||
|
||||
Reference in New Issue
Block a user