implement actions for TRIANGLE mode in glfw-gamepad.sml
This commit is contained in:
@@ -23,6 +23,26 @@ struct
|
|||||||
, squarePressed: bool
|
, 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
|
fun onPendingMode
|
||||||
( state: gamepad_state
|
( state: gamepad_state
|
||||||
, trianglePressed
|
, trianglePressed
|
||||||
@@ -95,6 +115,45 @@ struct
|
|||||||
(newState, actions)
|
(newState, actions)
|
||||||
end
|
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
|
fun handleButtons
|
||||||
( gamepadState
|
( gamepadState
|
||||||
, trianglePressed
|
, trianglePressed
|
||||||
@@ -119,6 +178,15 @@ struct
|
|||||||
, squarePressed
|
, squarePressed
|
||||||
, actions
|
, actions
|
||||||
)
|
)
|
||||||
|
| TRIANGLE =>
|
||||||
|
onTriangleMode
|
||||||
|
( gamepadState
|
||||||
|
, trianglePressed
|
||||||
|
, circlePressed
|
||||||
|
, crossPressed
|
||||||
|
, squarePressed
|
||||||
|
, actions
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
(* impure functions below *)
|
(* impure functions below *)
|
||||||
|
|||||||
Reference in New Issue
Block a user