Skip to content

Commit c20f171

Browse files
committed
Fix clang-format config, clang-format everything
1 parent f9c21cc commit c20f171

8 files changed

+50
-49
lines changed

.clang-format

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
1717
ConstructorInitializerIndentWidth: '2'
1818
ContinuationIndentWidth: '2'
1919
DeriveLineEnding: false
20+
DerivePointerAlignment: false
2021
IndentRequires: true
2122
IndentWidth: '2'
2223
MaxEmptyLinesToKeep: '1'

lib/InputDevice.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ void InputDevice::activate() {
261261
printf("----- DEBUG '%s' -----\n", name.c_str());
262262
printf(
263263
" Counts: a: %d, b: %d, h: %d\n",
264-
(int) controls.axes.size(),
264+
(int)controls.axes.size(),
265265
controls.buttons,
266266
controls.hats);
267267
printf(

lib/MappableInput.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace fredemmott::inputmapping {
1717

1818
class EventSource;
1919

20-
class MappableInput final {
20+
class MappableInput final {
2121
private:
2222
class Impl;
2323
std::shared_ptr<Impl> p;

lib/Mapper.cpp

+22-22
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@ struct DeviceOffsets {
2121
const off_t firstAxis;
2222
const off_t firstHat;
2323
const off_t firstButton;
24-
DeviceOffsets(InputDevice *dev)
24+
DeviceOffsets(InputDevice* dev)
2525
: firstAxis(0),
2626
firstHat(firstAxis + (sizeof(long) * dev->getAxisCount())),
2727
firstButton(firstHat + sizeof(int32_t) * dev->getHatCount()) {
2828
}
2929
};
3030

3131
struct DeviceState {
32-
const long *const axes;
33-
const bool *const buttons;
34-
const int32_t *const hats;
35-
36-
DeviceState(const uint8_t *data, const DeviceOffsets &offsets)
37-
: axes((long *)(data + offsets.firstAxis)),
38-
buttons((bool *)(data + offsets.firstButton)),
39-
hats((int32_t *)(data + offsets.firstHat)) {
32+
const long* const axes;
33+
const bool* const buttons;
34+
const int32_t* const hats;
35+
36+
DeviceState(const uint8_t* data, const DeviceOffsets& offsets)
37+
: axes((long*)(data + offsets.firstAxis)),
38+
buttons((bool*)(data + offsets.firstButton)),
39+
hats((int32_t*)(data + offsets.firstHat)) {
4040
}
4141
};
4242

@@ -46,10 +46,10 @@ BOOL WINAPI exit_event_handler(DWORD dwCtrlType) {
4646
return true;
4747
}
4848

49-
Mapper *gActiveInstance = nullptr;
49+
Mapper* gActiveInstance = nullptr;
5050

5151
struct ActiveInstanceGuard {
52-
ActiveInstanceGuard(Mapper *active) {
52+
ActiveInstanceGuard(Mapper* active) {
5353
gActiveInstance = active;
5454
}
5555
~ActiveInstanceGuard() {
@@ -59,16 +59,16 @@ struct ActiveInstanceGuard {
5959
}// namespace
6060

6161
void Mapper::setDevices(
62-
const std::vector<MappableInput> &inputs,
63-
const std::vector<std::shared_ptr<OutputDevice>> &outputs) {
64-
for (const auto &input: inputs) {
62+
const std::vector<MappableInput>& inputs,
63+
const std::vector<std::shared_ptr<OutputDevice>>& outputs) {
64+
for (const auto& input: inputs) {
6565
mEventSources.push_back(input.getEventSource());
6666
}
6767
mEventSinks
6868
= std::vector<std::shared_ptr<EventSink>>(outputs.begin(), outputs.end());
6969
}
7070

71-
void Mapper::passthrough(MappableInput &s, const MappableVJoyOutput &t) {
71+
void Mapper::passthrough(MappableInput& s, const MappableVJoyOutput& t) {
7272
s.XAxis >> t.XAxis;
7373
s.YAxis >> t.YAxis;
7474
s.ZAxis >> t.ZAxis;
@@ -109,15 +109,15 @@ void Mapper::run() {
109109
std::vector<HANDLE> fixed_events {gExitEvent};
110110

111111
std::map<HANDLE, std::shared_ptr<EventSource>> handle_to_source;
112-
for (const auto &source: mEventSources) {
112+
for (const auto& source: mEventSources) {
113113
auto handle = source->getHandle();
114114
fixed_events.push_back(handle);
115115
handle_to_source.insert({handle, source});
116116
}
117117
printf("---\nProfile running, hit Ctrl-C to exit and clean up HidHide.\n");
118118
while (true) {
119119
auto events = fixed_events;
120-
for (const auto &[event, _]: mInjected) {
120+
for (const auto& [event, _]: mInjected) {
121121
events.push_back(event);
122122
}
123123
const auto res
@@ -150,7 +150,7 @@ void Mapper::run() {
150150
}
151151

152152
void Mapper::flush() {
153-
for (const auto &output: mEventSinks) {
153+
for (const auto& output: mEventSinks) {
154154
output->flush();
155155
}
156156
}
@@ -163,18 +163,18 @@ typedef std::chrono::
163163
}
164164

165165
void Mapper::inject(
166-
const std::chrono::steady_clock::duration &delay,
167-
const std::function<void()> &handler) {
166+
const std::chrono::steady_clock::duration& delay,
167+
const std::function<void()>& handler) {
168168
if (!gActiveInstance) {
169169
return;
170170
}
171171
int64_t target_time;
172-
GetSystemTimeAsFileTime((FILETIME *)&target_time);
172+
GetSystemTimeAsFileTime((FILETIME*)&target_time);
173173
target_time += std::chrono::duration_cast<FILETIME_RESOLUTION>(delay).count();
174174

175175
auto timer = CreateWaitableTimer(nullptr, true, nullptr);
176176
SetWaitableTimer(
177-
timer, (LARGE_INTEGER *)&target_time, 0, nullptr, nullptr, false);
177+
timer, (LARGE_INTEGER*)&target_time, 0, nullptr, nullptr, false);
178178
gActiveInstance->mInjected.emplace(timer, handler);
179179
}
180180
}// namespace fredemmott::inputmapping

lib/OutputDevice.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace fredemmott::inputmapping {
1313

14-
class OutputDevice : public EventSink {
15-
};
14+
class OutputDevice : public EventSink {};
1615

1716
}// namespace fredemmott::inputmapping

lib/Profile.h

+12-11
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,26 @@ const detail::ViGEmX360ID VIGEM_X360_PAD;
4444
const detail::ViGEmDS4ID VIGEM_DS4_PAD;
4545

4646
class DeviceWithVisibility {
47-
private:
48-
DeviceSpecifier impl;
49-
public:
50-
explicit DeviceWithVisibility(const DeviceSpecifier& ds);
51-
operator const DeviceSpecifier& () const;
47+
private:
48+
DeviceSpecifier impl;
49+
50+
public:
51+
explicit DeviceWithVisibility(const DeviceSpecifier& ds);
52+
operator const DeviceSpecifier&() const;
5253
};
5354

5455
class UnhiddenDevice final : public DeviceWithVisibility {
55-
public:
56-
using DeviceWithVisibility::DeviceWithVisibility;
56+
public:
57+
using DeviceWithVisibility::DeviceWithVisibility;
5758
};
5859

5960
class HiddenDevice final : public DeviceWithVisibility {
60-
public:
61-
// clang-format off
61+
public:
62+
// clang-format off
6263
template<std::convertible_to<DeviceSpecifier> T>
6364
requires (!std::convertible_to<T, UnhiddenDevice>)
6465
HiddenDevice(const T& ds): DeviceWithVisibility(DeviceSpecifier(ds)) {}
65-
// clang-format on
66+
// clang-format on
6667
};
6768

6869
class Profile final {
@@ -132,7 +133,7 @@ void fill_hidden_ids(
132133
std::vector<HiddenDevice>& hidden_devices,
133134
const First& first,
134135
Rest... rest) {
135-
if constexpr(std::convertible_to<First, HiddenDevice>) {
136+
if constexpr (std::convertible_to<First, HiddenDevice>) {
136137
hidden_devices.push_back(first);
137138
}
138139

lib/VJoyDevice.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -99,52 +99,52 @@ long normalize_axis(long dx) {
9999
}
100100
}// namespace
101101

102-
VJoyDevice *VJoyDevice::setXAxis(long value) {
102+
VJoyDevice* VJoyDevice::setXAxis(long value) {
103103
p->state.wAxisX = normalize_axis(value);
104104
return this;
105105
}
106106

107-
VJoyDevice *VJoyDevice::setYAxis(long value) {
107+
VJoyDevice* VJoyDevice::setYAxis(long value) {
108108
p->state.wAxisY = normalize_axis(value);
109109
return this;
110110
}
111111

112-
VJoyDevice *VJoyDevice::setZAxis(long value) {
112+
VJoyDevice* VJoyDevice::setZAxis(long value) {
113113
p->state.wAxisZ = normalize_axis(value);
114114
return this;
115115
}
116116

117-
VJoyDevice *VJoyDevice::setRXAxis(long value) {
117+
VJoyDevice* VJoyDevice::setRXAxis(long value) {
118118
p->state.wAxisXRot = normalize_axis(value);
119119
return this;
120120
}
121121

122-
VJoyDevice *VJoyDevice::setRYAxis(long value) {
122+
VJoyDevice* VJoyDevice::setRYAxis(long value) {
123123
p->state.wAxisYRot = normalize_axis(value);
124124
return this;
125125
}
126126

127-
VJoyDevice *VJoyDevice::setRZAxis(long value) {
127+
VJoyDevice* VJoyDevice::setRZAxis(long value) {
128128
p->state.wAxisZRot = normalize_axis(value);
129129
return this;
130130
}
131131

132-
VJoyDevice *VJoyDevice::setSlider(long value) {
132+
VJoyDevice* VJoyDevice::setSlider(long value) {
133133
p->state.wSlider = normalize_axis(value);
134134
return this;
135135
}
136136

137-
VJoyDevice *VJoyDevice::setDial(long value) {
137+
VJoyDevice* VJoyDevice::setDial(long value) {
138138
p->state.wDial = normalize_axis(value);
139139
return this;
140140
}
141141

142-
VJoyDevice *VJoyDevice::setButton(uint8_t button, bool value) {
142+
VJoyDevice* VJoyDevice::setButton(uint8_t button, bool value) {
143143
button--;
144144
off_t offset = button % 32;
145145
auto mask = 1 << offset;
146146

147-
LONG *data = nullptr;
147+
LONG* data = nullptr;
148148
if (button < 32) {
149149
data = &p->state.lButtons;
150150
} else if (button < 64) {
@@ -165,7 +165,7 @@ VJoyDevice *VJoyDevice::setButton(uint8_t button, bool value) {
165165
return this;
166166
}
167167

168-
VJoyDevice *VJoyDevice::setHat(uint8_t hat, uint16_t v) {
168+
VJoyDevice* VJoyDevice::setHat(uint8_t hat, uint16_t v) {
169169
const DWORD value = v == Hat::CENTER ? DWORD(-1) : v;
170170
switch (hat) {
171171
case 1:

render.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
#include "lib/easymode.h"
1414
#include "lib/render_axis.h"
1515

16+
using fredemmott::inputmapping::maybe_shared_ptr;
1617
using fredemmott::inputmapping::render_axis;
1718
using fredemmott::inputmapping::Sink;
1819
using fredemmott::inputmapping::Source;
19-
using fredemmott::inputmapping::maybe_shared_ptr;
2020

2121
int main() {
2222
render_axis("linear.bmp", [](Axis::Value next) { return next; });

0 commit comments

Comments
 (0)