summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--cv/video-property-page.cpp29
-rw-r--r--cv/video-widget.cpp30
-rw-r--r--cv/video-widget.hpp2
-rw-r--r--dinput/keybinding-worker.cpp2
-rw-r--r--dinput/keybinding-worker.hpp4
-rw-r--r--spline/spline-widget.cpp114
-rw-r--r--spline/spline-widget.hpp18
-rw-r--r--tracker-joystick/ftnoir_tracker_joystick.h2
-rw-r--r--tracker-joystick/ftnoir_tracker_joystick_dialog.cpp14
9 files changed, 107 insertions, 108 deletions
diff --git a/cv/video-property-page.cpp b/cv/video-property-page.cpp
index e6177c5c..1b8b94cf 100644
--- a/cv/video-property-page.cpp
+++ b/cv/video-property-page.cpp
@@ -27,9 +27,6 @@
#include <dshow.h>
-#define CHECK(expr) if (FAILED(hr = (expr))) { qDebug() << QLatin1String(#expr) << hr; goto done; }
-#define CHECK2(expr) if (!(expr)) { qDebug() << QLatin1String(#expr); goto done; }
-
bool video_property_page::show_from_capture(cv::VideoCapture& cap, int /*index */)
{
return cap.set(cv::CAP_PROP_SETTINGS, 0);
@@ -39,14 +36,16 @@ struct prop_settings_worker final : QThread
{
explicit prop_settings_worker(int idx);
~prop_settings_worker() override;
- void _open_prop_page();
+
+private:
+ void open_prop_page();
void run() override;
cv::VideoCapture cap;
- int _idx = -1;
+ int idx = -1;
};
-prop_settings_worker::prop_settings_worker(int idx)
+prop_settings_worker::prop_settings_worker(int idx_)
{
int ret = (int)cap.get(cv::CAP_PROP_SETTINGS);
@@ -60,16 +59,16 @@ prop_settings_worker::prop_settings_worker(int idx)
});
else
{
- _idx = idx;
+ idx = idx_;
// DON'T MOVE IT
// ps3 eye will reset to default settings if done from another thread
- _open_prop_page();
+ open_prop_page();
}
}
-void prop_settings_worker::_open_prop_page()
+void prop_settings_worker::open_prop_page()
{
- cap.open(_idx);
+ cap.open(idx);
if (cap.isOpened())
{
@@ -87,14 +86,14 @@ void prop_settings_worker::_open_prop_page()
}
qDebug() << "property-page: can't open camera";
- _idx = -1;
+ idx = -1;
return;
ok:
portable::sleep(100);
- qDebug() << "property-page: opening for" << _idx;
+ qDebug() << "property-page: opening for" << idx;
if (!cap.set(cv::CAP_PROP_SETTINGS, 0))
{
@@ -110,7 +109,7 @@ ok:
prop_settings_worker::~prop_settings_worker()
{
- if (_idx != -1)
+ if (idx != -1)
{
// ax filter is race condition-prone
portable::sleep(250);
@@ -118,13 +117,13 @@ prop_settings_worker::~prop_settings_worker()
// idem
portable::sleep(250);
- qDebug() << "property-page: closed" << _idx;
+ qDebug() << "property-page: closed" << idx;
}
}
void prop_settings_worker::run()
{
- if (_idx != -1)
+ if (idx != -1)
{
while (cap.get(cv::CAP_PROP_SETTINGS) > 0)
portable::sleep(1000);
diff --git a/cv/video-widget.cpp b/cv/video-widget.cpp
index c80bd96b..e7df087e 100644
--- a/cv/video-widget.cpp
+++ b/cv/video-widget.cpp
@@ -29,29 +29,29 @@ void cv_video_widget::update_image(const cv::Mat& frame)
if (width < 1 || height < 1)
return;
- if (_frame.cols != frame.cols || _frame.rows != frame.rows)
- _frame = cv::Mat(frame.rows, frame.cols, CV_8UC3);
- frame.copyTo(_frame);
+ if (frame1.cols != frame.cols || frame1.rows != frame.rows)
+ frame1 = cv::Mat(frame.rows, frame.cols, CV_8UC3);
+ frame.copyTo(frame1);
freshp = true;
- if (_frame2.cols != _frame.cols || _frame2.rows != _frame.rows)
- _frame2 = cv::Mat(_frame.rows, _frame.cols, CV_8UC4);
+ if (frame2.cols != frame1.cols || frame2.rows != frame1.rows)
+ frame2 = cv::Mat(frame1.rows, frame1.cols, CV_8UC4);
- if (_frame3.cols != width || _frame3.rows != height)
- _frame3 = cv::Mat(height, width, CV_8UC4);
+ if (frame3.cols != width || frame3.rows != height)
+ frame3 = cv::Mat(height, width, CV_8UC4);
- cv::cvtColor(_frame, _frame2, cv::COLOR_BGR2BGRA);
+ cv::cvtColor(frame1, frame2, cv::COLOR_BGR2BGRA);
const cv::Mat* img;
- if (_frame.cols != width || _frame.rows != height)
+ if (frame1.cols != width || frame1.rows != height)
{
- cv::resize(_frame2, _frame3, cv::Size(width, height), 0, 0, cv::INTER_NEAREST);
+ cv::resize(frame2, frame3, cv::Size(width, height), 0, 0, cv::INTER_NEAREST);
- img = &_frame3;
+ img = &frame3;
}
else
- img = &_frame2;
+ img = &frame2;
const unsigned nbytes = unsigned(4 * img->rows * img->cols);
@@ -101,9 +101,9 @@ void cv_video_widget::paintEvent(QPaintEvent*)
width = W, height = H;
- _frame = cv::Mat();
- _frame2 = cv::Mat();
- _frame3 = cv::Mat();
+ frame1 = cv::Mat();
+ frame2 = cv::Mat();
+ frame3 = cv::Mat();
}
}
diff --git a/cv/video-widget.hpp b/cv/video-widget.hpp
index 8ad62a3c..104fa21e 100644
--- a/cv/video-widget.hpp
+++ b/cv/video-widget.hpp
@@ -40,7 +40,7 @@ private:
QImage texture;
std::vector<unsigned char> vec;
QTimer timer;
- cv::Mat _frame, _frame2, _frame3;
+ cv::Mat frame1, frame2, frame3;
int width = 320, height = 240;
bool freshp = false;
};
diff --git a/dinput/keybinding-worker.cpp b/dinput/keybinding-worker.cpp
index aa8faca8..e4cc6659 100644
--- a/dinput/keybinding-worker.cpp
+++ b/dinput/keybinding-worker.cpp
@@ -210,7 +210,7 @@ bool KeybindingWorker::run_joystick_nolock()
return true;
}
-KeybindingWorker::fun* KeybindingWorker::_add_receiver(fun& receiver)
+KeybindingWorker::fun* KeybindingWorker::add_receiver(fun& receiver)
{
QMutexLocker l(&mtx);
receivers.push_back(std::make_unique<fun>(receiver));
diff --git a/dinput/keybinding-worker.hpp b/dinput/keybinding-worker.hpp
index d1dc4149..fdcf94c9 100644
--- a/dinput/keybinding-worker.hpp
+++ b/dinput/keybinding-worker.hpp
@@ -63,7 +63,7 @@ private:
KeybindingWorker();
static KeybindingWorker& make();
- fun* _add_receiver(fun &receiver);
+ fun* add_receiver(fun& receiver);
void remove_receiver(fun* pos);
~KeybindingWorker() override;
@@ -83,7 +83,7 @@ public:
}
Token(fun receiver)
{
- pos = make()._add_receiver(receiver);
+ pos = make().add_receiver(receiver);
}
};
};
diff --git a/spline/spline-widget.cpp b/spline/spline-widget.cpp
index 64f9f156..4a591870 100644
--- a/spline/spline-widget.cpp
+++ b/spline/spline-widget.cpp
@@ -42,7 +42,7 @@ void spline_widget::setConfig(base_spline* spl)
connection = QMetaObject::Connection();
}
- _config = spl;
+ config = spl;
if (spl)
{
@@ -68,29 +68,29 @@ void spline_widget::setColorBezier(QColor const& color)
void spline_widget::force_redraw()
{
- _background = QPixmap();
+ background_img = QPixmap();
repaint();
}
void spline_widget::set_preview_only(bool val)
{
- _preview_only = val;
+ preview_only = val;
}
bool spline_widget::is_preview_only() const
{
- return _preview_only;
+ return preview_only;
}
void spline_widget::drawBackground()
{
- QPainter painter(&_background);
+ QPainter painter(&background_img);
painter.fillRect(rect(), widget_bg_color);
{
QColor bg_color(112, 154, 209);
- if (!isEnabled() && !_preview_only)
+ if (!isEnabled() && !preview_only)
bg_color = QColor(176,176,180);
painter.fillRect(pixel_bounds, bg_color);
}
@@ -107,9 +107,9 @@ void spline_widget::drawBackground()
const QPen pen(color__, 1, Qt::SolidLine, Qt::FlatCap);
- const int ystep = _y_step, xstep = _x_step;
- const double maxx = _config->max_input();
- const double maxy = _config->max_output();
+ const int ystep = y_step_, xstep = x_step_;
+ const double maxx = config->max_input();
+ const double maxy = config->max_output();
// horizontal grid
for (int i = 0; i <= maxy; i += ystep)
@@ -145,10 +145,10 @@ void spline_widget::drawBackground()
void spline_widget::drawFunction()
{
- QPainter painter(&_function);
+ QPainter painter(&spline_img);
painter.setRenderHint(QPainter::Antialiasing, true);
- const points_t points = _config->get_points();
+ const points_t points = config->get_points();
if (moving_control_point_idx >= 0 &&
moving_control_point_idx < points.size())
@@ -165,7 +165,7 @@ void spline_widget::drawFunction()
}
const QColor color_ = progn(
- if (!isEnabled() && !_preview_only)
+ if (!isEnabled() && !preview_only)
{
QColor color(spline_color);
const int avg = int(float(color.red() + color.green() + color.blue())/3);
@@ -187,7 +187,7 @@ void spline_widget::drawFunction()
const double dpr = devicePixelRatioF();
const double line_length_pixels = std::fmax(1, 2 * dpr);
const double step = std::fmax(.1, line_length_pixels / c.x());
- const double maxx = _config->max_input();
+ const double maxx = config->max_input();
//#define USE_CUBIC_SPLINE
#if defined USE_CUBIC_SPLINE
@@ -205,9 +205,9 @@ void spline_widget::drawFunction()
for (double k = 0; k < maxx; k += step*3) // NOLINT
{
- const auto next_1 = (double) _config->get_value_no_save(k + step*1);
- const auto next_2 = (double) _config->get_value_no_save(k + step*2);
- const auto next_3 = (double) _config->get_value_no_save(k + step*3);
+ const auto next_1 = (double) config->get_value_no_save(k + step*1);
+ const auto next_2 = (double) config->get_value_no_save(k + step*2);
+ const auto next_3 = (double) config->get_value_no_save(k + step*3);
QPointF b(clamp(point_to_pixel({k + step*1, next_1}))),
c(clamp(point_to_pixel({k + step*2, next_2}))),
@@ -221,14 +221,14 @@ void spline_widget::drawFunction()
QPointF prev = point_to_pixel({});
for (double i = 0; i < maxx; i += step) // NOLINT
{
- const auto val = (double) _config->get_value_no_save(i);
+ const auto val = (double) config->get_value_no_save(i);
const QPointF cur = point_to_pixel({i, val});
painter.drawLine(prev, cur);
prev = cur;
}
{
- const double maxx = _config->max_input();
- const double maxy = double(_config->get_value_no_save(maxx));
+ const double maxx = config->max_input();
+ const double maxy = double(config->get_value_no_save(maxx));
painter.drawLine(prev, point_to_pixel({ maxx, maxy }));
}
#endif
@@ -242,7 +242,7 @@ void spline_widget::drawFunction()
painter.fillRect(r2, widget_bg_color);
const int alpha = !isEnabled() ? 64 : 120;
- if (!_preview_only)
+ if (!preview_only)
{
for (auto const& point : points)
{
@@ -256,7 +256,7 @@ void spline_widget::drawFunction()
void spline_widget::paintEvent(QPaintEvent *e)
{
- if (!_config)
+ if (!config)
return;
QPainter p(this);
@@ -265,28 +265,28 @@ void spline_widget::paintEvent(QPaintEvent *e)
const int W = iround(width() * dpr);
const int H = iround(height() * dpr);
- if (_background.size() != QSize(W, H))
+ if (background_img.size() != QSize(W, H))
{
- _background = QPixmap(W, H);
- _background.setDevicePixelRatio(dpr);
- _draw_function = true;
+ background_img = QPixmap(W, H);
+ background_img.setDevicePixelRatio(dpr);
+ draw_function = true;
drawBackground();
}
- if (_draw_function)
+ if (draw_function)
{
- _draw_function = false;
- _function = _background;
+ draw_function = false;
+ spline_img = background_img;
drawFunction();
}
- p.drawPixmap(e->rect(), _function);
+ p.drawPixmap(e->rect(), spline_img);
// If the Tracker is active, the 'Last Point' it requested is recorded.
// Show that point on the graph, with some lines to assist.
// This new feature is very handy for tweaking the curves!
QPointF last;
- if (_config->get_last_value(last) && isEnabled())
+ if (config->get_last_value(last) && isEnabled())
drawPoint(p, point_to_pixel(last), QColor(255, 0, 0, 120));
}
@@ -312,14 +312,14 @@ void spline_widget::drawLine(QPainter& painter, const QPointF& start, const QPoi
void spline_widget::mousePressEvent(QMouseEvent *e)
{
- if (!_config || !isEnabled() || !is_in_bounds(e->localPos()) || _preview_only)
+ if (!config || !isEnabled() || !is_in_bounds(e->localPos()) || preview_only)
return;
const double min_dist = min_pt_distance();
moving_control_point_idx = -1;
- points_t points = _config->get_points();
+ points_t points = config->get_points();
if (e->button() == Qt::LeftButton)
{
@@ -352,50 +352,50 @@ void spline_widget::mousePressEvent(QMouseEvent *e)
if (!too_close)
{
- _config->add_point(pixel_to_point(e->localPos()));
+ config->add_point(pixel_to_point(e->localPos()));
show_tooltip(e->pos());
}
}
- _draw_function = true;
+ draw_function = true;
}
if (e->button() == Qt::RightButton)
{
- if (_config)
+ if (config)
{
for (int i = 0; i < points.size(); i++)
{
if (point_within_pixel(points[i], e->localPos()))
{
- _config->remove_point(i);
- _draw_function = true;
+ config->remove_point(i);
+ draw_function = true;
break;
}
}
}
}
- if (_draw_function)
+ if (draw_function)
repaint();
}
void spline_widget::mouseMoveEvent(QMouseEvent *e)
{
- if (_preview_only && _config)
+ if (preview_only && config)
{
show_tooltip(e->pos());
return;
}
- if (!_config || !isEnabled() || !isActiveWindow())
+ if (!config || !isEnabled() || !isActiveWindow())
{
QToolTip::hideText();
return;
}
const int i = moving_control_point_idx;
- const points_t points = _config->get_points();
+ const points_t points = config->get_points();
const int sz = points.size();
if (i >= 0 && i < sz)
@@ -428,8 +428,8 @@ void spline_widget::mouseMoveEvent(QMouseEvent *e)
if ((!has_prev || check_prev()) && (!has_next || check_next()))
{
- _config->move_point(i, new_pt);
- _draw_function = true;
+ config->move_point(i, new_pt);
+ draw_function = true;
repaint();
}
}
@@ -456,7 +456,7 @@ void spline_widget::mouseMoveEvent(QMouseEvent *e)
void spline_widget::mouseReleaseEvent(QMouseEvent *e)
{
- if (!_config || !isEnabled() || !isActiveWindow() || _preview_only)
+ if (!config || !isEnabled() || !isActiveWindow() || preview_only)
return;
const bool redraw = moving_control_point_idx != -1;
@@ -479,7 +479,7 @@ void spline_widget::mouseReleaseEvent(QMouseEvent *e)
if (redraw)
{
- _draw_function = true;
+ draw_function = true;
repaint();
}
}
@@ -504,8 +504,8 @@ void spline_widget::show_tooltip(const QPoint& pos, const QPointF& value_)
double x = value.x(), y = value.y();
- if (_preview_only)
- y = _config->get_value_no_save(x);
+ if (preview_only)
+ y = config->get_value_no_save(x);
const int x_ = iround(x), y_ = iround(y);
@@ -545,7 +545,7 @@ bool spline_widget::is_in_bounds(const QPointF& pos) const
void spline_widget::update_range()
{
- if (!_config)
+ if (!config)
return;
const int w = width(), h = height();
@@ -553,11 +553,11 @@ void spline_widget::update_range()
const int mwr = 15, mhr = 35;
pixel_bounds = QRect(mwl, mhl, (w - mwl - mwr), (h - mhl - mhr));
- c = { pixel_bounds.width() / _config->max_input(), pixel_bounds.height() / _config->max_output() };
- _draw_function = true;
+ c = { pixel_bounds.width() / config->max_input(), pixel_bounds.height() / config->max_output() };
+ draw_function = true;
- _background = QPixmap();
- _function = QPixmap();
+ background_img = QPixmap();
+ spline_img = QPixmap();
repaint();
}
@@ -573,7 +573,7 @@ void spline_widget::focusOutEvent(QFocusEvent* e)
if (moving_control_point_idx != -1)
QToolTip::hideText();
moving_control_point_idx = -1;
- _draw_function = true;
+ draw_function = true;
lower();
setCursor(Qt::ArrowCursor);
e->accept();
@@ -604,8 +604,8 @@ QPointF spline_widget::pixel_to_point(const QPointF& point)
if (snap_y > 0)
y = snap(y, snap_y);
- x = clamp(x, 0, _config->max_input());
- y = clamp(y, 0, _config->max_output());
+ x = clamp(x, 0, config->max_input());
+ y = clamp(y, 0, config->max_output());
return { x, y };
}
@@ -625,14 +625,14 @@ void spline_widget::resizeEvent(QResizeEvent *)
bool spline_widget::is_on_pt(const QPointF& pos, int* pt)
{
- if (!_config)
+ if (!config)
{
if (pt)
*pt = -1;
return false;
}
- const points_t points = _config->get_points();
+ const points_t points = config->get_points();
for (int i = 0; i < points.size(); i++)
{
diff --git a/spline/spline-widget.hpp b/spline/spline-widget.hpp
index a6d0eb9d..a8adfce1 100644
--- a/spline/spline-widget.hpp
+++ b/spline/spline-widget.hpp
@@ -48,10 +48,10 @@ public:
void set_preview_only(bool val);
bool is_preview_only() const;
- double x_step() const { return _x_step; }
- double y_step() const { return _y_step; }
- void set_x_step(double val) { _x_step = std::fmax(1., val); }
- void set_y_step(double val) { _y_step = std::fmax(1., val); }
+ double x_step() const { return x_step_; }
+ double y_step() const { return y_step_; }
+ void set_x_step(double val) { x_step_ = std::fmax(1., val); }
+ void set_y_step(double val) { y_step_ = std::fmax(1., val); }
void set_snap(double x, double y) { snap_x = x; snap_y = y; }
void get_snap(double& x, double& y) const { x = snap_x; y = snap_y; }
@@ -85,10 +85,10 @@ private:
static double snap(double x, double snap_value);
QPointF c;
- base_spline* _config = nullptr;
+ base_spline* config = nullptr;
- QPixmap _background;
- QPixmap _function;
+ QPixmap background_img;
+ QPixmap spline_img;
QColor spline_color;
QColor widget_bg_color = palette().background().color();
@@ -98,9 +98,9 @@ private:
QMetaObject::Connection connection;
double snap_x = 0, snap_y = 0;
- double _x_step = 10, _y_step = 10;
+ double x_step_ = 10, y_step_ = 10;
int moving_control_point_idx = -1;
- bool _draw_function = true, _preview_only = false;
+ bool draw_function = true, preview_only = false;
// point's circle radius on the widget
static constexpr inline int point_size_in_pixels_ = 4;
diff --git a/tracker-joystick/ftnoir_tracker_joystick.h b/tracker-joystick/ftnoir_tracker_joystick.h
index c61a1c8f..2fd1068f 100644
--- a/tracker-joystick/ftnoir_tracker_joystick.h
+++ b/tracker-joystick/ftnoir_tracker_joystick.h
@@ -63,7 +63,7 @@ public:
QString name;
QString guid;
};
- QList<joys> _joys;
+ QList<joys> joys_;
private slots:
void doOK();
void doCancel();
diff --git a/tracker-joystick/ftnoir_tracker_joystick_dialog.cpp b/tracker-joystick/ftnoir_tracker_joystick_dialog.cpp
index aa4b783a..aaf3037b 100644
--- a/tracker-joystick/ftnoir_tracker_joystick_dialog.cpp
+++ b/tracker-joystick/ftnoir_tracker_joystick_dialog.cpp
@@ -12,18 +12,18 @@ dialog_joystick::dialog_joystick() : tracker(nullptr)
{
win32_joy_ctx joy_ctx;
- _joys = QList<joys>();
+ joys_ = {};
- for (auto j : joy_ctx.get_joy_info())
- _joys.push_back(joys { j.name, j.guid });
+ for (const auto& j : joy_ctx.get_joy_info())
+ joys_.push_back(joys { j.name, j.guid });
}
{
const QString guid = s.guid;
int idx = 0;
- for (int i = 0; i < _joys.size(); i++)
+ for (int i = 0; i < joys_.size(); i++)
{
- const joys& j = _joys[i];
+ const joys& j = joys_[i];
if (j.guid == guid)
idx = i;
ui.joylist->addItem(j.name + " " + j.guid);
@@ -41,8 +41,8 @@ dialog_joystick::dialog_joystick() : tracker(nullptr)
void dialog_joystick::doOK() {
int idx = ui.joylist->currentIndex();
- joys def { "", "" };
- auto val = _joys.value(idx, def);
+ static const joys def { {}, {} };
+ auto val = joys_.value(idx, def);
s.guid = val.guid;
s.b->save();
close();