Skip to content

Commit

Permalink
chore: lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Hazer committed May 23, 2024
1 parent 0ce2a7e commit aa16e27
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
9 changes: 5 additions & 4 deletions src/platform/linux/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,7 @@ namespace platf {
#ifdef SUNSHINE_BUILD_X11
Display *xdisplay = ((input_raw_t *) input.get())->display;
if (!xdisplay) {
return util::point_t { };
return util::point_t {};

Check warning on line 1106 in src/platform/linux/input.cpp

View check run for this annotation

Codecov / codecov/patch

src/platform/linux/input.cpp#L1106

Added line #L1106 was not covered by tests
}
Window root, root_return, child_return;
root = DefaultRootWindow(xdisplay);
Expand All @@ -1117,14 +1117,15 @@ namespace platf {
<< " x: " << root_x << std::endl
<< " y: " << root_y << std::endl;

return util::point_t { (double)root_x, (double)root_y };
} else {
return util::point_t { (double) root_x, (double) root_y };
}
else {
BOOST_LOG(debug) << "Unable to query x11 pointer"sv << std::endl;
}
#else
BOOST_LOG(debug) << "Unable to query wayland pointer"sv << std::endl;
#endif
return util::point_t { };
return util::point_t {};

Check warning on line 1128 in src/platform/linux/input.cpp

View check run for this annotation

Codecov / codecov/patch

src/platform/linux/input.cpp#L1128

Added line #L1128 was not covered by tests
}

/**
Expand Down
18 changes: 7 additions & 11 deletions src/platform/macos/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
#include "src/platform/common.h"
#include "src/utility.h"

#include <ApplicationServices/ApplicationServices.h>
#include <CoreFoundation/CoreFoundation.h>
#include <iostream>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <CoreFoundation/CoreFoundation.h>
#include <ApplicationServices/ApplicationServices.h>

/**
* @brief Delay for a double click, in milliseconds.
Expand Down Expand Up @@ -344,8 +342,7 @@ const KeyCodeMap kKeyCodesMap[] = {
const CGEventType type,
const util::point_t raw_location,
const util::point_t previous_location,
const int click_count
) {
const int click_count) {
BOOST_LOG(debug) << "mouse_event: "sv << button << ", type: "sv << type << ", location:"sv << raw_location.x << ":"sv << raw_location.y << " click_count: "sv << click_count;

const auto macos_input = static_cast<macos_input_t *>(input.get());
Expand Down Expand Up @@ -395,8 +392,7 @@ const KeyCodeMap kKeyCodesMap[] = {
move_mouse(
input_t &input,
const int deltaX,
const int deltaY
) {
const int deltaY) {
const auto current = get_mouse_loc(input);

const auto location = util::point_t { current.x + deltaX, current.y + deltaY };
Expand All @@ -408,8 +404,7 @@ const KeyCodeMap kKeyCodesMap[] = {
input_t &input,
const touch_port_t &touch_port,
const float x,
const float y
) {
const float y) {
const auto macos_input = static_cast<macos_input_t *>(input.get());
const auto scaling = macos_input->displayScaling;
const auto display = macos_input->display;
Expand Down Expand Up @@ -456,7 +451,8 @@ const KeyCodeMap kKeyCodesMap[] = {

if (now < macos_input->last_mouse_event[mac_button][release] + MULTICLICK_DELAY_MS) {
post_mouse(input, mac_button, event, mouse_position, mouse_position, 2);

Check warning on line 453 in src/platform/macos/input.cpp

View check run for this annotation

Codecov / codecov/patch

src/platform/macos/input.cpp#L453

Added line #L453 was not covered by tests
} else {
}
else {
post_mouse(input, mac_button, event, mouse_position, mouse_position, 1);

Check warning on line 456 in src/platform/macos/input.cpp

View check run for this annotation

Codecov / codecov/patch

src/platform/macos/input.cpp#L456

Added line #L456 was not covered by tests
}

Expand Down
6 changes: 3 additions & 3 deletions src/platform/windows/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,8 @@ namespace platf {
send_input(i);
}

/**
* // TODO: This method seems to work better during tests,
/**
* // TODO: This method seems to work better during tests,
but it doesn't seem to cover the same features as the original method
void
abs_mouse(input_t &input, const touch_port_t &touch_port, float x, float y) {
Expand All @@ -551,7 +551,7 @@ namespace platf {
auto &mi = i.mi;

// mi.dwFlags = MOUSEEVENTF_MOVE;
mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_MOVE_NOCOALESCE; // TODO: Not sure if needed
mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_MOVE_NOCOALESCE; // TODO: Not sure if needed

Check warning on line 554 in src/platform/windows/input.cpp

View check run for this annotation

Codecov / codecov/patch

src/platform/windows/input.cpp#L554

Added line #L554 was not covered by tests
mi.dx = deltaX;
mi.dy = deltaY;

Expand Down
3 changes: 2 additions & 1 deletion src/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,8 @@ namespace util {
double x;
double y;

friend std::ostream& operator << (std::ostream &os, const point_t &p) {
friend std::ostream &
operator<<(std::ostream &os, const point_t &p) {
return (os << "Point(x: " << p.x << ", y: " << p.y << ")");
}
};
Expand Down
18 changes: 10 additions & 8 deletions tests/unit/test_mouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ INSTANTIATE_TEST_SUITE_P(
::testing::Values(
util::point_t { 40, 40 },
util::point_t { 70, 150 }));
// todo: add tests for hitting screen edges
// todo: add tests for hitting screen edges

TEST_P(MouseHIDTest, MoveInputTest) {
util::point_t mouse_delta = GetParam();
Expand All @@ -60,7 +60,8 @@ TEST_P(MouseHIDTest, MoveInputTest) {

if (!has_input_moved) {
std::cout << "MoveInputTest:: haven't moved" << std::endl;
} else {
}
else {
std::cout << "MoveInputTest:: moved" << std::endl;
}

Expand All @@ -82,19 +83,19 @@ TEST_P(MouseHIDTest, AbsMoveInputTest) {
auto old_loc = platf::get_mouse_loc(input);
std::cout << "AbsMoveInputTest:: got current mouse loc: " << old_loc << std::endl;

#ifdef _WIN32
#ifdef _WIN32
platf::touch_port_t abs_port {
0, 0,
65535, 65535
};
#elif __linux__
#elif __linux__
platf::touch_port_t abs_port {
0, 0,
19200, 12000
};
#else
platf::touch_port_t abs_port { };
#endif
#else
platf::touch_port_t abs_port {};
#endif
std::cout << "AbsMoveInputTest:: move: " << mouse_pos << std::endl;
platf::abs_mouse(input, abs_port, mouse_pos.x, mouse_pos.y);
std::this_thread::sleep_for(std::chrono::milliseconds(200));
Expand All @@ -108,7 +109,8 @@ TEST_P(MouseHIDTest, AbsMoveInputTest) {

if (!has_input_moved) {
std::cout << "AbsMoveInputTest:: haven't moved" << std::endl;
} else {
}
else {
std::cout << "AbsMoveInputTest:: moved" << std::endl;
}

Expand Down

0 comments on commit aa16e27

Please sign in to comment.