Skip to content

Commit

Permalink
Input remapping support
Browse files Browse the repository at this point in the history
  • Loading branch information
andon authored and andon committed Jan 30, 2017
1 parent 436906d commit 02e9f3d
Show file tree
Hide file tree
Showing 8 changed files with 311 additions and 15 deletions.
4 changes: 2 additions & 2 deletions include/DLL_VERSION.H
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@


#define TBF_MAJOR 0
#define TBF_MINOR 4
#define TBF_BUILD 5
#define TBF_MINOR 5
#define TBF_BUILD 0
#define TBF_REV 0


Expand Down
1 change: 1 addition & 0 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ struct tbf_config_t

struct {
std::wstring swap_keys = L"";
bool swap_wasd = false;
} keyboard;

struct {
Expand Down
61 changes: 49 additions & 12 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ std::wstring TBF_VER_STR = TBF_VERSION_STR_W;
std::wstring DEFAULT_BK2 = L"RAW\\MOVIE\\AM_TOZ_OP_001.BK2";

static
iSK_INI* dll_ini = nullptr;
iSK_INI* dll_ini = nullptr;
static
iSK_INI* gamepad_ini = nullptr;
iSK_INI* gamepad_ini = nullptr;
static
iSK_INI* render_ini = nullptr;
iSK_INI* keyboard_ini = nullptr;
static
iSK_INI* render_ini = nullptr;

tbf_config_t config;

Expand Down Expand Up @@ -90,6 +92,7 @@ struct {

struct {
tbf::ParameterStringW* swap_keys;
tbf::ParameterBool* swap_wasd;
} keyboard;


Expand Down Expand Up @@ -119,9 +122,10 @@ TBF_LoadConfig (std::wstring name)
);

// Load INI File
wchar_t wszFullName [ MAX_PATH + 2 ] = { L'\0' };
wchar_t wszPadName [ MAX_PATH + 2 ] = { L'\0' };
wchar_t wszRenderName [ MAX_PATH + 2 ] = { L'\0' };
wchar_t wszFullName [ MAX_PATH + 2 ] = { L'\0' };
wchar_t wszPadName [ MAX_PATH + 2 ] = { L'\0' };
wchar_t wszRenderName [ MAX_PATH + 2 ] = { L'\0' };
wchar_t wszKeyboardName [ MAX_PATH + 2 ] = { L'\0' };

lstrcatW (wszFullName, SK_GetConfigPath ());
lstrcatW (wszFullName, name.c_str ());
Expand All @@ -136,6 +140,10 @@ TBF_LoadConfig (std::wstring name)
lstrcatW (wszRenderName, L"TBFix_Render.ini");
render_ini = TBF_CreateINI (wszRenderName);

lstrcatW (wszKeyboardName, SK_GetConfigPath ());
lstrcatW (wszKeyboardName, L"TBFix_Keyboard.ini");
keyboard_ini = TBF_CreateINI (wszKeyboardName);

bool empty = dll_ini->get_sections ().empty ();

//
Expand Down Expand Up @@ -327,6 +335,17 @@ TBF_LoadConfig (std::wstring name)
L"TextureSet" );


keyboard.swap_wasd =
static_cast <tbf::ParameterBool *>
(g_ParameterFactory.create_parameter <bool>(
L"Swap the WASD and Arrow Keys")
);
keyboard.swap_wasd->register_to_ini (
keyboard_ini,
L"Keyboard.Remap",
L"SwapArrowsWithWASD" );


sys.version =
static_cast <tbf::ParameterStringW *>
(g_ParameterFactory.create_parameter <std::wstring> (
Expand Down Expand Up @@ -369,14 +388,17 @@ TBF_LoadConfig (std::wstring name)
//sys.intro_video->load (config.system.intro_video);
sys.injector->load (config.system.injector);

if (gamepad_ini->get_sections ().empty () || render_ini->get_sections ().empty ()) {
if (gamepad_ini->get_sections ().empty () || render_ini->get_sections ().empty () || keyboard_ini->get_sections ().empty ())
{
TBF_SaveConfig (name, false);

gamepad_ini->parse ();
render_ini->parse ();
gamepad_ini->parse ();
render_ini->parse ();
keyboard_ini->parse ();
}

input.gamepad.texture_set->load (config.input.gamepad.texture_set);
keyboard.swap_wasd->load (config.keyboard.swap_wasd);

render.rescale_shadows->load (config.render.shadow_rescale);
render.rescale_env_shadows->load (config.render.env_shadow_rescale);
Expand Down Expand Up @@ -428,13 +450,16 @@ TBF_SaveConfig (std::wstring name, bool close_config)

input.gamepad.texture_set->store (config.input.gamepad.texture_set);

keyboard.swap_wasd->store (config.keyboard.swap_wasd);

sys.version->store (TBF_VER_STR);
//sys.intro_video->store (config.system.intro_video);
sys.injector->store (config.system.injector);

wchar_t wszFullName [ MAX_PATH + 2 ] = { L'\0' };
wchar_t wszPadName [ MAX_PATH + 2 ] = { L'\0' };
wchar_t wszRenderName [ MAX_PATH + 2 ] = { L'\0' };
wchar_t wszFullName [ MAX_PATH + 2 ] = { L'\0' };
wchar_t wszPadName [ MAX_PATH + 2 ] = { L'\0' };
wchar_t wszRenderName [ MAX_PATH + 2 ] = { L'\0' };
wchar_t wszKeyboardName [ MAX_PATH + 2 ] = { L'\0' };

lstrcatW ( wszFullName,
SK_GetConfigPath () );
Expand All @@ -459,6 +484,13 @@ TBF_SaveConfig (std::wstring name, bool close_config)

render_ini->write (wszRenderName);

lstrcatW ( wszKeyboardName,
SK_GetConfigPath () );
lstrcatW ( wszKeyboardName,
L"TBFix_Keyboard.ini" );

keyboard_ini->write (wszKeyboardName);

if (close_config) {
if (dll_ini != nullptr) {
delete dll_ini;
Expand All @@ -474,5 +506,10 @@ TBF_SaveConfig (std::wstring name, bool close_config)
delete render_ini;
render_ini = nullptr;
}

if (keyboard_ini != nullptr) {
delete keyboard_ini;
keyboard_ini = nullptr;
}
}
}
5 changes: 5 additions & 0 deletions src/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ SKPlugIn_Init (HMODULE hModSpecialK)
tbf::RenderFix::Init ();
//tbf::KeyboardFix::Init ();

extern void
TBF_InitSDLOverride (void);

TBF_InitSDLOverride ();


CreateThread ( nullptr, 0,
[](LPVOID user) ->
Expand Down
Loading

0 comments on commit 02e9f3d

Please sign in to comment.