Show Input.h syntax highlighted
/**
**************************************************************************************
*Palisma - Secrets of the Illuminati is an open-source 2D RPG *
*Copyright (C) 2006, Tony Sparks *
* *
*This library is free software; you can redistribute it and/or *
*modify it under the terms of the GNU Lesser General Public *
*License as published by the Free Software Foundation; either *
*version 2.1 of the License, or (at your option) any later version. *
* *
*This library is distributed in the hope that it will be useful, *
*but WITHOUT ANY WARRANTY; without even the implied warranty of *
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
*Lesser General Public License for more details. *
* *
*You should have received a copy of the GNU Lesser General Public *
*License along with this library; if not, write to the Free Software *
*Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
**************************************************************************************
*/
#pragma once
#include "iinput.h"
#include "sdl.h"
#include <map>
#include <string>
/**
* Definitions
*/
#define MAX_KEYS 333
#define MAX_BUTTONS 4
#define MAX_JOYSTICKBUTTONS 10
#define NEXT_TIME 400
/**
=============================
A key representation
=============================
*/
typedef struct {
bool isDown;
bool Released;
long TimeStamp;
long NextTime;
} Key;
/**
* Input subsystem
*/
class Input : public IInput
{
public:
Input(void);
int Init();
void Update(long dt);
void Shutdown();
/*----------------------------
Handle Joystick Input
-----------------------------*/
int CheckJoystick();
void EnableJoystick();
int GetJoystickX();
int GetJoystickY();
int IsJoystickButtonDown(int button, bool stamp=false);
int GetMouseX();
int GetMouseY();
int GetDeltaMX();
int GetDeltaMY();
bool IsKeyDown( int key, bool stamp=false );
bool IsButtonDown( int button, bool stamp=false );
bool KeyReleased( int key );
bool ButtonReleased( int button );
public:
virtual ~Input(void);
private:
// current event
SDL_Event* m_event;
// the joystick
SDL_Joystick* m_joystick;
Key key[MAX_KEYS];
Key joyStickButtons[MAX_JOYSTICKBUTTONS];
bool button[MAX_BUTTONS];
int m_oldx, m_oldy;
int m_x, m_y;
/*------------------------
Key Binding functions
-------------------------*/
Bind_f bind_f;
UnBind_f unbind_f;
UnBindAll_f unbindAll_f;
};
See more files for this project here