Search Unity

[Free] Custom Input Manager

Discussion in 'Assets and Asset Store' started by daemon3000, Jan 18, 2014.

  1. mlarronde

    mlarronde

    Joined:
    Apr 12, 2013
    Posts:
    4
    Hi Daemon!, Thanks for this amazing plugin!
    I'm having an issue and I don't how to manage: Now the joystick controller works great, but I would like to use keyboard too, to navigate thought menus. The problem is that when I set the config for joystick the Horizongal and Vertical axis are analog, and I need to set digital in order to work, I tried to add two vertical (digital and analog) and two horizontal axes but the plugin throw me an error. So, how I could solve this? (to use joystick and keyboard only for menu) Thanks in advance.
     
  2. daemon3000

    daemon3000

    Joined:
    Aug 13, 2012
    Posts:
    139
    I don't quite understand what you want to do. Do you want to use joystick for gameplay but for menus you want to use both joystick and keyboard or do you want to use joystick for gameplay and keyboard for menus?
     
  3. mlarronde

    mlarronde

    Joined:
    Apr 12, 2013
    Posts:
    4
    Hi, thanks for your quick response :)
    Yes, first one: I want to use joystick for gameplay but for menus I want to use both joystick and keyboard.
    Could I achieve this? Because when I uses analog axis the "alternative" positive or negative doesn't trigger anymore when I try to use Keys.
     
  4. daemon3000

    daemon3000

    Joined:
    Aug 13, 2012
    Posts:
    139
    You can't have an axis be digital and analog at the same time but you could use the InputAdapter addon to switch between a keyboard input configuration and the joystick input configuration automatically. Another solution would be to edit the StandaloneInputModule script to add support for secondary buttons/axes.
     
  5. mlarronde

    mlarronde

    Joined:
    Apr 12, 2013
    Posts:
    4
    Thanks Daemon, I'll try to edit StandalonInputModule.
     
  6. Gley

    Gley

    Joined:
    Jul 20, 2016
    Posts:
    1
    daemon3000, Thank you for this great work ..
    but i have a problem , i flowed the instructions in github and i set this uo , but i dont know hw can i make this walking .
    please help ...

    thanks
     
  7. daemon3000

    daemon3000

    Joined:
    Aug 13, 2012
    Posts:
    139
    You can make it walk the same way you would with the built-in input, just replace the calls to Input.GetAxis and Input.GetButton with calls to InputManager.GetAxis and InputManager.GetButton. And remember to add using TeamUtility.IO; at the top of the script file.
     
  8. Jeswer

    Jeswer

    Joined:
    Aug 18, 2015
    Posts:
    5
    Hey daemon 3000. Thanks for the free input system
    So far it looks really amazing.
    One thing that really bothers me is that all of the scripts in the scripts folder of example 1 have no comments with them.
    It would mean a lot if you would write future software with comments and if this one would be provided with comments.
    This makes it easier for yourself and other people to understand the code.
     
    Last edited: Aug 12, 2016
  9. Jeswer

    Jeswer

    Joined:
    Aug 18, 2015
    Posts:
    5
    If you would make me a contributor on git I could add some code to the stuff that I'm figuring out.

    Name : Jaswir
     
  10. daemon3000

    daemon3000

    Joined:
    Aug 13, 2012
    Posts:
    139
    I'll try to add some comments next week. If you want to contribute, fork the repository, do your changes then make a pull request.
     
  11. Jeswer

    Jeswer

    Joined:
    Aug 18, 2015
    Posts:
    5
    Allright, great. Thanks for your quick response. Btw you might be interested in Resharper tool for visual studio. It gives one click fixes for improving coding and many other useful things to increase productivity
     
    Last edited: Aug 13, 2016
  12. Jeswer

    Jeswer

    Joined:
    Aug 18, 2015
    Posts:
    5
    Hi I have a question about the
    ScanInput() method in the InputManager class.
    ------------------
    if (((int)_scanFlags & (int)ScanFlags.Key) == (int)ScanFlags.Key)
    {
    scanSuccess = ScanKey();
    }
    if (!scanSuccess && (((int)_scanFlags & (int)ScanFlags.JoystickButton) == (int)ScanFlags.JoystickButton))
    {
    scanSuccess = ScanJoystickButton();
    }
    if (!scanSuccess && (((int)_scanFlags & (int)ScanFlags.JoystickAxis) == (int)ScanFlags.JoystickAxis))
    {
    scanSuccess = ScanJoystickAxis();
    }
    if (!scanSuccess && (((int)_scanFlags & (int)ScanFlags.MouseAxis) == (int)ScanFlags.MouseAxis))
    {
    ScanMouseAxis();
    }
    ------------------
    Here you take the bitwise and of
    ((int)_scanFlags & (int)ScanFlags.INPUTTYPE == (int)ScanFlags.INPUTTYPE
    What's the point of this? Couldn't you just check for
    ((int)_scanFlags == (int)ScanFlags.INPUTTYPE ?
    Wouldn't this give the same result?

    --Jaswir
     
  13. Tomeksi

    Tomeksi

    Joined:
    Oct 18, 2016
    Posts:
    1
    Hello!
    I'm having a problem with this "Use custom input module"
    Basicly when i press it, i get warning saying: "Unable to find any built -in input modules in the scene!"
    I have input manager placed in scene. I think this is the reason why my input are not working at all that i set in that input manager.

    I'll be waiting for your answer. Thank you!

    -Tomeksi
     
  14. daemon3000

    daemon3000

    Joined:
    Aug 13, 2012
    Posts:
    139
    Use custom input module is for the UI. When you select that option the plugin will look in the scene for an EventSystem game-object(usually created automatically when you create a UI canvas) and if it finds one it will replace some components to make it work with input from the plugin.

    To get input from the plugin in your own code you must call InputManager.GetButton or InputManager.GetAxis instead of Input.GetButton or Input.GetAxis. Look at the example scripts.
     
  15. z_orochii

    z_orochii

    Joined:
    Mar 8, 2013
    Posts:
    20
    Hi daemon! Just wanted to say thanks and that this thing is awesome.

    I've been thinkering with it all day, working on my custom key config screen, had some "problems" but mostly were because I didn't knew a thing or two about how to get it to work. Now it works flawlessly (besides my own UI design choices I guess) and I'm pretty happy with it :).

    Keep up the good work!
     
  16. Nischo

    Nischo

    Joined:
    Nov 26, 2013
    Posts:
    1
    Hey daemon3000,

    great addon! Really awesome work. ... I'm using the StartScan() method in the title screen of my game. I use it to wait for the first pressed input to know which is the main players controller. I had to make a small adjustment inside your code, which you might consider to incorporate in a next update:

    Code (CSharp):
    1.  
    2. private bool ScanJoystickButton()
    3. {
    4.    int scanStart = (int)KeyCode.Joystick1Button0;
    5.    int scanEnd = (int)KeyCode.Joystick8Button19;
    6.  
    7.  
    8.    if(_scanJoystick.HasValue)
    9.    {
    10.        scanStart = (int)KeyCode.Joystick1Button0 + _scanJoystick.Value * 20;
    11.        scanEnd = scanStart + 20;
    12.    }
    13.  
    14.    for (int key = scanStart; key < scanEnd; key++)
    15.    {
    16.        if(Input.GetKeyDown((KeyCode)key))
    17.        {
    18.            _scanResult.scanFlags = ScanFlags.JoystickButton;
    19.            _scanResult.key = (KeyCode)key;
    20.  
    21.            int joystick = ((key - (int)KeyCode.Joystick1Button0) / 20) + 1;
    22.  
    23.            _scanResult.joystick = _scanJoystick.HasValue ? _scanJoystick.Value : joystick;
    24.            _scanResult.joystickAxis = -1;
    25.            _scanResult.joystickAxisValue = 0.0f;
    26.            _scanResult.mouseAxis = -1;
    27.            _scanResult.userData = _scanUserData;
    28.            if(_scanHandler(_scanResult))
    29.            {
    30.                _scanHandler = null;
    31.                _scanResult.userData = null;
    32.                _scanFlags = ScanFlags.None;
    33.                return true;
    34.            }
    35.        }
    36.    }
    37.  
    38.    return false;
    39. }
    40.  
    The main goal was to not return "-1" as the joystick, but instead calculate it depending on the pressed key. The only drawback is that i had to adjust the scanStart and scanEnd which effectively include every possible joystick button in the scan. One way to fix that, would be to add a config flag inside the ScanSettings to ask if the user wants to know the used joystick.

    best regards
    Nico
     
    Last edited: Feb 20, 2017
  17. daemon3000

    daemon3000

    Joined:
    Aug 13, 2012
    Posts:
    139
    @Nischo Thank you for the feedback. I incorporated your code into the plugin, it's up on Github.
     
  18. MoonsaurusGames

    MoonsaurusGames

    Joined:
    Oct 8, 2014
    Posts:
    2
    Hello daemon, first of all, thanks you for your awesome plugin.
    I have an issue, when I move up the left stick the Input Adapter keep switching between keyboard and joystick. But if I move the stick slowly it works.

    Current Input Device: Joystick
    Current Input Device: KeyboardAndMouse
     
  19. daemon3000

    daemon3000

    Joined:
    Aug 13, 2012
    Posts:
    139
    @Lauro_Enabie
    What Unity version are you using?
    What type of controller are you using?
    Can you try the Input Adapter example scene and see if happens there too?
    Can you export your input setup(input editor window -> File menu -> Export) and send it to me?
     
  20. MoonsaurusGames

    MoonsaurusGames

    Joined:
    Oct 8, 2014
    Posts:
    2
    @daemon3000 I'm using the version 5.5.0f3, generic controller. The input adapter scene works fine.

    Edit: problem solved. I press F3 and figure out that I had 3 "vertical" inputs. Again thanks for your plugin and for a fast reply

    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <Input playerOneDefault="Joystick" playerTwoDefault="" playerThreeDefault="" playerFourDefault="">
    <InputConfiguration name="Joystick">
    <AxisConfiguration name="Horizontal">
    <description />
    <positive>None</positive>
    <altPositive>None</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>3</gravity>
    <sensitivity>3</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>AnalogAxis</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Vertical">
    <description />
    <positive>None</positive>
    <altPositive>None</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.2</deadZone>
    <gravity>0</gravity>
    <sensitivity>1</sensitivity>
    <snap>false</snap>
    <invert>true</invert>
    <type>AnalogAxis</type>
    <axis>1</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Mouse X">
    <description />
    <positive>None</positive>
    <altPositive>None</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.5</deadZone>
    <gravity>1</gravity>
    <sensitivity>10</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>AnalogAxis</type>
    <axis>3</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Mouse Y">
    <description />
    <positive>None</positive>
    <altPositive>None</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.5</deadZone>
    <gravity>1</gravity>
    <sensitivity>10</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>AnalogAxis</type>
    <axis>3</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="DPADH">
    <description />
    <positive>RightArrow</positive>
    <altPositive>D</altPositive>
    <negative>LeftArrow</negative>
    <altNegative>A</altNegative>
    <deadZone>0.9</deadZone>
    <gravity>10</gravity>
    <sensitivity>4</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>AnalogAxis</type>
    <axis>5</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="DPADV">
    <description />
    <positive>UpArrow</positive>
    <altPositive>W</altPositive>
    <negative>DownArrow</negative>
    <altNegative>S</altNegative>
    <deadZone>0.9</deadZone>
    <gravity>10</gravity>
    <sensitivity>4</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>AnalogAxis</type>
    <axis>6</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Fire1">
    <description />
    <positive>JoystickButton5</positive>
    <altPositive>None</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>1000</gravity>
    <sensitivity>1000</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>Button</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Fire2">
    <description />
    <positive>JoystickButton4</positive>
    <altPositive>None</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>1000</gravity>
    <sensitivity>1000</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>Button</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Fire3">
    <description />
    <positive>JoystickButton2</positive>
    <altPositive>None</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>1000</gravity>
    <sensitivity>1000</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>Button</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Submit">
    <description />
    <positive>Return</positive>
    <altPositive>JoystickButton0</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>1000</gravity>
    <sensitivity>1000</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>Button</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Cancel">
    <description />
    <positive>Escape</positive>
    <altPositive>JoystickButton7</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>1000</gravity>
    <sensitivity>1000</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>Button</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Skill">
    <description />
    <positive>E</positive>
    <altPositive>None</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>1000</gravity>
    <sensitivity>1000</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>AnalogAxis</type>
    <axis>8</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Target">
    <description />
    <positive>JoystickButton9</positive>
    <altPositive>JoystickButton1</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>1000</gravity>
    <sensitivity>1000</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>Button</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Potion">
    <description />
    <positive>Q</positive>
    <altPositive>JoystickButton3</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>1000</gravity>
    <sensitivity>1000</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>Button</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Dash">
    <description />
    <positive>LeftShift</positive>
    <altPositive>JoystickButton0</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>1000</gravity>
    <sensitivity>1000</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>Button</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Talk">
    <description />
    <positive>F</positive>
    <altPositive>JoystickButton2</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>1000</gravity>
    <sensitivity>1000</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>Button</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="LockCam">
    <description />
    <positive>G</positive>
    <altPositive>JoystickButton4</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>1000</gravity>
    <sensitivity>1000</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>Button</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Zoom">
    <description />
    <positive>Space</positive>
    <altPositive>JoystickButton4</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>1000</gravity>
    <sensitivity>1000</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>Button</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    </InputConfiguration>
    <InputConfiguration name="KeyboardAndMouse">
    <AxisConfiguration name="Horizontal">
    <description />
    <positive>RightArrow</positive>
    <altPositive>D</altPositive>
    <negative>LeftArrow</negative>
    <altNegative>A</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>3</gravity>
    <sensitivity>3</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>DigitalAxis</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Vertical">
    <description />
    <positive>W</positive>
    <altPositive>UpArrow</altPositive>
    <negative>S</negative>
    <altNegative>DownArrow</altNegative>
    <deadZone>0</deadZone>
    <gravity>3</gravity>
    <sensitivity>3</sensitivity>
    <snap>true</snap>
    <invert>false</invert>
    <type>DigitalAxis</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Fire1">
    <description />
    <positive>None</positive>
    <altPositive>Mouse0</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>1000</gravity>
    <sensitivity>1000</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>Button</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Fire2">
    <description />
    <positive>None</positive>
    <altPositive>Mouse1</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>1000</gravity>
    <sensitivity>1000</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>Button</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Fire3">
    <description />
    <positive>LeftShift</positive>
    <altPositive>Mouse2</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>1000</gravity>
    <sensitivity>1000</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>Button</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Jump">
    <description />
    <positive>Space</positive>
    <altPositive>None</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>1000</gravity>
    <sensitivity>1000</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>Button</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Mouse X">
    <description />
    <positive>None</positive>
    <altPositive>None</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0</deadZone>
    <gravity>0</gravity>
    <sensitivity>0.1</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>MouseAxis</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Mouse Y">
    <description />
    <positive>None</positive>
    <altPositive>None</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0</deadZone>
    <gravity>0</gravity>
    <sensitivity>0.1</sensitivity>
    <snap>false</snap>
    <invert>true</invert>
    <type>MouseAxis</type>
    <axis>1</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="DPADH">
    <description />
    <positive>RightArrow</positive>
    <altPositive>D</altPositive>
    <negative>LeftArrow</negative>
    <altNegative>A</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>3</gravity>
    <sensitivity>3</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>DigitalAxis</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="DPADV">
    <description />
    <positive>UpArrow</positive>
    <altPositive>W</altPositive>
    <negative>DownArrow</negative>
    <altNegative>S</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>3</gravity>
    <sensitivity>3</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>DigitalAxis</type>
    <axis>1</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Vertical">
    <description />
    <positive>None</positive>
    <altPositive>None</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.19</deadZone>
    <gravity>0</gravity>
    <sensitivity>1</sensitivity>
    <snap>false</snap>
    <invert>true</invert>
    <type>AnalogAxis</type>
    <axis>1</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Submit">
    <description />
    <positive>Return</positive>
    <altPositive>F</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>1000</gravity>
    <sensitivity>1000</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>Button</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Cancel">
    <description />
    <positive>Escape</positive>
    <altPositive>JoystickButton9</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>1000</gravity>
    <sensitivity>1000</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>Button</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Skill">
    <description />
    <positive>E</positive>
    <altPositive>JoystickButton6</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>1000</gravity>
    <sensitivity>1000</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>Button</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Target">
    <description />
    <positive>Mouse2</positive>
    <altPositive>None</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>1000</gravity>
    <sensitivity>1000</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>Button</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Potion">
    <description />
    <positive>Q</positive>
    <altPositive>JoystickButton3</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>1000</gravity>
    <sensitivity>1000</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>Button</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Dash">
    <description />
    <positive>LeftShift</positive>
    <altPositive>JoystickButton0</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>1000</gravity>
    <sensitivity>1000</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>Button</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Talk">
    <description />
    <positive>F</positive>
    <altPositive>JoystickButton2</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>1000</gravity>
    <sensitivity>1000</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>Button</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="LockCam">
    <description />
    <positive>G</positive>
    <altPositive>JoystickButton4</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>1000</gravity>
    <sensitivity>1000</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>Button</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    <AxisConfiguration name="Zoom">
    <description />
    <positive>Space</positive>
    <altPositive>JoystickButton4</altPositive>
    <negative>None</negative>
    <altNegative>None</altNegative>
    <deadZone>0.001</deadZone>
    <gravity>1000</gravity>
    <sensitivity>1000</sensitivity>
    <snap>false</snap>
    <invert>false</invert>
    <type>Button</type>
    <axis>0</axis>
    <joystick>0</joystick>
    </AxisConfiguration>
    </InputConfiguration>
    </Input>
     
    Last edited: Mar 10, 2017
  21. jonathanw12

    jonathanw12

    Joined:
    Apr 2, 2017
    Posts:
    1
    How do you use number pad keys with this? [8] does not work.
     
  22. jmanx18

    jmanx18

    Joined:
    Feb 6, 2013
    Posts:
    13
    I really like this solution so far but it seems that its hard coded to 4 players as my game supports more than that. unless there is a better way to add more players that I overlooked maybe?
     
  23. daemon3000

    daemon3000

    Joined:
    Aug 13, 2012
    Posts:
    139
    @jmanx18 Only 4 players at the moment. I'll work on it this week and add more players. How many players do you have in your game? Will support for 8 players be enough?
     
  24. LinTh137

    LinTh137

    Joined:
    Jan 25, 2017
    Posts:
    2
    Hi @daemon3000, first of all, thank you for this plugin, its aweseome even tho i didn't even understand completely.
    I have an issue, when i add the input adapter and manager to the first scene, and i go to a different one, an error occures: Input Axis joy_0_axis_0 is not setup. But if i add the inputmanager to the other scenes, then only the warning comes up that there are multiple inputmanagers. I dont know that its a relevant problem or i should just ignore it and go on, thats why im asking it.
    Anyway, can you tell me how to implement your plugin to make a controls menu where you can see the key bindigs and change them runtime?
    Oh i almost forgot, i use unity 5.6.3.
    Tahnk you for your help!
     
  25. daemon3000

    daemon3000

    Joined:
    Aug 13, 2012
    Posts:
    139
    @LinTh137 Can you send me a test project where the issue can be replicated?

    There is a controls menu example in "Assets/Input Manager/Examples/01 - Controls Menu/Scenes".
     
  26. LinTh137

    LinTh137

    Joined:
    Jan 25, 2017
    Posts:
    2
  27. pickle_rick1

    pickle_rick1

    Joined:
    Jan 7, 2018
    Posts:
    9
    hi having a problem with the keyboard mapping menu in game, mapping the input works but cant reset to default when I click the default button I get error "Default input profile doesn't contain an input configuration named ......."
     
  28. daemon3000

    daemon3000

    Joined:
    Aug 13, 2012
    Posts:
    139
    @pickle_rick1 I'm assuming you're using the "ResetInputConfiguration" script from the examples? If that's the case export your input configurations from the input editor and save them somewhere in the assets folder then assign that file to the script and give it the name of the input configuration you want to reset(make sure there's no typo and the names match).
     
  29. Vanderson_b

    Vanderson_b

    Joined:
    Sep 27, 2017
    Posts:
    1
    Hi @daemon3000, I have discovered your package and it's helping me lot with my project, thanks!!!

    I have an issue for you in making a co-op local multiplayer. I would like to know if there is any insight that you could give for a selection scene, where the others local players will join it pressing a submit button for example, using your package. When I`m doing this with the Canvas, I don't know how to deal with the Event System, as it just recognizing the player one.

    Best regards.
     
  30. daemon3000

    daemon3000

    Joined:
    Aug 13, 2012
    Posts:
    139
    @Vanderson_b The easiest way would be to create two buttons each player, one for "join game" and one for "leave game", and when the buttons are pressed add or remove the player in the selection screen.

    Here's a simple script that does this. It checks for input from each player and fires an event when it detects input. You can then set it up in the inspector to call your selection screen script and the selection script can add/remove players from the game.

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Events;
    3. using TeamUtility.IO;
    4.  
    5. public class PlayerSelectionInput : MonoBehaviour
    6. {
    7.     [System.Serializable]
    8.     public class SelectionEvent : UnityEvent<int> { }
    9.  
    10.     public const int PLAYER_ONE_ID = 0;
    11.     public const int PLAYER_TWO_ID = 1;
    12.     public const int PLAYER_THREE_ID = 2;
    13.     public const int PLAYER_FOUR_ID = 3;
    14.  
    15.     /*  
    16.      *    In your "slection screen" script add two methods like this:
    17.      *  
    18.      *    public OnPlayerJoinedGame(int playerIndex)
    19.      *    {
    20.      *        //    do something here
    21.      *    }
    22.      *  
    23.      *    public OnPlayerLeftGame(int playerIndex)
    24.      *    {
    25.      *        //    do something here
    26.      *    }
    27.      *  
    28.      *    You can then call these two functions from the inspector using the events below.
    29.      */
    30.     public SelectionEvent onPlayerJoinedGame;
    31.     public SelectionEvent onPlayerLeftGame;
    32.  
    33.     //    In the input editor you'll have to define two buttons for each player, "JoinGame" and "LeaveGame".
    34.     private void Update()
    35.     {
    36.         if(InputManager.GetButtonDown("JoinGame", PlayerID.One))
    37.         {
    38.             onPlayerJoinedGame.Invoke(PLAYER_ONE_ID);
    39.         }
    40.         else if(InputManager.GetButtonDown("LeaveGame", PlayerID.One))
    41.         {
    42.             onPlayerLeftGame.Invoke(PLAYER_ONE_ID);
    43.         }
    44.  
    45.         if(InputManager.GetButtonDown("JoinGame", PlayerID.Two))
    46.         {
    47.             onPlayerJoinedGame.Invoke(PLAYER_TWO_ID);
    48.         }
    49.         else if(InputManager.GetButtonDown("LeaveGame", PlayerID.Two))
    50.         {
    51.             onPlayerLeftGame.Invoke(PLAYER_TWO_ID);
    52.         }
    53.  
    54.         if(InputManager.GetButtonDown("JoinGame", PlayerID.Three))
    55.         {
    56.             onPlayerJoinedGame.Invoke(PLAYER_THREE_ID);
    57.         }
    58.         else if(InputManager.GetButtonDown("LeaveGame", PlayerID.Three))
    59.         {
    60.             onPlayerLeftGame.Invoke(PLAYER_THREE_ID);
    61.         }
    62.  
    63.         if(InputManager.GetButtonDown("JoinGame", PlayerID.Four))
    64.         {
    65.             onPlayerJoinedGame.Invoke(PLAYER_FOUR_ID);
    66.         }
    67.         else if(InputManager.GetButtonDown("LeaveGame", PlayerID.Four))
    68.         {
    69.             onPlayerLeftGame.Invoke(PLAYER_FOUR_ID);
    70.         }
    71.     }
    72. }
    73.  
     
  31. antsonthetree

    antsonthetree

    Joined:
    May 15, 2015
    Posts:
    102
    Hello - I just grabbed this off github. First thanks for making this available! I was able to run Example1 with no issues, but when I try to run Example 5 local co op (or really any of the others), I am unable to get the menu to come up. I've tried changing the pause menu keys in TU->InputManager menus but no dice. Any ideas?

    Thanks
     
    Last edited: Sep 14, 2021
  32. daemon3000

    daemon3000

    Joined:
    Aug 13, 2012
    Posts:
    139
    There's no pause menu in the other examples. It only exists in the first example to show you how you could go about implementing key rebinding in your game.
     
  33. antsonthetree

    antsonthetree

    Joined:
    May 15, 2015
    Posts:
    102
    Doh! I noticed that soon after I posted. My bad. Got another question. In a new Unity project I imported the package, created a new map with the TU menu. When I saved my old settings, after minimizing and maximizing Unity, I noticed that I get a lot (311) entries now in my Edit->Program Settings->Input menu. See pic. I can repro this consistently with Unity 2017.3 latest build. Is this supposed to happen?
     

    Attached Files:

    • lots.PNG
      lots.PNG
      File size:
      43.5 KB
      Views:
      784
  34. daemon3000

    daemon3000

    Joined:
    Aug 13, 2012
    Posts:
    139
    Yes, it's supposed to happen. I need all that for joystick input.
     
  35. snuffysam

    snuffysam

    Joined:
    Jun 9, 2013
    Posts:
    12
    I'm having some weird issues with the plugin.

    I opened the project in Unity, and it works fine. But if I export the InputManager folder as a plugin and import into my project, suddenly I get these compile errors:

    Code (csharp):
    1. Assets/InputManager/Examples/Common/Scripts/PauseManager.cs(18,23): error CS0066: `TeamUtility.IO.Examples.PauseManager.Paused': event must be of a delegate type
    2. Assets/InputManager/Examples/Common/Scripts/PauseManager.cs(19,23): error CS0066: `TeamUtility.IO.Examples.PauseManager.Unpaused': event must be of a delegate type
    3. Assets/InputManager/Source/Runtime/InputManager.cs(61,23): error CS0066: `TeamUtility.IO.InputManager.Loaded': event must be of a delegate type
    4. Assets/InputManager/Source/Runtime/InputManager.cs(62,23): error CS0066: `TeamUtility.IO.InputManager.Saved': event must be of a delegate type
    Looking at the code, it seems those four variables are in the format "public event Action VARIABLE", whereas all other events are in the format "public event<TYPE> Action VARIABLE".

    What do I add to get this to work? And why is this only happening in my project (it's not like I'm opening your project under a different version).
     
  36. daemon3000

    daemon3000

    Joined:
    Aug 13, 2012
    Posts:
    139
    Send me the package you exported from the plugin project.

    What Unity version are you using?
     
  37. snuffysam

    snuffysam

    Joined:
    Jun 9, 2013
    Posts:
    12
  38. daemon3000

    daemon3000

    Joined:
    Aug 13, 2012
    Posts:
    139
  39. snuffysam

    snuffysam

    Joined:
    Jun 9, 2013
    Posts:
    12
    Ok, I tried the new version. Now not only are the same error messages happening, but there are two more events that are causing compile errors.
    https://imgur.com/zzCRfF4

    I also updated my Unity to 2017.3.1f1 (since the new version is 2017.3), if that changes anything.
     
  40. daemon3000

    daemon3000

    Joined:
    Aug 13, 2012
    Posts:
    139
    There is no reason you should be getting those errors.

    What platform do you have selected in the build settings? This plugin doesn't work on iOS. I don't have a Mac so I can test it on iOS.
    What "Scripting Runtime Version" do you have selected in "Player Settings"?
    What "Scripting Backend" do you have selected in "Player Settings"?
    What "Api Compatibility Level" do you have selected in "Player Settings"?
     
  41. snuffysam

    snuffysam

    Joined:
    Jun 9, 2013
    Posts:
    12
    I have "PC, Mac, & Linux Standalone" selected for the build settings.
    Scripting Runtime Version is Stable (.NET 3.5 Equivalent).
    Scripting Backend is Mono.
    Api Compatibility Level is .NET 2.0 Subset.

    These all seem to be the same settings as your project, so I still don't see where the errors are coming from.
     
  42. daemon3000

    daemon3000

    Joined:
    Aug 13, 2012
    Posts:
    139
    I don't know man, this is really weird. Did you try importing it into a new project? Maybe it's something about you project.
     
  43. snuffysam

    snuffysam

    Joined:
    Jun 9, 2013
    Posts:
    12
    There were no errors when I imported the package into a new project.
    I suppose I'll look into what could be causing it, then.

    EDIT: Fixed it. Well, that was weird.

    I just had to replace "public event Action VARIABLE;" with "public event System.Action VARIABLE;" whenever applicable.

    Strange, but glad it works now!
     
  44. Wabunga

    Wabunga

    Joined:
    Nov 1, 2015
    Posts:
    1
    Hey, this input manager is awesome, but I'm having a couple problems.
    In the stock Unity Input, pressing Left and Right arrows at the same time would result in a "0" for my Horizontal axis. Now it will just ignore the second input until I let go of the first. Is there any way to make the axis function like it did before? Or, even better, ignore the OLD input when you press its opposite?
    I think if a player is holding Left, and then hits Right, they probably want their character to go Right, not Left or nowhere.

    Also, in UI, it's just ignoring order entirely and preferring Up if Up+Down and Right if Right+Left.
    Again, I'd prefer either a 0 or to prioritize the newest input.

    I'd be ecstatic if you could help me out here.

    Edit: I figured it out!
    I opened AxisConfiguration and changed:
    Code (CSharp):
    1. if(Input.GetKey(positive) || Input.GetKey(altPositive))
    2.                     axis = Positive;
    3.                 else if(Input.GetKey(negative) || Input.GetKey(altNegative))
    4.                     axis = Negative;
    To:
    Code (CSharp):
    1. if((Input.GetKey(positive) || Input.GetKey(altPositive)) && (Input.GetKey(negative) || Input.GetKey(altNegative)))
    2.                     axis = Neutral;
    3.                 else if(Input.GetKey(positive) || Input.GetKey(altPositive))
    4.                     axis = Positive;
    5.                 else if(Input.GetKey(negative) || Input.GetKey(altNegative))
    6.                     axis = Negative;
    In GetAxisRaw()

    So that at least gets it back to old Unity Input. Should be easy enough to do the rest of what I want from here. Thanks for making this awesome asset!
     
    Last edited: Mar 17, 2018
  45. JasonLeeKennedy

    JasonLeeKennedy

    Joined:
    Apr 14, 2017
    Posts:
    13
    Does this code automatically adjust for the connected controller type/platform?

    IE Do I need to write any code to detect OS (for the different XBox360 input setups) or connected controller type (PS3 vs XBox input)?

    I am trying to figure out if this will help me get around the fact that the bindings on the common controllers are different by OS/controller type.

    Thanks in advance.
     
  46. antsonthetree

    antsonthetree

    Joined:
    May 15, 2015
    Posts:
    102
    How can I rebind multi key combinations at runtime? Like Ctrl+T or Alt+K etc? The scan functions always picks the first key I press and just binds to Alt or Ctrl without the second key.
     
  47. daemon3000

    daemon3000

    Joined:
    Aug 13, 2012
    Posts:
    139
    @JasonLeeKennedy No, it doesn't adjust based on OS. However if you get the new version for github you can now add multiple bindings per axis configuration and it will pick up whichever receives input on that OS.
    The plugin also has support for XInput now so your game will work with any XInput compatible controller without you having to worry about different button codes.

    @antsonthetree You can't rebind key combination at the moment. I'll look into adding support for Alt, Shift, Ctrl modifiers. As a workaround you could have checkboxes for Alt, Shift, Ctrl in the controls menu so players can choose a key(with the scan function) and check on of the checkboxes for the modifiers they want.
     
  48. JasonLeeKennedy

    JasonLeeKennedy

    Joined:
    Apr 14, 2017
    Posts:
    13
    @daemon3000 thanks... I ended up working out a solution with an input mapping file 10-15 assigned axis and #ifdefined statement blocks to switch between the Windows/Linux/MacOS layouts.
     
  49. ThePunkPun

    ThePunkPun

    Joined:
    Nov 24, 2015
    Posts:
    4
    When I downloaded this project and started up the first example I got this error msg "ArgumentException: Input Axis mouse_axis_1 is not setup." what do I need to change? I have the newest Unity 2018.2.14f1
     
  50. daemon3000

    daemon3000

    Joined:
    Aug 13, 2012
    Posts:
    139
    Open the input editor and from the File menu select Overwrite Project Settings. Follow the instructions there and it should start working. You should have gotten that popup the first time you opened the project.