2020-04-08 06:55:35 +00:00
|
|
|
#ifndef MWINPUT_MWSENSORMANAGER_H
|
|
|
|
#define MWINPUT_MWSENSORMANAGER_H
|
|
|
|
|
|
|
|
#include <SDL_sensor.h>
|
|
|
|
|
2022-01-19 16:01:43 +00:00
|
|
|
#include <osg/Matrixf>
|
|
|
|
#include <osg/Vec3f>
|
|
|
|
|
2020-04-08 06:55:35 +00:00
|
|
|
#include <components/settings/settings.hpp>
|
|
|
|
#include <components/sdlutil/events.hpp>
|
|
|
|
|
|
|
|
namespace SDLUtil
|
|
|
|
{
|
|
|
|
class InputWrapper;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace MWWorld
|
|
|
|
{
|
|
|
|
class Player;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace MWInput
|
|
|
|
{
|
|
|
|
class SensorManager : public SDLUtil::SensorListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SensorManager();
|
|
|
|
|
|
|
|
virtual ~SensorManager();
|
|
|
|
|
|
|
|
void init();
|
|
|
|
|
2020-04-17 11:41:52 +00:00
|
|
|
void update(float dt);
|
2020-04-08 06:55:35 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void sensorUpdated(const SDL_SensorEvent &arg) override;
|
|
|
|
void displayOrientationChanged() override;
|
2020-04-08 06:55:35 +00:00
|
|
|
void processChangedSettings(const Settings::CategorySettingVector& changed);
|
|
|
|
|
2022-01-18 20:10:35 +00:00
|
|
|
bool isGyroAvailable() const;
|
|
|
|
std::array<float, 3> getGyroValues() const;
|
|
|
|
|
2020-04-08 06:55:35 +00:00
|
|
|
private:
|
|
|
|
|
2020-04-16 07:03:34 +00:00
|
|
|
void updateSensors();
|
|
|
|
void correctGyroscopeAxes();
|
2020-04-08 06:55:35 +00:00
|
|
|
|
2022-01-19 16:01:43 +00:00
|
|
|
osg::Matrixf mRotation;
|
|
|
|
osg::Vec3f mGyroValues;
|
2020-04-08 06:55:35 +00:00
|
|
|
float mGyroUpdateTimer;
|
|
|
|
|
|
|
|
SDL_Sensor* mGyroscope;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|