Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbubnikv <bubnikv@gmail.com>2020-03-13 16:19:02 +0300
committerbubnikv <bubnikv@gmail.com>2020-03-13 16:19:14 +0300
commit2f6326a2ebe519beb86dde4883f8f1493d0c0a6b (patch)
tree1a42697f0bee006532819775b4adca9fcb6f1269 /src/slic3r/GUI/Plater.cpp
parent3684eea53ddaa049a72d958079efc6c05fa33b66 (diff)
Windows specific refactoring of Mouse3DController and RemovableDriveManager.
PrusaSlicer newly registers by Windows operating system for HID USB plug / unplug notifications and for Volume attach / detach notifications, and the background threads of the two respective services are waken up on these Windows notifications. The RemovableDriveManager also wakes up every 30 seconds to cope with the drives ejected from Windows Explorer or from another application, for example Cura, for which Windows OS does not send out notifications.
Diffstat (limited to 'src/slic3r/GUI/Plater.cpp')
-rw-r--r--src/slic3r/GUI/Plater.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp
index 2a25762a8..218677931 100644
--- a/src/slic3r/GUI/Plater.cpp
+++ b/src/slic3r/GUI/Plater.cpp
@@ -2188,10 +2188,16 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
// Load the 3DConnexion device database.
mouse3d_controller.load_config(*wxGetApp().app_config);
// Start the background thread to detect and connect to a HID device (Windows and Linux).
- // Connect to a 3DConnextion driver (OSX).
+ // Connect to a 3DConnextion driver (OSX).
mouse3d_controller.init();
-
-
+#ifdef _WIN32
+ // Register an USB HID (Human Interface Device) attach event. evt contains Win32 path to the USB device containing VID, PID and other info.
+ // This event wakes up the Mouse3DController's background thread to enumerate HID devices, if the VID of the callback event
+ // is one of the 3D Mouse vendors (3DConnexion or Logitech).
+ this->q->Bind(EVT_HID_DEVICE_ATTACHED, [this](HIDDeviceAttachedEvent &evt) {
+ mouse3d_controller.device_attached(evt.data);
+ });
+#endif /* _WIN32 */
this->q->Bind(EVT_REMOVABLE_DRIVE_EJECTED, [this](RemovableDriveEjectEvent &evt) {
if (evt.data.second) {
@@ -2205,6 +2211,11 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
this->q->Bind(EVT_REMOVABLE_DRIVES_CHANGED, [this](RemovableDrivesChangedEvent &) { this->show_action_buttons(this->ready_to_slice); });
// Start the background thread and register this window as a target for update events.
wxGetApp().removable_drive_manager()->init(this->q);
+#ifdef _WIN32
+ // Trigger enumeration of removable media on Win32 notification.
+ this->q->Bind(EVT_VOLUME_ATTACHED, [this](VolumeAttachedEvent &evt) { wxGetApp().removable_drive_manager()->volumes_changed(); });
+ this->q->Bind(EVT_VOLUME_DETACHED, [this](VolumeDetachedEvent &evt) { wxGetApp().removable_drive_manager()->volumes_changed(); });
+#endif /* _WIN32 */
// Initialize the Undo / Redo stack with a first snapshot.
this->take_snapshot(_(L("New Project")));