Skip to content

Commit

Permalink
Allow both mouse movement and click-and-drag without local keybinds (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroInternalReflection authored Sep 12, 2022
1 parent 4840ee2 commit 32a7873
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion data/raw/keybindings.json
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,7 @@
"type": "keybinding",
"id": "MOUSE_MOVE",
"name": "Mouse move",
"bindings": [ { "input_method": "mouse", "key": "MOUSE_MOVE" }, { "input_method": "mouse", "key": "MOUSE_LEFT_PRESSED" } ]
"bindings": [ { "input_method": "mouse", "key": "MOUSE_MOVE" } ]
},
{
"type": "keybinding",
Expand Down
2 changes: 2 additions & 0 deletions src/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@ std::string action_ident( action_id act )
return "SELECT";
case ACTION_SEC_SELECT:
return "SEC_SELECT";
case ACTION_CLICK_AND_DRAG:
return "CLICK_AND_DRAG";
case ACTION_AUTOATTACK:
return "autoattack";
case ACTION_MAIN_MENU:
Expand Down
2 changes: 2 additions & 0 deletions src/action.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ enum action_id : int {
ACTION_SELECT,
/** Click on a point with secondary mouse button (usually right button) */
ACTION_SEC_SELECT,
/** action on left mouse button-down, for clicking and dragging */
ACTION_CLICK_AND_DRAG,
/**@}*/

// Character movement actions
Expand Down
1 change: 1 addition & 0 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2476,6 +2476,7 @@ input_context get_default_mode_input_context()
ctxt.register_action( "COORDINATE" );
ctxt.register_action( "MOUSE_MOVE" );
ctxt.register_action( "SELECT" );
ctxt.register_action( "CLICK_AND_DRAG" );
ctxt.register_action( "SEC_SELECT" );
return ctxt;
}
Expand Down
5 changes: 5 additions & 0 deletions src/handle_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2884,6 +2884,11 @@ bool game::handle_action()
user_action_counter += 1;
}

if( act == ACTION_CLICK_AND_DRAG ) {
// Need to return false to avoid disrupting actions like character mouse movement that require two clicks
return false;
}

if( act == ACTION_SELECT || act == ACTION_SEC_SELECT ) {
// Mouse button click
if( veh_ctrl ) {
Expand Down

0 comments on commit 32a7873

Please sign in to comment.