Apply clang-tidy style fixes to audio and input code
Use explicit != 0U comparisons for bitmask checks, static_cast instead of C-style casts, <cstdint>/<cstdio> instead of the C headers, and puts() instead of iprintf() for plain strings.
This commit is contained in:
1 parent
fca0c19207
commit
df9b859601
2 files changed
+24
-22
No files matched your search
+17
-15
@@ -1,22 +1,24 @@
|
||||
#include "game_input.h"
|
||||
|
||||
#include <bitset>
|
||||
#include <stdio.h>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
|
||||
bool handle_input_frame(InputContext &ctx) {
|
||||
scanKeys();
|
||||
const int keys = keysDown();
|
||||
const uint32_t keys = keysDown();
|
||||
|
||||
if (keys && *ctx.internals) {
|
||||
if ((keys != 0U) && *ctx.internals) {
|
||||
consoleSelect(ctx.topScreen);
|
||||
iprintf("\x1b[6;0Hkeys = %s", std::bitset<16>(keys).to_string().c_str());
|
||||
std::string key_str = "\x1b[6;0Hkeys = " + std::bitset<16>(keys).to_string();
|
||||
puts(key_str.c_str());
|
||||
}
|
||||
|
||||
if ((keys & KEY_START) && (keys & KEY_L)) {
|
||||
if (((keys & KEY_START) != 0U) && ((keys & KEY_L) != 0U)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (keys & KEY_SELECT) {
|
||||
if ((keys != 0U) && ((keys & KEY_SELECT) != 0U)) {
|
||||
*ctx.internals = !(*ctx.internals);
|
||||
if (*ctx.internals) {
|
||||
setBackdropColor(RGB15(0, 0, 7));
|
||||
@@ -28,44 +30,44 @@ bool handle_input_frame(InputContext &ctx) {
|
||||
}
|
||||
|
||||
if (!ctx.state->paused && !ctx.state->gameOver) {
|
||||
if (keys & KEY_UP) {
|
||||
if ((keys != 0U) && ((keys & KEY_UP) != 0U)) {
|
||||
ctx.state->snakeDirection = 0;
|
||||
draw_game(*ctx.state, *ctx.renderAssets);
|
||||
}
|
||||
|
||||
if (keys & KEY_RIGHT) {
|
||||
if ((keys != 0U) && ((keys & KEY_RIGHT) != 0U)) {
|
||||
ctx.state->snakeDirection = 1;
|
||||
draw_game(*ctx.state, *ctx.renderAssets);
|
||||
}
|
||||
|
||||
if (keys & KEY_DOWN) {
|
||||
if ((keys != 0U) && ((keys & KEY_DOWN) != 0U)) {
|
||||
ctx.state->snakeDirection = 2;
|
||||
draw_game(*ctx.state, *ctx.renderAssets);
|
||||
}
|
||||
|
||||
if (keys & KEY_LEFT) {
|
||||
if ((keys != 0U) && ((keys & KEY_LEFT) != 0U)) {
|
||||
ctx.state->snakeDirection = 3;
|
||||
draw_game(*ctx.state, *ctx.renderAssets);
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx.state->paused) {
|
||||
if (keys & KEY_X) {
|
||||
if ((keys != 0U) && ((keys & KEY_X) != 0U)) {
|
||||
audio_toggle_music(*ctx.audio);
|
||||
}
|
||||
|
||||
if (keys & KEY_Y) {
|
||||
if ((keys != 0U) && ((keys & KEY_Y) != 0U)) {
|
||||
ctx.state->hardMode = !ctx.state->hardMode;
|
||||
ctx.init_game();
|
||||
draw_game(*ctx.state, *ctx.renderAssets);
|
||||
}
|
||||
}
|
||||
|
||||
if (keys & KEY_R) {
|
||||
if ((keys != 0U) && ((keys & KEY_R) != 0U)) {
|
||||
lcdSwap();
|
||||
}
|
||||
|
||||
if (keys & KEY_START) {
|
||||
if ((keys != 0U) && ((keys & KEY_START) != 0U)) {
|
||||
if (!ctx.state->gameOver) {
|
||||
ctx.state->paused = !ctx.state->paused;
|
||||
|
||||
@@ -73,7 +75,7 @@ bool handle_input_frame(InputContext &ctx) {
|
||||
consoleSelect(ctx.topScreen);
|
||||
audio_play_pause(*ctx.audio);
|
||||
audio_pause_music_if_enabled(*ctx.audio);
|
||||
iprintf("\x1b[11;12HPaused");
|
||||
puts("\x1b[11;12HPaused");
|
||||
} else {
|
||||
audio_resume_music_if_enabled(*ctx.audio);
|
||||
audio_play_unpause(*ctx.audio);
|
||||
|
||||
Reference in new issue
Block a user