mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 00:37:51 -06:00
#3230 - Detection of 3Dconnexion devices every 2 seconds
This commit is contained in:
parent
b1047d2e26
commit
ab00f501f1
2 changed files with 12 additions and 0 deletions
|
@ -186,6 +186,7 @@ Mouse3DController::Mouse3DController()
|
|||
, m_running(false)
|
||||
, m_settings_dialog(false)
|
||||
{
|
||||
m_last_time = std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
|
||||
void Mouse3DController::init()
|
||||
|
@ -332,9 +333,18 @@ void Mouse3DController::render_settings_dialog(unsigned int canvas_width, unsign
|
|||
|
||||
bool Mouse3DController::connect_device()
|
||||
{
|
||||
static const long long DETECTION_TIME = 2; // seconds
|
||||
|
||||
if (is_device_connected())
|
||||
return false;
|
||||
|
||||
// check time since last detection took place
|
||||
auto now = std::chrono::high_resolution_clock::now();
|
||||
if (std::chrono::duration_cast<std::chrono::seconds>(now - m_last_time).count() < DETECTION_TIME)
|
||||
return false;
|
||||
|
||||
m_last_time = now;
|
||||
|
||||
// Enumerates devices
|
||||
hid_device_info* devices = hid_enumerate(0, 0);
|
||||
if (devices == nullptr)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue