Xbox360Controller: angle of analog stick to rotation

I am trying to come up with the logic for detecting the angle of an analog stick (in this case the Right stick) and have it translate into rotation for an object.

I understand how Input works, and that I will be calculating my angles from the -1 to +1 of each axis… but how to get an angle in degrees eludes me. Furthermore, I may need to Clamp the output into 8 cardinal angles later on.

Any code or pseudo would be appreciated.

C# preferred language.

Something like this should work:

float x = Input.GetAxis("SomeHorizontal");
float y = Input.GetAxis("SomeVertical");

if (x != 0.0f || y != 0.0f) {
    angle = Mathf.Atan2(y, x) * Mathf.Rad2Deg;
    // Do something with the angle here.
}

Note that different camera orientations and/or different interpretations of angles may require you to add or subtract from the resulting angle…usually + or - 90.0f.