1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- #include "qvibra.h"
- #include "qvibra_p.h"
- #include <math.h>
- #include <QDebug>
- QVibra::QVibra(QObject *parent) :
- QObject(parent)
- ,m_rotation(QVibra::Positive)
- {
- QT_TRAP_THROWING(d = QVibraPrivate::NewL(this));
- }
- QVibra::~QVibra()
- {
- delete d;
- }
- bool QVibra::start(int duration, int intensity)
- {
- int m_intensity = Min<int>(abs(intensity), 100);
- return ( this->d ) ? this->d->start(duration, ((this->m_rotation==QVibra::Positive) ? m_intensity : -m_intensity)) : false;
- }
- bool QVibra::stop()
- {
- return ( this->d ) ? this->d->stop() : false;
- }
- void QVibra::reserve()
- {
- if( this->d ) this->d->reserve();
- }
- void QVibra::release()
- {
- if( this->d ) this->d->release();
- }
- QVibra::Status QVibra::currentStatus() const
- {
- return (this->d) ? d->currentStatus() : StatusNotAllowed;
- }
- QVibra::EngineRotation QVibra::rotation(){
- return this->m_rotation;
- }
- void QVibra::setRotation(EngineRotation value){
- this->m_rotation = value;
- }
- QVibra::Error QVibra::error() const
- {
- return (this->d) ? d->error() : NotCreated;
- }
- QString QVibra::errorString() const
- {
- QString result = "";
- if (this->d) {
- switch(d->error()) {
- case QVibra::NoError : result = "NoError"; break;
- case QVibra::OutOfMemoryError : result = "OutOfMemoryError"; break;
- case QVibra::ArgumentError : result = "ArgumentError"; break;
- case QVibra::VibraInUseError : result = "VibraInUseError"; break;
- case QVibra::HardwareError : result = "HardwareError"; break;
- case QVibra::TimeOutError : result = "TimeOutError"; break;
- case QVibra::VibraLockedError : result = "VibraLockedError"; break; // Vibra is locked down because too much continuous use or explicitly blocked by for example some vibration sensitive accessory
- case QVibra::AccessDeniedError: result = "AccessDeniedError"; break;
- case QVibra::UnknownError : result = "UnknownError"; break;
- //case QVibra::NotCreated : result = "NotCreated"; break;
- default: result = "UnknownError"; break;
- }
- }
- return result;
- }
|