mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Abstractify some modules completely: timer, keyboard and mouse.
If this commit breaks some project file(s), well ... I AM RUDE AND I WILL BREAK EVERYTHING, AHAHAHAHAHAHAHHAHAHAHAHA!
This commit is contained in:
@@ -18,13 +18,14 @@
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#include <common/config.h>
|
||||
|
||||
#include "Keyboard.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace keyboard
|
||||
{
|
||||
|
||||
bool Keyboard::getConstant(const char * in, Keyboard::Key & out)
|
||||
{
|
||||
return keys.find(in, out);
|
||||
|
||||
@@ -184,6 +184,32 @@ namespace keyboard
|
||||
|
||||
virtual ~Keyboard(){}
|
||||
|
||||
/**
|
||||
* Checks whether a certain key is down or not.
|
||||
* @param key A key identifier.
|
||||
* @return boolean
|
||||
**/
|
||||
virtual bool isDown(Key * keylist) const = 0;
|
||||
|
||||
/**
|
||||
* Enables key repeating.
|
||||
* @param delay The amount of delay before repeating the key (in milliseconds)
|
||||
* @param interval Specifies the amount of time between repeats (in milliseconds)
|
||||
**/
|
||||
virtual void setKeyRepeat(int delay, int interval) const = 0;
|
||||
|
||||
/**
|
||||
* Gets the specified delay for the key repeat.
|
||||
* @return int
|
||||
**/
|
||||
virtual int getKeyRepeatDelay() const = 0;
|
||||
|
||||
/**
|
||||
* Gets the specified interval for the key repeat.
|
||||
* @return int
|
||||
**/
|
||||
virtual int getKeyRepeatInterval() const = 0;
|
||||
|
||||
static bool getConstant(const char * in, Key & out);
|
||||
static bool getConstant(Key in, const char *& out);
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#include <common/config.h>
|
||||
|
||||
#include "Keyboard.h"
|
||||
|
||||
namespace love
|
||||
|
||||
@@ -40,31 +40,9 @@ namespace sdl
|
||||
|
||||
// Implements Module.
|
||||
const char * getName() const;
|
||||
|
||||
/**
|
||||
* Checks whether a certain key is down or not.
|
||||
* @param key A key identifier.
|
||||
* @return boolean
|
||||
**/
|
||||
bool isDown(Key * keylist) const;
|
||||
|
||||
/**
|
||||
* Enables key repeating.
|
||||
* @param delay The amount of delay before repeating the key (in milliseconds)
|
||||
* @param interval Specifies the amount of time between repeats (in milliseconds)
|
||||
**/
|
||||
void setKeyRepeat(int delay, int interval) const;
|
||||
|
||||
/**
|
||||
* Gets the specified delay for the key repeat.
|
||||
* @return int
|
||||
**/
|
||||
int getKeyRepeatDelay() const;
|
||||
|
||||
/**
|
||||
* Gets the specified interval for the key repeat.
|
||||
* @return int
|
||||
**/
|
||||
int getKeyRepeatInterval() const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -18,13 +18,15 @@
|
||||
* 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
|
||||
{
|
||||
namespace sdl
|
||||
{
|
||||
static Keyboard * instance;
|
||||
|
||||
@@ -81,7 +83,7 @@ namespace sdl
|
||||
{
|
||||
try
|
||||
{
|
||||
instance = new Keyboard();
|
||||
instance = new love::keyboard::sdl::Keyboard();
|
||||
}
|
||||
catch(Exception & e)
|
||||
{
|
||||
@@ -100,7 +102,5 @@ namespace sdl
|
||||
|
||||
return luax_register_module(L, w);
|
||||
}
|
||||
|
||||
} // sdl
|
||||
} // keyboard
|
||||
} // love
|
||||
@@ -18,29 +18,21 @@
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_KEYBOARD_SDL_WRAP_KEYBOARD_H
|
||||
#define LOVE_KEYBOARD_SDL_WRAP_KEYBOARD_H
|
||||
#ifndef LOVE_KEYBOARD_WRAP_KEYBOARD_H
|
||||
#define LOVE_KEYBOARD_WRAP_KEYBOARD_H
|
||||
|
||||
// LOVE
|
||||
#include <common/config.h>
|
||||
#include "Keyboard.h"
|
||||
|
||||
// SDL
|
||||
#include <SDL.h>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace keyboard
|
||||
{
|
||||
namespace sdl
|
||||
{
|
||||
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);
|
||||
|
||||
} // sdl
|
||||
} // keyboard
|
||||
} // love
|
||||
|
||||
#endif // LOVE_KEYBOARD_SDL_WRAP_KEYBOARD_H
|
||||
#endif // LOVE_KEYBOARD_WRAP_KEYBOARD_H
|
||||
Reference in New Issue
Block a user