# \[Older Versions] JU Input Manager

## ℹNotice about new version

New version of JU Input Manager no longer supports input detection as shown in the topics below, but this page will be maintained for those who are still using old versions.\
For those who are on the new version go to the [Input Detection](/ju-tps-documentation/game-development/input-controls.md) page to see how it works.

## Inputs Change

To change the control in the new input system you will have to go to the Inputs folder, double click on the file "JUTPSInputControlls"

<div align="left"><figure><img src="/files/EvvQtkkkaDsb0kilZGkj" alt=""><figcaption></figcaption></figure></div>

The window below will appear, and here you can edit the controls as you like.

<figure><img src="/files/1Z1EuNRnqjmhGxQlueqV" alt=""><figcaption></figcaption></figure>

## Simple Input Detection

This page will be useful when you want to expand the system, add actions or just detect inputs.

Using the JU Input Manager to detect inputs is simple, inspired by the old input system:

{% code lineNumbers="true" %}

```csharp
using UnityEngine;

// 1 Step -> Import JUInputSystem
using JUTPS.JUInputSystem;

public class JUInputHandlingTest : MonoBehaviour
{
    void Update()
    {
        // 2 Step -> Check if Jump Button(Space Default) was pressed
        if (JUInput.GetButtonDown(JUInput.Buttons.JumpButton))
        {
            Debug.Log("Pressed Jump");
        }
    }
}
```

{% endcode %}

![](/files/NPNcrctIpv4skeNh3Q5p) <- With this code this message should appear in the console

In **line 4** the JUInputSystem is imported, in **line 11** the check is made if the jump button was pressed, and in **line 13** it is an example of action that can be replaced by any other code.

## Functions and Description

| Function                                                        | Summary                                                         |
| --------------------------------------------------------------- | --------------------------------------------------------------- |
| float GetAxis(Axis axis)                                        | Returns the value of the deafult axis                           |
| bool GetButtonDown(Buttons Button)                              | Returns the value of the deafult buttons when pressed down      |
| bool GetButton(Buttons Button)                                  | Returns the value of the deafult buttons when pressed           |
| GetButtonUp(Buttons Button)                                     | Returns the value of the deafult buttons when pressed up        |
| bool GetCustomButton(string CustomButtonName)                   | Returns the value of the custom buttons when pressed            |
| bool GetCustomButtonDown(string CustomButtonName)               | Returns the value of the custom buttons when pressed down       |
| bool GetCustomButtonUp(string CustomButtonName)                 | Returns the value of the custom buttons when pressed up         |
| bool GetCustomTouchButton(string CustomButtonName)              | Returns the value of the custom touch buttons when pressed      |
| bool GetCustomTouchButtonDown(string CustomButtonName)          | Returns the value of the custom touch buttons when pressed down |
| bool GetCustomTouchButtonUp(string CustomButtonName)            | Returns the value of the custom touch buttons when pressed up   |
| Vector2 GetCustomTouchfieldAxis(string CustomTouchfield)        | Returns the value of the custom Touchfield                      |
| Vector2 GetCustomVirtualJoystickAxis(string CustomJoystickName) | Returns the value of the custom Joystick                        |
| Vector2 GetMousePosition()                                      | Return current mouse position                                   |
| int GetTouchsLengh()                                            | Returns the number of touches on the screen                     |
| InputSystem.Controls.TouchControl\[] GetTouches()               |                                                                 |

| Enums   | Content                                                                                                                                                                                                    |
| ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Axis    | MoveHorizontal, MoveVertical, RotateHorizontal, RotateVertical                                                                                                                                             |
| Buttons | ShotButton, AimingButton, JumpButton, RunButton, PunchButton, RollButton, CrouchButton, ProneButton, ReloadButton, PickupButton, EnterVehicleButton, PreviousWeaponButton, NextWeaponButton, OpenInventory |

{% hint style="info" %}
The Enums above are all default JU TPS Inputs that you can easily access with the above functions.&#x20;

Example: float moveHorizontal = JUInput.GetAxis(JUInput.Axis.MoveHorizontal);
{% endhint %}

## Custom Inputs

In the JU Input Manager you can create custom inputs and call it normally, first create a Custom Input:

<div align="left"><figure><img src="/files/SS0hBAtfIxeAe0yt6fSO" alt=""><figcaption></figcaption></figure></div>

{% hint style="warning" %}
Note that the "Custom Button" only works in the **Old Input System**, if you want to check inputs in the new input system you can use [**Input Events Components**](/ju-tps-documentation/game-development/input-controls/input-events.md)
{% endhint %}

And you can call that input like this:

```csharp
 //Check if Custom Button "SuperPower" was pressed
if (JUInput.GetCustomButtonDown("SuperPower") || JUInput.GetCustomTouchButtonDown("SuperPower"))
{
   Debug.Log("Pressed M");
}
```

See below all Custom Input Functions:

| Functions                                                       | Summary                                                          |
| --------------------------------------------------------------- | ---------------------------------------------------------------- |
| bool GetCustomButton(string CustomButtonName)                   | Returns the value of the custom Input Button when pressed        |
| bool GetCustomButtonDown(string CustomButtonName)               | Returns the value of the custom Input Button when pressed Down   |
| bool GetCustomButtonUp(string CustomButtonName)                 | Returns the value of the custom Input Button when pressed up     |
| GetCustomTouchButton(string CustomButtonName)                   | Returns the value of the custom Virtual Button when pressed      |
| GetCustomTouchButtonDown(string CustomButtonName)               | Returns the value of the custom Virtual Button when pressed down |
| bool GetCustomTouchButtonUp(string CustomButtonName)            | Returns the value of the custom Virtual Button when pressed up   |
| Vector2 GetCustomTouchfieldAxis(string CustomTouchfield)        | Returns the value of the custom Touchfield                       |
| Vector2 GetCustomVirtualJoystickAxis(string CustomJoystickName) | Returns the value of the custom Joystick                         |

## Rewrite Functions

These functions rewrite the Inputs, it is used by [Mobile Rig](/ju-tps-documentation/game-development/how-to-create-a-mobile-game-with-ju-tps/mobile-inputs.md) to make the virtual buttons work.

| Functions                                                       | Summary                                        |
| --------------------------------------------------------------- | ---------------------------------------------- |
| RewriteInputAxis(Axis axis, float AxisValue)                    | Rewrite the value of a default JU input axis   |
| RewriteInputButtonPressed(Buttons button, bool ButtonValue)     | Rewrite the value of a default JU input button |
| RewriteInputButtonPressedDown(Buttons button, bool ButtonValue) | Rewrite the value of a default JU input button |
| RewriteInputButtonPressedUp(Buttons button, bool ButtonValue)   | Rewrite the value of a default JU input button |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://julhiecio.gitbook.io/ju-tps-documentation/game-development/input-controls/older-versions-ju-input-manager.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
