I would like to control the rotation of an object (think spinning a valve handle or a wheel) via forcing the player to spin their thumbstick in a certain direction.
I’ve attached an image to illustrate somewhat clearer.
I can’t find an input mapping for this; and I can’t think of a way to achieve this via scripting.
This would be my approach: You have to get the x and y axis of the thumbstick every frame and calculate the angle that they form with an arbitrary axis. Lets say, on your image, this axis is horizontal, so you can picture it leading from the X to the B button.
If the thumbstick is in its upmost position (so y=1, x=0) this would form a -90°/270° angle to this axis. If it is in its rightmost position (y=0, x=1) a 0° angle, in its down position a 90° angle and so on. This angle can be easily calculated with some trigonometry.
You have to update this angle every frame, and see how it changes compared to last frame.
I would store a variable, lets call it LastAngle that holds the angle that the stick had the last time it changed direction, and a variable direction that holds the direction it is currently traveling in. So if the angle increased this frame you set the direction to clockwise, if the angle decreased you set direction to anticlockwise. You check if the direction is the same as last frame. If not so you set the LastAngle to your current angle.
If you have all of this in place, you can check each frame how much the player has turned the stick consecutively in one direction, and fire an event for it. So you can eg check if your current angle is 180° bigger than LastAngle which would mean that the player has turned the stick by 180°.
There are some pitfalls (wrapping 360° to 0°, and maybe you should rather store the angle delta than the absolute angle in LastAngle since you would not be able to detect movements larger than 360°) but that should get you started.