Show IInput.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 "../iprocess.h"
#include "../shared/stringutil.h"
#include <map>
#include "inputbuffer.h"
#include "binder.h"
#include "../Console.h"
/**
=============================
Input subsystem interface
=============================
*/
class IInput : public IProcess
{
public:
virtual int Init()=0;
virtual void Update(long dt)=0;
virtual void Shutdown()=0;
/*----------------------------
Handle Joystick Input
-----------------------------*/
virtual int CheckJoystick()=0;
virtual void EnableJoystick()=0;
bool JoystickEnabled() { return m_joystickEnabled; };
virtual int GetJoystickX()=0;
virtual int GetJoystickY()=0;
virtual int IsJoystickButtonDown(int button, bool stamp=false)=0;
virtual int GetMouseX()=0;
virtual int GetMouseY()=0;
virtual int GetDeltaMX()=0;
virtual int GetDeltaMY()=0;
virtual bool IsKeyDown( int key, bool stamp=false )=0;
virtual bool IsButtonDown( int button, bool stamp=false )=0;
virtual bool KeyReleased( int key )=0;
virtual bool ButtonReleased( int button )=0;
InputBuffer* GetInputBuffer(int buffer) {
return buffList[buffer];
};
Binder* GetBinder() { return &m_binder; };
/**
=============================
Activate a desired buffer
=============================
*/
void ActivateBuffer(int i) {
if ( buffList.empty() )
return;
if ( i > buffList.size() )
{
i = 0;
}
m_current = i;
// deactivate old buffer
if ( m_currentBuffer )
m_currentBuffer->SetActive( false );
m_currentBuffer = buffList[m_current];
// activate new buffer
if ( m_currentBuffer )
m_currentBuffer->SetActive( true );
};
/** Deactivate a buffer */
void DeactivateBuffer( int buf ) {
if ( buffList.empty() )
return;
if ( buf > buffList.size() )
{
buf = 0;
} buffList[buf]->SetActive( false );
};
/** Add a buffer */
void AddBuffer( InputBuffer* b, int buf ) {
if ( buffList.find( buf ) == buffList.end() )
{ buffList[buf] = b;
} else {
if ( buffList[buf] )
{ delete buffList[buf]; }
buffList[buf] = b;
}
};
void RemoveBuffer( int buf ) {
buffList.erase( buf );
}
AUTO_SIZE;
private:
Binder m_binder;
protected:
// current buffer number
int m_current;
// ref to current buffer
InputBuffer* m_currentBuffer;
// buff list
std::map<int, InputBuffer* > buffList;
// if joystick is availible
bool m_joystickEnabled;
};
/**
=============================
Bind a command with a key
=============================
*/
class Bind_f : public ICommand
{
public:
Bind_f() {};
void Exec(std::string &s);
~Bind_f() {};
};
/**
=============================
UnBind a command with a key
=============================
*/
class UnBind_f : public ICommand
{
public:
UnBind_f() {};
void Exec(std::string &s);
~UnBind_f() {};
};
/**
=============================
UnBindAll a command with a key
=============================
*/
class UnBindAll_f : public ICommand
{
public:
UnBindAll_f() {};
void Exec(std::string &s);
~UnBindAll_f() {};
};
See more files for this project here