1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- /*
- * InputDefintion.h
- *
- * Created on: 5 déc. 2020
- * Author: fanch
- */
- #ifndef SRC_INPUTDEFINTION_H_
- #define SRC_INPUTDEFINTION_H_
- #include "utils.h"
- #include "AbsInput.h"
- /**
- * @brief Classe qui représente un type d'input défini dans le JSON. Il permet d'instancier et de
- * configurer les boutons et controllers.
- */
- class InputDefinition
- {
- public:
- InputDefinition(){}
- InputDefinition(const std::string& name, Json::Value& v){
- m_name=name;
- Json::Value root = v["actions"];
- for( Json::Value::const_iterator itr = root.begin() ; itr != root.end() ; itr++ ) {
- std::string k = itr.key().asString();
- Json::Value v = *itr;
- m_actions.push_back(new InputActionList(k, new InputAction("", v)));
- }
- std::string t = v["type"].asString();
- if(t=="BUTTON") m_type=BUTTON;
- if(t=="CONTROLLER") m_type=CONTROLLER;
- }
- virtual ~InputDefinition(){
- int s = m_actions.size();
- for(int i=0; i<s; i++) delete m_actions[i];
- }
- AbsInput* instanciate(PadDefinition* p, Json::Value& v);
- protected:
- std::string m_name;
- InputType m_type;
- std::vector<InputActionList*> m_actions;
- friend class PadDefinition;
- };
- #endif /* SRC_INPUTDEFINTION_H_ */
|