-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add command line vibrate command
- Loading branch information
Showing
8 changed files
with
185 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// This file is part of Projecteur - https://github.com/jahnf/projecteur | ||
// - See LICENSE.md and README.md | ||
|
||
#include "device-command-helper.h" | ||
|
||
#include "device-hidpp.h" | ||
#include "spotlight.h" | ||
|
||
// ------------------------------------------------------------------------------------------------- | ||
DeviceCommandHelper::DeviceCommandHelper(QObject* parent, Spotlight* spotlight) | ||
: QObject(parent), m_spotlight(spotlight) | ||
{ | ||
|
||
} | ||
|
||
// ------------------------------------------------------------------------------------------------- | ||
DeviceCommandHelper::~DeviceCommandHelper() = default; | ||
|
||
|
||
// ------------------------------------------------------------------------------------------------- | ||
bool DeviceCommandHelper::sendVibrateCommand(uint8_t intensity, uint8_t length) | ||
{ | ||
if (m_spotlight.isNull()) { | ||
return false; | ||
} | ||
|
||
for ( auto const& dev : m_spotlight->connectedDevices()) { | ||
if (auto connection = m_spotlight->deviceConnection(dev.id)) { | ||
if (!connection->hasHidppSupport()) { | ||
continue; | ||
} | ||
|
||
for (auto const& subInfo : connection->subDevices()) { | ||
auto const& subConn = subInfo.second; | ||
if (!subConn || !subConn->hasFlags(DeviceFlag::Vibrate)) { | ||
continue; | ||
} | ||
|
||
if (auto hidppConn = std::dynamic_pointer_cast<SubHidppConnection>(subConn)) | ||
{ | ||
hidppConn->sendVibrateCommand(intensity, length, | ||
[](HidppConnectionInterface::MsgResult, HIDPP::Message&&) { | ||
// logDebug(hid) << tr("Vibrate command returned: %1 (%2)") | ||
// .arg(toString(result)).arg(msg.hex()); | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// This file is part of Projecteur - https://github.com/jahnf/projecteur | ||
// - See LICENSE.md and README.md | ||
#pragma once | ||
|
||
#include <QObject> | ||
#include <QPointer> | ||
|
||
class Spotlight; | ||
|
||
/// Class that offers easy access to device commands with a given Spotlight | ||
/// instance. | ||
class DeviceCommandHelper : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit DeviceCommandHelper(QObject* parent, Spotlight* spotlight); | ||
virtual ~DeviceCommandHelper(); | ||
|
||
bool sendVibrateCommand(uint8_t intensity, uint8_t length); | ||
|
||
private: | ||
QPointer<Spotlight> m_spotlight; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters