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

Add SSInput + Allow Keybindings #33983

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

Ryan180602
Copy link
Contributor

@Ryan180602 Ryan180602 commented Jul 30, 2023

🆑
tweak: Keybinding can now be done.
tweak: Examining has a funny magnifying icon.
/:cl:

Picked up from #33851
Currently has the issues of:

  • One key being able to be bound to multiple actions (if that's something we want to curtail).
  • ESC does not work to clear the parser.
  • Toggling hotkey doesn't change the parser's colour.

@Ryan180602 Ryan180602 force-pushed the ssinput branch 2 times, most recently from ff3c36f to 1588766 Compare July 30, 2023 10:33
@SuhEugene

This comment was marked as off-topic.

@SierraKomodo SierraKomodo added the Test Merge Indicates the PR should be trialed on server before further review or approval. label Jul 30, 2023
Copy link

@francinum francinum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lack of support for parser clearing on a system with rather severe sticky-key problems makes this unsafe to test.

SSinput doesn't present a very big value-add over native functionality, in exchange for lumbering input with soft-code overhead, amongst other issues.

Comment on lines +21 to +22
"Any" = "\"KeyDown \[\[*\]\]\"",
"Any+UP" = "\"KeyUp \[\[*\]\]\"",
Copy link

@francinum francinum Aug 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method of input interception is near-completely incompatible with "default"/ non-hotkey mode. Alternative ways of handling this exist, but aren't very pleasant and require significant additional code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it need to be compatible? It exists separately. They don't intersect.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I apologize, the fact that this code has been substantially edited from what is usually considered SSInput wasn't noticed.

Comment on lines +26 to +29
if(!prefs.hotkeys && length(_key) == 1 && _key != "Alt" && _key != "Ctrl" && _key != "Shift")
var/current_text = winget(src, "input", "text")
winset(src, "outputwindow.input", "focus=true;text=[current_text + url_encode(_key)]")
return
Copy link

@francinum francinum Aug 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is about as good as you can get while staying performant, but is also still not fast enough to not drop input above like, 70WPM.

The original code did not include reading back from the existing text, which is even slower, and will likely result in clobbering at even higher WPM due to the queued nature of instant, and simultaneous access, with latency.

Input handling with respect to modifier keys gets incredibly weird if the textbox has both focus and content as well.

I didn't do it that way originally for that explicit reason. I simply accepted having one character as better than having nothing, which was the original state of this code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Macro changes from hotkeys to default when hotkeys toggled so this piece of code is unnecessary. It exists just as fallback.

Copy link

@francinum francinum Aug 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code confused me, and caused me to fundamentally misunderstand the way they've altered this system. In the state it is, it seems like it'd function fine enough.

@@ -132,5 +135,7 @@ Thanks to spacemaniac and mcdonald for help with the JS side of this.
winset(src, "asset_cache_browser", "background-color = none;background-color = [COLOR_DARKMODE_BACKGROUND]")
winset(src, "asset_cache_browser", "text-color = #000000;text-color = [COLOR_DARKMODE_TEXT]")

//winset(src, "input", "background-color = none;background-color = [COLOR_DARKMODE_BACKGROUND]")
//winset(src, "input", "text-color = #000000;text-color = [COLOR_DARKMODE_TEXT]")
update_hotkey_mode() // Updates input color and focus
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, i see an issue why color doesn't update

Comment on lines +140 to +141
winset(src, "hotkeytoggle", "background-color = #ffffff;background-color = #494949")
winset(src, "hotkeytoggle", "text-color = #000000;text-color = [COLOR_DARKMODE_TEXT]")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lines 53-54 need to be removed in this case

@MuckerMayhem
Copy link
Contributor

Hotkey mode doesn't seem to toggle completely when pressing tab or the button, that should be fixed to act like it normally would before this is test merged.

Comment on lines +28 to +33
/proc/sanitize_islist(value, default)
if(islist(value) && length(value))
return value
if(default)
return default

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to implement this proc instead of using the already existing LAZY_INIT_LIST() define?

Comment on lines +18 to +20
// This is for when macro sets are eventualy datumized
/datum/controller/subsystem/input/proc/setup_default_macro_sets()
macro_set = list(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dmdocs for procs and vars need three slashes to be parsed.

Suggested change
// This is for when macro sets are eventualy datumized
/datum/controller/subsystem/input/proc/setup_default_macro_sets()
macro_set = list(
/// This is for when macro sets are eventualy datumized
/datum/controller/subsystem/input/proc/setup_default_macro_sets()
macro_set = list(

)


// Badmins just wanna have fun ♪
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment isn't necessary.

Suggested change
// Badmins just wanna have fun ♪


// Badmins just wanna have fun ♪
/datum/controller/subsystem/input/proc/refresh_client_macro_sets()
for(var/client/C in GLOB.clients)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for(var/client/C in GLOB.clients)
for(var/client/C as anything in GLOB.clients)



/datum/controller/subsystem/input/fire()
for(var/client/C in GLOB.clients)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for(var/client/C in GLOB.clients)
for(var/client/C as anything in GLOB.clients)

// Only way to do that is to tie the behavior into the focus's keyLoop().

/atom/movable/keyLoop(client/user)
var/movement_dir = 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semantics for bitfields.

Suggested change
var/movement_dir = 0
var/movement_dir = EMPTY_BITFIELD

Comment on lines +3 to +4
/datum/proc/key_down(key, client/user) // Called when a key is pressed down initially
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/datum/proc/key_down(key, client/user) // Called when a key is pressed down initially
return
/// Called when a key is pressed down initially
/datum/proc/key_down(key, client/user)
return

return


/datum/proc/key_up(key, client/user) // Called when a key is released
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/datum/proc/key_up(key, client/user) // Called when a key is released
/// Called when a key is released
/datum/proc/key_up(key, client/user)

return


/datum/proc/keyLoop(client/user) // Called once every frame
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/datum/proc/keyLoop(client/user) // Called once every frame
/// Called once every frame
/datum/proc/keyLoop(client/user)

Comment on lines +16 to +18
// removes all the existing macros
/client/proc/erase_all_macros()
var/erase_output = ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// removes all the existing macros
/client/proc/erase_all_macros()
var/erase_output = ""
/// removes all the existing macros
/client/proc/erase_all_macros()
var/erase_output = ""

@SierraKomodo SierraKomodo added the Stale PR This PR has seemingly been abandoned by its author. label Dec 17, 2023
@Ryan180602
Copy link
Contributor Author

stale for now, i'll come back and work on this soon:tm:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Sprites Stale PR This PR has seemingly been abandoned by its author. Test Merge Indicates the PR should be trialed on server before further review or approval.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants