Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Number on aplhanumeric part of keyboard can be binded to custom action and colide with wiel item change without warning #15746

Open
sfence opened this issue Feb 2, 2025 · 6 comments
Assignees
Labels
Bug Issues that were confirmed to be a bug @ Client / Controls / Input

Comments

@sfence
Copy link
Contributor

sfence commented Feb 2, 2025

Luanti version

Tested on Luanti 5.10 (MacOS + Linux)
Testen on Luanti from master on Linux
All no SDL builds.

Operating system and version

Tested on MacOS and Linux Arch.

CPU model

No response

GPU model

No response

Active renderer

No response

Summary

Users can rebind alphanumeric numbers to custom actions, which cause control collision. There is no warning about key collisions in this case.

Steps to reproduce

Start the game, rebind forward, backward, left, and right to some numbers on the alphanumeric keyboard (you will see no warning about key collision), and try to walk.

You should observe the change of wield item and move at the same time.

@sfence sfence added the Unconfirmed bug Bug report that has not been confirmed to exist/be reproducible label Feb 2, 2025
@SmallJoker
Copy link
Member

What is the expected outcome? What should be done to prevent key collisions? It's the player's responsibility to configure the hotkeys such that they are usable.

@y5nw
Copy link
Contributor

y5nw commented Feb 2, 2025

Can you see if it helps resolve the issue by adding the following settings to minetest.conf?

keymap_slot1=
keymap_slot2=
keymap_slot3=
keymap_slot4=
keymap_slot5=
keymap_slot6=
keymap_slot7=
keymap_slot8=
keymap_slot9=
keymap_slot10=

