Implemented sensor API
This commit is contained in:
parent
59c3c2c0b0
commit
7daaaa649e
@ -37,6 +37,7 @@
|
||||
#include <SFML/Window/Keyboard.hpp>
|
||||
#include <SFML/Window/Mouse.hpp>
|
||||
#include <SFML/Window/Touch.hpp>
|
||||
#include <SFML/Window/Sensor.hpp>
|
||||
#include <SFML/Window/VideoMode.hpp>
|
||||
#include <SFML/Window/Window.hpp>
|
||||
#include <SFML/Window/WindowStyle.hpp>
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <SFML/Window/Joystick.hpp>
|
||||
#include <SFML/Window/Keyboard.hpp>
|
||||
#include <SFML/Window/Mouse.hpp>
|
||||
#include <SFML/Window/Sensor.hpp>
|
||||
|
||||
|
||||
namespace sf
|
||||
@ -151,6 +152,16 @@ public :
|
||||
int x; ///< X position of the touch, relative to the left of the owner window
|
||||
int y; ///< Y position of the touch, relative to the top of the owner window
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Sensor events parameters (SensorEnabled, SensorData, SensorDisabled)
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
struct SensorEvent
|
||||
{
|
||||
Sensor::Type type;
|
||||
Sensor::Data data;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Enumeration of the different types of events
|
||||
@ -179,6 +190,9 @@ public :
|
||||
TouchBegan, ///< A touch event began (data in event.touch)
|
||||
TouchMoved, ///< A touch moved (data in event.touch)
|
||||
TouchEnded, ///< A touch event ended (data in event.touch)
|
||||
SensorEnabled, ///< A sensor was enabled (data in event.sensor)
|
||||
SensorData, ///< A new sensor data arrived (data in event.sensor)
|
||||
SensorDisabled, ///< A sensor was disabled (data in event.sensor)
|
||||
|
||||
Count ///< Keep last -- the total number of event types
|
||||
};
|
||||
@ -200,6 +214,7 @@ public :
|
||||
JoystickButtonEvent joystickButton; ///< Joystick button event parameters (Event::JoystickButtonPressed, Event::JoystickButtonReleased)
|
||||
JoystickConnectEvent joystickConnect; ///< Joystick (dis)connect event parameters (Event::JoystickConnected, Event::JoystickDisconnected)
|
||||
TouchEvent touch; ///< Touch events parameters (Event::TouchBegan, Event::TouchMoved, Event::TouchEnded)
|
||||
SensorEvent sensor; ///< Sensor events parameters (Event::SensorEnabled, Event::SensorData, Event::SensorDisabled)
|
||||
};
|
||||
};
|
||||
|
||||
|
196
include/SFML/Window/Sensor.hpp
Normal file
196
include/SFML/Window/Sensor.hpp
Normal file
@ -0,0 +1,196 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented;
|
||||
// you must not claim that you wrote the original software.
|
||||
// If you use this software in a product, an acknowledgment
|
||||
// in the product documentation would be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such,
|
||||
// and must not be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SFML_SENSOR_HPP
|
||||
#define SFML_SENSOR_HPP
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Window/Export.hpp>
|
||||
#include <SFML/System/Vector2.hpp>
|
||||
#include <SFML/System/Vector3.hpp>
|
||||
#include <SFML/System/Time.hpp>
|
||||
|
||||
|
||||
namespace sf
|
||||
{
|
||||
class Window;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Give access to the real-time state of the sensor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
class SFML_WINDOW_API Sensor
|
||||
{
|
||||
public :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Sensor type
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum Type
|
||||
{
|
||||
Accelerometer, ///< The acceleration sensor measures the acceleration force
|
||||
Gyroscope, ///< The gyroscope sensor measures the rate of rotation
|
||||
Magnetometer, ///< The magnetic sensor measures the ambient magnetic field
|
||||
Temperature, ///< The temperature sensor measures the ambient room temperature
|
||||
Proximity, ///< The proximity sensor measures how close an object is
|
||||
Gravity, ///< The gravity sensor measures the force of gravity
|
||||
Light, ///< The light sensor measures the amount of ambient light or illumination
|
||||
LinearAcceleration, ///< The linear acceleration sensor that measures acceleration
|
||||
Orientation, ///< The orientation sensor that measures the degrees of orientation
|
||||
Pressure, ///< The pressure sensor give air pressure readings
|
||||
Altimeter, ///< The altimeter measures the altitude by using air pressure measurements
|
||||
Compass, ///< The compass sensor give compass heading readings
|
||||
|
||||
Count ///< Keep last -- the total number of sensor type
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Sensor data
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
union Data
|
||||
{
|
||||
struct
|
||||
{
|
||||
float x; ///< X-axis data
|
||||
float y; ///< Y-axis data
|
||||
float z; ///< Z-axis data
|
||||
}
|
||||
acceleration, ///< Acceleration in m/s^2 (Sensor::Accelerometer, Sensor::Gravity, Sensor::LinearAcceleration)
|
||||
magnetic, ///< Magnetic in uT (Sensor::Magnetometer)
|
||||
vector, ///< Vector representing angle in degrees (Sensor::Orientation, Sensor::Compass)
|
||||
gyroscope; ///< Gyroscope data in rad/s (Sensor::Gyroscope)
|
||||
float temperature; ///< Temperature in degrees Celsius (Sensor::Temperature)
|
||||
float distance; ///< Distance in meter (Sensor::Proximity, Sensor::Altimeter)
|
||||
float light; ///< Illumination in lx (Sensor::Light)
|
||||
float pressure; ///< Pressure in hPa (Sensor::Pressure)
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Check if a sensor is available on the underlying platform
|
||||
///
|
||||
/// \param sensor Sensor to check
|
||||
///
|
||||
/// \return True if the sensor is available, false otherwise
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static bool isAvailable(Type sensor);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the resolution of a sensor
|
||||
///
|
||||
/// The resolution represents the sensitivity of a sensor. The
|
||||
/// resolution of a sensor is the smallest change it can detect in
|
||||
/// the quantity that it is measuring
|
||||
///
|
||||
/// \param sensor Sensor to check
|
||||
///
|
||||
/// \return The sensor's resolution in the sensor's unit.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static float getResolution(Type sensor);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the maximum range of a sensor
|
||||
///
|
||||
/// The resolution represents the sensitivity of a sensor. The
|
||||
/// value returned is in the sensor's unit.
|
||||
///
|
||||
/// \param sensor Sensor to check
|
||||
///
|
||||
/// \return The sensor's resolution in the sensor's unit.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static Vector2f getMaximumRange(Type sensor);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the minimum delay allowed between two events
|
||||
///
|
||||
/// When setting the refresh rate of a sensor, you'll need to
|
||||
/// make sure the value is a superior to the minimum delay
|
||||
/// allowable
|
||||
///
|
||||
/// \param sensor Sensor to check
|
||||
///
|
||||
/// \return The minimum delay allowed between two events
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Time getMinimumDelay(Type sensor);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Check if a sensor is enabled
|
||||
///
|
||||
/// \param sensor Sensor to check
|
||||
///
|
||||
/// \return True if the sensor is enabled, false otherwise
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static bool isEnable(Type sensor);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Enable or disable a sensor
|
||||
///
|
||||
/// A sensor is disabled by default otherwise it would consume too
|
||||
/// much battery power. Once a sensor enabled, it will start sending
|
||||
/// sensor events of that type (if available).
|
||||
///
|
||||
/// \param sensor Sensor to enable
|
||||
/// \param enable True to enable, false to disable
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static void setEnable(Type sensor, bool enable = true);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the refresh rate of a sensor
|
||||
///
|
||||
/// This is the delay you want between each measure report
|
||||
///
|
||||
/// \param sensor Sensor to modify
|
||||
/// \param rate Delay between each event
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static void setRefreshRate(Type sensor, const Time& rate);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current sensor data
|
||||
///
|
||||
/// If the sensor support real-time retrieval, you'll get
|
||||
/// the current sensor data otherwise this is likely the
|
||||
/// latest data of this sensor type.
|
||||
///
|
||||
/// \param sensor Sensor to check
|
||||
///
|
||||
/// \return The current sensor data
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static Data getData(Type sensor);
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
||||
|
||||
#endif // SFML_SENSOR_HPP
|
94
src/SFML/Window/Android/SensorImpl.cpp
Normal file
94
src/SFML/Window/Android/SensorImpl.cpp
Normal file
@ -0,0 +1,94 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2013 Jonathan De Wachter (dewachter.jonathan@gmail.com)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented;
|
||||
// you must not claim that you wrote the original software.
|
||||
// If you use this software in a product, an acknowledgment
|
||||
// in the product documentation would be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such,
|
||||
// and must not be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Window/SensorImpl.hpp>
|
||||
#include <SFML/System/Lock.hpp>
|
||||
#include <SFML/System/Time.hpp>
|
||||
|
||||
|
||||
namespace sf
|
||||
{
|
||||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorImpl::initialize()
|
||||
{
|
||||
// To implement
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorImpl::cleanup()
|
||||
{
|
||||
// To implement
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
SensorCaps& SensorImpl::initialize(unsigned int type)
|
||||
{
|
||||
// To implement
|
||||
SensorCaps capabilities;
|
||||
capabilities.available = false;
|
||||
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorImpl::terminate()
|
||||
{
|
||||
// To implement
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
SensorState& SensorImpl::update()
|
||||
{
|
||||
// To implement
|
||||
static SensorState state;
|
||||
return state;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SensorImpl::isEnable()
|
||||
{
|
||||
// To implement
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorImpl::setEnable(bool enable)
|
||||
{
|
||||
// To implement
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorImpl::setRefreshRate(const Time& rate)
|
||||
{
|
||||
// To implement
|
||||
}
|
||||
|
||||
} // namespace priv
|
||||
|
||||
} // namespace sf
|
108
src/SFML/Window/Android/SensorImpl.hpp
Normal file
108
src/SFML/Window/Android/SensorImpl.hpp
Normal file
@ -0,0 +1,108 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2013 Jonathan De Wachter (dewachter.jonathan@gmail.com)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented;
|
||||
// you must not claim that you wrote the original software.
|
||||
// If you use this software in a product, an acknowledgment
|
||||
// in the product documentation would be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such,
|
||||
// and must not be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SFML_SENSORIMPLANDROID_HPP
|
||||
#define SFML_SENSORIMPLANDROID_HPP
|
||||
|
||||
|
||||
namespace sf
|
||||
{
|
||||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Android implementation of sensors
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
class SensorImpl
|
||||
{
|
||||
public :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Perform the global initialization of the sensor module
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static void initialize();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Perform the global cleanup of the sensor module
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static void cleanup();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Initialize the sensor
|
||||
///
|
||||
/// \param type Index assigned to the sensor
|
||||
///
|
||||
/// \return The sensor capabilities
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
SensorCaps& initialize(unsigned int type);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the sensor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void terminate();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Update the sensor and get its new state
|
||||
///
|
||||
/// \return Sensor state
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
SensorState& update();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Check if the sensor is enabled
|
||||
///
|
||||
/// \return True if the sensor is enabled, false otherwise
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool isEnable();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Enable or disable the sensor
|
||||
///
|
||||
/// \param enable True to enable, false to disable
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void setEnable(bool enable);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the refresh rate of the sensor
|
||||
///
|
||||
/// \param rate Delay between each refresh
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void setRefreshRate(const Time& rate);
|
||||
|
||||
};
|
||||
|
||||
} // namespace priv
|
||||
|
||||
} // namespace sf
|
||||
|
||||
|
||||
#endif // SFML_SENSORIMPLANDROID_HPP
|
@ -24,7 +24,12 @@ set(SRC
|
||||
${INCROOT}/Mouse.hpp
|
||||
${SRCROOT}/Mouse.cpp
|
||||
${INCROOT}/Touch.hpp
|
||||
${SRCROOT}/Touch.cpp
|
||||
${SRCROOT}/Touch.cpp
|
||||
${INCROOT}/Sensor.hpp
|
||||
${SRCROOT}/Sensor.cpp
|
||||
${SRCROOT}/SensorImpl.hpp
|
||||
${SRCROOT}/SensorManager.cpp
|
||||
${SRCROOT}/SensorManager.hpp
|
||||
${SRCROOT}/VideoMode.cpp
|
||||
${INCROOT}/VideoMode.hpp
|
||||
${SRCROOT}/VideoModeImpl.hpp
|
||||
@ -64,6 +69,8 @@ elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD)
|
||||
${SRCROOT}/Unix/Display.hpp
|
||||
${SRCROOT}/Unix/InputImpl.cpp
|
||||
${SRCROOT}/Unix/InputImpl.hpp
|
||||
${SRCROOT}/Unix/SensorImpl.cpp
|
||||
${SRCROOT}/Unix/SensorImpl.hpp
|
||||
${SRCROOT}/Unix/VideoModeImpl.cpp
|
||||
${SRCROOT}/Unix/WindowImplX11.cpp
|
||||
${SRCROOT}/Unix/WindowImplX11.hpp
|
||||
@ -103,6 +110,8 @@ elseif(SFML_OS_MACOSX)
|
||||
${SRCROOT}/OSX/HIDJoystickManager.cpp
|
||||
${SRCROOT}/OSX/JoystickImpl.cpp
|
||||
${SRCROOT}/OSX/JoystickImpl.hpp
|
||||
${SRCROOT}/OSX/SensorImpl.cpp
|
||||
${SRCROOT}/OSX/SensorImpl.hpp
|
||||
${SRCROOT}/OSX/SFApplication.h
|
||||
${SRCROOT}/OSX/SFApplication.m
|
||||
${SRCROOT}/OSX/SFApplicationDelegate.h
|
||||
@ -135,6 +144,8 @@ elseif(SFML_OS_IOS)
|
||||
${SRCROOT}/iOS/InputImpl.hpp
|
||||
${SRCROOT}/iOS/JoystickImpl.mm
|
||||
${SRCROOT}/iOS/JoystickImpl.hpp
|
||||
${SRCROOT}/iOS/SensorImpl.mm
|
||||
${SRCROOT}/iOS/SensorImpl.hpp
|
||||
${SRCROOT}/iOS/VideoModeImpl.mm
|
||||
${SRCROOT}/iOS/WindowImplUIKit.hpp
|
||||
${SRCROOT}/iOS/WindowImplUIKit.mm
|
||||
@ -157,7 +168,9 @@ elseif(SFML_OS_ANDROID)
|
||||
${SRCROOT}/Android/InputImpl.hpp
|
||||
${SRCROOT}/Android/InputImpl.cpp
|
||||
${SRCROOT}/Android/JoystickImpl.hpp
|
||||
${SRCROOT}/Android/JoystickImpl.cpp)
|
||||
${SRCROOT}/Android/JoystickImpl.cpp
|
||||
${SRCROOT}/Android/SensorImpl.hpp
|
||||
${SRCROOT}/Android/SensorImpl.cpp)
|
||||
source_group("android" FILES ${PLATFORM_SRC})
|
||||
endif()
|
||||
|
||||
|
109
src/SFML/Window/OSX/SensorImpl.hpp
Normal file
109
src/SFML/Window/OSX/SensorImpl.hpp
Normal file
@ -0,0 +1,109 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2013 Marco Antognini (antognini.marco@gmail.com),
|
||||
// Laurent Gomila (laurent.gom@gmail.com),
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented;
|
||||
// you must not claim that you wrote the original software.
|
||||
// If you use this software in a product, an acknowledgment
|
||||
// in the product documentation would be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such,
|
||||
// and must not be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SFML_SENSORIMPLOSX_HPP
|
||||
#define SFML_SENSORIMPLOSX_HPP
|
||||
|
||||
|
||||
namespace sf
|
||||
{
|
||||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Mac OS X implementation of sensors
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
class SensorImpl
|
||||
{
|
||||
public :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Perform the global initialization of the sensor module
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static void initialize();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Perform the global cleanup of the sensor module
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static void cleanup();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Initialize the sensor
|
||||
///
|
||||
/// \param type Index assigned to the sensor
|
||||
///
|
||||
/// \return The sensor capabilities
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
SensorCaps& initialize(unsigned int type);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the sensor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void terminate();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Update the sensor and get its new state
|
||||
///
|
||||
/// \return Sensor state
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
SensorState& update();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Check if the sensor is enabled
|
||||
///
|
||||
/// \return True if the sensor is enabled, false otherwise
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool isEnable();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Enable or disable the sensor
|
||||
///
|
||||
/// \param enable True to enable, false to disable
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void setEnable(bool enable);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the refresh rate of the sensor
|
||||
///
|
||||
/// \param rate Delay between each refresh
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void setRefreshRate(const Time& rate);
|
||||
|
||||
};
|
||||
|
||||
} // namespace priv
|
||||
|
||||
} // namespace sf
|
||||
|
||||
|
||||
#endif // SFML_SENSORIMPLOSX_HPP
|
93
src/SFML/Window/OSX/SensorImpl.mm
Normal file
93
src/SFML/Window/OSX/SensorImpl.mm
Normal file
@ -0,0 +1,93 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2013 Marco Antognini (antognini.marco@gmail.com),
|
||||
// Laurent Gomila (laurent.gom@gmail.com),
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented;
|
||||
// you must not claim that you wrote the original software.
|
||||
// If you use this software in a product, an acknowledgment
|
||||
// in the product documentation would be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such,
|
||||
// and must not be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Window/SensorImpl.hpp>
|
||||
|
||||
|
||||
namespace sf
|
||||
{
|
||||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorImpl::initialize()
|
||||
{
|
||||
// Not applicable
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorImpl::cleanup()
|
||||
{
|
||||
// Not applicable
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
SensorCaps& SensorImpl::initialize(unsigned int type)
|
||||
{
|
||||
// Not applicable
|
||||
SensorCaps capabilities;
|
||||
capabilities.available = false;
|
||||
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorImpl::terminate()
|
||||
{
|
||||
// Not applicable
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
SensorState& SensorImpl::update()
|
||||
{
|
||||
// Not applicable
|
||||
static SensorState state;
|
||||
return state;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SensorImpl::isEnable()
|
||||
{
|
||||
// Not applicable
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorImpl::setEnable(bool enable)
|
||||
{
|
||||
// Not applicable
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorImpl::setRefreshRate(const Time& rate)
|
||||
{
|
||||
// Not applicable
|
||||
}
|
||||
|
||||
} // namespace priv
|
||||
|
||||
} // namespace sf
|
83
src/SFML/Window/Sensor.cpp
Normal file
83
src/SFML/Window/Sensor.cpp
Normal file
@ -0,0 +1,83 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented;
|
||||
// you must not claim that you wrote the original software.
|
||||
// If you use this software in a product, an acknowledgment
|
||||
// in the product documentation would be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such,
|
||||
// and must not be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Window/Sensor.hpp>
|
||||
#include <SFML/Window/SensorManager.hpp>
|
||||
|
||||
|
||||
namespace sf
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Sensor::isAvailable(Type sensor)
|
||||
{
|
||||
return priv::SensorManager::getInstance().getCapabilities(sensor).available;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
float Sensor::getResolution(Type sensor)
|
||||
{
|
||||
return priv::SensorManager::getInstance().getCapabilities(sensor).resolution;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector2f Sensor::getMaximumRange(Type sensor)
|
||||
{
|
||||
return priv::SensorManager::getInstance().getCapabilities(sensor).maximumRange;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Time Sensor::getMinimumDelay(Type sensor)
|
||||
{
|
||||
return priv::SensorManager::getInstance().getCapabilities(sensor).minimumDelay;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool Sensor::isEnable(Type sensor)
|
||||
{
|
||||
return priv::SensorManager::getInstance().isEnable(sensor);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sensor::setEnable(Type sensor, bool enable)
|
||||
{
|
||||
return priv::SensorManager::getInstance().setEnable(sensor, enable);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void Sensor::setRefreshRate(Type sensor, const Time& rate)
|
||||
{
|
||||
priv::SensorManager::getInstance().setRefreshRate(sensor, rate);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Sensor::Data Sensor::getData(Type sensor)
|
||||
{
|
||||
return priv::SensorManager::getInstance().getState(sensor).pendingData->back();
|
||||
}
|
||||
|
||||
} // namespace sf
|
100
src/SFML/Window/SensorImpl.hpp
Normal file
100
src/SFML/Window/SensorImpl.hpp
Normal file
@ -0,0 +1,100 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented;
|
||||
// you must not claim that you wrote the original software.
|
||||
// If you use this software in a product, an acknowledgment
|
||||
// in the product documentation would be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such,
|
||||
// and must not be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SFML_SENSORIMPL_HPP
|
||||
#define SFML_SENSORIMPL_HPP
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Config.hpp>
|
||||
#include <SFML/Window/Sensor.hpp>
|
||||
#include <SFML/System/Time.hpp>
|
||||
#include <SFML/System/Vector2.hpp>
|
||||
#include <queue>
|
||||
#include <cstddef>
|
||||
|
||||
|
||||
namespace sf
|
||||
{
|
||||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Structure holding a sensor's capabilities
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
struct SensorCaps
|
||||
{
|
||||
SensorCaps()
|
||||
{
|
||||
available = false;
|
||||
resolution = 0;
|
||||
maximumRange = Vector2f(0, 0);
|
||||
minimumDelay = Time::Zero;
|
||||
}
|
||||
|
||||
bool available; ///< Is the sensor available on the underlying platform
|
||||
float resolution; ///< How sensible the sensor is in the sensor's unit
|
||||
Vector2f maximumRange; ///< Maximum range of the sensor in the sensor's unit
|
||||
Time minimumDelay; ///< Minimum delay allowed between two events
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Structure holding a sensor's state
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
struct SensorState
|
||||
{
|
||||
SensorState()
|
||||
{
|
||||
pendingData = NULL;
|
||||
enabled = false;
|
||||
refreshRate = Time::Zero;
|
||||
}
|
||||
|
||||
std::queue<Sensor::Data>* pendingData; ///< Pending sensor data
|
||||
bool enabled; ///< Is the sensor currently enabled?
|
||||
Time refreshRate; ///< Delay between two events
|
||||
};
|
||||
|
||||
} // namespace priv
|
||||
|
||||
} // namespace sf
|
||||
|
||||
|
||||
#if defined(SFML_SYSTEM_WINDOWS)
|
||||
#include <SFML/Window/Win32/SensorImpl.hpp>
|
||||
#elif defined(SFML_SYSTEM_LINUX)
|
||||
#include <SFML/Window/Unix/SensorImpl.hpp>
|
||||
#elif defined(SFML_SYSTEM_MACOS)
|
||||
#include <SFML/Window/OSX/SensorImpl.hpp>
|
||||
#elif defined(SFML_SYSTEM_IOS)
|
||||
#include <SFML/Window/iOS/SensorImpl.hpp>
|
||||
#elif defined(SFML_SYSTEM_ANDROID)
|
||||
#include <SFML/Window/Android/SensorImpl.hpp>
|
||||
#endif
|
||||
|
||||
|
||||
#endif // SFML_SENSORIMPL_HPP
|
150
src/SFML/Window/SensorManager.cpp
Normal file
150
src/SFML/Window/SensorManager.cpp
Normal file
@ -0,0 +1,150 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented;
|
||||
// you must not claim that you wrote the original software.
|
||||
// If you use this software in a product, an acknowledgment
|
||||
// in the product documentation would be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such,
|
||||
// and must not be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Window/SensorManager.hpp>
|
||||
#include <SFML/System/Err.hpp>
|
||||
|
||||
|
||||
namespace sf
|
||||
{
|
||||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
SensorManager& SensorManager::getInstance()
|
||||
{
|
||||
static SensorManager instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
const SensorCaps& SensorManager::getCapabilities(unsigned int sensor) const
|
||||
{
|
||||
return m_sensors[sensor].capabilities;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
const SensorState& SensorManager::getState(unsigned int sensor) const
|
||||
{
|
||||
return m_sensors[sensor].state;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorManager::update()
|
||||
{
|
||||
for (int i = 0; i < Sensor::Count; ++i)
|
||||
{
|
||||
Item& item = m_sensors[i];
|
||||
|
||||
// Skip unavailable sensors
|
||||
if (!item.capabilities.available)
|
||||
continue;
|
||||
|
||||
// Get the current state of the sensor
|
||||
item.state = item.sensor.update();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SensorManager::isEnable(unsigned int sensor)
|
||||
{
|
||||
if (!m_sensors[sensor].capabilities.available)
|
||||
{
|
||||
err() << "This sensor isn't available on your system (call Sensor::isAvailable to check it)" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return m_sensors[sensor].sensor.isEnable();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorManager::setEnable(unsigned int sensor, bool enable)
|
||||
{
|
||||
if (!m_sensors[sensor].capabilities.available)
|
||||
{
|
||||
err() << "This sensor isn't available on your system (call Sensor::isAvailable to check it)" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
m_sensors[sensor].sensor.setEnable(enable);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorManager::setRefreshRate(unsigned int sensor, const Time& rate)
|
||||
{
|
||||
if (!m_sensors[sensor].capabilities.available)
|
||||
{
|
||||
err() << "This sensor isn't available on your system (call Sensor::isAvailable to check it)" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
m_sensors[sensor].sensor.setRefreshRate(rate);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
SensorManager::SensorManager()
|
||||
{
|
||||
// Global sensor initialization
|
||||
SensorImpl::initialize();
|
||||
|
||||
// Per sensor initialization
|
||||
for (int i = 0; i < Sensor::Count; ++i)
|
||||
{
|
||||
// Initialize the sensor and get its capabilities
|
||||
m_sensors[i].capabilities = m_sensors[i].sensor.initialize(i);
|
||||
|
||||
// Available sensors are disabled by default
|
||||
if (m_sensors[i].capabilities.available)
|
||||
m_sensors[i].sensor.setEnable(false);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
SensorManager::~SensorManager()
|
||||
{
|
||||
// Per sensor cleanup
|
||||
for (int i = 0; i < Sensor::Count; ++i)
|
||||
{
|
||||
if (m_sensors[i].capabilities.available)
|
||||
{
|
||||
// Disable the sensor
|
||||
m_sensors[i].sensor.setEnable(false);
|
||||
|
||||
// Terminate the sensor
|
||||
m_sensors[i].sensor.terminate();
|
||||
}
|
||||
}
|
||||
|
||||
// Global sensor cleanup
|
||||
SensorImpl::cleanup();
|
||||
}
|
||||
|
||||
} // namespace priv
|
||||
|
||||
} // namespace sf
|
146
src/SFML/Window/SensorManager.hpp
Normal file
146
src/SFML/Window/SensorManager.hpp
Normal file
@ -0,0 +1,146 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented;
|
||||
// you must not claim that you wrote the original software.
|
||||
// If you use this software in a product, an acknowledgment
|
||||
// in the product documentation would be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such,
|
||||
// and must not be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SFML_SENSORMANAGER_HPP
|
||||
#define SFML_SENSORMANAGER_HPP
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Window/Sensor.hpp>
|
||||
#include <SFML/Window/SensorImpl.hpp>
|
||||
#include <SFML/System/NonCopyable.hpp>
|
||||
|
||||
|
||||
namespace sf
|
||||
{
|
||||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Global sensor manager
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
class SensorManager : NonCopyable
|
||||
{
|
||||
public :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the global unique instance of the manager
|
||||
///
|
||||
/// \return Unique instance of the sensor manager
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static SensorManager& getInstance();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the capabilities of a sensor
|
||||
///
|
||||
/// \param sensor Index of the sensor
|
||||
///
|
||||
/// \return Capabilities of the sensor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const SensorCaps& getCapabilities(unsigned int sensor) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current state of a sensor
|
||||
///
|
||||
/// \param sensor Index of the sensor
|
||||
///
|
||||
/// \return Current state of the sensor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
const SensorState& getState(unsigned int sensor) const;
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Update the state of all the sensors
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void update();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the current status of a sensor
|
||||
///
|
||||
/// \param sensor Index of the sensor
|
||||
///
|
||||
/// \return True if the sensor is enabled, false otherwise
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool isEnable(unsigned int sensor);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Enable or disable a sensor
|
||||
///
|
||||
/// \param sensor Index of the sensor
|
||||
/// \param enable Whether it should be enabled or not
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void setEnable(unsigned int sensor, bool enable);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the refresh rate of a sensor
|
||||
///
|
||||
/// \param sensor Index of the sensor
|
||||
/// \param rate Delay between each event
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void setRefreshRate(unsigned int sensor, const Time& rate);
|
||||
|
||||
private:
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Default constructor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
SensorManager();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Destructor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
~SensorManager();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Sensor information and state
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
struct Item
|
||||
{
|
||||
SensorImpl sensor; ///< Sensor implementation
|
||||
SensorState state; ///< The current sensor state
|
||||
SensorCaps capabilities; ///< The sensor capabilities
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
Item m_sensors[Sensor::Count]; ///< Sensors information and state
|
||||
};
|
||||
|
||||
} // namespace priv
|
||||
|
||||
} // namespace sf
|
||||
|
||||
|
||||
#endif // SFML_SENSORMANAGER_HPP
|
92
src/SFML/Window/Unix/SensorImpl.cpp
Normal file
92
src/SFML/Window/Unix/SensorImpl.cpp
Normal file
@ -0,0 +1,92 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented;
|
||||
// you must not claim that you wrote the original software.
|
||||
// If you use this software in a product, an acknowledgment
|
||||
// in the product documentation would be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such,
|
||||
// and must not be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Window/SensorImpl.hpp>
|
||||
|
||||
|
||||
namespace sf
|
||||
{
|
||||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorImpl::initialize()
|
||||
{
|
||||
// Not applicable
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorImpl::cleanup()
|
||||
{
|
||||
// Not applicable
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
SensorCaps& SensorImpl::initialize(unsigned int type)
|
||||
{
|
||||
// Not applicable
|
||||
SensorCaps capabilities;
|
||||
capabilities.available = false;
|
||||
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorImpl::terminate()
|
||||
{
|
||||
// Not applicable
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
SensorState& SensorImpl::update()
|
||||
{
|
||||
// Not applicable
|
||||
static SensorState state;
|
||||
return state;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SensorImpl::isEnable()
|
||||
{
|
||||
// Not applicable
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorImpl::setEnable(bool enable)
|
||||
{
|
||||
// Not applicable
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorImpl::setRefreshRate(const Time& rate)
|
||||
{
|
||||
// Not applicable
|
||||
}
|
||||
|
||||
} // namespace priv
|
||||
|
||||
} // namespace sf
|
108
src/SFML/Window/Unix/SensorImpl.hpp
Normal file
108
src/SFML/Window/Unix/SensorImpl.hpp
Normal file
@ -0,0 +1,108 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented;
|
||||
// you must not claim that you wrote the original software.
|
||||
// If you use this software in a product, an acknowledgment
|
||||
// in the product documentation would be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such,
|
||||
// and must not be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SFML_SENSORIMPLLINUX_HPP
|
||||
#define SFML_SENSORIMPLLINUX_HPP
|
||||
|
||||
|
||||
namespace sf
|
||||
{
|
||||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Linux implementation of sensors
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
class SensorImpl
|
||||
{
|
||||
public :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Perform the global initialization of the sensor module
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static void initialize();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Perform the global cleanup of the sensor module
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static void cleanup();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Initialize the sensor
|
||||
///
|
||||
/// \param type Index assigned to the sensor
|
||||
///
|
||||
/// \return The sensor capabilities
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
SensorCaps& initialize(unsigned int type);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the sensor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void terminate();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Update the sensor and get its new state
|
||||
///
|
||||
/// \return Sensor state
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
SensorState& update();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Check if the sensor is enabled
|
||||
///
|
||||
/// \return True if the sensor is enabled, false otherwise
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool isEnable();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Enable or disable the sensor
|
||||
///
|
||||
/// \param enable True to enable, false to disable
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void setEnable(bool enable);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the refresh rate of the sensor
|
||||
///
|
||||
/// \param rate Delay between each refresh
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void setRefreshRate(const Time& rate);
|
||||
|
||||
};
|
||||
|
||||
} // namespace priv
|
||||
|
||||
} // namespace sf
|
||||
|
||||
|
||||
#endif // SFML_SENSORIMPLLINUX_HPP
|
92
src/SFML/Window/Win32/SensorImpl.cpp
Normal file
92
src/SFML/Window/Win32/SensorImpl.cpp
Normal file
@ -0,0 +1,92 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented;
|
||||
// you must not claim that you wrote the original software.
|
||||
// If you use this software in a product, an acknowledgment
|
||||
// in the product documentation would be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such,
|
||||
// and must not be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Window/SensorImpl.hpp>
|
||||
|
||||
|
||||
namespace sf
|
||||
{
|
||||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorImpl::initialize()
|
||||
{
|
||||
// Not applicable
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorImpl::cleanup()
|
||||
{
|
||||
// Not applicable
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
SensorCaps& SensorImpl::initialize(unsigned int type)
|
||||
{
|
||||
// Not applicable
|
||||
SensorCaps capabilities;
|
||||
capabilities.available = false;
|
||||
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorImpl::terminate()
|
||||
{
|
||||
// Not applicable
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
SensorState& SensorImpl::update()
|
||||
{
|
||||
// Not applicable
|
||||
static SensorState state;
|
||||
return state;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SensorImpl::isEnable()
|
||||
{
|
||||
// Not applicable
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorImpl::setEnable(bool enable)
|
||||
{
|
||||
// Not applicable
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorImpl::setRefreshRate(const Time& rate)
|
||||
{
|
||||
// Not applicable
|
||||
}
|
||||
|
||||
} // namespace priv
|
||||
|
||||
} // namespace sf
|
108
src/SFML/Window/Win32/SensorImpl.hpp
Normal file
108
src/SFML/Window/Win32/SensorImpl.hpp
Normal file
@ -0,0 +1,108 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented;
|
||||
// you must not claim that you wrote the original software.
|
||||
// If you use this software in a product, an acknowledgment
|
||||
// in the product documentation would be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such,
|
||||
// and must not be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SFML_SENSORIMPLWIN32_HPP
|
||||
#define SFML_SENSORIMPLWIN32_HPP
|
||||
|
||||
|
||||
namespace sf
|
||||
{
|
||||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Windows implementation of sensors
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
class SensorImpl
|
||||
{
|
||||
public :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Perform the global initialization of the sensor module
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static void initialize();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Perform the global cleanup of the sensor module
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static void cleanup();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Initialize the sensor
|
||||
///
|
||||
/// \param type Index assigned to the sensor
|
||||
///
|
||||
/// \return The sensor capabilities
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
SensorCaps& initialize(unsigned int type);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the sensor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void terminate();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Update the sensor and get its new state
|
||||
///
|
||||
/// \return Sensor state
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
SensorState& update();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Check if the sensor is enabled
|
||||
///
|
||||
/// \return True if the sensor is enabled, false otherwise
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool isEnable();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Enable or disable the sensor
|
||||
///
|
||||
/// \param enable True to enable, false to disable
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void setEnable(bool enable);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the refresh rate of the sensor
|
||||
///
|
||||
/// \param rate Delay between each refresh
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void setRefreshRate(const Time& rate);
|
||||
|
||||
};
|
||||
|
||||
} // namespace priv
|
||||
|
||||
} // namespace sf
|
||||
|
||||
|
||||
#endif // SFML_SENSORIMPLWIN32_HPP
|
@ -28,6 +28,7 @@
|
||||
#include <SFML/Window/WindowImpl.hpp>
|
||||
#include <SFML/Window/Event.hpp>
|
||||
#include <SFML/Window/JoystickManager.hpp>
|
||||
#include <SFML/Window/SensorManager.hpp>
|
||||
#include <SFML/System/Sleep.hpp>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
@ -86,6 +87,11 @@ m_joyThreshold(0.1f)
|
||||
JoystickManager::getInstance().update();
|
||||
for (unsigned int i = 0; i < Joystick::Count; ++i)
|
||||
m_joyStates[i] = JoystickManager::getInstance().getState(i);
|
||||
|
||||
// Get the initial sensor states
|
||||
SensorManager::getInstance().update();
|
||||
for (unsigned int i = 0; i < Sensor::Count; ++i)
|
||||
m_senStates[i] = SensorManager::getInstance().getState(i);
|
||||
}
|
||||
|
||||
|
||||
@ -108,10 +114,11 @@ bool WindowImpl::popEvent(Event& event, bool block)
|
||||
{
|
||||
// If the event queue is empty, let's first check if new events are available from the OS
|
||||
if (m_events.empty())
|
||||
{
|
||||
{
|
||||
// Get events from the system
|
||||
processJoystickEvents();
|
||||
processEvents();
|
||||
processSensorEvents();
|
||||
processEvents();
|
||||
|
||||
// In blocking mode, we must process events until one is triggered
|
||||
if (block)
|
||||
@ -123,6 +130,7 @@ bool WindowImpl::popEvent(Event& event, bool block)
|
||||
{
|
||||
sleep(milliseconds(10));
|
||||
processJoystickEvents();
|
||||
processSensorEvents();
|
||||
processEvents();
|
||||
}
|
||||
}
|
||||
@ -213,6 +221,52 @@ void WindowImpl::processJoystickEvents()
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void WindowImpl::processSensorEvents()
|
||||
{
|
||||
// First update sensor states
|
||||
SensorManager::getInstance().update();
|
||||
|
||||
for (unsigned int i = 0; i < Sensor::Count; ++i)
|
||||
{
|
||||
// Copy the previous state of the sensor and get the new one
|
||||
SensorState previousState = m_senStates[i];
|
||||
m_senStates[i] = SensorManager::getInstance().getState(i);
|
||||
|
||||
// Check whether it's still enabled
|
||||
bool enabled = m_senStates[i].enabled;
|
||||
if (previousState.enabled ^ enabled)
|
||||
{
|
||||
Event event;
|
||||
event.type = enabled ? Event::SensorEnabled : Event::SensorDisabled;
|
||||
event.sensor.type = static_cast<Sensor::Type>(i);
|
||||
pushEvent(event);
|
||||
|
||||
// This sensor has been disabled, we don't want these pending data
|
||||
if (!enabled)
|
||||
{
|
||||
while (!m_senStates[i].pendingData->empty())
|
||||
m_senStates[i].pendingData->pop();
|
||||
}
|
||||
}
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
// Send pending sensor data events
|
||||
while (!m_senStates[i].pendingData->empty())
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::SensorData;
|
||||
event.sensor.type = static_cast<Sensor::Type>(i);
|
||||
event.sensor.data = m_senStates[i].pendingData->front();
|
||||
pushEvent(event);
|
||||
|
||||
m_senStates[i].pendingData->pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace priv
|
||||
|
||||
} // namespace sf
|
||||
|
@ -34,6 +34,8 @@
|
||||
#include <SFML/Window/Event.hpp>
|
||||
#include <SFML/Window/Joystick.hpp>
|
||||
#include <SFML/Window/JoystickImpl.hpp>
|
||||
#include <SFML/Window/Sensor.hpp>
|
||||
#include <SFML/Window/SensorImpl.hpp>
|
||||
#include <SFML/Window/VideoMode.hpp>
|
||||
#include <SFML/Window/WindowHandle.hpp>
|
||||
#include <SFML/Window/ContextSettings.hpp>
|
||||
@ -225,12 +227,19 @@ private :
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void processJoystickEvents();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Read the sensors state and generate the appropriate events
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void processSensorEvents();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
std::queue<Event> m_events; ///< Queue of available events
|
||||
JoystickState m_joyStates[Joystick::Count]; ///< Previous state of the joysticks
|
||||
SensorState m_senStates[Sensor::Count]; ///< Previous state of the sensors
|
||||
float m_joyThreshold; ///< Joystick threshold (minimum motion for MOVE event to be generated)
|
||||
};
|
||||
|
||||
|
108
src/SFML/Window/iOS/SensorImpl.hpp
Normal file
108
src/SFML/Window/iOS/SensorImpl.hpp
Normal file
@ -0,0 +1,108 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented;
|
||||
// you must not claim that you wrote the original software.
|
||||
// If you use this software in a product, an acknowledgment
|
||||
// in the product documentation would be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such,
|
||||
// and must not be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SFML_SENSORIMPLIOS_HPP
|
||||
#define SFML_SENSORIMPLIOS_HPP
|
||||
|
||||
|
||||
namespace sf
|
||||
{
|
||||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief iOS implementation of sensors
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
class SensorImpl
|
||||
{
|
||||
public :
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Perform the global initialization of the sensor module
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static void initialize();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Perform the global cleanup of the sensor module
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static void cleanup();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Initialize the sensor
|
||||
///
|
||||
/// \param type Index assigned to the sensor
|
||||
///
|
||||
/// \return The sensor capabilities
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
SensorCaps& initialize(unsigned int type);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Close the sensor
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void terminate();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Update the sensor and get its new state
|
||||
///
|
||||
/// \return Sensor state
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
SensorState& update();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Check if the sensor is enabled
|
||||
///
|
||||
/// \return True if the sensor is enabled, false otherwise
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
bool isEnable();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Enable or disable the sensor
|
||||
///
|
||||
/// \param enable True to enable, false to disable
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void setEnable(bool enable);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the refresh rate of the sensor
|
||||
///
|
||||
/// \param rate Delay between each refresh
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void setRefreshRate(const Time& rate);
|
||||
|
||||
};
|
||||
|
||||
} // namespace priv
|
||||
|
||||
} // namespace sf
|
||||
|
||||
|
||||
#endif // SFML_SENSORIMPLIOS_HPP
|
92
src/SFML/Window/iOS/SensorImpl.mm
Normal file
92
src/SFML/Window/iOS/SensorImpl.mm
Normal file
@ -0,0 +1,92 @@
|
||||
////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SFML - Simple and Fast Multimedia Library
|
||||
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented;
|
||||
// you must not claim that you wrote the original software.
|
||||
// If you use this software in a product, an acknowledgment
|
||||
// in the product documentation would be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such,
|
||||
// and must not be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Headers
|
||||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Window/SensorImpl.hpp>
|
||||
|
||||
|
||||
namespace sf
|
||||
{
|
||||
namespace priv
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorImpl::initialize()
|
||||
{
|
||||
// To implement
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorImpl::cleanup()
|
||||
{
|
||||
// To implement
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
SensorCaps& SensorImpl::initialize(unsigned int type)
|
||||
{
|
||||
// To implement
|
||||
SensorCaps capabilities;
|
||||
capabilities.available = false;
|
||||
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorImpl::terminate()
|
||||
{
|
||||
// To implement
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
SensorState& SensorImpl::update()
|
||||
{
|
||||
// To implement
|
||||
static SensorState state;
|
||||
return state;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
bool SensorImpl::isEnable()
|
||||
{
|
||||
// To implement
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorImpl::setEnable(bool enable)
|
||||
{
|
||||
// To implement
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorImpl::setRefreshRate(const Time& rate)
|
||||
{
|
||||
// To implement
|
||||
}
|
||||
|
||||
} // namespace priv
|
||||
|
||||
} // namespace sf
|
Loading…
Reference in New Issue
Block a user