First scan through joystickcamerastates code, to try to mak eit a bit easier to understand

The "camera states" will now be considered the velocity variables from `CameraInteractionState`
This commit is contained in:
Emma Broman
2025-12-16 16:12:11 +01:00
parent 0923f46cc8
commit 0c19f651d8
2 changed files with 87 additions and 66 deletions

View File

@@ -116,8 +116,10 @@ public:
int button) const;
private:
struct JoystickCameraState {
std::string joystickName;
// There is one of these structs for each connected joystick, describing the orbital
// input mapping for that given joystick
struct Joystick {
std::string name;
// We use a vector for the axes and a map for the buttons since the axis are going
// to be accessed much more often and thus have to be more efficient
@@ -144,16 +146,28 @@ private:
std::multimap<int, ButtonInformation> buttonMapping;
};
std::vector<JoystickCameraState> _joystickCameraStates;
// There may be multiple joysticks connected, each with their own state and mapping
std::vector<Joystick> _joysticks;
// Find the item in _joystickCameraStates that corresponds to the given joystickName
// return a pointer to the item, if not found then return nullptr
JoystickCameraState* joystickCameraState(const std::string& joystickName);
const JoystickCameraState* joystickCameraState(const std::string& joystickName) const;
/**
* Get the mapped information for a given joystick.
*
* \param joystickName The name of the joystick to get the mapping for
* \return The joystick mapping information, or nullptr if no mapping exists
*/
Joystick* joystickMapping(const std::string& joystickName);
const Joystick* joystickMapping(const std::string& joystickName) const;
// Ues getJoystickCameraState(name) to find the joystickCameraState that
// corresponds to the given joystickName. If not found then add a new item if possible
JoystickCameraState* findOrAddJoystickCameraState(const std::string& joystickName);
/**
* Find the mapped information for a joystick if it exists. Otherwise, add a new
* joystick with the provided name, if possible (i.e. if there is not already the
* maximum number of joysticks connected).
*
* \param joystickName The name of the joystick to find or add
* \return The joystick mapping information for either the found or added joystick,
* or nullptr if the joystick could not be added
*/
Joystick* findOrAddJoystickMapping(const std::string& joystickName);
};
} // namespace openspace::interaction