2011-08-03 20:05:33 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2007, 2010 - Bit-Blot
|
|
|
|
|
|
|
|
This file is part of Aquaria.
|
|
|
|
|
|
|
|
Aquaria is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program 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 General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
2012-09-23 02:51:13 +00:00
|
|
|
#ifndef ACTIONSET_H
|
|
|
|
#define ACTIONSET_H
|
2011-08-03 20:05:33 +00:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
#include "ActionInput.h"
|
|
|
|
|
2020-08-11 10:04:15 +00:00
|
|
|
class InputMapper;
|
2011-08-03 20:05:33 +00:00
|
|
|
class Event;
|
|
|
|
|
2016-07-17 03:54:09 +00:00
|
|
|
const int ACTIONSET_REASSIGN_JOYSTICK = -2;
|
|
|
|
|
2016-07-15 01:22:27 +00:00
|
|
|
struct JoystickConfig
|
|
|
|
{
|
|
|
|
JoystickConfig();
|
2017-01-20 03:51:38 +00:00
|
|
|
unsigned int s1ax, s1ay, s2ax, s2ay;
|
2016-07-15 01:22:27 +00:00
|
|
|
float s1dead, s2dead;
|
|
|
|
};
|
|
|
|
|
2020-08-11 10:04:15 +00:00
|
|
|
// One ActionSet is a serializable configuration of input mappings.
|
2011-08-03 20:05:33 +00:00
|
|
|
class ActionSet
|
|
|
|
{
|
2020-08-11 10:04:15 +00:00
|
|
|
typedef std::vector<ActionInput> ActionInputSet;
|
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
public:
|
2016-07-15 01:22:27 +00:00
|
|
|
ActionSet();
|
2020-08-11 16:02:19 +00:00
|
|
|
ActionSet(const ActionSet& o);
|
|
|
|
~ActionSet();
|
|
|
|
void initPlayer(unsigned playerID); // call after finishing up
|
|
|
|
|
|
|
|
// runtime binds
|
|
|
|
void bindAction(const std::string& name, unsigned action);
|
|
|
|
void clearBoundActions();
|
2016-07-15 01:22:27 +00:00
|
|
|
|
2016-07-17 03:54:09 +00:00
|
|
|
int assignJoystickByName(bool force); // -1 if no such joystick found
|
|
|
|
void assignJoystickIdx(int idx, bool updateValues);
|
2016-07-19 00:45:56 +00:00
|
|
|
|
2020-08-11 16:02:19 +00:00
|
|
|
bool getDeviceID(unsigned field, unsigned& deviceID) const;
|
|
|
|
|
2016-07-19 00:45:56 +00:00
|
|
|
// note: this only ENABLES joysticks if they are needed, but never disables any
|
2016-07-16 20:08:39 +00:00
|
|
|
void updateJoystick();
|
2011-08-03 20:05:33 +00:00
|
|
|
|
2020-08-11 10:04:15 +00:00
|
|
|
ActionInput& ensureActionInput(const std::string &name);
|
|
|
|
const ActionInput *getActionInputByName(const std::string &name) const;
|
2011-08-03 20:05:33 +00:00
|
|
|
|
2020-08-11 10:04:15 +00:00
|
|
|
int joystickID; // >= 0: use that, -1 = no joystick, or ACTIONSET_REASSIGN_JOYSTICK
|
2016-07-15 01:22:27 +00:00
|
|
|
|
|
|
|
// --- Saved in config ---
|
2020-08-11 16:02:19 +00:00
|
|
|
struct Config
|
|
|
|
{
|
|
|
|
ActionInputSet inputSet;
|
|
|
|
JoystickConfig joycfg;
|
|
|
|
std::string joystickName;
|
|
|
|
std::string joystickGUID;
|
|
|
|
std::string name;
|
|
|
|
bool enabled;
|
|
|
|
} cfg;
|
2016-07-15 01:22:27 +00:00
|
|
|
// -----------------------
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2016-06-30 00:58:55 +00:00
|
|
|
//std::string insertInputIntoString(const std::string &string);
|
2016-07-15 01:22:27 +00:00
|
|
|
private:
|
2016-07-16 20:08:39 +00:00
|
|
|
int _whichJoystickForName(); // -1 if no such joystick found
|
2020-08-11 16:02:19 +00:00
|
|
|
|
|
|
|
InputMapper *_inputmapper;
|
2011-08-03 20:05:33 +00:00
|
|
|
};
|
2012-09-23 02:51:13 +00:00
|
|
|
|
|
|
|
#endif
|