Search Unity

Rewired - Advanced Input for Unity

Discussion in 'Assets and Asset Store' started by guavaman, Sep 25, 2014.

  1. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,967
  2. Xaon

    Xaon

    Joined:
    Feb 28, 2013
    Posts:
    53
    Hi. I'm, writing this question in a hurry so sorry if the answer is already in this huge topic.

    I'm developing a splitsreen multiplayer game. The thing is if there's only one controlles connected I want players to share this controller, so one player uses left stick and second uses right stick. But if there are two controllers connected, I want player 1 use left stick on controller 1 and player 2 use also left stick but on controller 2.

    I've managed to check if theres one or more controllers and assign them accordingly but the button mapping won't change. So for now I'm stick with player two always using right stick, no matter the countroller count.

    Here's assign code:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Rewired;
    5.  
    6.  
    7. public class JoystickAutoAssign : MonoBehaviour {
    8.     void Start() {
    9.         StartCoroutine(AssignRoutine());
    10.     }
    11.  
    12.     IEnumerator AssignRoutine() {
    13.         yield return new WaitWhile(() => (ReInput.isReady == false));
    14.  
    15.         int player1ID = 0;
    16.         int player2ID = 1;
    17.  
    18.         var playerOne = ReInput.players.GetPlayer(player1ID);
    19.         var playerTwo = ReInput.players.GetPlayer(player2ID);
    20.  
    21.         var joystics = ReInput.controllers.Joysticks;
    22.  
    23.         if(joystics.Count == 0)
    24.         {
    25.             //DO NOTHING
    26.         }
    27.         else if(joystics.Count == 1)
    28.         {
    29.             playerOne.controllers.AddController(ControllerType.Joystick, joystics[0].id, false);
    30.             playerTwo.controllers.AddController(ControllerType.Joystick, joystics[0].id, false);
    31.         }
    32.         else
    33.         {
    34.             playerOne.controllers.AddController(ControllerType.Joystick, joystics[0].id, true);
    35.             playerTwo.controllers.AddController(ControllerType.Joystick, joystics[1].id, true);
    36.         }
    37.     }
    38. }


    I've tried to use player.controllers.maps.LoadMap method but it does nothing for me. I've checked the docs but it seams that I'm doing everything as written in here: http://guavaman.com/projects/rewired/docs/HowTos.html#managing-controller-maps-runtime . Also I cannot grasp how to work with ActionElementMap from scripting side but I feel I could do a workaround with it.

    Can anyone point me to a tutorial explaining step by step how to work with loading map at runtime?
     
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,967
    The very next topic in the How To's: Loading Controller Maps at runtime

    Post your code when loading the Controller Maps and show the maps in the Rewired Editor that you are trying to load.
     
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,967
  5. Wilbert-Blom

    Wilbert-Blom

    Joined:
    Aug 13, 2011
    Posts:
    81
    Does Rewired support using a gamepad with the HoloLens ?
     
  6. Xaon

    Xaon

    Joined:
    Feb 28, 2013
    Posts:
    53
    First of all, thanks for quick reply.

    Here's my current setup of Rewired Input Manager:
    settings.png
    map_category.png
    player_1_setup.png
    player_2_setup.png
    joystick_maps.png

    And here are code I've tried:

    Code (CSharp):
    1.  {//(joystics.Count >= 2)
    2.             playerOne.controllers.AddController(ControllerType.Joystick, joystics[0].id, true);
    3.             ControllerMap p1Map = playerOne.controllers.maps.GetMap(1);//.GetMap(0); - also not working//.GetMap(2); - also not working
    4.             playerTwo.controllers.maps.AddMap(ControllerType.Joystick, joystics[1].id, p1Map);
    5.             playerTwo.controllers.AddController(ControllerType.Joystick, joystics[1].id, true);
    6. }

    Code (CSharp):
    1.  {//(joystics.Count >= 2)
    2.             playerOne.controllers.AddController(ControllerType.Joystick, joystics[0].id, true);
    3.             playerTwo.controllers.maps.LoadMap(ControllerType.Joystick, joystics[1].id, 0, 1);
    4.             playerTwo.controllers.AddController(ControllerType.Joystick, joystics[1].id, true);
    5. }
    Code (CSharp):
    1.  {//(joystics.Count >= 2)
    2.             playerOne.controllers.AddController(ControllerType.Joystick, joystics[0].id, true);
    3.             playerTwo.controllers.maps.LoadMap(ControllerType.Joystick, joystics[1].id, "Default", "Player 1 - silngle pad");
    4.             playerTwo.controllers.AddController(ControllerType.Joystick, joystics[1].id, true);
    5. }
    I've also tried to call LoadMap after calling AddController for second player and it didn't help.
     
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,967
    @Xaon Thanks for posing this information. There are several problems:

    >> ControllerMap p1Map = playerOne.controllers.maps.GetMap(1);//.GetMap(0); - also not working//.GetMap(2); - also
    >> not working

    You are using an overload that takes a mapId. This is a unique id assigned to each Controller Map instance and is not an index and does not correspond to the Id field you see in the Rewired Input Manager. This mapId overload is only useful if you already know the unique id of the map you're looking for (usually only useful when you've already listed all maps in the Player in the case of a controller remapping screen). When you do not know the id of the map you're looking for, you use the Category and Layout to retrieve it as all the examples show.

    Code (CSharp):
    1. {//(joystics.Count >= 2)
    2.             playerOne.controllers.AddController(ControllerType.Joystick, joystics[0].id, true);
    3.             ControllerMap p1Map = playerOne.controllers.maps.GetMap(1);//.GetMap(0); - also not working//.GetMap(2); - also not working
    4.             playerTwo.controllers.maps.AddMap(ControllerType.Joystick, joystics[1].id, p1Map);
    5.             playerTwo.controllers.AddController(ControllerType.Joystick, joystics[1].id, true);
    6. }
    7.  
    As the documentation states:

    Before a Player can use a Controller Map, it first must be loaded into that Player. Controller Maps are loaded for each Player automatically at start (or, in the case of Joysticks, they are loaded when a Joystick is assigned to the Player) based on the Controller Map assignments you've made in the Players page of the Rewired Input Manager.

    -----

    You must assign the Joystick to the Player first. You cannot assign the map first then the Joystick. The call to load the map will do nothing because there is no Joystick owned by the Player that can accept the map. Then when you assign the Joystick to the Player, the default map will be loaded automatically.

    The easiest way to understand why would be to imagine the opposite approach. If all Controller Maps were in the Player already or existed when a matching Joystick was not assigned, the Player would have hundreds of maps in it to cover all the possible joystick types one might attach. In addition, it would be impossible to support multiple of the same Joystick assigned to the same Player with different map configurations. Joystick Maps do not and cannot exist in a Player if the corresponding Joystick is not already assigned to that Player. When the Joystick is unassigned, all corresponding Joystick Maps are removed.

    Code (CSharp):
    1.  {//(joystics.Count >= 2)
    2.             playerOne.controllers.AddController(ControllerType.Joystick, joystics[0].id, true);
    3.             ControllerMap p1Map = playerOne.controllers.maps.GetMap(1);//.GetMap(0); - also not working//.GetMap(2); - also not working
    4.             playerTwo.controllers.maps.AddMap(ControllerType.Joystick, joystics[1].id, p1Map);
    5.             playerTwo.controllers.AddController(ControllerType.Joystick, joystics[1].id, true);
    6. }
    You cannot take the same map from Player 1 and assign it to Player 2. Controller maps store references to their owning Player and Controllers within. You would be creating an impossible scenario because now Player 1 and 2 would have the exact same Controller Map, but all information in the map would say it is owned by Player 2 and applies to Player 2's controller only.

    Second, each Controller Map applies to one specific Controller. A Controller Map is tied to the unique id of a particular Controller. Even if you had two identical Joysticks attached to the system, each Joystick Map would apply only to one specific Joystick of those two based on the Joystick.id property.

    Code (CSharp):
    1.  {//(joystics.Count >= 2)
    2.             playerOne.controllers.AddController(ControllerType.Joystick, joystics[0].id, true);
    3.             playerTwo.controllers.maps.LoadMap(ControllerType.Joystick, joystics[1].id, 0, 1);
    4.             playerTwo.controllers.AddController(ControllerType.Joystick, joystics[1].id, true);
    5. }
    Code (CSharp):
    1.  {//(joystics.Count >= 2)
    2.             playerOne.controllers.AddController(ControllerType.Joystick, joystics[0].id, true);
    3.             playerTwo.controllers.maps.LoadMap(ControllerType.Joystick, joystics[1].id, "Default", "Player 1 - silngle pad");
    4.             playerTwo.controllers.AddController(ControllerType.Joystick, joystics[1].id, true);
    5. }
    Again, you must assign the Joystick before loading the map.

    Are you using the Debug Information in the Rewired Input Manager inspector to see what is happening? All Controller Maps, Controllers, and every Rewired runtime object is displayed in real time there for exactly this purpose.

    Also, are you aware of this from the API documentation?

    Loads a controller map from the maps defined in the Rewired Editor. Replaces if a map already exists with the same category and layout. When replaced, map enabled state is copied from the existing map into the replacement. Otherwise, map starts disabled and must be enabled before it can contribute to input.

    --

    If it is loading the Controller Map, it would start disabled because you are not overwriting an existing enabled map already loaded. Again, you can see the enabled state of all maps in the Debug Information in the Rewired Input Manager inspector.

    The example on the How To's page shows using the overload with the final boolean value denoting the initial enabled state of the map:

    Code (csharp):
    1. // Load joysticks maps in each joystick in the "UI" category and "Default" layout and set it to be enabled on start
    2. foreach(Joystick joystick in player.controllers.Joysticks) {
    3.    player.controllers.maps.LoadMap(ControllerType.Joystick, joystick.id, "UI", "Default", true);
    4. }
    The final "true" value there says to enable the newly loaded map.
     
    Last edited: Apr 20, 2017
    rubble1 likes this.
  8. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,967
    Rewired has not been tested with Holo Lens.
     
  9. dotsquid

    dotsquid

    Joined:
    Aug 11, 2016
    Posts:
    146
    Hi there.
    Is there any way to temporary disable (and enable later) Player, so calling to any GetButton-like and GetAxis-like methods returns false / zero?
    I found the only way to do that by disabling all Controller Maps of the Player. But that looks overcomplicated.
     
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,967
    A Player cannot be disabled. Just add a flag inside the class you are using the Player in and have your own iflag which controls whether the Player can contribute input. There are many things that do not need to be injected into the input system to handle. The thinking behind this sounds in practice very similar to the "how do you use an input" concept in the FAQ and I think the same answer applies.
     
  11. dotsquid

    dotsquid

    Joined:
    Aug 11, 2016
    Posts:
    146
    You described my plan B. I've asked just in case I missed this in the documentation.
    Thanks.
     
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,967
    @Xaon Rewriting your original code, it should look something like this. (Note: this was not tested and was typed in this window, so if there are compiler errors, I apologize.)

    Code (csharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Rewired;
    5.  
    6.  
    7. public class JoystickAutoAssign : MonoBehaviour {
    8.     void Start() {
    9.         StartCoroutine(AssignRoutine());
    10.     }
    11.  
    12.     IEnumerator AssignRoutine() {
    13.         yield return new WaitWhile(() => (ReInput.isReady == false));
    14.  
    15.         int player1ID = 0;
    16.         int player2ID = 1;
    17.  
    18.         var playerOne = ReInput.players.GetPlayer(player1ID);
    19.         var playerTwo = ReInput.players.GetPlayer(player2ID);
    20.  
    21.         var joystics = ReInput.controllers.Joysticks;
    22.  
    23.         if(joystics.Count == 0)
    24.         {
    25.             //DO NOTHING
    26.         }
    27.         else if(joystics.Count == 1) // shared pad
    28.         {
    29.             int joyId = joystics[0].id;
    30.        
    31.             // Clear all controller assignments first so existing maps are unloaded
    32.             // in case switching from individual controllers to a shared controller
    33.             // you could clear the separate maps manually instead, but this is simpler
    34.             playerOne.controllers.ClearControllersOfType(ControllerType.Joystick);
    35.             playerTwo.controllers.ClearControllersOfType(ControllerType.Joystick);
    36.        
    37.             // Assign the joysticks
    38.             playerOne.controllers.AddController(ControllerType.Joystick, joyId, false);
    39.             playerTwo.controllers.AddController(ControllerType.Joystick, joyId, false);
    40.                  
    41.             // The default is set for the shared pad so the defaults will already be loaded on assignment
    42.             // No need to manually load them here
    43.         }
    44.         else // separate pads
    45.         {
    46.        
    47.             int joyId1 = joystics[0].id;
    48.             int joyId2 = joystics[1].id;
    49.                
    50.             // Assign the joysticks unassigning them from other Players
    51.             playerOne.controllers.AddController(ControllerType.Joystick, joyId1, true);
    52.             playerTwo.controllers.AddController(ControllerType.Joystick, joyId2, true);
    53.                  
    54.             // Clear the shared layout maps automatically loaded when the joysticks were assigned
    55.             playerOne.controllers.ClearMapsForController(ControllerType.Joystick, joyId1, "Default", false);
    56.             playerTwo.controllers.ClearMapsForController(ControllerType.Joystick, joyId2, "Default", false);
    57.        
    58.             // Load the individual joystick maps for each player and make sure they're enabled on start
    59.             playerOne.controllers.maps.LoadMap(ControllerType.Joystick, joyId1 , "Default", "Default", true);
    60.             playerTwo.controllers.maps.LoadMap(ControllerType.Joystick, joyId2 , "Default", "Default", true);
    61.         }
    62.     }
    63. }
     
    Last edited: Apr 20, 2017
    rubble1 likes this.
  13. Xaon

    Xaon

    Joined:
    Feb 28, 2013
    Posts:
    53
    @guavaman many thanks! It works!

    I just had to replace
    Code (CSharp):
    1.  
    2.             playerOne.controllers.ClearControllersOfType(ControllerType.Joystick);
    3.             playerTwo.controllers.ClearControllersOfType(ControllerType.Joystick);
    with
    Code (CSharp):
    1.  
    2.             playerOne.controllers.maps.ClearControllersOfType(ControllerType.Joystick);
    3.             playerTwo.controllers.maps.ClearControllersOfType(ControllerType.Joystick);
    and change joystick layout name but it was a copy & paste solution!
     
    rubble1 likes this.
  14. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,967
    Actually that does not have the same effect as the code I posted. My intention was to un-assign the two controllers from both Players first. By changing it to maps.ClearControllersOfType, you're clearing the maps, not un-assigning the controllers. It will not correctly go back to a shared gamepad if the user has two controllers attached and then unplugs one of them because the current individual map will still be loaded. You would have to clear the maps and also load the shared maps manually to make it work right.
     
    Last edited: Apr 22, 2017
  15. Freznosis

    Freznosis

    Joined:
    Jul 16, 2014
    Posts:
    226
    Hello, I'm geting this error when my Logitech G920 wheel is connected. I'm not sure what it is and I found literally nothing from searching. Any idea what the problem could be?

    Code (CSharp):
    1. Rewired: Error remapping joystick template 104e31d8-9115-4dd5-a398-2e54d35e6c83 to joystick 0f5ba315-3e83-4237-8374-28bea596914d
    2. ------- Rewired System Info -------
    3. Unity version: 5.6.0f3
    4. Rewired version: 1.1.0.0.U5
    5. Platform: Windows
    6. Editor Platform: Windows
    7. Using Unity input: False
    8. Primary input source: RawInput
    9. Use XInput: True
    10. Use Steam RawInput fix: True
    11. Native mouse handling: True
    12. Enhanced device support: True
    13.  
    14. UnityEngine.Debug:LogError(Object)
    15. Rewired.Logger:LogError(Object, Boolean)
    16. Rewired.Data.UserData:EyKlfyzktFptAltyzvpNDlpaHDP(HardwareControllerMapIdentifier, ControllerMap_Editor, HardwareJoystickTemplateMap, HardwareJoystickMap, Int32, Int32)
    17. Rewired.Data.UserData:KtgxfcIjswuGVHUcSNahjzKrtGn(Joystick, Int32, Int32)
    18. Rewired.MapHelper:TwQJvfbNvUYYbljHGeWXySCvMtT(Joystick, vljfECFuxuCIGFkiVACbnQOlvImI, qcZSVZFzrqogGJQmbUhrzlEesv, Boolean)
    19. Rewired.MapHelper:KmpyivcsSVReqqgYFNZCzEFkMzP(Boolean)
    20. Rewired.MapHelper:LoadDefaultMaps(ControllerType)
    21. Rewired.UI.ControlMapper.ControlMapper:OnRestoreDefaultsConfirmed(Int32) (at Assets/Rewired/Extras/ControlMapper/Scripts/ControlMapper.cs:855)
    22. Rewired.UI.ControlMapper.<OpenModal>c__AnonStorey5:<>m__1() (at Assets/Rewired/Extras/ControlMapper/Scripts/ControlMapper.cs:2355)
    23. UnityEngine.Events.UnityEvent:Invoke()
    24. Rewired.UI.ControlMapper.CustomButton:Press() (at Assets/Rewired/Extras/ControlMapper/Scripts/CustomButton.cs:171)
    25. Rewired.UI.ControlMapper.CustomButton:OnPointerClick(PointerEventData) (at Assets/Rewired/Extras/ControlMapper/Scripts/CustomButton.cs:181)
    26. UnityEngine.EventSystems.EventSystem:Update()

    Edit: Updated to 1.1.1.0 and still getting the same error, I'm bummed and don't know what the problem could be or how to fix it because the error isn't giving me any solid information on why it's happening. :/
     
    Last edited: Apr 22, 2017
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,967
    EDIT: I'm testing a mock and seeing the error. Investigating.

    See this post for the solution.
     
    Last edited: Apr 22, 2017
  17. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    147
    I'm trying to figure out how to change controls from one to another. An example is non-combat keybinds and combat keybinds. I'm using playmaker and I have installed the integration with Rewired. What actions do I need to use to switch between non-combat and combat keybinds?
     
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,967
    The documentation for PlayMaker use is the same as without. PlayMaker Actions are nothing but mirrors of the same functions in the scripting API.

    Documentation:
    How To's - Enabling and Disabling Controller Maps

    Scripting: player.controllers.maps.SetMapsEnabled
    PlayMaker: RewiredPlayerSetControllerMapsEnabled

    Note that most of the control remapping API (lower level stuff like polling, conflict checking, creating bindings) is not available through PlayMaker.
     
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,967
    There was an error in the Racing Wheel template GUID for this controller. The field contained a new line and two copies of the GUID. This caused the wheel to not be found in the list of controllers because it was expecting an invalid GUID. The attached Racing Wheel Template fixes the error. Replace the file in Rewired/Internal/Data/Controllers/HardwareMaps/Joysticks/Templates with the files in the attached zip.
     

    Attached Files:

  20. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,967
    Have you read the documentation on Controller Maps? This is fundamental foundation information you need to understand to be able to use the Rewired system.

    Examples of multiple category setups in the Rewired Input Manager for this exact usage is shown in the examples included with Rewired (though not the part about switching active maps):
    1. Control Remapping 1
    2. Control Mapper Demo
    The concepts are also shown in the overview video at 17:40.

    Step by step instructions:
    1. In the Rewired Input Manager editor, Create two Map Categories: "Combat" and "NonCombat".
    2. Create Keyboard and or Joystick Maps in these two categories for the devices you want it to apply to. (Dual Analog Gamepad Template, etc.)
    3. Assign these new controller maps to your Player(s) on the Player page. Make sure one or the other map is set to enabled on start but not both. Whichever map should be enabled by default, set that to Start Enabled. For the other, uncheck Start Enabled.
    4. When you want to enable one mode and disable the other, in PlayMaker make two RewiredPlayerSetControllerMapsEnabled actions, one to enable the category you wish enabled and one to disable the category you wish disabled. Example: To switch to "Combat" mode, on one Action, enable "Combat" and disable "NonCombat."
    5. Always use the Debug Information in the Rewired Input Manager inspector to view detailed information on the Controller Maps, Controllers, and other Rewired objects live in the editor to debug issues.
     
    Last edited: Apr 22, 2017
  21. Freznosis

    Freznosis

    Joined:
    Jul 16, 2014
    Posts:
    226
    Well that did the trick! Thanks a bunch, this is definitely a must have asset :)
     
  22. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,462
    Glad you posted about the issue originally so it could be fixed! Do you work with any other racing wheels or just the G920?
     
  23. Freznosis

    Freznosis

    Joined:
    Jul 16, 2014
    Posts:
    226
    I develop with a G27, G920, and Thrustmaster T300 RS, all have seemed to work exceptionally well with this asset (not including Force-feedback of course which I just implemented myself).
     
  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,967
    Using Direct Input or the respective SDKs?
     
  25. Freznosis

    Freznosis

    Joined:
    Jul 16, 2014
    Posts:
    226
    Yeah just a DirectInput wrapper.
     
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,967
    Thanks!
     
    Freznosis likes this.
  27. SVC-Games

    SVC-Games

    Joined:
    May 21, 2013
    Posts:
    113
    Back in Unity 5.4 when debugging I could pause the game using unity's pause button and then make inputs with my controllers and advance using the frame by frame button in unity editor.

    Example: Pause game, keep pressing right, advance frame by frame and the gameobject will move right. Press the jump button and the next time I advance a frame the character would jump.

    This was great to test really precise actions like "hadokens" or jumping at the last posible moment, or other input fine tuning.

    Since 5.5 (if I'm not mistaken) if you press "next frame" with a direction pressed (for example) the gameobject doesn't move. Is this a thing of Unity or Rewired?
     
  28. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,967
    It's most likely due to the option added in 1.0.0.111:
    - Added "Ignore Input When App Not In Focus" option to Rewired Input Manager Settings.

    Before, certain input sources such as XInput and Direct Input would always return input when the app was not in focus. Keyboard and Raw Input did not. Now input is ignored by default when the app is not in focus just like Unity's input system. You have to click back in the game window in the editor before input will be returned when this option is enabled. I cannot think of any other possible thing that could cause this.
     
    SVC-Games likes this.
  29. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    147
    I'm using playmaker and I would like to know if it's possible to disable a Action then enable after a playmaker state is ran.
     
  30. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,967
    You don't disable Actions in Rewired. You disable Controller Maps or Action Element Maps. The documentation to achieve this is here:

    How To's: Enabling and disabling Controller Maps
    How To's: Enabling and disabling Action Element Maps

    The exact same concepts apply to PlayMaker as scripting. There are Actions included in the PlayMaker integration to enable and disable Controller Maps and Action Element Maps.

    Equivalent PlayMaker Actions:
    RewiredPlayerSetControllerMapsEnabled
    RewiredActionElementMapGetEnabled
    RewiredActionElementMapSetEnabled
     
  31. gearedgeek

    gearedgeek

    Joined:
    Jun 19, 2015
    Posts:
    147
    Here's the thing, I have two mouse and keyboard maps under the default layout. At the start the player controls are assigned a float 1 or 2. Depending which float the player is the mouse and keyboard maps are assign after the previous maps are unassigned. I have sent you a pm with screenshots of what I have.
     
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,967
    Your PlayMaker actions are disabling and enabling Controller Maps by category, not assigning/unassigning them. It's not the same thing. Unassigning a map removes it from the Player. Disabling it leaves it in the Player but makes that map not contribute any input to the final Action value. This doesn't have anything to do with your issue, but it is important that you understand the difference between assigning and enabling Controller Maps.
     
  33. kurismakku

    kurismakku

    Joined:
    Sep 18, 2013
    Posts:
    39
    Bug: when user right clicks on window border (in windowed mode) while user is holding some button, when he left clicks back inside of the game window, the button will remain pressed even if user is not holding it anymore. How to fix this?
     
  34. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,967
    I need more information. Please tell me the platform with OS version, the chosen input sources, the Unity version, the Rewired version, whether "Ignore input when app not in focus" is enabled, and whether you're talking about a button a joystick (if so, which one), keyboard, or mouse. Every platform and input source works completely differently.

    Edit: I cannot reproduce this in Windows.

    If this is in OSX, the explanation would be that I/O kit joystick input is message based, not polling based. The system is required to send an On event to turn the button on and an Off event to turn the button off. If the application is not receiving the Off event due to some series of circumstances, the button will be stuck in the On position.
     
    Last edited: Apr 27, 2017
  35. kurismakku

    kurismakku

    Joined:
    Sep 18, 2013
    Posts:
    39
    Tested on Windows 10 and OSX Macbook Pro. We tested mouse and keyboard, both of them get stuck.
    Rewired version 1.0.0.110.U5 so I guess we don't have that option.
     
  36. kurismakku

    kurismakku

    Joined:
    Sep 18, 2013
    Posts:
    39
    Updated now to newest version, still the same problem. Tested on another PC, Windows 10.
    Unity version 5.3.4f1
    "Ignore input when app not in focus" set to TRUE
     
  37. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,967
    Can you please clearly outline the exact process step by step that I need to do to reproduce this including what device/joystick you're using? I cannot reproduce it based on my understanding of the process on the mouse, keyboard, XInput gamepad, or other gamepad.
     
  38. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,967
    I have been able to reproduce it with the following steps:

    1. Hold down a key on the keyboard.
    2. While still holding the key, right click in the window's top bar bringing up the context menu.
    3. Release the key while the context menu is open.
    4. Left-click back in the game window.
    5. The key is stuck on.

    I will investigate, but based on what I know about how the different input sources work (especially Unity's keyboard input, which Rewired uses for all keyboard input.), this could be a pretty hard case to work around that may have unintended side effects for certain controllers like flight sticks that have Mode switches or other always-on buttons.
     
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,967
    @kurismakku

    As I expected, the case for keyboard on Windows and OSX and mouse on OSX (and probably Windows if Native Mouse Input is not enabled) come down to UnityEngine.Input

    Rewired polls Unity's input system every frame for values for the keyboard keys. Logging what happens directly from UnityEngine.Input.GetKey, you can see that the key press gets stuck using Unity's input system. OSX uses UnityEngine.Input for both keyboard and mouse input, so the same thing happens. If you were to test on a gamepad using Raw Input / XInput on Windows using Rewired's native input, you would see it does not get stuck. The mouse buttons don't get stuck on Windows with Rewired's Native Mouse Handling enabled either.

    I don't think a solution is possible for this issue. Unity's input system only provides the UnityEngine.Input.ResetInputAxes function to clear axis values, but I do not believe it affects UnityEngine.Input.GetKey. I believe the only solution to this issue would be to replace UnityEngine.Input for keyboard and mouse input with native implementations on Windows, OSX, and probably Linux.

    This issue is reproducible in the editor as well.

    Edit: I thought using ApplicationFocus might be able to be used as a workaround, but this event is not fired by Unity when you right-click into or out of the title bar of the window. There appears to be no way to detect this edge case so a workaround can be implemented.

    Please file this as a bug report to Unity. I will do the same. I'm adding it to the Known Issues documentation as well.
     
    Last edited: Apr 27, 2017
  40. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,967
    @kurismakku I've attached a key code tester script which gets key input directly from UnityEngine.Input and displays it on screen. Attach this script to a GameObject and press Play.
     

    Attached Files:

  41. SVC-Games

    SVC-Games

    Joined:
    May 21, 2013
    Posts:
    113
    Thanks, it worked like a charm. It's VERY useful for testing frame by frame :)
     
  42. Freznosis

    Freznosis

    Joined:
    Jul 16, 2014
    Posts:
    226
    Hello, I'm back again with another steering wheel problem lol. When using the G29 and assigning the map it seems if the shifter butters all have ID's that are one too high and it causes the reverse gear to not be assignable because Gear 6 is taking its place instead.


    It also seems that this problem is affecting the clutch not being assignable either. Any ideas what it could be?

    Also another problem that seems inconsistent is that some players can assign up to 4 controllers (as defined by my Rewired settings) however some other plays cannot assign the same type's of controllers and upon hitting Auto-Assign it forces them to use one or the other and not both. (For this example it is a G27 wheel and a handbrake peripheral that seem to be fighting for the same spot)
     
  43. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,967
    Did you make the map using the Racing Wheel Template or the G29 directly?

    It sounds like there's really something up with G29's based on this and other reports of weridness. There is either some kind of big difference in driver versions (possibly related to OS version?), hardware revisions, or firmware revisions that change mappings.

    Use the Joystick Element Identifier tool in Rewired/DevTools to view what the native input source is returning for these elements and post it here.

    I don't know what you mean about them fighting for the same spot. If you have the max joysticks per player set to 4, Rewired will assign up to 4 Joysticks to that Player. Is it assigning less than 4 when only 4 devices are attached? Do you have multiple Players which could be getting the other joysticks?
     
    Last edited: May 5, 2017
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,967
    Rewired 1.1.2.0 is available for registered users to download on the Rewired website. If you'd like to receive early access to updates, please contact me here. The Unity Asset Store should receive the update in 5-10 business days.

    Be sure to read Updating Rewired before updating.

    1.1.2.0:

    Changes:
    - Nintendo Switch Joy Con controllers changed to map +/- buttons to Center 2 on the Dual Analog Gamepad Template.

    New Controller Definitions:
    - Atari Jaguar Gamepad

    Bug Fixes:
    - Fixed bad guid format in Racing Wheel Template for Logitech G920.
    - Fixed incorrect default UI submit string in RewiredStandaloneInputModule.cs introduced in 1.1.0.0.
    - Windows, Raw Input: Fixed incorrect hat values for certain rare devices.
    - Rewired Editor: Fixed bug where Custom Controllers with no Axes would prevent selecting another Custom Controller in the list.
    - Touch Controls: Fixed editor bug causing the displayed list of Axes and Buttons in the selected Touch Control to be incorrect or fail to display when Create Custom Controller enabled on the parent Touch Controller and the Custom Controller's id does not align with the index.
    - Logitech G29 definition: Fixed incorrect button indices for shifter buttons.
     
    Last edited: May 6, 2017
  45. Freznosis

    Freznosis

    Joined:
    Jul 16, 2014
    Posts:
    226
    Yeah I did and it was a no go :/ I edited the G29 identifiers to be one up (identifier++) and they seem to be working for the testers now. For example Shifter 1 had an element number of 11 and changing it to 12 and so on with the rest of the gears made reverse work again, however the clutch axis is hit or miss with the testers.

    Precisely that is what is happening. The G27 is auto detected and the player map is assigned for the G27, however when going into the controller mapper and attempting to bind the handbrake just doesn't work. However if you goto auto-assign controller and use input from the handbrake controller then the G27 get's unbinded and the handbrake gets binded. It's as if Rewired only wants to use one of them at a time instead of both of them. The controller limit doesn't seem to be the problem because other people can bind the same handbrake and wheel at the same time.

     
  46. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,967
    I do believe the shifters were wrong after checking. I can see that Shifter 1 has the same button index as L3 which is wrong. I will shift the button indices on the shifter in the definiton.

    The fact that you have some testers that the clutch works for and some that it doesn't proves there's an unknown variable here at play. OS version, driver version, firmware version, possibly wheel version (different geographic regions?), some setting in the Logitech driver, 3rd party software changing the axes, or something must be responsible. I had another user report G29 problems and his axis mappings were completely different from the original mappings made for the device in both Raw Input and Direct Input, yet no explanation was ever found. The only way I _might_ be able to make this device work for all your users is to discover what is causing G29's to have different mappings for different people. You should make sure all your testers have the latest version of the Logitech driver. In addition, if they have used the Logitech

    It is probably best to just remove this device from the recognized controllers. That way they will be able to map it themselves as an Unknown Controller. This How To's topic shows how to remove a device from the recognized controllers list. Otherwise, the only other way to proceed is to get axis mapping information from the testers that the clutch doesn't work for using the Joystick Element Identifier tool (just make a build of the tool) and compare the results with the existing definition.

    Are you using Raw Input or Direct Input?

    What do you mean by "auto-assign controller"? Are you calling Rewired.controllers.AutoAssignJoysticks? How are you doing the assignment? What means do you have of assigning controllers to Players? Or are you referring to pressing the "Assign Controller" button in Control Mapper?

    If I'm understanding what you are saying, I see no way possible that could happen. The only way it could happen is if the HID device is actually disappearing from the list which is very unlikely. Is there any chance you can record a video or series of pictures showing what you are describing? I'm having somewhat of a difficult time understanding exactly what you are describing.

    How many Players do you have?

    Please use the Debug Information in the Rewired Input Manager inspector in the editor to view exactly what is appearing to Rewired. Open the Controllers section and see if both devices are listed. Open the Players section -> Controllers to see what controllers are assigned to your Player. You may be able to learn something about what is happening. If you do not have a G29 and only the testers do, then disregard the above instructions.
     
    Last edited: May 6, 2017
  47. kenshin

    kenshin

    Joined:
    Apr 21, 2010
    Posts:
    920
    Hi,

    I am interested to create a simple game that runs on my PC and can be remotely controlled by my android phone via bluetooth.
    Is possible to realize that using Rewired?

    If yes what is the raw schema? (i.e. PC game app with rewired and an android with a custom apk with rewired too?)

    Thanks in advance for the support!!!
     
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,967
    Hi,

    No, this is not possible with Rewired directly. The only way you could achieve such as setup with Rewired is to use Custom Controllers and write code to feed the values into Rewired. The actual communication between the PC and the Android phone would have to come from some other plugin or be something you wrote yourself.
     
    kenshin likes this.
  49. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,967
    @ModularBuilds

    Just a followup to the above message with a little more information. As you can see from @FlaxenFlash's posted results here, there is some other variant of the G29 out there with completely different axis mappings from the one used for creation of the definition. I've compared the two side by side on paper in both Direct Input and Raw Input. They have identical controller identification information as evidenced by the fact that they are both recognized, but axis mappings vary greatly and do overlap so there is no possibility of making a definition that can handle both variants. The only way such a definition would be possible is by adding code to allow the user to choose which variant he is using. (Could come in the form of some kind of automatic UI that says "Press the Clutch" and based on what axis comes back, choose the right definition. But just to be clear, this is not possible at the moment as the choice of hardware definition to use is handled automatically based only on the information provided by the device.) If there was a way to pinpoint what is causing this variation in axis mapping, then it might be simpler and just, for example, tell the users to enable/disable some setting in the driver, or to update the firmware, flip a switch, etc.
     
    Last edited: May 6, 2017
    Freznosis likes this.
  50. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,462
    I wonder if @devotid has run into this issue since his games supports the G29 also.

    It would be good to know what version of Windows is being used and exactly what Logitech driver is being used and if the Logitech profiler is being used at the same time.

    I did notice these issues with the G29 posted on the forums which I found very interesting. These were some of cases I found the most interesting.

    (a) G29 controller Y axis is mapped to clutch?

    I did notice see some messages about problems with axis mapping for the wheel input base on this Logitech forum message. Basically in this case the Y-axis is mapped to the clutch and the wheel does not work at all.

    https://community.logitech.com/s/feed/0D53100005B1D7uCAF

    (b) Logitech G29 doesn't works, HELP!!

    http://forum.projectcarsgame.com/archive/index.php/t-44694.html


    (c) G29 Wheel, Paddles and Buttons Failing and erratic behavior

    This Logitech forum post was the most interesting because Logitech support mentioned a tool called WheelDriverCleaner.

    https://community.logitech.com/s/qu...dles-and-buttons-failing-and-erratic-behavior

    >>>
    1. Disconnect the Gaming wheel from your computer.
    2. Download and save WheelDriverCleaner.exe to your desktop
    3. Run the cleaner tool by double clicking the file from your desktop.
    4. Close the cleaner tool dialog box.Reconnect your Gaming wheel to your computer.
    <<<<

    So I wonder if this WheelDriverCleaner tool will help solve some of these issues?

    (d) G29 not connecting to games

    The game he was trying to use was Euro Truck simulator.

    This case was interesting because he did all of the expecting install/reinstall drivers. But the OP said the culprit ended up being Steam.

    https://community.logitech.com/s/question/0D53100006qM2ZICA0/g29-not-connecting-to-games

    (e) Logitech G29 Review and Compared to G27 (inside sim racing)

    At around 13:41 thru 14:20 into the video the reviewer mentioned that Logitech Profiler that the clutch was a separate axis but on the G29 the clutch goes up off of the steering axis.

     
    Last edited: May 7, 2017
unityunity