Skip to content

Commit

Permalink
FF8: Fix input scheme for Steam
Browse files Browse the repository at this point in the history
  • Loading branch information
julianxhokaxhiu committed Dec 5, 2024
1 parent 3f01764 commit 03f95b1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 44 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

- External textures: Fix texture not reloaded between fields ( https://github.com/julianxhokaxhiu/FFNx/pull/761 )

## FF8 Steam

- Input: Fix button schema mapping

# 1.21.0

- Full commit list since last stable release: https://github.com/julianxhokaxhiu/FFNx/compare/1.20.3...1.21.0
Expand Down
65 changes: 21 additions & 44 deletions src/ff8_opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,16 +433,16 @@ LPDIJOYSTATE2 ff8_update_gamepad_status()
ff8_externals.dinput_gamepad_state->rgdwPOV[1] = -1;
ff8_externals.dinput_gamepad_state->rgdwPOV[2] = -1;
ff8_externals.dinput_gamepad_state->rgdwPOV[3] = -1;
ff8_externals.dinput_gamepad_state->rgbButtons[0] = gamepad.IsPressed(steam_edition ? XINPUT_GAMEPAD_A : XINPUT_GAMEPAD_X) ? 0x80 : 0; // Cross (Steam)/Square
ff8_externals.dinput_gamepad_state->rgbButtons[1] = gamepad.IsPressed(steam_edition ? XINPUT_GAMEPAD_B : XINPUT_GAMEPAD_A) ? 0x80 : 0; // Circle (Steam)/Cross
ff8_externals.dinput_gamepad_state->rgbButtons[2] = gamepad.IsPressed(steam_edition ? XINPUT_GAMEPAD_X : XINPUT_GAMEPAD_B) ? 0x80 : 0; // Square (Steam)/Circle
ff8_externals.dinput_gamepad_state->rgbButtons[0] = gamepad.IsPressed(XINPUT_GAMEPAD_X) ? 0x80 : 0; // Square
ff8_externals.dinput_gamepad_state->rgbButtons[1] = gamepad.IsPressed(XINPUT_GAMEPAD_A) ? 0x80 : 0; // Cross
ff8_externals.dinput_gamepad_state->rgbButtons[2] = gamepad.IsPressed(XINPUT_GAMEPAD_B) ? 0x80 : 0; // Circle
ff8_externals.dinput_gamepad_state->rgbButtons[3] = gamepad.IsPressed(XINPUT_GAMEPAD_Y) ? 0x80 : 0; // Triangle
ff8_externals.dinput_gamepad_state->rgbButtons[4] = gamepad.IsPressed(XINPUT_GAMEPAD_LEFT_SHOULDER) ? 0x80 : 0; // L1
ff8_externals.dinput_gamepad_state->rgbButtons[5] = gamepad.IsPressed(XINPUT_GAMEPAD_RIGHT_SHOULDER) ? 0x80 : 0; // R1
ff8_externals.dinput_gamepad_state->rgbButtons[6] = (steam_edition ? gamepad.IsPressed(XINPUT_GAMEPAD_BACK) : gamepad.leftTrigger > 0.85f) ? 0x80 : 0; // SELECT (Steam)/L2
ff8_externals.dinput_gamepad_state->rgbButtons[7] = (steam_edition ? gamepad.IsPressed(XINPUT_GAMEPAD_START) : gamepad.rightTrigger > 0.85f) ? 0x80 : 0; // START (Steam)/R2
ff8_externals.dinput_gamepad_state->rgbButtons[8] = (steam_edition ? gamepad.leftTrigger > 0.85f : gamepad.IsPressed(XINPUT_GAMEPAD_BACK)) ? 0x80 : 0; // L2 (Steam)/SELECT
ff8_externals.dinput_gamepad_state->rgbButtons[9] = (steam_edition ? gamepad.rightTrigger > 0.85f : gamepad.IsPressed(XINPUT_GAMEPAD_START)) ? 0x80 : 0; // R2 (Steam)/START
ff8_externals.dinput_gamepad_state->rgbButtons[6] = gamepad.leftTrigger > 0.85f ? 0x80 : 0; // L2
ff8_externals.dinput_gamepad_state->rgbButtons[7] = gamepad.rightTrigger > 0.85f ? 0x80 : 0; // R2
ff8_externals.dinput_gamepad_state->rgbButtons[8] = gamepad.IsPressed(XINPUT_GAMEPAD_BACK) ? 0x80 : 0; // SELECT
ff8_externals.dinput_gamepad_state->rgbButtons[9] = gamepad.IsPressed(XINPUT_GAMEPAD_START) ? 0x80 : 0; // START
ff8_externals.dinput_gamepad_state->rgbButtons[10] = gamepad.IsPressed(XINPUT_GAMEPAD_LEFT_THUMB) ? 0x80 : 0; // L3
ff8_externals.dinput_gamepad_state->rgbButtons[11] = gamepad.IsPressed(XINPUT_GAMEPAD_RIGHT_THUMB) ? 0x80 : 0; // R3
ff8_externals.dinput_gamepad_state->rgbButtons[12] = gamepad.IsPressed(0x400) ? 0x80 : 0; // PS Button
Expand Down Expand Up @@ -565,26 +565,26 @@ int ff8_draw_gamepad_icon_or_keyboard_key(int a1, ff8_draw_menu_sprite_texture_i

switch (rgbButton)
{
case 0: // Cross (Steam)/Square
return steam_edition ? 134 : 135;
case 1: // Circle (Steam)/Cross
return steam_edition ? 133 : 134;
case 2: // Square (Steam)/Circle
return steam_edition ? 135 : 133;
case 0: // Square
return 135;
case 1: // Cross
return 134;
case 2: // Circle
return 133;
case 3: // Triangle
return 132;
case 4: // L1
return 130;
case 5: // R1
return 131;
case 6: // SELECT (Steam)/L2
return steam_edition ? 136 : 128;
case 7: // START (Steam)/R2
return steam_edition ? 139 : 129;
case 8: // L2 (Steam)/SELECT
return steam_edition ? 128 : 136;
case 9: // R2 (Steam)/START
return steam_edition ? 129 : 139;
case 6: // L2
return 128;
case 7: // R2
return 129;
case 8: // SELECT
return 136;
case 9: // START
return 139;
}
}

Expand Down Expand Up @@ -1148,29 +1148,6 @@ void ff8_init_hooks(struct game_obj *_game_object)
replace_function(ff8_externals.dinput_update_gamepad_status, ff8_update_gamepad_status);
replace_function(ff8_externals.dinput_get_input_device_capabilities_number_of_buttons, ff8_get_input_device_capabilities_number_of_buttons);

if (steam_edition)
{
// Create ff8input.cfg with the same default values than the FF8_Launcher

// When the game starts without ff8input.cfg file
patch_code_byte(ff8_externals.input_init + 0x29, 225); // 226 => 225
patch_code_byte(ff8_externals.input_init + 0x3C, 224); // 225 => 224
patch_code_byte(ff8_externals.input_init + 0x53, 226); // 224 => 226
patch_code_byte(ff8_externals.input_init + 0xA7, 232); // 230 => 232
patch_code_byte(ff8_externals.input_init + 0xBA, 233); // 231 => 233
patch_code_byte(ff8_externals.input_init + 0xD1, 230); // 232 => 230
patch_code_byte(ff8_externals.input_init + 0xE4, 231); // 233 => 231

// When the player reset the controls in the game menu
patch_code_byte(ff8_externals.ff8input_cfg_reset + 0xD8, 225); // 226 => 225
patch_code_byte(ff8_externals.ff8input_cfg_reset + 0xEB, 224); // 225 => 224
patch_code_byte(ff8_externals.ff8input_cfg_reset + 0x102, 226); // 224 => 226
patch_code_byte(ff8_externals.ff8input_cfg_reset + 0x156, 232); // 230 => 232
patch_code_byte(ff8_externals.ff8input_cfg_reset + 0x169, 233); // 231 => 233
patch_code_byte(ff8_externals.ff8input_cfg_reset + 0x180, 230); // 232 => 230
patch_code_byte(ff8_externals.ff8input_cfg_reset + 0x193, 231); // 233 => 231
}

// #####################
// Analog 360 patch
// #####################
Expand Down

0 comments on commit 03f95b1

Please sign in to comment.