Skip to content

Commit

Permalink
Input: Added default axis mapping array, show it in Custom Controls
Browse files Browse the repository at this point in the history
  • Loading branch information
midwan committed Mar 5, 2022
1 parent 87bdd03 commit 2ca7b8d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
13 changes: 6 additions & 7 deletions src/osdep/amiberry_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,18 @@ static void fill_blank_controller()
axi = SDL_CONTROLLER_AXIS_INVALID;
}

constexpr int default_mapping[] = {
constexpr int default_button_mapping[] = {
INPUTEVENT_JOY2_CD32_RED, INPUTEVENT_JOY2_CD32_BLUE, INPUTEVENT_JOY2_CD32_GREEN, INPUTEVENT_JOY2_CD32_YELLOW,
0, 0, INPUTEVENT_JOY2_CD32_PLAY, 0, 0, INPUTEVENT_JOY2_CD32_RWD, INPUTEVENT_JOY2_CD32_FFW,
INPUTEVENT_JOY2_UP, INPUTEVENT_JOY2_DOWN, INPUTEVENT_JOY2_LEFT, INPUTEVENT_JOY2_RIGHT,
0, 0, 0, 0, 0, 0
};

constexpr int default_axis_mapping[] = {
INPUTEVENT_JOY2_HORIZ, INPUTEVENT_JOY2_VERT, INPUTEVENT_JOY2_HORIZ, INPUTEVENT_JOY2_VERT,
0, 0
};

constexpr int remap_event_list[] = {
// joystick port 1
INPUTEVENT_JOY2_UP, INPUTEVENT_JOY2_DOWN, INPUTEVENT_JOY2_LEFT, INPUTEVENT_JOY2_RIGHT,
Expand Down Expand Up @@ -951,9 +956,6 @@ static int init_joystick()
strcat(retroarch_config_file, sanitized_name.c_str());
strcat(retroarch_config_file, ".cfg");

//fill_default_controller();
//host_input_buttons[cpt] = default_controller_map;

if (my_existsfile(retroarch_config_file))
{
write_log("Retroarch controller cfg file found, using that for mapping\n");
Expand Down Expand Up @@ -1510,9 +1512,6 @@ int input_get_default_joystick(struct uae_input_device* uid, int i, int port, in
setid(uid, i, ID_BUTTON_OFFSET + SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, 0, port, INPUTEVENT_JOY1_2ND_BUTTON, gp);
}

//
// Amiberry extra mappings
//
// Configure a few extra default mappings, for convenience
std::array<int, SDL_CONTROLLER_BUTTON_MAX> button_map[2]{};
button_map[0] = currprefs.jports[port].amiberry_custom_none;
Expand Down
3 changes: 2 additions & 1 deletion src/osdep/amiberry_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ extern int kb_cd32_retroarch_player4[23];
extern const TCHAR* find_inputevent_name(int key);
extern int find_inputevent(TCHAR* key);
extern int find_in_array(const int arr[], int n, int key);
extern const int default_mapping[];
extern const int default_button_mapping[];
extern const int default_axis_mapping[];
extern const int remap_event_list[];
extern const int remap_event_list_size;

Expand Down
16 changes: 8 additions & 8 deletions src/osdep/gui/PanelCustom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ void RefreshPanelCustom()
else
{
// Default mapping
const auto evt = default_mapping[temp_button];
const auto evt = default_button_mapping[temp_button];
const auto x = find_in_array(remap_event_list, remap_event_list_size, evt);
cboCustomButtonAction[n]->setSelected(x + 1);
}
Expand All @@ -553,13 +553,13 @@ void RefreshPanelCustom()
{
cboCustomAxisAction[n]->setSelected(0);
}
//else
//{
// // Default mapping
// const auto evt = default_mapping[temp_axis];
// const auto x = find_in_array(remap_event_list, remap_event_list_size, evt);
// cboCustomAxisAction[n]->setSelected(x + 1);
//}
else
{
// Default mapping
const auto evt = default_axis_mapping[temp_axis];
const auto x = find_in_array(remap_event_list, remap_event_list_size, evt);
cboCustomAxisAction[n]->setSelected(x + 1);
}
}

if (did->mapping.number_of_hats > 0 || changed_prefs.input_analog_remap == true)
Expand Down

0 comments on commit 2ca7b8d

Please sign in to comment.