Merged SDL2 changes from bartbes/love-experiments/SDL2 into default.

- Added love.system module, including clipboard functions.

- Added custom hardware cursors (love.mouse.newCursor, love.mouse.setCursor.)

- Revamped love.joystick:
-- added Joystick objects and moved love.joystick functions which operated on individual joysticks to methods on the Joystick objects.
-- Added love.joystick.getJoystick and love.joystick.getJoystickCount.
-- Added events for when joysticks are connected and disconnected.
-- Added 'Gamepad' methods to Joystick objects: Joystick:isGamepad, Joystick:getGamepadAxis, and Joystick:isGamepadDown. They're a common abstraction for xbox controller-like joystick across operating systems.

- Added monitor choosing support and "fullscreen desktop" mode to love.window.

- Moved unicode text input events to their own callback function (love.textinput), removed the key repeat functions from love.keyboard and made the second argument of love.keypressed a boolean saying whether the keypress was a repeat.

- liblove now works with love.window and love.graphics in OS X
This commit is contained in:
Alex Szpakowski
2013-08-25 16:51:42 -03:00
parent 035130533b
commit 113ed1cfe7
67 changed files with 4691 additions and 1665 deletions
+59 -22
View File
@@ -26,7 +26,8 @@
#include "common/EnumMap.h"
// SDL
#include <SDL.h>
#include <SDL_joystick.h>
#include <SDL_gamecontroller.h>
namespace love
{
@@ -37,38 +38,74 @@ namespace sdl
class Joystick : public love::joystick::Joystick
{
private:
SDL_Joystick **joysticks;
public:
Joystick();
Joystick(int id);
Joystick(int id, int joyindex);
virtual ~Joystick();
// Implements Module.
bool open(int deviceindex);
void close();
bool isConnected() const;
const char *getName() const;
void reload();
bool checkIndex(int index);
int getJoystickCount();
const char *getName(int index);
bool open(int index);
bool isOpen(int index);
bool verifyJoystick(int index);
int getAxisCount(int index);
int getButtonCount(int index);
int getHatCount(int index);
float clampval(float x);
float getAxis(int index, int axis);
int getAxes(lua_State *L);
bool isDown(int index, int *buttonlist);
Hat getHat(int index, int hat);
void close(int index);
int getAxisCount() const;
int getButtonCount() const;
int getHatCount() const;
float getAxis(int axisindex) const;
std::vector<float> getAxes() const;
Hat getHat(int hatindex) const;
bool isDown(const std::vector<int> &buttonlist) const;
bool openGamepad(int deviceindex);
bool isGamepad() const;
float getGamepadAxis(GamepadAxis axis) const;
bool isGamepadDown(const std::vector<GamepadButton> &blist) const;
void *getHandle() const;
std::string getGUID() const;
int getInstanceID() const;
int getID() const;
static bool getConstant(Hat in, Uint8 &out);
static bool getConstant(Uint8 in, Hat &out);
static bool getConstant(SDL_GameControllerAxis in, GamepadAxis &out);
static bool getConstant(GamepadAxis in, SDL_GameControllerAxis &out);
static bool getConstant(SDL_GameControllerButton in, GamepadButton &out);
static bool getConstant(GamepadButton in, SDL_GameControllerButton &out);
private:
Joystick() {}
SDL_Joystick *joyhandle;
SDL_GameController *controller;
SDL_JoystickID instanceid;
std::string guid;
int id;
std::string name;
static EnumMap<Hat, Uint8, Joystick::HAT_MAX_ENUM>::Entry hatEntries[];
static EnumMap<Hat, Uint8, Joystick::HAT_MAX_ENUM> hats;
}; // Joystick
static EnumMap<GamepadAxis, SDL_GameControllerAxis, GAMEPAD_AXIS_MAX_ENUM>::Entry gpAxisEntries[];
static EnumMap<GamepadAxis, SDL_GameControllerAxis, GAMEPAD_AXIS_MAX_ENUM> gpAxes;
static EnumMap<GamepadButton, SDL_GameControllerButton, GAMEPAD_BUTTON_MAX_ENUM>::Entry gpButtonEntries[];
static EnumMap<GamepadButton, SDL_GameControllerButton, GAMEPAD_BUTTON_MAX_ENUM> gpButtons;
};
} // sdl
} // joystick