Skip to content

Commit

Permalink
chore: fix clang code style
Browse files Browse the repository at this point in the history
  • Loading branch information
Hazer committed May 27, 2024
1 parent 5957c9b commit 91f5661
Show file tree
Hide file tree
Showing 19 changed files with 107 additions and 113 deletions.
2 changes: 1 addition & 1 deletion src/input/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ namespace input {
// The minor axis is perpendicular to major axis so the angle must be rotated by 90 degrees
return { multiply_polar_by_cartesian_scalar(major, angle, scalar), multiply_polar_by_cartesian_scalar(minor, angle + (M_PI / 2), scalar) };

Check warning on line 73 in src/input/common.cpp

View check run for this annotation

Codecov / codecov/patch

src/input/common.cpp#L73

Added line #L73 was not covered by tests
}
}
} // namespace input
12 changes: 5 additions & 7 deletions src/input/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@

#include <cstdint>
extern "C" {
#include <moonlight-common-c/src/Input.h>
#include <moonlight-common-c/src/Limelight.h>
#include <moonlight-common-c/src/Input.h>
#include <moonlight-common-c/src/Limelight.h>
}

#include <functional>

#include "src/globals.h"
#include "src/platform/common.h"
#include "src/thread_pool.h"
#include "src/globals.h"

#include "gamepad.h"

namespace input {

struct gamepad_orchestrator {
gamepad_orchestrator(): gamepads(gamepad::MAX_GAMEPADS) {

};
gamepad_orchestrator():

Check warning on line 20 in src/input/common.h

View check run for this annotation

Codecov / codecov/patch

src/input/common.h#L19-L20

Added lines #L19 - L20 were not covered by tests
gamepads(gamepad::MAX_GAMEPADS) {};

std::vector<gamepad::gamepad_t> gamepads;
};
Expand Down Expand Up @@ -56,7 +55,6 @@ namespace input {
float
from_netfloat(netfloat f);


/**
* @brief Multiplies a polar coordinate pair by a cartesian scaling factor.
* @param r The radial coordinate.
Expand Down
14 changes: 5 additions & 9 deletions src/input/gamepad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ namespace input::gamepad {
free_id(gamepadMask, id);

Check warning on line 37 in src/input/gamepad.cpp

View check run for this annotation

Codecov / codecov/patch

src/input/gamepad.cpp#L37

Added line #L37 was not covered by tests
}


void
print(PNV_MULTI_CONTROLLER_PACKET packet) {

Check warning on line 41 in src/input/gamepad.cpp

View check run for this annotation

Codecov / codecov/patch

src/input/gamepad.cpp#L41

Added line #L41 was not covered by tests
// Moonlight spams controller packet even when not necessary
Expand Down Expand Up @@ -117,7 +116,6 @@ namespace input::gamepad {
<< "--end controller battery packet--"sv;
}


/**
* @brief Called to pass a controller arrival message to the platform backend.
* @param input The input context pointer.
Expand Down Expand Up @@ -226,7 +224,6 @@ namespace input::gamepad {
platf::gamepad_motion(platf_input, motion);

Check warning on line 224 in src/input/gamepad.cpp

View check run for this annotation

Codecov / codecov/patch

src/input/gamepad.cpp#L224

Added line #L224 was not covered by tests
}


void
passthrough(std::shared_ptr<input_t> &input, PNV_MULTI_CONTROLLER_PACKET packet) {

Check warning on line 228 in src/input/gamepad.cpp

View check run for this annotation

Codecov / codecov/patch

src/input/gamepad.cpp#L228

Added line #L228 was not covered by tests
if (!config::input.controller) {
Expand Down Expand Up @@ -368,15 +365,14 @@ namespace input::gamepad {
}

platf::gamepad_battery_t battery {
{ gamepad.id, packet->controllerNumber },
packet->batteryState,
packet->batteryPercentage
};
{ gamepad.id, packet->controllerNumber },
packet->batteryState,
packet->batteryPercentage
};

Check warning on line 371 in src/input/gamepad.cpp

View check run for this annotation

Codecov / codecov/patch

src/input/gamepad.cpp#L367-L371

Added lines #L367 - L371 were not covered by tests

platf::gamepad_battery(platf_input, battery);

Check warning on line 373 in src/input/gamepad.cpp

View check run for this annotation

Codecov / codecov/patch

src/input/gamepad.cpp#L373

Added line #L373 was not covered by tests
}


/**
* @brief Batch two controller touch messages.
* @param dest The original packet to batch into.
Expand Down Expand Up @@ -471,4 +467,4 @@ namespace input::gamepad {
return batch_result_e::batched;

Check warning on line 467 in src/input/gamepad.cpp

View check run for this annotation

Codecov / codecov/patch

src/input/gamepad.cpp#L466-L467

Added lines #L466 - L467 were not covered by tests
}

}
} // namespace input::gamepad
13 changes: 6 additions & 7 deletions src/input/gamepad.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

#include <cstdint>
extern "C" {
#include <moonlight-common-c/src/Input.h>
#include <moonlight-common-c/src/Limelight.h>
#include <moonlight-common-c/src/Input.h>
#include <moonlight-common-c/src/Limelight.h>
}

#include <functional>

#include "src/globals.h"
#include "src/platform/common.h"
#include "src/thread_pool.h"
#include "src/globals.h"

#include "init.h"

Expand All @@ -25,7 +25,6 @@ namespace input::gamepad {
UP
};


template <std::size_t N>
int
alloc_id(std::bitset<N> &gamepad_mask);
Expand All @@ -37,11 +36,11 @@ namespace input::gamepad {
void
free_gamepad(platf::input_t &platf_input, int id);


struct gamepad_t {
gamepad_t():
gamepad_state {}, back_timeout_id {}, id { -1 }, back_button_state { button_state_e::NONE } {}
~gamepad_t() {
~
gamepad_t() {

Check warning on line 43 in src/input/gamepad.h

View check run for this annotation

Codecov / codecov/patch

src/input/gamepad.h#L40-L43

Added lines #L40 - L43 were not covered by tests
if (id >= 0) {
task_pool.push([id = this->id]() {
free_gamepad(platf_input, id);
Expand Down Expand Up @@ -155,4 +154,4 @@ namespace input::gamepad {
*/
batch_result_e
batch(PSS_CONTROLLER_MOTION_PACKET dest, PSS_CONTROLLER_MOTION_PACKET src);
}
} // namespace input::gamepad
3 changes: 1 addition & 2 deletions src/input/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ namespace input {
struct input_t;
static platf::input_t platf_input;


enum class batch_result_e {
batched, // This entry was batched with the source entry
not_batchable, // Not eligible to batch but continue attempts to batch
terminate_batch, // Stop trying to batch with this entry
};
}
} // namespace input
6 changes: 3 additions & 3 deletions src/input/keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

