Skip to content

Commit ff0685e

Browse files
Added button down/button up handling to gamepad
1 parent 2f743b1 commit ff0685e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

trikNetwork/src/gamepadConnection.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,16 @@ void GamepadConnection::processData(const QByteArray &data)
4141
}
4242
} else if (commandName == "btn") {
4343
const int buttonCode = cmd.at(1).trimmed().toInt();
44-
emit button(buttonCode, 1);
44+
int state = 1;
45+
if (cmd.length() > 2) {
46+
state = cmd.at(2) == "down" ? 1 : 0;
47+
}
48+
49+
emit button(buttonCode, state);
4550
} else if (commandName == "wheel") {
4651
const int perc = cmd.at(1).trimmed().toInt();
4752
emit wheel(perc);
4853
} else {
4954
QLOG_ERROR() << "Gamepad: unknown command" << commandName;
5055
}
5156
}
52-

0 commit comments

Comments
 (0)