Skip to content

Commit

Permalink
Added. text input listener
Browse files Browse the repository at this point in the history
  • Loading branch information
britzl committed Jan 9, 2025
1 parent c9bd84e commit 589fbd0
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 2 deletions.
27 changes: 27 additions & 0 deletions examples/utils/utils.gui
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,33 @@ nodes {
parent: "panel"
inherit_alpha: true
}
nodes {
position {
x: -136.0
y: 77.0
}
size {
x: 200.0
y: 100.0
}
type: TYPE_TEXT
text: "<text>"
font: "rpg"
id: "input"
pivot: PIVOT_NW
outline {
x: 1.0
y: 1.0
z: 1.0
}
shadow {
x: 1.0
y: 1.0
z: 1.0
}
parent: "panel"
inherit_alpha: true
}
nodes {
position {
x: 71.0
Expand Down
27 changes: 25 additions & 2 deletions examples/utils/utils.gui_script
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ function init(self)
local steam_deck = steam.utils_is_steam_running_on_steam_deck() and "true" or "false"
local server_real_time = steam.utils_get_server_real_time()
gui.set_text(gui.get_node("info"), TEXT:format(seconds, app_id, steam_deck, server_real_time))

steam.set_listener(function(self, e, t)
print("listener event", e)
pprint(t)
if e == "GamepadTextInputDismissed_t" then
local text = t.m_szTextInput
gui.set_text(gui.get_node("input"), text)
elseif e == "FloatingGamepadTextInputDismissed_t" then
gui.set_text(gui.get_node("input"), "Dismissed floating text")
end
end)
end

function final(self)
Expand All @@ -36,10 +47,22 @@ function on_input(self, action_id, action)
end)
rpg.button("floating_text", action_id, action, function()
local ok = steam.utils_show_floating_gamepad_text_input(steam.EFloatingGamepadTextInputModeModeSingleLine, 10, 10, 100, 100)
print(ok)
if ok then
gui.set_text(gui.get_node("input"), "Showing floating gamepad text input")
else
gui.set_text(gui.get_node("input"), "Failed to show floating gamepad text input")
end
end)
rpg.button("gamepad_text", action_id, action, function()
local ok = steam.utils_show_gamepad_text_input(steam.EGamepadTextInputModeNormal, steam.EGamepadTextInputLineModeSingleLine, "Some description", "Existing text")
print(ok)
if ok then
gui.set_text(gui.get_node("input"), "Showing gamepad text input")
else
gui.set_text(gui.get_node("input"), "Failed to show gamepad text input")
end
end)

if action_id == hash("text") then
gui.set_text(gui.get_node("input"), action.text)
end
end
8 changes: 8 additions & 0 deletions input/game.input_binding
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@ mouse_trigger {
input: MOUSE_BUTTON_LEFT
action: "touch"
}
text_trigger {
input: TEXT
action: "text"
}
text_trigger {
input: MARKED_TEXT
action: "marked_text"
}

0 comments on commit 589fbd0

Please sign in to comment.