#include <cstdint>
extern "C" {
#include <moonlight-common-c/src/Input.h>
#include <moonlight-common-c/src/Limelight.h>
#include <moonlight-common-c/src/Input.h>
#include <moonlight-common-c/src/Limelight.h>
}

#include <functional>

#include "common.h"
#include "src/platform/common.h"
#include "src/thread_safe.h"
#include "common.h"

namespace input::keyboard {

Expand Down
6 changes: 3 additions & 3 deletions src/input/mouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

#include <cstdint>
extern "C" {
#include <moonlight-common-c/src/Input.h>
#include <moonlight-common-c/src/Limelight.h>
#include <moonlight-common-c/src/Input.h>
#include <moonlight-common-c/src/Limelight.h>
}

#include <functional>

#include "common.h"
#include "src/platform/common.h"
#include "src/thread_safe.h"
#include "common.h"

namespace input::mouse {

Expand Down
31 changes: 15 additions & 16 deletions src/input/pen.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <cstdint>
extern "C" {
#include <moonlight-common-c/src/Input.h>
#include <moonlight-common-c/src/Limelight.h>
#include <moonlight-common-c/src/Input.h>
#include <moonlight-common-c/src/Limelight.h>
}

#include <bitset>
Expand All @@ -18,11 +18,11 @@ extern "C" {
#include "src/thread_pool.h"
#include "src/utility.h"

#include <boost/endian/buffers.hpp>
#include "pen.h"
#include "common.h"
#include "touch.h"
#include "pen.h"
#include "processor.h"
#include "touch.h"
#include <boost/endian/buffers.hpp>

using namespace std::literals;

Expand Down Expand Up @@ -107,20 +107,19 @@ namespace input::pen {
platf::pen(input->client_context.get(), abs_port, pen);

Check warning on line 107 in src/input/pen.cpp

View check run for this annotation

Codecov / codecov/patch

src/input/pen.cpp#L107

Added line #L107 was not covered by tests
}


/**
* @brief Batch two pen messages.
* @param dest The original packet to batch into.
* @param src A later packet to attempt to batch.
* @return `batch_result_e` : The status of the batching operation.
*/
batch_result_e
batch(PSS_PEN_PACKET dest, PSS_PEN_PACKET src) {
/**
* @brief Batch two pen messages.
* @param dest The original packet to batch into.
* @param src A later packet to attempt to batch.
* @return `batch_result_e` : The status of the batching operation.
*/
batch_result_e
batch(PSS_PEN_PACKET dest, PSS_PEN_PACKET src) {

Check warning on line 117 in src/input/pen.cpp

View check run for this annotation

Codecov / codecov/patch

src/input/pen.cpp#L117

Added line #L117 was not covered by tests
// Only batch hover or move events
if (dest->eventType != LI_TOUCH_EVENT_MOVE &&
dest->eventType != LI_TOUCH_EVENT_HOVER) {
return batch_result_e::terminate_batch;

Check warning on line 121 in src/input/pen.cpp

View check run for this annotation

Codecov / codecov/patch

src/input/pen.cpp#L120-L121

Added lines #L120 - L121 were not covered by tests
}
}

// Batched events must be the same type
if (dest->eventType != src->eventType) {
Expand All @@ -142,4 +141,4 @@ namespace input::pen {
return batch_result_e::batched;

Check warning on line 141 in src/input/pen.cpp

View check run for this annotation

Codecov / codecov/patch

src/input/pen.cpp#L140-L141

Added lines #L140 - L141 were not covered by tests
}

}
} // namespace input::pen
43 changes: 21 additions & 22 deletions src/input/pen.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,38 @@

#include <cstdint>
extern "C" {
#include <moonlight-common-c/src/Input.h>
#include <moonlight-common-c/src/Limelight.h>
#include <moonlight-common-c/src/Input.h>
#include <moonlight-common-c/src/Limelight.h>
}

#include <functional>

#include "common.h"
#include "src/platform/common.h"
#include "src/thread_safe.h"
#include "common.h"

namespace input::pen {
/**
* @brief Prints a pen packet.
* @param packet The pen packet.
*/
void
print(PSS_PEN_PACKET packet);
/**
* @brief Prints a pen packet.
* @param packet The pen packet.
*/
void
print(PSS_PEN_PACKET packet);

/**
/**
* @brief Called to pass a pen message to the platform backend.
* @param input The input context pointer.
* @param packet The pen packet.
*/
void
passthrough(std::shared_ptr<input_t> &input, PSS_PEN_PACKET packet);

/**
* @brief Batch two pen messages.
* @param dest The original packet to batch into.
* @param src A later packet to attempt to batch.
* @return `batch_result_e` : The status of the batching operation.
*/
batch_result_e
batch(PSS_PEN_PACKET dest, PSS_PEN_PACKET src);
}
void
passthrough(std::shared_ptr<input_t> &input, PSS_PEN_PACKET packet);

/**
* @brief Batch two pen messages.
* @param dest The original packet to batch into.
* @param src A later packet to attempt to batch.
* @return `batch_result_e` : The status of the batching operation.
*/
batch_result_e
batch(PSS_PEN_PACKET dest, PSS_PEN_PACKET src);
} // namespace input::pen
11 changes: 5 additions & 6 deletions src/input/processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

#include <cstdint>
extern "C" {
#include <moonlight-common-c/src/Input.h>
#include <moonlight-common-c/src/Limelight.h>
#include <moonlight-common-c/src/Input.h>
#include <moonlight-common-c/src/Limelight.h>
}

#include <bitset>
Expand All @@ -19,8 +19,8 @@ extern "C" {
#include <unordered_map>

#include "common.h"
#include "init.h"
#include "gamepad.h"
#include "init.h"
#include "pen.h"
#include "processor.h"

Expand Down Expand Up @@ -69,7 +69,6 @@ namespace input {
return kpid & 0xFF;
}


static task_pool_util::TaskPool::task_id_t key_press_repeat_id {};
static std::unordered_map<key_press_id_t, bool> key_press {};
static std::array<std::uint8_t, 5> mouse_press {};
Expand Down Expand Up @@ -633,7 +632,6 @@ namespace input {
platf::touch(input->client_context.get(), abs_port, touch);
}


/**
* @brief Batch two relative mouse messages.
* @param dest The original packet to batch into.
Expand Down Expand Up @@ -932,7 +930,8 @@ namespace input {

class deinit_t: public platf::deinit_t {
public:
~deinit_t() override {
~
deinit_t() override {

Check warning on line 934 in src/input/processor.cpp

View check run for this annotation

Codecov / codecov/patch

src/input/processor.cpp#L933-L934

Added lines #L933 - L934 were not covered by tests
platf_input.reset();
}
};
Expand Down
5 changes: 2 additions & 3 deletions src/input/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#include <functional>

#include "src/platform/common.h"
#include "common.h"
#include "src/platform/common.h"
#include "src/thread_safe.h"

namespace input {
Expand All @@ -25,7 +25,6 @@ namespace input {
std::shared_ptr<input_t>
alloc(safe::mail_t mail);


struct input_t {
enum shortkey_e {
CTRL = 0x1,
Expand All @@ -52,7 +51,7 @@ namespace input {
int shortcutFlags;

gamepad_orchestrator *gamepads_orchestrator;
std::vector<gamepad::gamepad_t>* gamepads = &gamepads_orchestrator->gamepads;
std::vector<gamepad::gamepad_t> *gamepads = &gamepads_orchestrator->gamepads;

Check warning on line 54 in src/input/processor.h

View check run for this annotation

Codecov / codecov/patch

src/input/processor.h#L54

Added line #L54 was not covered by tests

std::unique_ptr<platf::client_input_t> client_context;

Expand Down
2 changes: 1 addition & 1 deletion src/input/touch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ namespace input::touch {

return std::pair { (x - offsetX) * touch_port.scalar_inv, (y - offsetY) * touch_port.scalar_inv };

Check warning on line 40 in src/input/touch.cpp

View check run for this annotation

Codecov / codecov/patch

src/input/touch.cpp#L40

Added line #L40 was not covered by tests
}
}
} // namespace input::touch
Loading

0 comments on commit 91f5661

Please sign in to comment.