|
|
@ -3,115 +3,151 @@ |
|
|
|
* SPDX-License-Identifier: BSD-3-Clause |
|
|
|
* SPDX-License-Identifier: BSD-3-Clause |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
#include <sensors_plus_aurora/sensors_plus_aurora_plugin.h> |
|
|
|
|
|
|
|
#include <flutter/method-channel.h> |
|
|
|
#include <flutter/method-channel.h> |
|
|
|
|
|
|
|
#include <sensors_plus_aurora/sensors_plus_aurora_plugin.h> |
|
|
|
#include <QDebug> |
|
|
|
#include <QDebug> |
|
|
|
|
|
|
|
|
|
|
|
#include <sensormanagerinterface.h> |
|
|
|
|
|
|
|
#include <orientationsensor_i.h> |
|
|
|
|
|
|
|
#include <accelerometersensor_i.h> |
|
|
|
#include <accelerometersensor_i.h> |
|
|
|
#include <compasssensor_i.h> |
|
|
|
|
|
|
|
#include <tapsensor_i.h> |
|
|
|
|
|
|
|
#include <alssensor_i.h> |
|
|
|
#include <alssensor_i.h> |
|
|
|
|
|
|
|
#include <compasssensor_i.h> |
|
|
|
|
|
|
|
#include <magnetometersensor_i.h> |
|
|
|
|
|
|
|
#include <orientationsensor_i.h> |
|
|
|
#include <proximitysensor_i.h> |
|
|
|
#include <proximitysensor_i.h> |
|
|
|
#include <rotationsensor_i.h> |
|
|
|
#include <rotationsensor_i.h> |
|
|
|
#include <magnetometersensor_i.h> |
|
|
|
#include <sensormanagerinterface.h> |
|
|
|
|
|
|
|
#include <tapsensor_i.h> |
|
|
|
namespace KeyChannel |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
constexpr auto Orientation = "sensors_plus_aurora_orientationsensor"; |
|
|
|
|
|
|
|
constexpr auto Accelerometer = "sensors_plus_aurora_accelerometersensor"; |
|
|
|
|
|
|
|
constexpr auto Compass = "sensors_plus_aurora_compasssensor"; |
|
|
|
|
|
|
|
constexpr auto Tap = "sensors_plus_aurora_tapsensor"; |
|
|
|
|
|
|
|
constexpr auto ALS = "sensors_plus_aurora_alssensor"; |
|
|
|
|
|
|
|
constexpr auto Proximity = "sensors_plus_aurora_proximitysensor"; |
|
|
|
|
|
|
|
constexpr auto Rotation = "sensors_plus_aurora_rotationsensor"; |
|
|
|
|
|
|
|
constexpr auto Magnetometer = "sensors_plus_aurora_magnetometersensor"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace KeySensor |
|
|
|
namespace KeyChannel { |
|
|
|
{ |
|
|
|
constexpr auto Orientation = "sensors_plus_aurora_orientationsensor"; |
|
|
|
constexpr auto Orientation = "orientationsensor"; |
|
|
|
constexpr auto Accelerometer = "sensors_plus_aurora_accelerometersensor"; |
|
|
|
constexpr auto Accelerometer = "accelerometersensor"; |
|
|
|
constexpr auto Compass = "sensors_plus_aurora_compasssensor"; |
|
|
|
constexpr auto Compass = "compasssensor"; |
|
|
|
constexpr auto Tap = "sensors_plus_aurora_tapsensor"; |
|
|
|
constexpr auto Tap = "tapsensor"; |
|
|
|
constexpr auto ALS = "sensors_plus_aurora_alssensor"; |
|
|
|
constexpr auto ALS = "alssensor"; |
|
|
|
constexpr auto Proximity = "sensors_plus_aurora_proximitysensor"; |
|
|
|
constexpr auto Proximity = "proximitysensor"; |
|
|
|
constexpr auto Rotation = "sensors_plus_aurora_rotationsensor"; |
|
|
|
constexpr auto Rotation = "rotationsensor"; |
|
|
|
constexpr auto Magnetometer = "sensors_plus_aurora_magnetometersensor"; |
|
|
|
constexpr auto Magnetometer = "magnetometersensor"; |
|
|
|
} // namespace KeyChannel
|
|
|
|
} /* namespace */ |
|
|
|
|
|
|
|
|
|
|
|
namespace KeySensor { |
|
|
|
|
|
|
|
constexpr auto Orientation = "orientationsensor"; |
|
|
|
|
|
|
|
constexpr auto Accelerometer = "accelerometersensor"; |
|
|
|
|
|
|
|
constexpr auto Compass = "compasssensor"; |
|
|
|
|
|
|
|
constexpr auto Tap = "tapsensor"; |
|
|
|
|
|
|
|
constexpr auto ALS = "alssensor"; |
|
|
|
|
|
|
|
constexpr auto Proximity = "proximitysensor"; |
|
|
|
|
|
|
|
constexpr auto Rotation = "rotationsensor"; |
|
|
|
|
|
|
|
constexpr auto Magnetometer = "magnetometersensor"; |
|
|
|
|
|
|
|
} // namespace KeySensor
|
|
|
|
|
|
|
|
|
|
|
|
void SensorsPlusAuroraPlugin::RegisterWithRegistrar(PluginRegistrar ®istrar) |
|
|
|
void SensorsPlusAuroraPlugin::RegisterWithRegistrar(PluginRegistrar ®istrar) |
|
|
|
{ |
|
|
|
{ |
|
|
|
registrar.RegisterEventChannel( |
|
|
|
registrar.RegisterEventChannel( |
|
|
|
KeyChannel::Orientation, MethodCodecType::Standard, |
|
|
|
KeyChannel::Orientation, |
|
|
|
[this](const Encodable &) |
|
|
|
MethodCodecType::Standard, |
|
|
|
{ EnableSensorOrientation(); return EventResponse(); }, |
|
|
|
[this](const Encodable &) { |
|
|
|
[this](const Encodable &) |
|
|
|
EnableSensorOrientation(); |
|
|
|
{ DisableSensorOrientation(); return EventResponse(); }); |
|
|
|
return EventResponse(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
[this](const Encodable &) { |
|
|
|
|
|
|
|
DisableSensorOrientation(); |
|
|
|
|
|
|
|
return EventResponse(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
registrar.RegisterEventChannel( |
|
|
|
registrar.RegisterEventChannel( |
|
|
|
KeyChannel::Accelerometer, MethodCodecType::Standard, |
|
|
|
KeyChannel::Accelerometer, |
|
|
|
[this](const Encodable &) |
|
|
|
MethodCodecType::Standard, |
|
|
|
{ EnableSensorAccelerometer(); return EventResponse(); }, |
|
|
|
[this](const Encodable &) { |
|
|
|
[this](const Encodable &) |
|
|
|
EnableSensorAccelerometer(); |
|
|
|
{ DisableSensorAccelerometer(); return EventResponse(); }); |
|
|
|
return EventResponse(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
[this](const Encodable &) { |
|
|
|
|
|
|
|
DisableSensorAccelerometer(); |
|
|
|
|
|
|
|
return EventResponse(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
registrar.RegisterEventChannel( |
|
|
|
registrar.RegisterEventChannel( |
|
|
|
KeyChannel::Compass, MethodCodecType::Standard, |
|
|
|
KeyChannel::Compass, |
|
|
|
[this](const Encodable &) |
|
|
|
MethodCodecType::Standard, |
|
|
|
{ EnableSensorCompass(); return EventResponse(); }, |
|
|
|
[this](const Encodable &) { |
|
|
|
[this](const Encodable &) |
|
|
|
EnableSensorCompass(); |
|
|
|
{ DisableSensorCompass(); return EventResponse(); }); |
|
|
|
return EventResponse(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
[this](const Encodable &) { |
|
|
|
|
|
|
|
DisableSensorCompass(); |
|
|
|
|
|
|
|
return EventResponse(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
registrar.RegisterEventChannel( |
|
|
|
registrar.RegisterEventChannel( |
|
|
|
KeyChannel::Tap, MethodCodecType::Standard, |
|
|
|
KeyChannel::Tap, |
|
|
|
[this](const Encodable &) |
|
|
|
MethodCodecType::Standard, |
|
|
|
{ EnableSensorTap(); return EventResponse(); }, |
|
|
|
[this](const Encodable &) { |
|
|
|
[this](const Encodable &) |
|
|
|
EnableSensorTap(); |
|
|
|
{ DisableSensorTap(); return EventResponse(); }); |
|
|
|
return EventResponse(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
[this](const Encodable &) { |
|
|
|
|
|
|
|
DisableSensorTap(); |
|
|
|
|
|
|
|
return EventResponse(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
registrar.RegisterEventChannel( |
|
|
|
registrar.RegisterEventChannel( |
|
|
|
KeyChannel::ALS, MethodCodecType::Standard, |
|
|
|
KeyChannel::ALS, |
|
|
|
[this](const Encodable &) |
|
|
|
MethodCodecType::Standard, |
|
|
|
{ EnableSensorALS(); return EventResponse(); }, |
|
|
|
[this](const Encodable &) { |
|
|
|
[this](const Encodable &) |
|
|
|
EnableSensorALS(); |
|
|
|
{ DisableSensorALS(); return EventResponse(); }); |
|
|
|
return EventResponse(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
[this](const Encodable &) { |
|
|
|
|
|
|
|
DisableSensorALS(); |
|
|
|
|
|
|
|
return EventResponse(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
registrar.RegisterEventChannel( |
|
|
|
registrar.RegisterEventChannel( |
|
|
|
KeyChannel::Proximity, MethodCodecType::Standard, |
|
|
|
KeyChannel::Proximity, |
|
|
|
[this](const Encodable &) |
|
|
|
MethodCodecType::Standard, |
|
|
|
{ EnableSensorProximity(); return EventResponse(); }, |
|
|
|
[this](const Encodable &) { |
|
|
|
[this](const Encodable &) |
|
|
|
EnableSensorProximity(); |
|
|
|
{ DisableSensorProximity(); return EventResponse(); }); |
|
|
|
return EventResponse(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
[this](const Encodable &) { |
|
|
|
|
|
|
|
DisableSensorProximity(); |
|
|
|
|
|
|
|
return EventResponse(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
registrar.RegisterEventChannel( |
|
|
|
registrar.RegisterEventChannel( |
|
|
|
KeyChannel::Rotation, MethodCodecType::Standard, |
|
|
|
KeyChannel::Rotation, |
|
|
|
[this](const Encodable &) |
|
|
|
MethodCodecType::Standard, |
|
|
|
{ EnableSensorRotation(); return EventResponse(); }, |
|
|
|
[this](const Encodable &) { |
|
|
|
[this](const Encodable &) |
|
|
|
EnableSensorRotation(); |
|
|
|
{ DisableSensorRotation(); return EventResponse(); }); |
|
|
|
return EventResponse(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
[this](const Encodable &) { |
|
|
|
|
|
|
|
DisableSensorRotation(); |
|
|
|
|
|
|
|
return EventResponse(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
registrar.RegisterEventChannel( |
|
|
|
registrar.RegisterEventChannel( |
|
|
|
KeyChannel::Magnetometer, MethodCodecType::Standard, |
|
|
|
KeyChannel::Magnetometer, |
|
|
|
[this](const Encodable &) |
|
|
|
MethodCodecType::Standard, |
|
|
|
{ EnableSensorMagnetometer(); return EventResponse(); }, |
|
|
|
[this](const Encodable &) { |
|
|
|
[this](const Encodable &) |
|
|
|
EnableSensorMagnetometer(); |
|
|
|
{ DisableSensorMagnetometer(); return EventResponse(); }); |
|
|
|
return EventResponse(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
[this](const Encodable &) { |
|
|
|
|
|
|
|
DisableSensorMagnetometer(); |
|
|
|
|
|
|
|
return EventResponse(); |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T> |
|
|
|
template<typename T> |
|
|
|
bool SensorsPlusAuroraPlugin::RegisterSensorInterface(QString sensor) |
|
|
|
bool SensorsPlusAuroraPlugin::RegisterSensorInterface(QString sensor) |
|
|
|
{ |
|
|
|
{ |
|
|
|
SensorManagerInterface &sm = SensorManagerInterface::instance(); |
|
|
|
SensorManagerInterface &sm = SensorManagerInterface::instance(); |
|
|
|
if (!sm.isValid()) |
|
|
|
if (!sm.isValid()) { |
|
|
|
{ |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QDBusReply<bool> reply(sm.loadPlugin(sensor)); |
|
|
|
QDBusReply<bool> reply(sm.loadPlugin(sensor)); |
|
|
|
if (!reply.isValid() || !reply.value()) |
|
|
|
if (!reply.isValid() || !reply.value()) { |
|
|
|
{ |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -135,18 +171,15 @@ void SensorsPlusAuroraPlugin::EventChannelData(std::string channel, std::vector< |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void SensorsPlusAuroraPlugin::EnableSensorOrientation() |
|
|
|
void SensorsPlusAuroraPlugin::EnableSensorOrientation() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_ifaceOrientation == nullptr) |
|
|
|
if (m_ifaceOrientation == nullptr) { |
|
|
|
{ |
|
|
|
if (!RegisterSensorInterface<OrientationSensorChannelInterface>(KeySensor::Orientation)) { |
|
|
|
if (!RegisterSensorInterface<OrientationSensorChannelInterface>(KeySensor::Orientation)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
EventChannelNull(KeyChannel::Orientation); |
|
|
|
EventChannelNull(KeyChannel::Orientation); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_ifaceOrientation = OrientationSensorChannelInterface::interface(KeySensor::Orientation); |
|
|
|
m_ifaceOrientation = OrientationSensorChannelInterface::interface(KeySensor::Orientation); |
|
|
|
|
|
|
|
|
|
|
|
if (!m_ifaceOrientation) |
|
|
|
if (!m_ifaceOrientation) { |
|
|
|
{ |
|
|
|
|
|
|
|
EventChannelNull(KeyChannel::Orientation); |
|
|
|
EventChannelNull(KeyChannel::Orientation); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -163,12 +196,9 @@ void SensorsPlusAuroraPlugin::EnableSensorOrientation() |
|
|
|
|
|
|
|
|
|
|
|
void SensorsPlusAuroraPlugin::DisableSensorOrientation() |
|
|
|
void SensorsPlusAuroraPlugin::DisableSensorOrientation() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_ifaceOrientation == nullptr) |
|
|
|
if (m_ifaceOrientation) { |
|
|
|
{ |
|
|
|
m_ifaceOrientation->stop(); |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_ifaceOrientation->stop(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SensorsPlusAuroraPlugin::EventSensorOrientation(const Unsigned &data) |
|
|
|
void SensorsPlusAuroraPlugin::EventSensorOrientation(const Unsigned &data) |
|
|
@ -183,18 +213,17 @@ void SensorsPlusAuroraPlugin::EventSensorOrientation(const Unsigned &data) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void SensorsPlusAuroraPlugin::EnableSensorAccelerometer() |
|
|
|
void SensorsPlusAuroraPlugin::EnableSensorAccelerometer() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_ifaceAccelerometer == nullptr) |
|
|
|
if (m_ifaceAccelerometer == nullptr) { |
|
|
|
{ |
|
|
|
if (!RegisterSensorInterface<AccelerometerSensorChannelInterface>( |
|
|
|
if (!RegisterSensorInterface<AccelerometerSensorChannelInterface>(KeySensor::Accelerometer)) |
|
|
|
KeySensor::Accelerometer)) { |
|
|
|
{ |
|
|
|
|
|
|
|
EventChannelNull(KeyChannel::Accelerometer); |
|
|
|
EventChannelNull(KeyChannel::Accelerometer); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_ifaceAccelerometer = AccelerometerSensorChannelInterface::interface(KeySensor::Accelerometer); |
|
|
|
m_ifaceAccelerometer = AccelerometerSensorChannelInterface::interface( |
|
|
|
|
|
|
|
KeySensor::Accelerometer); |
|
|
|
|
|
|
|
|
|
|
|
if (!m_ifaceAccelerometer) |
|
|
|
if (!m_ifaceAccelerometer) { |
|
|
|
{ |
|
|
|
|
|
|
|
EventChannelNull(KeyChannel::Accelerometer); |
|
|
|
EventChannelNull(KeyChannel::Accelerometer); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -211,12 +240,9 @@ void SensorsPlusAuroraPlugin::EnableSensorAccelerometer() |
|
|
|
|
|
|
|
|
|
|
|
void SensorsPlusAuroraPlugin::DisableSensorAccelerometer() |
|
|
|
void SensorsPlusAuroraPlugin::DisableSensorAccelerometer() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_ifaceAccelerometer == nullptr) |
|
|
|
if (m_ifaceAccelerometer) { |
|
|
|
{ |
|
|
|
m_ifaceAccelerometer->stop(); |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_ifaceAccelerometer->stop(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SensorsPlusAuroraPlugin::EventSensorAccelerometer(const XYZ &data) |
|
|
|
void SensorsPlusAuroraPlugin::EventSensorAccelerometer(const XYZ &data) |
|
|
@ -233,18 +259,15 @@ void SensorsPlusAuroraPlugin::EventSensorAccelerometer(const XYZ &data) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void SensorsPlusAuroraPlugin::EnableSensorCompass() |
|
|
|
void SensorsPlusAuroraPlugin::EnableSensorCompass() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_ifaceCompass == nullptr) |
|
|
|
if (m_ifaceCompass == nullptr) { |
|
|
|
{ |
|
|
|
if (!RegisterSensorInterface<CompassSensorChannelInterface>(KeySensor::Compass)) { |
|
|
|
if (!RegisterSensorInterface<CompassSensorChannelInterface>(KeySensor::Compass)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
EventChannelNull(KeyChannel::Compass); |
|
|
|
EventChannelNull(KeyChannel::Compass); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_ifaceCompass = CompassSensorChannelInterface::interface(KeySensor::Compass); |
|
|
|
m_ifaceCompass = CompassSensorChannelInterface::interface(KeySensor::Compass); |
|
|
|
|
|
|
|
|
|
|
|
if (!m_ifaceCompass) |
|
|
|
if (!m_ifaceCompass) { |
|
|
|
{ |
|
|
|
|
|
|
|
EventChannelNull(KeyChannel::Compass); |
|
|
|
EventChannelNull(KeyChannel::Compass); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -261,12 +284,9 @@ void SensorsPlusAuroraPlugin::EnableSensorCompass() |
|
|
|
|
|
|
|
|
|
|
|
void SensorsPlusAuroraPlugin::DisableSensorCompass() |
|
|
|
void SensorsPlusAuroraPlugin::DisableSensorCompass() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_ifaceCompass == nullptr) |
|
|
|
if (m_ifaceCompass) { |
|
|
|
{ |
|
|
|
m_ifaceCompass->stop(); |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_ifaceCompass->stop(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SensorsPlusAuroraPlugin::EventSensorCompass(const Compass &data) |
|
|
|
void SensorsPlusAuroraPlugin::EventSensorCompass(const Compass &data) |
|
|
@ -282,18 +302,15 @@ void SensorsPlusAuroraPlugin::EventSensorCompass(const Compass &data) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void SensorsPlusAuroraPlugin::EnableSensorTap() |
|
|
|
void SensorsPlusAuroraPlugin::EnableSensorTap() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_ifaceTap == nullptr) |
|
|
|
if (m_ifaceTap == nullptr) { |
|
|
|
{ |
|
|
|
if (!RegisterSensorInterface<TapSensorChannelInterface>(KeySensor::Tap)) { |
|
|
|
if (!RegisterSensorInterface<TapSensorChannelInterface>(KeySensor::Tap)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
EventChannelNull(KeyChannel::Tap); |
|
|
|
EventChannelNull(KeyChannel::Tap); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_ifaceTap = TapSensorChannelInterface::interface(KeySensor::Tap); |
|
|
|
m_ifaceTap = TapSensorChannelInterface::interface(KeySensor::Tap); |
|
|
|
|
|
|
|
|
|
|
|
if (!m_ifaceTap) |
|
|
|
if (!m_ifaceTap) { |
|
|
|
{ |
|
|
|
|
|
|
|
EventChannelNull(KeyChannel::Tap); |
|
|
|
EventChannelNull(KeyChannel::Tap); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -309,12 +326,9 @@ void SensorsPlusAuroraPlugin::EnableSensorTap() |
|
|
|
|
|
|
|
|
|
|
|
void SensorsPlusAuroraPlugin::DisableSensorTap() |
|
|
|
void SensorsPlusAuroraPlugin::DisableSensorTap() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_ifaceTap == nullptr) |
|
|
|
if (m_ifaceTap) { |
|
|
|
{ |
|
|
|
m_ifaceTap->stop(); |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_ifaceTap->stop(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SensorsPlusAuroraPlugin::EventSensorTap(const Tap &data) |
|
|
|
void SensorsPlusAuroraPlugin::EventSensorTap(const Tap &data) |
|
|
@ -330,18 +344,15 @@ void SensorsPlusAuroraPlugin::EventSensorTap(const Tap &data) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void SensorsPlusAuroraPlugin::EnableSensorALS() |
|
|
|
void SensorsPlusAuroraPlugin::EnableSensorALS() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_ifaceALS == nullptr) |
|
|
|
if (m_ifaceALS == nullptr) { |
|
|
|
{ |
|
|
|
if (!RegisterSensorInterface<ALSSensorChannelInterface>(KeySensor::ALS)) { |
|
|
|
if (!RegisterSensorInterface<ALSSensorChannelInterface>(KeySensor::ALS)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
EventChannelNull(KeyChannel::ALS); |
|
|
|
EventChannelNull(KeyChannel::ALS); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_ifaceALS = ALSSensorChannelInterface::interface(KeySensor::ALS); |
|
|
|
m_ifaceALS = ALSSensorChannelInterface::interface(KeySensor::ALS); |
|
|
|
|
|
|
|
|
|
|
|
if (!m_ifaceALS) |
|
|
|
if (!m_ifaceALS) { |
|
|
|
{ |
|
|
|
|
|
|
|
EventChannelNull(KeyChannel::ALS); |
|
|
|
EventChannelNull(KeyChannel::ALS); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -358,12 +369,9 @@ void SensorsPlusAuroraPlugin::EnableSensorALS() |
|
|
|
|
|
|
|
|
|
|
|
void SensorsPlusAuroraPlugin::DisableSensorALS() |
|
|
|
void SensorsPlusAuroraPlugin::DisableSensorALS() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_ifaceALS == nullptr) |
|
|
|
if (m_ifaceALS) { |
|
|
|
{ |
|
|
|
m_ifaceALS->stop(); |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_ifaceALS->stop(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SensorsPlusAuroraPlugin::EventSensorALS(const Unsigned &data) |
|
|
|
void SensorsPlusAuroraPlugin::EventSensorALS(const Unsigned &data) |
|
|
@ -378,18 +386,15 @@ void SensorsPlusAuroraPlugin::EventSensorALS(const Unsigned &data) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void SensorsPlusAuroraPlugin::EnableSensorProximity() |
|
|
|
void SensorsPlusAuroraPlugin::EnableSensorProximity() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_ifaceProximity == nullptr) |
|
|
|
if (m_ifaceProximity == nullptr) { |
|
|
|
{ |
|
|
|
if (!RegisterSensorInterface<ProximitySensorChannelInterface>(KeySensor::Proximity)) { |
|
|
|
if (!RegisterSensorInterface<ProximitySensorChannelInterface>(KeySensor::Proximity)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
EventChannelNull(KeyChannel::Proximity); |
|
|
|
EventChannelNull(KeyChannel::Proximity); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_ifaceProximity = ProximitySensorChannelInterface::interface(KeySensor::Proximity); |
|
|
|
m_ifaceProximity = ProximitySensorChannelInterface::interface(KeySensor::Proximity); |
|
|
|
|
|
|
|
|
|
|
|
if (!m_ifaceProximity) |
|
|
|
if (!m_ifaceProximity) { |
|
|
|
{ |
|
|
|
|
|
|
|
EventChannelNull(KeyChannel::Proximity); |
|
|
|
EventChannelNull(KeyChannel::Proximity); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -406,12 +411,9 @@ void SensorsPlusAuroraPlugin::EnableSensorProximity() |
|
|
|
|
|
|
|
|
|
|
|
void SensorsPlusAuroraPlugin::DisableSensorProximity() |
|
|
|
void SensorsPlusAuroraPlugin::DisableSensorProximity() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_ifaceProximity == nullptr) |
|
|
|
if (m_ifaceProximity) { |
|
|
|
{ |
|
|
|
m_ifaceProximity->stop(); |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_ifaceProximity->stop(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SensorsPlusAuroraPlugin::EventSensorProximity(const Proximity &data) |
|
|
|
void SensorsPlusAuroraPlugin::EventSensorProximity(const Proximity &data) |
|
|
@ -426,18 +428,15 @@ void SensorsPlusAuroraPlugin::EventSensorProximity(const Proximity &data) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void SensorsPlusAuroraPlugin::EnableSensorRotation() |
|
|
|
void SensorsPlusAuroraPlugin::EnableSensorRotation() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_ifaceRotation == nullptr) |
|
|
|
if (m_ifaceRotation == nullptr) { |
|
|
|
{ |
|
|
|
if (!RegisterSensorInterface<RotationSensorChannelInterface>(KeySensor::Rotation)) { |
|
|
|
if (!RegisterSensorInterface<RotationSensorChannelInterface>(KeySensor::Rotation)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
EventChannelNull(KeyChannel::Rotation); |
|
|
|
EventChannelNull(KeyChannel::Rotation); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_ifaceRotation = RotationSensorChannelInterface::interface(KeySensor::Rotation); |
|
|
|
m_ifaceRotation = RotationSensorChannelInterface::interface(KeySensor::Rotation); |
|
|
|
|
|
|
|
|
|
|
|
if (!m_ifaceRotation) |
|
|
|
if (!m_ifaceRotation) { |
|
|
|
{ |
|
|
|
|
|
|
|
EventChannelNull(KeyChannel::Rotation); |
|
|
|
EventChannelNull(KeyChannel::Rotation); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -454,12 +453,9 @@ void SensorsPlusAuroraPlugin::EnableSensorRotation() |
|
|
|
|
|
|
|
|
|
|
|
void SensorsPlusAuroraPlugin::DisableSensorRotation() |
|
|
|
void SensorsPlusAuroraPlugin::DisableSensorRotation() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_ifaceRotation == nullptr) |
|
|
|
if (m_ifaceRotation) { |
|
|
|
{ |
|
|
|
m_ifaceRotation->stop(); |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_ifaceRotation->stop(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SensorsPlusAuroraPlugin::EventSensorRotation(const XYZ &data) |
|
|
|
void SensorsPlusAuroraPlugin::EventSensorRotation(const XYZ &data) |
|
|
@ -476,18 +472,15 @@ void SensorsPlusAuroraPlugin::EventSensorRotation(const XYZ &data) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void SensorsPlusAuroraPlugin::EnableSensorMagnetometer() |
|
|
|
void SensorsPlusAuroraPlugin::EnableSensorMagnetometer() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_ifaceMagnetometer == nullptr) |
|
|
|
if (m_ifaceMagnetometer == nullptr) { |
|
|
|
{ |
|
|
|
if (!RegisterSensorInterface<MagnetometerSensorChannelInterface>(KeySensor::Magnetometer)) { |
|
|
|
if (!RegisterSensorInterface<MagnetometerSensorChannelInterface>(KeySensor::Magnetometer)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
EventChannelNull(KeyChannel::Magnetometer); |
|
|
|
EventChannelNull(KeyChannel::Magnetometer); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_ifaceMagnetometer = MagnetometerSensorChannelInterface::interface(KeySensor::Magnetometer); |
|
|
|
m_ifaceMagnetometer = MagnetometerSensorChannelInterface::interface(KeySensor::Magnetometer); |
|
|
|
|
|
|
|
|
|
|
|
if (!m_ifaceMagnetometer) |
|
|
|
if (!m_ifaceMagnetometer) { |
|
|
|
{ |
|
|
|
|
|
|
|
EventChannelNull(KeyChannel::Magnetometer); |
|
|
|
EventChannelNull(KeyChannel::Magnetometer); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -504,12 +497,9 @@ void SensorsPlusAuroraPlugin::EnableSensorMagnetometer() |
|
|
|
|
|
|
|
|
|
|
|
void SensorsPlusAuroraPlugin::DisableSensorMagnetometer() |
|
|
|
void SensorsPlusAuroraPlugin::DisableSensorMagnetometer() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_ifaceMagnetometer == nullptr) |
|
|
|
if (m_ifaceMagnetometer) { |
|
|
|
{ |
|
|
|
m_ifaceMagnetometer->stop(); |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_ifaceMagnetometer->stop(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SensorsPlusAuroraPlugin::EventSensorMagnetometer(const MagneticField &data) |
|
|
|
void SensorsPlusAuroraPlugin::EventSensorMagnetometer(const MagneticField &data) |
|
|
|