Add ability to map analogue triggers to digital buttons
This commit is contained in:
parent
b393a35325
commit
f5887d64c2
|
@ -57,9 +57,25 @@ enum DreamcastKey
|
|||
DC_AXIS_Y2 = 0x20003,
|
||||
|
||||
// System axes
|
||||
EMU_AXIS_NONE = 0x00000,
|
||||
EMU_AXIS_DPAD1_X = DC_DPAD_LEFT,
|
||||
EMU_AXIS_DPAD1_Y = DC_DPAD_UP,
|
||||
EMU_AXIS_DPAD2_X = DC_DPAD2_LEFT,
|
||||
EMU_AXIS_DPAD2_Y = DC_DPAD2_RIGHT,
|
||||
EMU_AXIS_NONE = 0x00000,
|
||||
EMU_AXIS_DPAD1_X = DC_DPAD_LEFT,
|
||||
EMU_AXIS_DPAD1_Y = DC_DPAD_UP,
|
||||
EMU_AXIS_DPAD2_X = DC_DPAD2_LEFT,
|
||||
EMU_AXIS_DPAD2_Y = DC_DPAD2_UP,
|
||||
EMU_AXIS_BTN_A = 0x40000 | DC_BTN_A,
|
||||
EMU_AXIS_BTN_B = 0x40000 | DC_BTN_B,
|
||||
EMU_AXIS_BTN_C = 0x40000 | DC_BTN_C,
|
||||
EMU_AXIS_BTN_D = 0x40000 | DC_BTN_D,
|
||||
EMU_AXIS_BTN_X = 0x40000 | DC_BTN_X,
|
||||
EMU_AXIS_BTN_Y = 0x40000 | DC_BTN_Y,
|
||||
EMU_AXIS_BTN_Z = 0x40000 | DC_BTN_Z,
|
||||
EMU_AXIS_BTN_START = 0x40000 | DC_BTN_START,
|
||||
EMU_AXIS_DPAD_UP = 0x40000 | DC_DPAD_UP,
|
||||
EMU_AXIS_DPAD_DOWN = 0x40000 | DC_DPAD_DOWN,
|
||||
EMU_AXIS_DPAD_LEFT = 0x40000 | DC_DPAD_LEFT,
|
||||
EMU_AXIS_DPAD_RIGHT = 0x40000 | DC_DPAD_RIGHT,
|
||||
EMU_AXIS_DPAD2_UP = 0x40000 | DC_DPAD2_UP,
|
||||
EMU_AXIS_DPAD2_DOWN = 0x40000 | DC_DPAD2_DOWN,
|
||||
EMU_AXIS_DPAD2_LEFT = 0x40000 | DC_DPAD2_LEFT,
|
||||
EMU_AXIS_DPAD2_RIGHT = 0x40000 | DC_DPAD2_RIGHT,
|
||||
};
|
||||
|
|
|
@ -225,6 +225,13 @@ bool GamepadDevice::gamepad_axis_input(u32 code, int value)
|
|||
else
|
||||
*this_axis = (s8)v;
|
||||
}
|
||||
else if (((int)key >> 16) == 4) // Map triggers to digital buttons
|
||||
{
|
||||
if (v <= -64)
|
||||
kcode[_maple_port] |= (key & ~0x40000); // button released
|
||||
else if (v >= 64)
|
||||
kcode[_maple_port] &= ~(key & ~0x40000); // button pressed
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
|
|
|
@ -74,7 +74,23 @@ axis_list[] =
|
|||
{ EMU_AXIS_DPAD1_X, "compat", "axis_dpad1_x", "compat", "axis_dpad1_x_inverted" },
|
||||
{ EMU_AXIS_DPAD1_Y, "compat", "axis_dpad1_y", "compat", "axis_dpad1_y_inverted" },
|
||||
{ EMU_AXIS_DPAD2_X, "compat", "axis_dpad2_x", "compat", "axis_dpad2_x_inverted" },
|
||||
{ EMU_AXIS_DPAD2_Y, "compat", "axis_dpad2_y", "compat", "axis_dpad2_y_inverted" }
|
||||
{ EMU_AXIS_DPAD2_Y, "compat", "axis_dpad2_y", "compat", "axis_dpad2_y_inverted" },
|
||||
{ EMU_AXIS_BTN_A, "compat", "axis_btn_a", "compat", "axis_btn_a_inverted" },
|
||||
{ EMU_AXIS_BTN_B, "compat", "axis_btn_b", "compat", "axis_btn_b_inverted" },
|
||||
{ EMU_AXIS_BTN_C, "compat", "axis_btn_c", "compat", "axis_btn_c_inverted" },
|
||||
{ EMU_AXIS_BTN_D, "compat", "axis_btn_d", "compat", "axis_btn_d_inverted" },
|
||||
{ EMU_AXIS_BTN_X, "compat", "axis_btn_x", "compat", "axis_btn_x_inverted" },
|
||||
{ EMU_AXIS_BTN_Y, "compat", "axis_btn_y", "compat", "axis_btn_y_inverted" },
|
||||
{ EMU_AXIS_BTN_Z, "compat", "axis_btn_z", "compat", "axis_btn_z_inverted" },
|
||||
{ EMU_AXIS_BTN_START, "compat", "axis_btn_start", "compat", "axis_btn_start_inverted" },
|
||||
{ EMU_AXIS_DPAD_LEFT, "compat", "axis_dpad1_left", "compat", "axis_dpad1_left_inverted" },
|
||||
{ EMU_AXIS_DPAD_RIGHT, "compat", "axis_dpad1_right", "compat", "axis_dpad1_right_inverted" },
|
||||
{ EMU_AXIS_DPAD_UP, "compat", "axis_dpad1_up", "compat", "axis_dpad1_up_inverted" },
|
||||
{ EMU_AXIS_DPAD_DOWN, "compat", "axis_dpad1_down", "compat", "axis_dpad1_down_inverted" },
|
||||
{ EMU_AXIS_DPAD2_LEFT, "compat", "axis_dpad2_left", "compat", "axis_dpad2_left_inverted" },
|
||||
{ EMU_AXIS_DPAD2_RIGHT, "compat", "axis_dpad2_right", "compat", "axis_dpad2_right_inverted" },
|
||||
{ EMU_AXIS_DPAD2_UP, "compat", "axis_dpad2_up", "compat", "axis_dpad2_up_inverted" },
|
||||
{ EMU_AXIS_DPAD2_DOWN, "compat", "axis_dpad2_down", "compat", "axis_dpad2_down_inverted" }
|
||||
};
|
||||
|
||||
std::map<std::string, std::shared_ptr<InputMapping>> InputMapping::loaded_mappings;
|
||||
|
|
|
@ -449,9 +449,14 @@ const char *button_names[] = { "Start", "A", "B", "X", "Y", "DPad Up", "DPad Dow
|
|||
"Left Stick Up", "Left Stick Down", "Left Stick Left", "Left Stick Right" };
|
||||
const char *arcade_button_names[] = { "Start", "Button 1", "Button 2", "Button 3", "Button 4", "Up", "Down", "Left", "Right",
|
||||
"Menu", "Exit", "Fast-forward", "N/A", "N/A",
|
||||
"Service", "Coin", "Test", "Button 5", "Button 6", "Button 7", "Button 8" };
|
||||
const DreamcastKey axis_keys[] = { DC_AXIS_X, DC_AXIS_Y, DC_AXIS_LT, DC_AXIS_RT, DC_AXIS_X2, DC_AXIS_Y2, EMU_AXIS_DPAD1_X, EMU_AXIS_DPAD1_Y, EMU_AXIS_DPAD2_X, EMU_AXIS_DPAD2_Y };
|
||||
const char *axis_names[] = { "Left Stick X", "Left Stick Y", "Left Trigger", "Right Trigger", "Right Stick X", "Right Stick Y", "DPad X", "DPad Y", "Right DPad X", "Right DPad Y" };
|
||||
"Service", "Coin", "Test", "Button 5", "Button 6", "Button 7", "Button 8", "N/A", "N/A", "N/A", "N/A" };
|
||||
const DreamcastKey axis_keys[] = { DC_AXIS_X, DC_AXIS_Y, DC_AXIS_LT, DC_AXIS_RT, DC_AXIS_X2, DC_AXIS_Y2, EMU_AXIS_DPAD1_X, EMU_AXIS_DPAD1_Y, EMU_AXIS_DPAD2_X, EMU_AXIS_DPAD2_Y,
|
||||
EMU_AXIS_BTN_START, EMU_AXIS_BTN_A, EMU_AXIS_BTN_B, EMU_AXIS_BTN_X, EMU_AXIS_BTN_Y, EMU_AXIS_DPAD_UP, EMU_AXIS_DPAD_DOWN, EMU_AXIS_DPAD_LEFT, EMU_AXIS_DPAD_RIGHT,
|
||||
EMU_AXIS_BTN_C, EMU_AXIS_BTN_D, EMU_AXIS_BTN_Z, EMU_AXIS_DPAD2_UP, EMU_AXIS_DPAD2_DOWN, EMU_AXIS_DPAD2_LEFT, EMU_AXIS_DPAD2_RIGHT};
|
||||
const char *axis_names[] = { "Left Stick X", "Left Stick Y", "Left Trigger", "Right Trigger", "Right Stick X", "Right Stick Y", "DPad X", "DPad Y", "Right DPad X", "Right DPad Y",
|
||||
"Start", "A", "B", "X", "Y", "DPad Up", "DPad Down", "DPad Left", "DPad Right", "C", "D", "Z", "Right DPad Up", "Right DPad Down", "Right DPad Left", "Right DPad Right"};
|
||||
const char *arcade_axis_names[] = { "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "Start", "Button 1", "Button 2", "Button 3", "Button 4", "Up", "Down", "Left", "Right",
|
||||
"Service", "Coin", "Test", "Button 5", "Button 6", "Button 7", "Button 8"};
|
||||
|
||||
static MapleDeviceType maple_expansion_device_type_from_index(int idx)
|
||||
{
|
||||
|
@ -487,7 +492,7 @@ static void detect_input_popup(int index, bool analog)
|
|||
if (ImGui::BeginPopupModal(analog ? "Map Axis" : "Map Button", NULL, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove))
|
||||
{
|
||||
ImGui::Text("Waiting for %s '%s'...", analog ? "axis" : "button",
|
||||
analog ? axis_names[index]
|
||||
analog ? arcade_button_mode ? arcade_axis_names[index] : axis_names[index]
|
||||
: arcade_button_mode ? arcade_button_names[index] : button_names[index]);
|
||||
double now = os_GetSeconds();
|
||||
ImGui::Text("Time out in %d s", (int)(5 - (now - map_start_time)));
|
||||
|
@ -592,7 +597,7 @@ static void controller_mapping_popup(std::shared_ptr<GamepadDevice> gamepad)
|
|||
{
|
||||
sprintf(key_id, "axis_id%d", j);
|
||||
ImGui::PushID(key_id);
|
||||
ImGui::Text("%s", axis_names[j]);
|
||||
ImGui::Text("%s", arcade_button_mode ? arcade_axis_names[j] : axis_names[j]);
|
||||
ImGui::NextColumn();
|
||||
u32 code = input_mapping->get_axis_code(axis_keys[j]);
|
||||
if (code != (u32)-1)
|
||||
|
|
Loading…
Reference in New Issue