If yes, then I assume that this issue (similar to #15729) would fall under the scope of #10927 / #11209; maybe we can make this a sub-issue.

@y5nw y5nw self-assigned this Feb 2, 2025
@sfence sfence changed the title Number on aplhanumeric part of keyboard ca be binded to custom action and colide with wiel item change. Number on aplhanumeric part of keyboard can be binded to custom action and colide with wiel item change. Feb 2, 2025
@sfence sfence changed the title Number on aplhanumeric part of keyboard can be binded to custom action and colide with wiel item change. Number on aplhanumeric part of keyboard can be binded to custom action and colide with wiel item change without warning Feb 2, 2025
@sfence
Copy link
Contributor Author

sfence commented Feb 2, 2025

@SmallJoker If should show a warning about "Key is already in use".

@sfence
Copy link
Contributor Author

sfence commented Feb 2, 2025

@y5nw It results in slot changing stops to work.

@y5nw
Copy link
Contributor

y5nw commented Feb 2, 2025

Ok, so it seems like I misread the issue here; this is about collision warnings being missing.

Looking at the source code, it appears that, in general, keybinding settings that do not appear in the key change menu are not taken into consideration when checking for collisions:

bool key_in_use = false;
if (strcmp(kp.sym(), "") != 0) {
for (key_setting *ks : key_settings) {
if (ks != active_key && ks->key == kp) {
key_in_use = true;
break;
}
}
}

void GUIKeyChangeMenu::add_key(int id, std::wstring button_name, const std::string &setting_name)
{
key_setting *k = new key_setting;
k->id = id;
k->button_name = std::move(button_name);
k->setting_name = setting_name;
k->key = getKeySetting(k->setting_name.c_str());
key_settings.push_back(k);
}
// compare with button_titles in touchcontrols.cpp
void GUIKeyChangeMenu::init_keys()
{
this->add_key(GUI_ID_KEY_FORWARD_BUTTON, wstrgettext("Forward"), "keymap_forward");
this->add_key(GUI_ID_KEY_BACKWARD_BUTTON, wstrgettext("Backward"), "keymap_backward");
this->add_key(GUI_ID_KEY_LEFT_BUTTON, wstrgettext("Left"), "keymap_left");
this->add_key(GUI_ID_KEY_RIGHT_BUTTON, wstrgettext("Right"), "keymap_right");
this->add_key(GUI_ID_KEY_AUX1_BUTTON, wstrgettext("Aux1"), "keymap_aux1");
this->add_key(GUI_ID_KEY_JUMP_BUTTON, wstrgettext("Jump"), "keymap_jump");
this->add_key(GUI_ID_KEY_SNEAK_BUTTON, wstrgettext("Sneak"), "keymap_sneak");
this->add_key(GUI_ID_KEY_DROP_BUTTON, wstrgettext("Drop"), "keymap_drop");
this->add_key(GUI_ID_KEY_INVENTORY_BUTTON, wstrgettext("Inventory"), "keymap_inventory");
this->add_key(GUI_ID_KEY_HOTBAR_PREV_BUTTON, wstrgettext("Prev. item"), "keymap_hotbar_previous");
this->add_key(GUI_ID_KEY_HOTBAR_NEXT_BUTTON, wstrgettext("Next item"), "keymap_hotbar_next");
this->add_key(GUI_ID_KEY_ZOOM_BUTTON, wstrgettext("Zoom"), "keymap_zoom");
this->add_key(GUI_ID_KEY_CAMERA_BUTTON, wstrgettext("Change camera"), "keymap_camera_mode");
this->add_key(GUI_ID_KEY_MINIMAP_BUTTON, wstrgettext("Toggle minimap"), "keymap_minimap");
this->add_key(GUI_ID_KEY_FLY_BUTTON, wstrgettext("Toggle fly"), "keymap_freemove");
this->add_key(GUI_ID_KEY_PITCH_MOVE, wstrgettext("Toggle pitchmove"), "keymap_pitchmove");
this->add_key(GUI_ID_KEY_FAST_BUTTON, wstrgettext("Toggle fast"), "keymap_fastmove");
this->add_key(GUI_ID_KEY_NOCLIP_BUTTON, wstrgettext("Toggle noclip"), "keymap_noclip");
this->add_key(GUI_ID_KEY_MUTE_BUTTON, wstrgettext("Mute"), "keymap_mute");
this->add_key(GUI_ID_KEY_DEC_VOLUME_BUTTON, wstrgettext("Dec. volume"), "keymap_decrease_volume");
this->add_key(GUI_ID_KEY_INC_VOLUME_BUTTON, wstrgettext("Inc. volume"), "keymap_increase_volume");
this->add_key(GUI_ID_KEY_AUTOFWD_BUTTON, wstrgettext("Autoforward"), "keymap_autoforward");
this->add_key(GUI_ID_KEY_CHAT_BUTTON, wstrgettext("Chat"), "keymap_chat");
this->add_key(GUI_ID_KEY_SCREENSHOT_BUTTON, wstrgettext("Screenshot"), "keymap_screenshot");
this->add_key(GUI_ID_KEY_RANGE_BUTTON, wstrgettext("Range select"), "keymap_rangeselect");
this->add_key(GUI_ID_KEY_DEC_RANGE_BUTTON, wstrgettext("Dec. range"), "keymap_decrease_viewing_range_min");
this->add_key(GUI_ID_KEY_INC_RANGE_BUTTON, wstrgettext("Inc. range"), "keymap_increase_viewing_range_min");
this->add_key(GUI_ID_KEY_CONSOLE_BUTTON, wstrgettext("Console"), "keymap_console");
this->add_key(GUI_ID_KEY_CMD_BUTTON, wstrgettext("Command"), "keymap_cmd");
this->add_key(GUI_ID_KEY_CMD_LOCAL_BUTTON, wstrgettext("Local command"), "keymap_cmd_local");
this->add_key(GUI_ID_KEY_BLOCK_BOUNDS_BUTTON, wstrgettext("Block bounds"), "keymap_toggle_block_bounds");
this->add_key(GUI_ID_KEY_HUD_BUTTON, wstrgettext("Toggle HUD"), "keymap_toggle_hud");
this->add_key(GUI_ID_KEY_CHATLOG_BUTTON, wstrgettext("Toggle chat log"), "keymap_toggle_chat");
this->add_key(GUI_ID_KEY_FOG_BUTTON, wstrgettext("Toggle fog"), "keymap_toggle_fog");
}

@y5nw y5nw added Bug Issues that were confirmed to be a bug and removed Unconfirmed bug Bug report that has not been confirmed to exist/be reproducible labels Feb 2, 2025
@sfence
Copy link
Contributor Author

sfence commented Feb 3, 2025

@y5nw I updated the description, based on @SmallJoker comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues that were confirmed to be a bug @ Client / Controls / Input
Projects
None yet
Development

No branches or pull requests

3 participants