Using both Mouse Aim and Controller Aim at the same time

ok so, so far i have two scripts that control the direction and rotation that the object is facing, on for mouse aim and one for using the right analog stick. they both work perfectly as intended by themselves but i cannot think of a way to get it to switch between using the mouse input and using the controller input

    var mouse_pos : Vector3;
	var target : Transform;
	var object_pos : Vector3;
	var angle : float;
	
	function Update() {
		
//for right analog aiming
		joyx_pos = Input.GetAxis("RHorizontal");
		joyy_pos = Input.GetAxis("RVertical");
		angle = Mathf.Atan2(joyy_pos, joyx_pos) * Mathf.Rad2Deg;
		transform.rotation = Quaternion.Euler(Vector3(0,0,angle));
		
//for mouse aiming	
		mouse_pos = Input.mousePosition;
		mouse_pos.z = 5.23;
		object_pos = Camera.main.WorldToScreenPoint(target.position);
		mouse_pos.x = mouse_pos.x - object_pos.x;
		mouse_pos.y = mouse_pos.y - object_pos.y;
		angle = Mathf.Atan2(mouse_pos.y, mouse_pos.x) * Mathf.Rad2Deg;
		transform.rotation = Quaternion.Euler(Vector3(0, 0, angle));
		
	}

kinda new here but any help or ideas would be appreciated

ok so i managed to figure it out myself

    var target : Transform;
	var object_pos : Vector3;
	var angle : float;
	var inputselection : boolean; //false = controller, true = mouse

function Update() {
	

	
	if(Input.GetAxis("Mouse X")<0 || Input.GetAxis("Mouse X")>0 || Input.GetAxis("Mouse Y")<0 || Input.GetAxis("Mouse Y")>0){
	inputselection = true;
	}
	if(Input.GetAxis("RHorizontal")<0 || Input.GetAxis("RHorizontal")>0 || Input.GetAxis("RVertical")<0 || Input.GetAxis("RVertical")>0){
	inputselection = false;
	}
	
	if(!inputselection){
	joyx_pos = Input.GetAxis("RHorizontal");
	joyy_pos = Input.GetAxis("RVertical");
	angle = Mathf.Atan2(joyy_pos, joyx_pos) * Mathf.Rad2Deg;
	transform.rotation = Quaternion.Euler(Vector3(0,0,angle));
	}
	
	if(inputselection){
	mouse_pos = Input.mousePosition;
	mouse_pos.z = 10;
	object_pos = Camera.main.WorldToScreenPoint(target.position);
	mouse_pos.x = mouse_pos.x - object_pos.x;
	mouse_pos.y = mouse_pos.y - object_pos.y;
	angle = Mathf.Atan2(mouse_pos.y, mouse_pos.x) * Mathf.Rad2Deg;
	transform.rotation = Quaternion.Euler(Vector3(0, 0, angle));
	}
}`

using the boolean inputselection, i could determine which input type was being used the second it detected input from either the mouse or the controllers second analog stick, and because the aiming and the movement are completely separate, you can use the controller for movement and the mouse for aiming or whatever combination the player chooses without having to change any settings

the first 2 if statements determine if the mouse is moving or not and if there is any input from the right analog stick, and switching between the rotation controls based on the last input detected