Skip to content

Commit

Permalink
trx/types: improve #if TR_VERSION
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Jan 13, 2025
1 parent db7c93f commit 7c10f42
Show file tree
Hide file tree
Showing 10 changed files with 562 additions and 567 deletions.
8 changes: 1 addition & 7 deletions src/libtrx/game/input/backends/controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ static BUILTIN_CONTROLLER_LAYOUT m_BuiltinLayout[] = {
{ role, { BT_BUTTON, { .button = bind }, 0 } },
#define INPUT_CONTROLLER_ASSIGN_AXIS(role, bind, axis_dir) \
{ role, { BT_AXIS, { .axis = bind }, axis_dir } },
#if TR_VERSION == 1
#include "game/input/backends/controller_tr1.def"
#elif TR_VERSION == 2
#include "game/input/backends/controller_tr2.def"
#endif
#include "game/input/backends/controller.def"
// guard
{ -1, { 0, { 0 }, 0 } },
};
Expand Down Expand Up @@ -436,9 +432,7 @@ static bool M_CustomUpdate(INPUT_STATE *const result, const INPUT_LAYOUT layout)
if (m_Controller == NULL) {
return false;
}
#if TR_VERSION == 1 || TR_VERSION == 2
result->menu_back |= M_JoyBtn(SDL_CONTROLLER_BUTTON_Y);
#endif
return true;
}

Expand Down
8 changes: 1 addition & 7 deletions src/libtrx/game/input/backends/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ static bool m_Conflicts[INPUT_LAYOUT_NUMBER_OF][INPUT_ROLE_NUMBER_OF] = {};
static BUILTIN_KEYBOARD_LAYOUT m_BuiltinLayout[] = {
// clang-format off
#define INPUT_KEYBOARD_ASSIGN(role, key) { role, key },
#if TR_VERSION == 1
#include "game/input/backends/keyboard_tr1.def"
#elif TR_VERSION == 2
#include "game/input/backends/keyboard_tr2.def"
#endif
#include "game/input/backends/keyboard.def"
{ -1, SDL_SCANCODE_UNKNOWN },
// clang-format on
};
Expand Down Expand Up @@ -382,11 +378,9 @@ static void M_Init(void)
static bool M_CustomUpdate(INPUT_STATE *const result, const INPUT_LAYOUT layout)
{
// we only do this for keyboard input
#if TR_VERSION == 1 || TR_VERSION == 2
result->menu_confirm |= result->action;
result->toggle_fullscreen =
KEY_DOWN(SDL_SCANCODE_RETURN) && KEY_DOWN(SDL_SCANCODE_LALT);
#endif
return true;
}

Expand Down
6 changes: 1 addition & 5 deletions src/libtrx/game/text.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ static GLYPH_INFO m_Glyphs[] = {
.width = width_, \
.mesh_idx = mesh_idx_, \
__VA_ARGS__ },
#if TR_VERSION == 1
#include "text_tr1.def"
#elif TR_VERSION == 2
#include "text_tr2.def"
#endif
#include "text.def"
{ .text = NULL }, // guard
};

Expand Down
5 changes: 5 additions & 0 deletions src/libtrx/game/text.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#if TR_VERSION == 1
#include "text_tr1.def"
#elif TR_VERSION == 2
#include "text_tr2.def"
#endif
5 changes: 5 additions & 0 deletions src/libtrx/include/libtrx/game/input/backends/controller.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#if TR_VERSION == 1
#include "game/input/backends/controller_tr1.def"
#elif TR_VERSION == 2
#include "game/input/backends/controller_tr2.def"
#endif
5 changes: 5 additions & 0 deletions src/libtrx/include/libtrx/game/input/backends/keyboard.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#if TR_VERSION == 1
#include "game/input/backends/keyboard_tr1.def"
#elif TR_VERSION == 2
#include "game/input/backends/keyboard_tr2.def"
#endif
5 changes: 5 additions & 0 deletions src/libtrx/include/libtrx/game/sound/ids.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#if TR_VERSION == 1
#include "ids_tr1.def"
#elif TR_VERSION == 2
#include "ids_tr2.def"
#endif
Loading

0 comments on commit 7c10f42

Please sign in to comment.