Skip to content

Commit

Permalink
all: Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
StollD committed Feb 6, 2024
1 parent 4557a94 commit 197f8f2
Show file tree
Hide file tree
Showing 28 changed files with 152 additions and 112 deletions.
8 changes: 4 additions & 4 deletions src/apps/calibrate/calibrate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ class Calibrate : public core::Application {

public:
Calibrate(const core::Config &config,
const core::DeviceInfo &info,
std::optional<const ipts::Metadata> metadata)
: core::Application(config, info, metadata)
, m_diagonal {std::hypot(config.width, config.height)} {};
const core::DeviceInfo &info,
std::optional<const ipts::Metadata> metadata)
: core::Application(config, info, metadata),
m_diagonal {std::hypot(config.width, config.height)} {};

void on_start() override
{
Expand Down
6 changes: 3 additions & 3 deletions src/apps/daemon/daemon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class Daemon : public core::Application {
Daemon(const core::Config &config,
const core::DeviceInfo &info,
std::optional<const ipts::Metadata> metadata)
: core::Application(config, info, metadata)
, m_touch {config, info}
, m_stylus {config, info} {};
: core::Application(config, info, metadata),
m_touch {config, info},
m_stylus {config, info} {};

void on_start() override
{
Expand Down
12 changes: 8 additions & 4 deletions src/apps/daemon/touch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,11 @@ class TouchDevice {
m_lift.clear();

// Determine all indices that were in the last frame but not in this one
std::set_difference(m_last.cbegin(), m_last.cend(), m_current.cbegin(),
m_current.cend(), std::inserter(m_lift, m_lift.begin()));
std::set_difference(m_last.cbegin(),
m_last.cend(),
m_current.cbegin(),
m_current.cend(),
std::inserter(m_lift, m_lift.begin()));
}

/*!
Expand All @@ -197,8 +200,9 @@ class TouchDevice {
if (!m_config.touch_disable_on_palm)
return false;

return std::any_of(contacts.cbegin(), contacts.cend(),
[&](const auto &c) { return !c.valid.value_or(true); });
return std::any_of(contacts.cbegin(), contacts.cend(), [&](const auto &c) {
return !c.valid.value_or(true);
});
}

/*!
Expand Down
6 changes: 3 additions & 3 deletions src/apps/dump/dump.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class Dump : public core::Application {
const core::DeviceInfo &info,
std::optional<const ipts::Metadata> metadata,
std::filesystem::path output)
: core::Application(config, info, metadata)
, m_out {std::move(output)} {};
: core::Application(config, info, metadata),
m_out {std::move(output)} {};

void on_start() override
{
Expand Down Expand Up @@ -68,7 +68,7 @@ class Dump : public core::Application {

// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
m_writer.write(reinterpret_cast<char *>(data.data()),
casts::to<std::streamsize>(size));
casts::to<std::streamsize>(size));

// Pad the data with zeros, so that we always write a full buffer.
std::fill_n(std::ostream_iterator<u8>(m_writer), m_info.buffer_size - size, '\0');
Expand Down
10 changes: 5 additions & 5 deletions src/apps/visualization/visualize-png.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ class VisualizePNG : public Visualize {

public:
VisualizePNG(const core::Config &config,
const core::DeviceInfo &info,
std::optional<const ipts::Metadata> metadata,
std::filesystem::path output)
: Visualize(config, info, metadata)
, m_output {std::move(output)} {};
const core::DeviceInfo &info,
std::optional<const ipts::Metadata> metadata,
std::filesystem::path output)
: Visualize(config, info, metadata),
m_output {std::move(output)} {};

void on_start() override
{
Expand Down
11 changes: 7 additions & 4 deletions src/apps/visualization/visualize-sdl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class VisualizeSDL : public Visualize {

public:
VisualizeSDL(const core::Config &config,
const core::DeviceInfo &info,
std::optional<const ipts::Metadata> metadata)
const core::DeviceInfo &info,
std::optional<const ipts::Metadata> metadata)
: Visualize(config, info, metadata)
{
SDL_Init(SDL_INIT_VIDEO);
Expand All @@ -54,8 +54,11 @@ class VisualizeSDL : public Visualize {
SDL_GetRendererOutputSize(m_renderer, &m_size.x(), &m_size.y());

// Create a texture that will be rendered later
m_rtex = SDL_CreateTexture(m_renderer, SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING, m_size.x(), m_size.y());
m_rtex = SDL_CreateTexture(m_renderer,
SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING,
m_size.x(),
m_size.y());

// Create a texture for drawing.
m_tex = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, m_size.x(), m_size.y());
Expand Down
11 changes: 6 additions & 5 deletions src/apps/visualization/visualize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class Visualize : public core::Application {

public:
Visualize(const core::Config &config,
const core::DeviceInfo &info,
std::optional<const ipts::Metadata> metadata)
const core::DeviceInfo &info,
std::optional<const ipts::Metadata> metadata)
: core::Application(config, info, metadata) {};

void on_contacts(const std::vector<contacts::Contact<f64>> & /* unused */) override
Expand Down Expand Up @@ -161,8 +161,9 @@ class Visualize : public core::Application {
const f64 diag = m_size.cast<f64>().hypotNorm();

// Select Font
m_cairo->select_font_face("monospace", Cairo::FONT_SLANT_NORMAL,
Cairo::FONT_WEIGHT_NORMAL);
m_cairo->select_font_face("monospace",
Cairo::FONT_SLANT_NORMAL,
Cairo::FONT_WEIGHT_NORMAL);
m_cairo->set_font_size(24.0);

for (const auto &contact : m_contacts) {
Expand Down Expand Up @@ -190,7 +191,7 @@ class Visualize : public core::Application {

// Center the text at the mean point of the contact
m_cairo->move_to(mean.x() - (extends.x_bearing + extends.width / 2),
mean.y() - (extends.y_bearing + extends.height / 2));
mean.y() - (extends.y_bearing + extends.height / 2));
m_cairo->save();

m_cairo->show_text(index);
Expand Down
2 changes: 1 addition & 1 deletion src/common/casts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ template <class To, class From>
constexpr inline To to(const From value)
{
static_assert(!std::is_same_v<From, f64> || !std::is_same_v<To, f32>,
"f64 to f32 cannot be narrowed safely. Please use gsl::narrow_cast!");
"f64 to f32 cannot be narrowed safely. Please use gsl::narrow_cast!");

using Common = std::common_type_t<To, From>;

Expand Down
2 changes: 1 addition & 1 deletion src/contacts/contact.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Contact {

public:
static std::optional<Contact<T>> find_in_frame(const usize index,
const std::vector<Contact<T>> &frame)
const std::vector<Contact<T>> &frame)
{
for (const Contact<T> &contact : frame) {
if (contact.index != index)
Expand Down
34 changes: 19 additions & 15 deletions src/contacts/detection/algorithms/cluster.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ class RecursionState {

public:
RecursionState(const DenseBase<Derived> &heatmap,
T activation_threshold,
T deactivation_threshold,
Box &cluster,
Image<bool> &visited)
: heatmap {heatmap}
, activation_threshold {activation_threshold}
, deactivation_threshold {deactivation_threshold}
, cluster {cluster}
, visited {visited} {};
T activation_threshold,
T deactivation_threshold,
Box &cluster,
Image<bool> &visited)
: heatmap {heatmap},
activation_threshold {activation_threshold},
deactivation_threshold {deactivation_threshold},
cluster {cluster},
visited {visited} {};
};

/*!
Expand All @@ -55,8 +55,8 @@ class RecursionState {
*/
template <class Derived>
void span_recursive(const RecursionState<Derived> state,
const Point &position,
const typename DenseBase<Derived>::Scalar previous)
const Point &position,
const typename DenseBase<Derived>::Scalar previous)
{
using T = typename DenseBase<Derived>::Scalar;

Expand Down Expand Up @@ -122,9 +122,9 @@ void span_recursive(const RecursionState<Derived> state,
*/
template <class Derived>
Box span(const DenseBase<Derived> &heatmap,
const Point &position,
const typename DenseBase<Derived>::Scalar activation_threshold,
const typename DenseBase<Derived>::Scalar deactivation_threshold)
const Point &position,
const typename DenseBase<Derived>::Scalar activation_threshold,
const typename DenseBase<Derived>::Scalar deactivation_threshold)
{
using T = typename DenseBase<Derived>::Scalar;

Expand All @@ -147,7 +147,11 @@ Box span(const DenseBase<Derived> &heatmap,
visited.setConstant(false);

const impl::RecursionState<Derived> state {
heatmap, activation_threshold, deactivation_threshold, cluster, visited,
heatmap,
activation_threshold,
deactivation_threshold,
cluster,
visited,
};

impl::span_recursive(state, position, std::numeric_limits<T>::max());
Expand Down
8 changes: 4 additions & 4 deletions src/contacts/detection/algorithms/convolution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ namespace impl {
*/
template <class DerivedData, class DerivedKernel>
void run_generic(const DenseBase<DerivedData> &in,
const DenseBase<DerivedKernel> &kernel,
DenseBase<DerivedData> &out)
const DenseBase<DerivedKernel> &kernel,
DenseBase<DerivedData> &out)
{
using T = typename DenseBase<DerivedKernel>::Scalar;

Expand Down Expand Up @@ -81,8 +81,8 @@ void run_generic(const DenseBase<DerivedData> &in,
*/
template <class DerivedData, class DerivedKernel>
inline void run(const DenseBase<DerivedData> &in,
const DenseBase<DerivedKernel> &kernel,
DenseBase<DerivedData> &out)
const DenseBase<DerivedKernel> &kernel,
DenseBase<DerivedData> &out)
{
constexpr usize Rows = DerivedKernel::RowsAtCompileTime;
constexpr usize Cols = DerivedKernel::ColsAtCompileTime;
Expand Down
16 changes: 8 additions & 8 deletions src/contacts/detection/algorithms/gaussian.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ T gaussian_like(const Vector2<T> &x, const Vector2<T> &mean, const Matrix2<T> &p

template <class T, class DerivedData>
void assemble_system(Matrix6<T> &m,
Vector6<T> &rhs,
const Box &b,
const DenseBase<DerivedData> &data,
const Matrix<T> &w)
Vector6<T> &rhs,
const Box &b,
const DenseBase<DerivedData> &data,
const Matrix<T> &w)
{
const Eigen::Index cols = data.cols();
const Eigen::Index rows = data.rows();
Expand Down Expand Up @@ -164,7 +164,7 @@ bool extract_params(const Vector6<T> &chi, T &scale, Vector2<T> &mean, Matrix2<T

template <class Derived>
void update_weight_maps(std::vector<Parameters<typename DenseBase<Derived>::Scalar>> &params,
DenseBase<Derived> &total)
DenseBase<Derived> &total)
{
using T = typename DenseBase<Derived>::Scalar;

Expand Down Expand Up @@ -320,9 +320,9 @@ bool ge_solve(Matrix6<T> a, Vector6<T> b, Vector6<T> &x)

template <class Derived, class DerivedData>
void fit(std::vector<Parameters<typename DenseBase<Derived>::Scalar>> &params,
const DenseBase<DerivedData> &data,
DenseBase<Derived> &tmp,
usize iterations)
const DenseBase<DerivedData> &data,
DenseBase<Derived> &tmp,
usize iterations)
{
using T = typename DenseBase<Derived>::Scalar;

Expand Down
4 changes: 2 additions & 2 deletions src/contacts/detection/algorithms/maximas.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ namespace iptsd::contacts::detection::maximas {
*/
template <class Derived>
void find(const DenseBase<Derived> &data,
typename DenseBase<Derived>::Scalar threshold,
std::vector<Point> &maximas)
typename DenseBase<Derived>::Scalar threshold,
std::vector<Point> &maximas)
{
using T = typename DenseBase<Derived>::Scalar;

Expand Down
4 changes: 2 additions & 2 deletions src/contacts/detection/algorithms/neutral.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ enum class Algorithm {
*/
template <class Derived>
typename DenseBase<Derived>::Scalar calculate(const DenseBase<Derived> &heatmap,
const Algorithm algorithm,
const typename DenseBase<Derived>::Scalar offset)
const Algorithm algorithm,
const typename DenseBase<Derived>::Scalar offset)
{
switch (algorithm) {
case Algorithm::MODE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ namespace iptsd::contacts::detection::convolution::impl {
*/
template <class DerivedData, class DerivedKernel>
inline void run_3x3(const DenseBase<DerivedData> &in,
const DenseBase<DerivedKernel> &kernel,
DenseBase<DerivedData> &out)
const DenseBase<DerivedKernel> &kernel,
DenseBase<DerivedData> &out)
{
using T = typename DenseBase<DerivedData>::Scalar;
using S = typename DenseBase<DerivedKernel>::Scalar;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ namespace iptsd::contacts::detection::convolution::impl {
*/
template <class DerivedData, class DerivedKernel>
void run_5x5(const DenseBase<DerivedData> &in,
const DenseBase<DerivedKernel> &kernel,
DenseBase<DerivedData> &out)
const DenseBase<DerivedKernel> &kernel,
DenseBase<DerivedData> &out)
{
using T = typename DenseBase<DerivedData>::Scalar;
using S = typename DenseBase<DerivedKernel>::Scalar;
Expand Down
19 changes: 13 additions & 6 deletions src/contacts/detection/detector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ class Detector {

// Recalculate the neutral value if neccessary
if (m_counter == 0) {
m_neutral = neutral::calculate(heatmap, m_config.neutral_value_algorithm,
m_config.neutral_value_offset);
m_neutral = neutral::calculate(heatmap,
m_config.neutral_value_algorithm,
m_config.neutral_value_offset);
}

// Update counter
Expand Down Expand Up @@ -156,7 +157,12 @@ class Detector {
const Vector2<Eigen::Index> size = cluster.sizes() + one;

gaussian::Parameters<TFit> params {
true, 1, mean, prec, cluster, Image<TFit> {size.y(), size.x()},
true,
1,
mean,
prec,
cluster,
Image<TFit> {size.y(), size.x()},
};

m_fitting_params.push_back(std::move(params));
Expand Down Expand Up @@ -186,9 +192,10 @@ class Detector {
orientation /= gsl::narrow_cast<TFit>(M_PI);
}

contacts.push_back(
Contact<T> {mean.template cast<T>(), size.template cast<T>(),
gsl::narrow_cast<T>(orientation), m_config.normalize});
contacts.push_back(Contact<T> {mean.template cast<T>(),
size.template cast<T>(),
gsl::narrow_cast<T>(orientation),
m_config.normalize});
}
}
};
Expand Down
6 changes: 3 additions & 3 deletions src/contacts/finder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class Finder {

public:
Finder(Config<T> config)
: m_detector {config.detection}
, m_stabilizer {config.stability}
, m_validator {config.validation} {};
: m_detector {config.detection},
m_stabilizer {config.stability},
m_validator {config.validation} {};

/*!
* Resets the contact finder by clearing all stored previous frames.
Expand Down
4 changes: 2 additions & 2 deletions src/contacts/tracking/distances.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ namespace iptsd::contacts::tracking::distances {
*/
template <class Derived>
void calculate(const std::vector<Contact<typename DenseBase<Derived>::Scalar>> &x,
const std::vector<Contact<typename DenseBase<Derived>::Scalar>> &y,
DenseBase<Derived> &out)
const std::vector<Contact<typename DenseBase<Derived>::Scalar>> &y,
DenseBase<Derived> &out)
{
using T = typename DenseBase<Derived>::Scalar;

Expand Down
Loading

0 comments on commit 197f8f2

Please sign in to comment.