3 * Interface definition for encapsulated commands.
4 * Started Spring 2001 by David Megginson, david@megginson.com
5 * This code is released into the Public Domain.
10 #ifndef __SGBINDING_HXX
11 #define __SGBINDING_HXX
14 #include <simgear/compiler.h>
20 #include <simgear/props/props.hxx>
21 #include <simgear/props/condition.hxx>
23 #include "commands.hxx"
26 * An input binding of some sort.
28 * <p>This class represents a binding that can be assigned to a
29 * keyboard key, a joystick button or axis, or even a panel
32 class SGBinding : public SGConditional
37 * Default constructor.
43 * Convenience constructor.
45 * @param node The binding will be built from this node.
47 SGBinding (const SGPropertyNode * node, SGPropertyNode* root);
53 virtual ~SGBinding ();
57 * Get the command name.
59 * @return The string name of the command for this binding.
61 const std::string &getCommandName () const { return _command_name; }
65 * Get the command itself.
67 * @return The command associated with this binding, or 0 if none
70 SGCommandMgr::command_t getCommand () const { return _command; }
74 * Get the argument that will be passed to the command.
76 * @return A property node that will be passed to the command as its
77 * argument, or 0 if none was supplied.
79 const SGPropertyNode * getArg () { return _arg; }
83 * Read a binding from a property node.
85 * @param node The property node containing the binding.
87 void read (const SGPropertyNode * node, SGPropertyNode* root);
97 * Fire a binding with a scaled movement (rather than absolute position).
99 void fire (double offset, double max) const;
103 * Fire a binding with a setting (i.e. joystick axis).
105 * A double 'setting' property will be added to the arguments.
107 * @param setting The input setting, usually between -1.0 and 1.0.
109 void fire (double setting) const;
114 SGBinding (const SGBinding &binding);
116 std::string _command_name;
117 mutable SGCommandMgr::command_t _command;
118 mutable SGPropertyNode_ptr _arg;
119 mutable SGPropertyNode_ptr _setting;
122 typedef std::vector<SGSharedPtr<SGBinding> > SGBindingList;
123 typedef std::map<unsigned,SGBindingList> SGBindingMap;