summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--compat/check-visible.cpp9
-rw-r--r--logic/shortcuts.cpp26
-rw-r--r--opentrack/main-window.cpp9
-rw-r--r--video-ps3eye/module.cpp33
-rw-r--r--video-ps3eye/module.hpp11
m---------video-ps3eye/ps3eye-driver0
6 files changed, 38 insertions, 50 deletions
diff --git a/compat/check-visible.cpp b/compat/check-visible.cpp
index f786ca14..4da649c7 100644
--- a/compat/check-visible.cpp
+++ b/compat/check-visible.cpp
@@ -29,6 +29,15 @@ void set_is_visible(const QWidget& w, bool force)
return;
}
+ {
+ int ndisplays = GetSystemMetrics(SM_CMONITORS);
+ if (ndisplays > 1)
+ {
+ visible = true;
+ return;
+ }
+ }
+
HWND hwnd = (HWND)w.winId();
if (!force && timer.elapsed_ms() < (visible ? visible_timeout : invisible_timeout))
diff --git a/logic/shortcuts.cpp b/logic/shortcuts.cpp
index 377fa3e5..26465101 100644
--- a/logic/shortcuts.cpp
+++ b/logic/shortcuts.cpp
@@ -83,26 +83,28 @@ void Shortcuts::bind_shortcut(K& key, const key_opts& k, bool held)
#ifdef _WIN32
-void Shortcuts::receiver(const Key& k)
+void Shortcuts::receiver(const Key& key)
{
const unsigned sz = keys.size();
for (unsigned i = 0; i < sz; i++)
{
- K& k_ = std::get<0>(keys[i]);
- if (k.guid != k_.guid)
+ K& k = std::get<0>(keys[i]);
+ if (key.guid != k.guid)
continue;
- if (k.keycode != k_.keycode)
- continue;
-
- if (k_.held && !k.held) continue;
- if (k_.alt != k.alt) continue;
- if (k_.ctrl != k.ctrl) continue;
- if (k_.shift != k.shift) continue;
- if (!k_.should_process())
+ if (key.keycode != k.keycode)
continue;
+ if (k.held && !key.held) continue;
+ if (key.held)
+ {
+ if (k.alt != key.alt) continue;
+ if (k.ctrl != key.ctrl) continue;
+ if (k.shift != key.shift) continue;
+ if (!k.should_process())
+ continue;
+ }
fun& f = std::get<1>(keys[i]);
- f(k.held);
+ f(key.held);
}
}
diff --git a/opentrack/main-window.cpp b/opentrack/main-window.cpp
index 37beafe3..4f6972f4 100644
--- a/opentrack/main-window.cpp
+++ b/opentrack/main-window.cpp
@@ -280,14 +280,7 @@ main_window::~main_window()
stop_tracker_();
close();
- constexpr int inc = 25, max = 1000;
-
- for (int k = 0; k < max; k += inc)
- {
- QEventLoop ev;
- ev.processEvents();
- portable::sleep(inc);
- }
+ portable::sleep(1000);
}
exit();
diff --git a/video-ps3eye/module.cpp b/video-ps3eye/module.cpp
index 812e523c..1d4e43f1 100644
--- a/video-ps3eye/module.cpp
+++ b/video-ps3eye/module.cpp
@@ -144,6 +144,7 @@ bool ps3eye_camera::start(info& args)
return false;
volatile auto& ptr = *(ps3eye::shm*)shm.ptr();
+ QString error;
using mode = ps3eye::shm_in::mode;
@@ -181,14 +182,13 @@ bool ps3eye_camera::start(info& args)
portable::sleep(sleep_ms);
}
- run_in_thread_sync(qApp, [&]() {
- QString error;
- if (ptr.out.error_string[0] == '\0')
- error = "Unknown error";
- else
- error = QString::fromLatin1((const char*)ptr.out.error_string,
- strnlen((const char*)ptr.out.error_string, sizeof(ptr.out.error_string)));
+ if (ptr.out.error_string[0] == '\0')
+ error = "Unknown error";
+ else
+ error = QString::fromLatin1((const char*)ptr.out.error_string,
+ strnlen((const char*)ptr.out.error_string, sizeof(ptr.out.error_string)));
+ run_in_thread_async(qApp, [=]() {
QMessageBox::critical(nullptr, "Can't open camera", "PS3 Eye driver error: " + error, QMessageBox::Close);
});
@@ -247,19 +247,16 @@ OTR_REGISTER_CAMERA(ps3eye_camera_)
dialog::dialog(QWidget* parent) : QWidget(parent)
{
ui.setupUi(this);
- t.setSingleShot(true);
- t.setInterval(500);
tie_setting(s.exposure, ui.exposure_slider);
tie_setting(s.gain, ui.gain_slider);
ui.exposure_label->setValue((int)*s.exposure);
ui.gain_label->setValue((int)*s.gain);
- connect(&s.exposure, value_::value_changed<slider_value>(), this, [this](const slider_value&) { s.set_exposure(); t.stop(); t.start(); });
- connect(&s.gain, value_::value_changed<slider_value>(), this, [this](const slider_value&) { s.set_gain(); t.stop(); t.start(); });
+ connect(&s.exposure, value_::value_changed<slider_value>(), this, [this](const slider_value&) { s.set_exposure(); });
+ connect(&s.gain, value_::value_changed<slider_value>(), this, [this](const slider_value&) { s.set_gain(); });
connect(ui.exposure_slider, &QSlider::valueChanged, ui.exposure_label, &QSpinBox::setValue);
connect(ui.gain_slider, &QSlider::valueChanged, ui.gain_label, &QSpinBox::setValue);
connect(ui.buttonBox, &QDialogButtonBox::accepted, this, &dialog::do_ok);
connect(ui.buttonBox, &QDialogButtonBox::rejected, this, &dialog::do_cancel);
- connect(&t, &QTimer::timeout, this, [this]() { s.apply(); });
}
// XXX copypasta -sh 20200329
@@ -270,7 +267,7 @@ void settings::set_gain()
auto& ptr = *(ps3eye::shm volatile*)shm.ptr();
ptr.in.gain = (unsigned char)*gain;
- //++ptr.in.settings_updated;
+ ++ptr.in.settings_updated;
std::atomic_thread_fence(std::memory_order_seq_cst);
}
@@ -281,16 +278,6 @@ void settings::set_exposure()
auto& ptr = *(ps3eye::shm volatile*)shm.ptr();
ptr.in.exposure = (unsigned char)*exposure;
- //++ptr.in.settings_updated;
- std::atomic_thread_fence(std::memory_order_seq_cst);
-}
-
-void settings::apply()
-{
- if (!shm.success())
- return;
-
- auto& ptr = *(ps3eye::shm volatile*)shm.ptr();
++ptr.in.settings_updated;
std::atomic_thread_fence(std::memory_order_seq_cst);
}
diff --git a/video-ps3eye/module.hpp b/video-ps3eye/module.hpp
index 955463d6..56ffe5df 100644
--- a/video-ps3eye/module.hpp
+++ b/video-ps3eye/module.hpp
@@ -8,8 +8,8 @@
#include "compat/timer.hpp"
#include "ui_dialog.h"
+#include <QDialog>
#include <QProcess>
-#include <QTimer>
using namespace options;
@@ -27,7 +27,6 @@ struct settings final
void set_exposure();
void set_gain();
- void apply();
};
class dialog final : public QWidget
@@ -36,15 +35,13 @@ class dialog final : public QWidget
Ui_Dialog ui;
settings s;
- QTimer t;
-
shm_wrapper shm { "ps3eye-driver-shm", nullptr, sizeof(ps3eye::shm) };
- void do_ok() { s.b->save(); s.apply(); close(); }
- void do_cancel() { s.b->reload(); s.apply(); close(); }
+ void do_ok() { s.b->save(); close(); deleteLater(); }
+ void do_cancel() { s.b->reload(); close(); deleteLater(); }
protected:
- void closeEvent(QCloseEvent*) override { do_cancel(); deleteLater(); }
+ void closeEvent(QCloseEvent*) override { do_cancel(); }
public:
explicit dialog(QWidget* parent = nullptr);
diff --git a/video-ps3eye/ps3eye-driver b/video-ps3eye/ps3eye-driver
-Subproject f0259c700099df522e652238ff77257c70a8a4f
+Subproject 2cde6fbfbde7874daab634ca3b35b7ede14ed88