From 50868b830bcca8d211644a54a1966eb1cda2f927 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Wed, 21 Jan 2026 20:50:04 +0000 Subject: [PATCH] implement actions for TRIANGLE mode in glfw-gamepad.sml --- shell/glfw-gamepad.sml | 68 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/shell/glfw-gamepad.sml b/shell/glfw-gamepad.sml index b44d2ee..1ebdf84 100644 --- a/shell/glfw-gamepad.sml +++ b/shell/glfw-gamepad.sml @@ -23,6 +23,26 @@ struct , squarePressed: bool } + fun setToPendingAndUnshifted (gamepadState: gamepad_state) = + let + val + { mode = _ + , shiftChr = _ + , trianglePressed + , circlePressed + , crossPressed + , squarePressed + } = gamepadState + in + { mode = PENDING + , shiftChr = false + , trianglePressed = false + , circlePressed = false + , crossPressed = false + , squarePressed = false + } + end + fun onPendingMode ( state: gamepad_state , trianglePressed @@ -95,6 +115,45 @@ struct (newState, actions) end + fun onTriangleMode + ( gamepadState + , trianglePressed + , circlePressed + , crossPressed + , squarePressed + , actions + ) = + if trianglePressed then + let + val newState = setToPendingAndUnshifted gamepadState + val actions = IM.CHAR_EVENT #"a" :: actions + in + (newState, actions) + end + else if circlePressed then + let + val newState = setToPendingAndUnshifted gamepadState + val actions = IM.CHAR_EVENT #"b" :: actions + in + (newState, actions) + end + else if crossPressed then + let + val newState = setToPendingAndUnshifted gamepadState + val actions = IM.CHAR_EVENT #"c" :: actions + in + (newState, actions) + end + else if squarePressed then + let + val newState = setToPendingAndUnshifted gamepadState + val actions = IM.CHAR_EVENT #"d" :: actions + in + (newState, actions) + end + else + (gamepadState, actions) + fun handleButtons ( gamepadState , trianglePressed @@ -119,6 +178,15 @@ struct , squarePressed , actions ) + | TRIANGLE => + onTriangleMode + ( gamepadState + , trianglePressed + , circlePressed + , crossPressed + , squarePressed + , actions + ) end (* impure functions below *)