Keyboard presses (and thus keybindings) will now report the turf the mouse was over when a player presses or releases a key (#90480)

## About The Pull Request

Semi WIP cus I need to probably make an issue report for lummox, but
apart from that ready for review

Uses the new mouse-pos so we can combine it with screen size and size to
estimate very accurately the mouse position in turf terms. In future
also will need to add a way to continously poll the users mouse pos but
this alone is very useful

## Why It's Good For The Game

This isnt used yet, but the benefits are pretty damn obvious (hitting E
and dashing towards where your mouse??? 1990s features?????)

## Changelog
🆑
refactor: Added the possibility for keybindings to report the turf they
clicked on.
/🆑

---------

Co-authored-by: TiviPlus <572233640+TiviPlus@users.noreply.com>
This commit is contained in:
TiviPlus
2025-05-17 07:03:01 +02:00
committed by Roxy
parent dcd41131dd
commit 78bc9dba91
15 changed files with 144 additions and 67 deletions
+4 -4
View File
@@ -16,13 +16,13 @@
if(LAZYLEN(hotkey_keys) && !LAZYLEN(classic_keys))
classic_keys = hotkey_keys.Copy()
/datum/keybinding/proc/down(client/user)
/datum/keybinding/proc/down(client/user, turf/target)
SHOULD_CALL_PARENT(TRUE)
return SEND_SIGNAL(user.mob, keybind_signal) & COMSIG_KB_ACTIVATED
return SEND_SIGNAL(user.mob, keybind_signal, target) & COMSIG_KB_ACTIVATED
/datum/keybinding/proc/up(client/user)
/datum/keybinding/proc/up(client/user, turf/target)
SHOULD_CALL_PARENT(TRUE)
SEND_SIGNAL(user.mob, DEACTIVATE_KEYBIND(keybind_signal))
SEND_SIGNAL(user.mob, DEACTIVATE_KEYBIND(keybind_signal), target)
return FALSE
/datum/keybinding/proc/can_use(client/user)
+9 -9
View File
@@ -19,7 +19,7 @@
description = "Go ghost"
keybind_signal = COMSIG_KB_ADMIN_AGHOST_DOWN
/datum/keybinding/admin/admin_ghost/down(client/user)
/datum/keybinding/admin/admin_ghost/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -33,7 +33,7 @@
description = "Opens up the new player panel"
keybind_signal = COMSIG_KB_ADMIN_PLAYERPANELNEW_DOWN
/datum/keybinding/admin/player_panel_new/down(client/user)
/datum/keybinding/admin/player_panel_new/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -47,7 +47,7 @@
description = "Toggles buildmode"
keybind_signal = COMSIG_KB_ADMIN_TOGGLEBUILDMODE_DOWN
/datum/keybinding/admin/toggle_buildmode_self/down(client/user)
/datum/keybinding/admin/toggle_buildmode_self/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -61,7 +61,7 @@
description = "Enters stealth mode"
keybind_signal = COMSIG_KB_ADMIN_STEALTHMODETOGGLE_DOWN
/datum/keybinding/admin/stealthmode/down(client/user)
/datum/keybinding/admin/stealthmode/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -75,7 +75,7 @@
description = "Toggles ghost-like invisibility (Don't abuse this)"
keybind_signal = COMSIG_KB_ADMIN_INVISIMINTOGGLE_DOWN
/datum/keybinding/admin/invisimin/down(client/user)
/datum/keybinding/admin/invisimin/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -89,7 +89,7 @@
description = "Allows you to send a message to dead chat"
keybind_signal = COMSIG_KB_ADMIN_DSAY_DOWN
/datum/keybinding/admin/deadsay/down(client/user)
/datum/keybinding/admin/deadsay/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -103,7 +103,7 @@
description = "Shed your admin powers"
keybind_signal = COMSIG_KB_ADMIN_DEADMIN_DOWN
/datum/keybinding/admin/deadmin/down(client/user)
/datum/keybinding/admin/deadmin/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -117,7 +117,7 @@
description = "Regain your admin powers"
keybind_signal = COMSIG_KB_ADMIN_READMIN_DOWN
/datum/keybinding/admin/readmin/down(client/user)
/datum/keybinding/admin/readmin/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -131,7 +131,7 @@
description = "Open the View-Tags menu"
keybind_signal = COMSIG_KB_ADMIN_VIEWTAGS_DOWN
/datum/keybinding/admin/view_tags/down(client/user)
/datum/keybinding/admin/view_tags/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -12,7 +12,7 @@
description = "Reconnects you to your most recently used AI shell"
keybind_signal = COMSIG_KB_SILICON_RECONNECT_DOWN
/datum/keybinding/artificial_intelligence/reconnect/down(client/user)
/datum/keybinding/artificial_intelligence/reconnect/down(client/user, turf/target)
. = ..()
if(.)
return
+4 -4
View File
@@ -13,7 +13,7 @@
category = CATEGORY_CARBON
keybind_signal = COMSIG_KB_CARBON_TOGGLETHROWMODE_DOWN
/datum/keybinding/carbon/toggle_throw_mode/down(client/user)
/datum/keybinding/carbon/toggle_throw_mode/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -29,14 +29,14 @@
category = CATEGORY_CARBON
keybind_signal = COMSIG_KB_CARBON_HOLDTHROWMODE_DOWN
/datum/keybinding/carbon/hold_throw_mode/down(client/user)
/datum/keybinding/carbon/hold_throw_mode/down(client/user, turf/target)
. = ..()
if(.)
return
var/mob/living/carbon/carbon_user = user.mob
carbon_user.throw_mode_on(THROW_MODE_HOLD)
/datum/keybinding/carbon/hold_throw_mode/up(client/user)
/datum/keybinding/carbon/hold_throw_mode/up(client/user, turf/target)
. = ..()
if(.)
return
@@ -49,7 +49,7 @@
description = "Give the item you're currently holding"
keybind_signal = COMSIG_KB_CARBON_GIVEITEM_DOWN
/datum/keybinding/carbon/give/down(client/user)
/datum/keybinding/carbon/give/down(client/user, turf/target)
. = ..()
if(.)
return
+4 -4
View File
@@ -10,7 +10,7 @@
description = "Ask an admin for help."
keybind_signal = COMSIG_KB_CLIENT_GETHELP_DOWN
/datum/keybinding/client/admin_help/down(client/user)
/datum/keybinding/client/admin_help/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -25,7 +25,7 @@
description = "Take a screenshot."
keybind_signal = COMSIG_KB_CLIENT_SCREENSHOT_DOWN
/datum/keybinding/client/screenshot/down(client/user)
/datum/keybinding/client/screenshot/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -39,7 +39,7 @@
description = "Makes the game window fullscreen."
keybind_signal = COMSIG_KB_CLIENT_FULLSCREEN_DOWN
/datum/keybinding/client/toggle_fullscreen/down(client/user)
/datum/keybinding/client/toggle_fullscreen/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -53,7 +53,7 @@
description = "Hide most HUD features"
keybind_signal = COMSIG_KB_CLIENT_MINIMALHUD_DOWN
/datum/keybinding/client/minimal_hud/down(client/user)
/datum/keybinding/client/minimal_hud/down(client/user, turf/target)
. = ..()
if(.)
return
+4 -4
View File
@@ -7,7 +7,7 @@
full_name = "IC Say"
keybind_signal = COMSIG_KB_CLIENT_SAY_DOWN
/datum/keybinding/client/communication/say/down(client/user)
/datum/keybinding/client/communication/say/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -22,7 +22,7 @@
full_name = "IC Radio (;)"
keybind_signal = COMSIG_KB_CLIENT_RADIO_DOWN
/datum/keybinding/client/communication/radio/down(client/user)
/datum/keybinding/client/communication/radio/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -36,7 +36,7 @@
full_name = "Out Of Character Say (OOC)"
keybind_signal = COMSIG_KB_CLIENT_OOC_DOWN
/datum/keybinding/client/communication/ooc/down(client/user)
/datum/keybinding/client/communication/ooc/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -50,7 +50,7 @@
full_name = "Custom Emote (/Me)"
keybind_signal = COMSIG_KB_CLIENT_ME_DOWN
/datum/keybinding/client/communication/me/down(client/user)
/datum/keybinding/client/communication/me/down(client/user, turf/target)
. = ..()
if(.)
return
+1 -1
View File
@@ -11,7 +11,7 @@
name = initial(faketype.key)
full_name = capitalize(initial(faketype.key))
/datum/keybinding/emote/down(client/user)
/datum/keybinding/emote/down(client/user, turf/target)
. = ..()
if(.)
return
+2 -2
View File
@@ -12,7 +12,7 @@
description = "Quickly puts an item in the best slot available"
keybind_signal = COMSIG_KB_HUMAN_QUICKEQUIP_DOWN
/datum/keybinding/human/quick_equip/down(client/user)
/datum/keybinding/human/quick_equip/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -31,7 +31,7 @@
var/slot_item_name = "belt"
keybind_signal = COMSIG_KB_HUMAN_QUICKEQUIPBELT_DOWN
/datum/keybinding/human/quick_equip_belt/down(client/user)
/datum/keybinding/human/quick_equip_belt/down(client/user, turf/target)
. = ..()
if(.)
return
+13 -13
View File
@@ -12,7 +12,7 @@
description = "Break free of your current state. Handcuffed? on fire? Resist!"
keybind_signal = COMSIG_KB_LIVING_RESIST_DOWN
/datum/keybinding/living/resist/down(client/user)
/datum/keybinding/living/resist/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -22,7 +22,7 @@
owner.hud_used.resist_icon.icon_state = "[owner.hud_used.resist_icon.base_icon_state]_on"
return TRUE
/datum/keybinding/living/resist/up(client/user)
/datum/keybinding/living/resist/up(client/user, turf/target)
. = ..()
if(.)
return
@@ -38,7 +38,7 @@
description = "Look up at the next z-level. Only works if directly below open space."
keybind_signal = COMSIG_KB_LIVING_LOOKUP_DOWN
/datum/keybinding/living/look_up/down(client/user)
/datum/keybinding/living/look_up/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -46,7 +46,7 @@
L.look_up()
return TRUE
/datum/keybinding/living/look_up/up(client/user)
/datum/keybinding/living/look_up/up(client/user, turf/target)
. = ..()
var/mob/living/L = user.mob
L.end_look()
@@ -60,7 +60,7 @@
description = "Look down at the previous z-level. Only works if directly above open space."
keybind_signal = COMSIG_KB_LIVING_LOOKDOWN_DOWN
/datum/keybinding/living/look_down/down(client/user)
/datum/keybinding/living/look_down/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -68,7 +68,7 @@
L.look_down()
return TRUE
/datum/keybinding/living/look_down/up(client/user)
/datum/keybinding/living/look_down/up(client/user, turf/target)
. = ..()
var/mob/living/L = user.mob
L.end_look()
@@ -81,7 +81,7 @@
description = "Lay down, or get up."
keybind_signal = COMSIG_KB_LIVING_REST_DOWN
/datum/keybinding/living/rest/down(client/user)
/datum/keybinding/living/rest/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -97,7 +97,7 @@
keybind_signal = COMSIG_KB_LIVING_TOGGLE_COMBAT_DOWN
/datum/keybinding/living/toggle_combat_mode/down(client/user)
/datum/keybinding/living/toggle_combat_mode/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -111,7 +111,7 @@
description = "Enable combat mode."
keybind_signal = COMSIG_KB_LIVING_ENABLE_COMBAT_DOWN
/datum/keybinding/living/enable_combat_mode/down(client/user)
/datum/keybinding/living/enable_combat_mode/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -125,7 +125,7 @@
description = "Disable combat mode."
keybind_signal = COMSIG_KB_LIVING_DISABLE_COMBAT_DOWN
/datum/keybinding/living/disable_combat_mode/down(client/user)
/datum/keybinding/living/disable_combat_mode/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -139,7 +139,7 @@
description = "Held down to cycle to the other move intent, release to cycle back"
keybind_signal = COMSIG_KB_LIVING_TOGGLEMOVEINTENT_DOWN
/datum/keybinding/living/toggle_move_intent/down(client/user)
/datum/keybinding/living/toggle_move_intent/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -147,7 +147,7 @@
M.toggle_move_intent()
return TRUE
/datum/keybinding/living/toggle_move_intent/up(client/user)
/datum/keybinding/living/toggle_move_intent/up(client/user, turf/target)
. = ..()
var/mob/living/M = user.mob
M.toggle_move_intent()
@@ -160,7 +160,7 @@
description = "Pressing this cycle to the opposite move intent, does not cycle back"
keybind_signal = COMSIG_KB_LIVING_TOGGLEMOVEINTENTALT_DOWN
/datum/keybinding/living/toggle_move_intent_alternative/down(client/user)
/datum/keybinding/living/toggle_move_intent_alternative/down(client/user, turf/target)
. = ..()
if(.)
return
+7 -7
View File
@@ -9,7 +9,7 @@
description = ""
keybind_signal = COMSIG_KB_MOB_STOPPULLING_DOWN
/datum/keybinding/mob/stop_pulling/down(client/user)
/datum/keybinding/mob/stop_pulling/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -27,7 +27,7 @@
description = ""
keybind_signal = COMSIG_KB_MOB_SWAPHANDS_DOWN
/datum/keybinding/mob/swap_hands/down(client/user)
/datum/keybinding/mob/swap_hands/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -42,7 +42,7 @@
description = "Uses whatever item you have inhand"
keybind_signal = COMSIG_KB_MOB_ACTIVATEINHAND_DOWN
/datum/keybinding/mob/activate_inhand/down(client/user)
/datum/keybinding/mob/activate_inhand/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -57,7 +57,7 @@
description = ""
keybind_signal = COMSIG_KB_MOB_DROPITEM_DOWN
/datum/keybinding/mob/drop_item/down(client/user)
/datum/keybinding/mob/drop_item/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -71,7 +71,7 @@
user.mob.dropItemToGround(I)
return TRUE
/datum/keybinding/mob/target/down(client/user)
/datum/keybinding/mob/target/down(client/user, turf/target)
. = ..()
if(.)
return .
@@ -180,13 +180,13 @@
description = "Prevents you from moving"
keybind_signal = COMSIG_KB_MOB_BLOCKMOVEMENT_DOWN
/datum/keybinding/mob/prevent_movement/down(client/user)
/datum/keybinding/mob/prevent_movement/down(client/user, turf/target)
. = ..()
if(.)
return
user.movement_locked = TRUE
/datum/keybinding/mob/prevent_movement/up(client/user)
/datum/keybinding/mob/prevent_movement/up(client/user, turf/target)
. = ..()
if(.)
return
+2 -2
View File
@@ -37,7 +37,7 @@
description = "Moves your character up a z-level if possible"
keybind_signal = COMSIG_KB_MOVEMENT_ZLEVEL_MOVEUP_DOWN
/datum/keybinding/movement/zlevel_upwards/down(client/user)
/datum/keybinding/movement/zlevel_upwards/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -51,7 +51,7 @@
description = "Moves your character down a z-level if possible"
keybind_signal = COMSIG_KB_MOVEMENT_ZLEVEL_MOVEDOWN_DOWN
/datum/keybinding/movement/zlevel_downwards/down(client/user)
/datum/keybinding/movement/zlevel_downwards/down(client/user, turf/target)
. = ..()
if(.)
return
+5 -5
View File
@@ -12,7 +12,7 @@
description = "Equips or unequips the first module"
keybind_signal = COMSIG_KB_SILICON_TOGGLEMODULEONE_DOWN
/datum/keybinding/robot/moduleone/down(client/user)
/datum/keybinding/robot/moduleone/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -27,7 +27,7 @@
description = "Equips or unequips the second module"
keybind_signal = COMSIG_KB_SILICON_TOGGLEMODULETWO_DOWN
/datum/keybinding/robot/moduletwo/down(client/user)
/datum/keybinding/robot/moduletwo/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -42,7 +42,7 @@
description = "Equips or unequips the third module"
keybind_signal = COMSIG_KB_SILICON_TOGGLEMODULETHREE_DOWN
/datum/keybinding/robot/modulethree/down(client/user)
/datum/keybinding/robot/modulethree/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -57,7 +57,7 @@
description = "Unequips the active module"
keybind_signal = COMSIG_KB_SILICON_UNEQUIPMODULE_DOWN
/datum/keybinding/robot/unequip_module/down(client/user)
/datum/keybinding/robot/unequip_module/down(client/user, turf/target)
. = ..()
if(.)
return
@@ -73,7 +73,7 @@
description = "Returns you to your AI core"
keybind_signal = COMSIG_KB_SILION_UNDEPLOY_DOWN
/datum/keybinding/robot/undeploy/down(client/user)
/datum/keybinding/robot/undeploy/down(client/user, turf/target)
. = ..()
if(.)
return