Skip to content

Commit df69598

Browse files
committed
Convert hat values
1 parent 328016b commit df69598

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

lib/MappableFAVHIDOutput.cpp

+10-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ MappableFAVHIDOutput::MappableFAVHIDOutput(uint8_t favhid_id)
2121
: MappableFAVHIDOutput(std::make_shared<FAVHIDDevice>(favhid_id)) {
2222
}
2323

24-
static decltype(FAVHID::FAVJoyState2::Report::x) ConvertAxisValue(
24+
static constexpr decltype(FAVHID::FAVJoyState2::Report::x) ConvertAxisValue(
2525
Axis::Value input) {
2626
int64_t value = input;
2727
value -= Axis::MIN;
@@ -209,14 +209,21 @@ std::shared_ptr<OutputDevice> MappableFAVHIDOutput::getDevice() const {
209209

210210
ButtonSinkPtr MappableFAVHIDOutput::button(uint8_t id) const {
211211
return [this, id](Button::Value value) {
212-
p->mState.SetButton(id, value);
212+
p->mState.SetButton(id - 1, value);
213213
p->mDevice->set(p->mState);
214214
};
215215
}
216216

217+
static constexpr int8_t ConvertHatValue(Hat::Value value) {
218+
if (value == Hat::CENTER) {
219+
return 0b1111;
220+
}
221+
return value / 4500;
222+
}
223+
217224
HatSinkPtr MappableFAVHIDOutput::hat(uint8_t id) const {
218225
return [this, id](Hat::Value value) {
219-
p->mState.SetPOV(id, value);
226+
p->mState.SetPOV(id - 1, ConvertHatValue(value));
220227
p->mDevice->set(p->mState);
221228
};
222229
}

third-party/favhidclient.cmake

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
include(FetchContent)
22
find_package(Git)
3+
4+
set(FAVHID_REVISION "12979fd7b6021975407a39080d13327504c878ba")
35
FetchContent_Declare(
46
favhidclient
57
GIT_REPOSITORY https://github.com/fredemmott/favhid-client.git
68
GIT_TAG main
7-
UPDATE_COMMAND
8-
"${GIT_EXECUTABLE}" reset --hard e3d4f8a471c73ef7da3081544850b7604fb9c764
9+
PATCH_COMMAND "${GIT_EXECUTABLE}" reset --hard "${FAVHID_REVISION}"
910
EXCLUDE_FROM_ALL
1011
)
1112

0 commit comments

Comments
 (0)