Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Rewired - Advanced Input for Unity

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

  1. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,483
    Short answer is raw + Xinput is a good combination on windows side to support with regards to windows input APIs. This is also mentioned in the Rewired documentation Best practices.

    The best practices section is a good place to look at here for more details and other things you should consider.

    https://guavaman.com/projects/rewired/docs/BestPractices.html

    There is some discussion under windows for raw, direct and Xinput under the Windows section of the settings.

    https://guavaman.com/projects/rewired/docs/RewiredEditor.html#Settings
     
  2. jamespaterson

    jamespaterson

    Joined:
    Jun 19, 2018
    Posts:
    239
    Hi. Just wanted to say i used rewired for the first time a few days ago for my game input and it works absolutely brilliantly. Thank you.
     
    guavaman likes this.
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,280
    On all platforms, you choose your input settings and those settings are used for the entire duration of Rewired's existence unless changed and reset. The input source has to be initialized at the start of runtime (or whenever Rewired initializes). Entirely different code paths are used for each input source, different controller definitions, etc. The user cannot change what input sources are in use unless you choose to expose the configuration setting to them in some way, and if they do change it, Rewired has to be complete reset and be reinitialized losing all runtime configuration values that existed prior to the change.

    The reason the default settings are Raw Input + Use XInput is because that represents the most versatile setting that supports the most features possible. Everything else only exists so the user can choose to use some other API for their own special needs. 99% of games don't need anything but Raw Input + XInput.

    https://guavaman.com/projects/rewired/docs/BestPractices.html

    Windows Standalone Platform:
    • Always enable Use XInput (enabled by default). XInput provides automatic controller comaptibility with all XInput-compatible controllers such as Xbox controllers and clones. It also provides support for vibration and independent triggers on these controllers. There are many problems your players will encounter if you disable XInput. Most problematic is Steam which relies on creating emulated XInput devices for the Steam Controller, Steam Streaming, Steam Link, and controller remapping through Steam Big Picture mode. With XInput disabled, the Steam Controller, Steam Streaming, and Steam Link cannot be supported.
    No I don't. This area of Rewired was never meant for user use. It's not designed to be user friendly nor is it documented much. Most fields have hover tool-tips. Beyond that, there is no documentation.

    The special throttle stuff was added a much later time to allow for the universal setting Throttle Calibration Mode you see here:
    https://guavaman.com/projects/rewired/docs/RewiredEditor.html#Settings

    That is a setting that allows throttles to be transformed from the default 0-1 range to a 0-center range. Those values in the controller definition are never used unless you change the Throttle Calibration Mode from its default. It's extremely unlikely you'd need this.
     
  4. Legendary_keith

    Legendary_keith

    Joined:
    Apr 21, 2015
    Posts:
    10
    Hello guavaman,

    I'm working on a vr (android) app and i was wondering if the Oculus (quest) touch controllers work with the gamepadtemplate (basic stuff like pushing buttons and triggers)? If that doesn't work, how can i let players let them set their controls manually? (for example: player presses trigger from his left vr touch controller assign it as "shoot")
     
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,280
    The list of explicitly supported controllers is here:
    https://guavaman.com/projects/rewired/docs/SupportedControllers.html

    Oculus Quest is not on that list.

    All controllers that are not on that list behave the same way and can only be supported through runtime user mapping. All the information about that is also on that same page:

    https://guavaman.com/projects/rewired/docs/SupportedControllers.html#controllers-without-definitions

    The Android platform uses UnityEngine.Input as the input source, therefore, the controller can only be supported if Unity exposes it as a joystick through their input system.

    https://guavaman.com/projects/rewired/docs/Overview.html#tested-platforms
     
  6. Gigacee

    Gigacee

    Joined:
    Mar 4, 2015
    Posts:
    29
    Help me...I have a Corgi Engine Integration problem. The interact button does not work...I can't open a door, talk to a NPC, etc. Other buttons, such as jumping and dashing, work fine. Any ideas? Thanks☺

    Unity 2019.4.3f1
    Corgi Engine 6.5
    Rewired 1.1.35.3.U2019
     
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,280
    Use Debug Information to determine if there is a problem in your Rewired mappings or with your controller:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information
     
  8. Gigacee

    Gigacee

    Joined:
    Mar 4, 2015
    Posts:
    29
    I looked at Debug Information, but the "Interact" button wasn't there to begin with. I tried to change the "Jump" button to the "Interact" button, and I can talk to a NPC ... but of course I no longer cannot jump. How can I assign jumping and interacting to the same button?
     

    Attached Files:

  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,280
    Change the bindings on joysticks, keyboard, and mouse maps to add an Interact binding. If you don't know how to do this, read the documentation on how to use Rewired.

    https://guavaman.com/projects/rewired/docs/

    https://guavaman.com/projects/rewired/docs/QuickStart.html

    The Corgi Engine integration was made for Corgi Engine 4.0:
    https://guavaman.com/projects/rewired/docs/Integration.html#CorgiEngine

    It does not automatically support any new actions or functions added to Corgi Engine after that version. Integrations only provide a basic starting point anyway, so customizing it to your game is necessary regardless.
     
  10. Gigacee

    Gigacee

    Joined:
    Mar 4, 2015
    Posts:
    29
    OK, Thank you. I'll try it.
     
  11. Ryan_Simpson

    Ryan_Simpson

    Joined:
    Jul 4, 2013
    Posts:
    3
    Hey Guavaman,
    Firstly Thank you for such a great plugin.
    Secondly, I have a question regarding how best to use "Player.controllers.maps.GetElementMapsWithAction"
    I'm working in a codebase that already heavily uses Rewired so I'm learning on the go.
    If I launch the game (editor or built to a console) and there are no controllers connected Player.Controllers contains no joysticks, and maps will not have loaded any joystick maps. and when I connect the controller the player will have their joysticks maps loaded thats all fine and dandy.

    However I need to call the GetElementMapsWithAction and get the maps that use that action before the controller is connected (Start Screen for example) is there a way to get the desired controller map even if its not connected/assigned to the player yet?
    I'm reading through the docs and stuff as we speak but can't work out what part this falls under.

    I had a guess that I could maybe enforce a call to Player.controllers.maps.LoadDefaultMap(Controllers.Joystick) and then run the GetElementMapsWithAction call, would this work? I assume this would only get the map for one controller layout most likely the Gamepad Template map?

    I just essentially need a way to get a 'default controller map' data from GetElementMapsWithAction even if no controller is connected.

    Sorry if this is poorly worded, if it needs more explanation I'll be happy to clarify.


    Edit:
    I tried " calling Player.controllers.maps.LoadDefaultMap(Controllers.Joystick) and then running the GetElementMapsWithAction call"
    This did not give me the desired outcome, as GetElementMapsWithAction did not return a loaded controller map for any of my actions. :(
     
    Last edited: Jul 16, 2020
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,280
    Joystick Maps cannot be loaded in a Player if the Joystick to which they belong isn't connected and assigned to that Player. There is no way to know before a controller is connected what controller definition will be loaded because you don't have any information about the controller with which to identify it. Controller Maps must know the specific, platform-specific, input source-specific definition that will be loaded that contains the element mappings in order to create Controller Maps and it cannot know that without the controller attached.

    The only way to do what you want is to use the functions that were designed for this purpose after people kept asking for this feature:
    https://guavaman.com/projects/rewir...nput_MappingHelper_GetJoystickMapInstance.htm

    The API documentation an explanation about the caveats about using these functions.
     
  13. kopanz

    kopanz

    Joined:
    Dec 6, 2016
    Posts:
    8
    I see Rewired supports a lot of racing wheels but it doesn't have force feedback support for racing wheels. Is there a way to get XInput or SDL handle from rewired and send custom commands to controllers ?
     
  14. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,280
    XInput does not handle the vast majority of steering wheels. Even many wheels, guitars, and other controllers made for Xbox One do not work with XInput at all.

    Force feedback for wheels on Windows always requires either implementing the manufacturer's SDK like Logitech or using Direct Input. SDL2's force feedback support is just a wrapper around Direct Input and XInput (gamepads).

    Rewired provides no API wrapper for Direct Input or SDL2. Calling these functions requires that you implement a native library that exposes a C-compatible interface so you can call into it from C#. This would be entirely independent of Rewired.
     
  15. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    347
    Considering Rewired as I'd like to be able to display "Press [Space] to open" sentences using Text Mesh Pro, where [Space] is obviously the mapped key, rather than the word Space. There is a detailed section here about doing this: https://guavaman.com/projects/rewired/docs/HowTos.html#get-element-name-for-action - but there's two methods, and the first is a long loop through all of the inputs, and the second is a relatively easier method:
    Code (CSharp):
    1. // Get the Controller Template
    2. var gamepad = controller.GetTemplate<IGamepadTemplate>();
    3. if(gamepad == null) return;
    4.  
    5. // Get the first button map with the Action "Jump"
    6. var mapping = player.controllers.maps.GetFirstElementMapWithAction("Jump", skipDisabledMaps);
    7. if(mapping == null) return;
    8.  
    9. // Get the Controller Template Element Targets for the Action Element Map
    10. int targetCount = gamepad.GetElementTargets(mapping, results);
    11. for(int i = 0; i < targetCount; i++) {
    12.     Debug.Log(results[i].descriptiveName);
    13. }
    14.  
    I'm not sure what Controller Templates are, but I assume you'd probably just have one of these for a very simple game, and presumably
    player.controllers.maps.GetFirstElementMapWithAction("Jump", skipDisabledMaps);
    would display the mapped key for Jump? This would be the most useful part of ReWired for my simple purposes, and I just want to double-check that grabbing the mapped key name as a string is as easy as it sounds.
     
  16. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,483
    guavaman likes this.
  17. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,280
    The Gamepad Template version is only going to work for a gamepad that is supported by the Gamepad Template -- these gamepads. It will not work with any other controller. The long version is much more versatile and universal.
     
  18. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    347
    Ah ok, so each time I need to get the mapped key name of a specific key to display, I’d have to run through all of the inputs and grab it (obviously it could also be cached)?
     
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,280
    Read the code again. The "Long Version" loop is an example of finding mappings for all Actions. That's not what you are trying to do if you just want to show "Press [Space] for Jump." One single line of that code will give you what you want:

    player.controllers.maps.GetFirstButtonMapWithAction("Jump", skipDisabledMaps).elementIdentifierName;

    You do not need to cache this information.
     
    Last edited: Jul 21, 2020
    Zebbi likes this.
  20. jgthompson90

    jgthompson90

    Joined:
    Jun 24, 2020
    Posts:
    13
    Hi! I've been playing around with Rewired for a mobile game, for Android. I have two joysticks, one for movement and one for looking (camera) and I have two buttons for Shooting and Jumping. I can get everything to work in the Unity editor's Game tab, but once I put it onto my phone, the two joysticks do not work. The buttons DO work. The joysticks don't work in a sense where they are not recognizing me touching the joysticks. Any ideas? I've looked at the Troubleshooting documentation, but that hasn't helped.

    As of right now, for my settings in the Rewired Input Manager.
    -I created a player: Player0.
    -I created Actions under the default category. The Actions are Move Horizontal, Move Vertical, Look Horizontal, Look Vertical, Fire and Jump.The Movements are assigned to the Axis type.
    -Using Default Action Category.
    -Using Default Input Behaviors.
    -I created a Custom Controller (which is 0: FPSContoller), where I have the Movements listed under the Axes as StickX, StickY, CameraLookX, and CameraLookY and have the Calibrate unchecked. Under the buttons I have my Fire and Jump.
    -Using Default Custom Controller Layout, but I renamed the Descriptive name to "Touch".
    -Set up the Custom Controller Map to where I have my elements added. Move Horizontal, Move Vertical, Look Horizontal, Look Vertical, Fire, and Jump.


    Like I said, it works in the Unity Editor, but when I load the game to my phone, the Joysticks does not recognize me touching them. However, the buttons DO WORK and they DO RECOGNIZE my touch. Seems odd, like I am missing something. They're Interactable. Any ideas? Like I said, I went through the documentation inside and out and went through the Troubleshooting, Reinstalled ReWired. It just doesn't make sense that the Buttons recognize my touch but the Joysticks don't.

    Edit: Side note, The Rewired debug tool is registering the two virtual joysticks (stick x and stick y) and measuring their movement within -1 and 1 when playing on the Unity Editor.
     
    Last edited: Jul 22, 2020
  21. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,280
    Touch Joysticks will react to touch movement regardless of what, if any, Actions are bound to their axes. A touch control not even reacting when you touch it is a sign of Unity UI problems. Something very likely blocking the raycast to the joystick control in the Unity UI object hierarchy.
     
  22. Loewi_f

    Loewi_f

    Joined:
    Nov 13, 2019
    Posts:
    14
    Hello Guavaman,
    I've used Rewired(1.1.26.0 U2018) in my Project(2018.4.24f) for android app.It works perfectly on most mobiles ,but for some type of mobile,there are some "ControllerDataFiles missing " or " not initialized " errors ,which never appears in editor. It may be the error about mobile cpu type like x86 , or something else?
     

    Attached Files:

  23. jgthompson90

    jgthompson90

    Joined:
    Jun 24, 2020
    Posts:
    13
    Yup, that was it. Thanks! I was so focused on the input manager, that I wasnt looking at other causes. I ended up having to uncheck Lock Cursor in my First Person Controller script.


     
  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,280
    There's no known cause or solution for the "ControllerDataFiles missing " error. Your problem is outside Rewired. It's related to Unity and serialized data being corrupted as the error states. This is outside my ability to deal with corrupted data in your project.

    https://guavaman.com/projects/rewired/docs/KnownIssues.html#serialized-data-corruption-after-import
    https://guavaman.com/projects/rewir...ialized-data-corruption-after-upgrading-unity

    The "Not initialized" error means there is no Rewired Input Manager in your scene before the first script attempts to call a ReInput function.

    >> t may be the error about mobile cpu type like x86 , or something else?

    No at all. Rewired on Android is nothing more than .Net DLLs and scripts, the same as anything else you build in Unity.
     
  25. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,280
    Then it sounds like you have Simulate Mouse With Touches enabled and it's treating your touch as mouse input. You also do not have Allow Mouse Input If Touch Supported disabled so it is using the fake virtual mouse Unity creates for UI input.
     
  26. the_mr_matt

    the_mr_matt

    Joined:
    Jul 21, 2015
    Posts:
    95
    Hello!

    I'm using Rewired Event System to control my UI.
    1. How do I setup a scroll input for scrollrects? I followed the guide here but it doesn't mention scrolling.
    2. I have set up certain buttons to trigger on the UICancel action to go back to the previous menu. This is triggered by scrolling down on the mouse wheel even though it is not bound in the mouse maps.
     
  27. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    375
    Hello, after updating to the latest rewired version, 1.1.35.3.U2019, and updating the game, multiple players reported that their controllers are no longer being detected and they also can't see it in the control mapper.

    We didn't do anything else in this update about controllers other than updating rewired. Is this a known issue?
     
  28. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    375
    I also updated Steamworks in this update. I narrowed the issue down to Steamworks. So it's this issue;
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#steamworks

    But it's not throwing any exceptions, it disables all controller detection of Rewired. A user has a G29, a Thrustmaster shifter, an addon for shifter, all three was undetected, and disabling steam integration fixed it for him.

    I will try whats suggested on that page.

    Edit: Note that I couldn't reproduce the issue.
     
  29. ben06feb

    ben06feb

    Joined:
    Oct 2, 2012
    Posts:
    29
    Hi, How can I map a new key to a action at runtime through script, and what is API to list out all key values of keyboard/mouse/joystick and it's modifier keys in a list, also checking the conflict with other actions. Could any one provide the details of script for those functions.
     
  30. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,793
    Still no news with il2cpp issue with Rewired plugin?
     
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,280
    1. Scrolling works exactly the same way it does with the Unity Standalone Input Module. There is nothing special or different about the RewiredStandaloneInputModule.

    2. That's not possible. Use Debug Information to view your Controller Maps, bindings, and the actual value of Actions live at runtime. https://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information
     
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,280
    If you're not getting exceptions, that link does not explain your issue.

    I have no information for you if some kind of update to Steamworks is breaking controllers. That should simply not be possible. Rewired communicates directly with the Windows APIs -- Raw Input / Direct Input, and/or XInput. Rewired has no knowledge of Steamworks and cannot be made to work differently than it does. Steam is responsible for their hooking of the Windows input libraries making all the changes they want to make before the application sees it. The application is completely blind to what Steam is doing and cannot be written in any different way.

    Your issue probably has nothing to do with a Rewired update or a Steamworks update. These kind of issues happen all the time around updates and almost always turn out to be purely coincidental in my experience.

    The first thing that comes to mind for me is Steam configuration problems on your user's end. There is an entire section of the documentation devoted to Steam configuration problems:
    https://guavaman.com/projects/rewired/docs/Troubleshooting.html#steam

    NOTE: This documentation is not authoritative. Refer to Steam's own documentation.

    My best guess:
    Disable Generic Gamepad Configuration Support.
     
  33. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,280
  34. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,280
    Rewired comes with numerous complete examples showing you how to do rebinding:
    https://guavaman.com/projects/rewired/docs/Examples.html#simple-control-remapping
    https://guavaman.com/projects/rewired/docs/Examples.html#simple-combined-keyboard-mouse-remapping
    https://guavaman.com/projects/rewired/docs/Examples.html#control-remapping-1
    https://guavaman.com/projects/rewired/docs/ControlMapper.html
     
  35. the_mr_matt

    the_mr_matt

    Joined:
    Jul 21, 2015
    Posts:
    95
    Is there a way to get the default binding for a specific action in a controller? I found LoadDefaultMaps but this appears to firstly get all the actions, and secondly it doesn't actually return them, it just assigns them directly.
     
  36. the_mr_matt

    the_mr_matt

    Joined:
    Jul 21, 2015
    Posts:
    95
    Nevermind, found the MapInstance methods.

    The unity forum search function is absolutely appalling. Struggled to find the phrase "default map" because it kept omitting the word "map".
     
  37. the_mr_matt

    the_mr_matt

    Joined:
    Jul 21, 2015
    Posts:
    95
    In the process of implementing my own serialization system. Is there a simple way to immediately assign a specific elementIdentifierId to an actionId for a given controller (i.e. on start).
     
  38. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,280
    I really don't know what you're asking.

    To assign an Action to an element identifier for a particular controller, you just make a Controller Map in the Rewired Input Manager and assign it to the Player. That's exactly what the Rewired Editor and Controller Maps exist for. To make pre-runtime element assignments for all controllers you want to support.

    If you want to change bindings at runtime through code, you change them in the Action Element Map in the Controller Map for the controller in question. You have full access to everything in the Controller Map. There are many examples in the documentation and the examples included with Rewired showing changing bindings.
     
  39. the_mr_matt

    the_mr_matt

    Joined:
    Jul 21, 2015
    Posts:
    95
    That was intended to be at runtime. I don't want to use the InputMapper because these are to be loaded at the start of the game from the save data.

    I have looked through the examples and documentation extensively, but I'm sorry to say I am thoroughly confused.

    This is my attempt. The result was this particular binding would be set to mouse vertical regardless of what I set in the save data.

    Code (CSharp):
    1. var binding = ... // Load the binding from my save data
    2. var map = Player.controllers.maps.GetMap(binding.mapCategory);
    3.  
    4. ElementAssignment elementAssignment = new ElementAssignment(binding.binding, binding.actionID, binding.inverted, binding.mapCategory);
    5. map.ReplaceOrCreateElementMap(elementAssignment, out ActionElementMap result);
    I'm also confused about the best way to get a map in the first place. When I put Player.controllers.Keyboard as a parameter into GetMaps, it just returns null. I expected to be able to use Player.controllers.Keyboard.GetMap but this doesn't exist. Could you clarify?
     
    Last edited: Jul 26, 2020
  40. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,280
    It sounds to me like you're trying to re-invent things that Rewired already provides.

    I did not suggest you use Input Mapper. Input Mapper is for reading bindings from the user at runtime so they can change their mappings. What you are describing is making a binding to an element identifier id at the time the controller is first used (at start, on assignment, etc.) What I am saying is, what is the purpose of trying to do this in code when Rewired already provides you with the means to create your bindings in the Rewired Input Manager which are then loaded at start or at the time the controller is assigned to the player?

    You say you're trying to do this for a serialization system. Again, what's the purpose of writing a custom system to load bindings when Rewired already provides you with all the functions you need to export/import all information about Controller Maps, Controllers, Calibrations, etc.? There are already functions that will import/export XML or JSON from a Controller Map. This JSON can easily be saved/loaded however you want.

    Rewired includes the UserDataStore class to provide a flexible interface for load/saving all possible pieces of data one would want to save. UserDataStore_PlayerPrefs saves to Unity's PlayerPrefs, or you can make your own sub-class of UserDataStore and save/load the data you choose to the target you choose.

    The information you are providing doesn't match the information the overload you are calling requires. Look at the API documentation:

    You have chosen to use this constructor overload:
    https://guavaman.com/projects/rewir.../html/M_Rewired_ElementAssignment__ctor_9.htm

    The parameters it takes:

    elementIdentifierId
    Type: System.Int32
    The element identifier id the Action will be bound to.

    actionId
    Type: System.Int32
    The id of the Action that will be bound to the controller element.

    invert
    Type: System.Boolean
    Is the axis inverted? Used only for axis assignments.

    elementMapId
    Type: System.Int32
    The id of the ActionElementMap that this assignment will be replacing. (Optional)

    You are passing it these values:
    binding.binding, binding.actionID, binding.inverted, binding.mapCategory

    I do not have any information about what binding.binding is, but I'm assuming you've saved an element identifier id.

    The last value, elementMapId, you're passing the mapCategory. This is wrong and will not work. See the description of this parameter:

    elementMapId
    Type: System.Int32
    The id of the ActionElementMap that this assignment will be replacing. (Optional)

    But more than the specific parameters you're passing, you're using an overload constructor that is not sufficient to provide all the information required to describe a complete assignment except in the case of a full-axis assignment. If that is the only assignment type you're interested in, then that's fine, but I suspect you are interested in being able to assign buttons, split axes, etc.

    The description of this overload is:
    A struct for use in element assignment. Overload for assignment of a full axis to replace an existing element map.

    That is only going to provide you enough information to create a full-axis binding.

    The ElementAssignment is a struct. You do not have to choose any specific overload. All you have to do is provide all the data required to describe the assignment in its entirety. The overloads are only provided as a convenience for making specific assignment types so you don't have to provide all the information that wouldn't end up being used anyway for that assignment type.

    You can just as easily use the parameterless constructor and provide the data to describe the assignment you want.

    new ElementAssignment() {
    actionId = x,
    ...
    };

    All the fields are listed here:
    https://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_ElementAssignment.htm

    There are many examples of working with Controller Maps in the documentation. The How To's page contains a ton of examples of getting controller maps from the Player in a variety of ways throughout the page. Important Classes shows that player.controllers.maps is the goto for all things Controller Map related in the Player.

    You don't seem to understand Rewired's mapping system and how Controllers relate to Controller Maps. Read the Controller Maps documentation:
    https://guavaman.com/projects/rewired/docs/ControllerMaps.html

    Look at the diagrams at the bottom.

    You are thinking a Controller contains maps (wanting to get access to maps from Player.controllers.Keyboard). That's not how Rewired works. The Rewired Player is the glue for Controllers and Controller Maps. The Controller knows nothing about Controller Maps. The Player contains Controllers and Controller Maps. Each Map is associated to one Controller. The Map contains bindings for elements on that Controller.

    You cannot get a Controller Map from the Keyboard because the Keyboard is a Controller and does not contain any maps. The Player contains the maps. Some of those maps may be for the Keyboard, some for the Mouse, some for Joysticks or Custom Controllers assigned to the Player.
     
    Last edited: Jul 27, 2020
  41. TheFalconeerDev

    TheFalconeerDev

    Joined:
    Sep 18, 2019
    Posts:
    37
    Hi there

    I read you don't support unity 2020, I am however forced to test 2020 to circumvent issues on XboxOne. this is giving a error "duplicate action name found in action list" for every Action it seems.

    Just wondering if 2020 support is on the horizon, or you have a rough estimate , or it won't be supported at all.
    Love rewired,, would love to hear what to expect in this regard.

    Cheers
    Tomas

    note , on further inspection, that error isn't fatal, but it is interesting,because performance for rewired on xbox has been 1ms to 1.8 ms quite steady.. perhaps I've done something very wrong. and these errors have been happening beneath the surface even in 2019.. hmmmm
     
    Last edited: Jul 27, 2020
  42. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,280
    These errors have nothing to do with Unity 2020. This is caused by a Microsoft compiler optimizer error. This is a very well known issue with many possible symptoms. See this for resolution:
    https://guavaman.com/projects/rewired/docs/KnownIssues.html#windows-standalone-il2cpp-vs2019-hang
     
  43. TheFalconeerDev

    TheFalconeerDev

    Joined:
    Sep 18, 2019
    Posts:
    37
  44. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,280
    Setting Unity to VS2015 will not work. IL2CPP is a separate executable and is hard-coded to use the latest version of VS it finds on the system. You cannot choose which compiler IL2CPP uses. You have to follow the workarounds I listed in that link.
     
  45. TheFalconeerDev

    TheFalconeerDev

    Joined:
    Sep 18, 2019
    Posts:
    37
    hmm I've set the environment variable as well, I'll circle round for another pass. kinda given up on 2020 anyway, kept crashing
     
  46. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,280
    If the environment variable is set correctly, it should work. But this problem should not have anything to do with Unity 2020. If it does, then there's a new problem that I don't have any information about. From the nature of the problem you're reporting, there's no way this could be caused simply by running it in Unity 2020. If you do not have corrupted serialized data in the Rewired Input Manager game object, you do not actually have multiple Actions with the same string name (not possible to do in the Rewired Input Manager, but possible through data corruption, incorrect merging of source control, etc.), then there is no possible code path that can lead to that error and it means the code as written is not executing as written. Another user reported this exact error and the cause was the Visual Studio 2019 compiler optimizer bug.
     
  47. TheFalconeerDev

    TheFalconeerDev

    Joined:
    Sep 18, 2019
    Posts:
    37
    ok. sounds logical, I've tried to export and reimport the rewired data, as to exclude corruption. Not sure what else I could do to safeguard against that.

    On a related question, Series X, currently working towards that. The dev who's doing the integration for it,noted that rewired can't detect the platform. Should we acquire a series X version separately via the Microsoft portals ? (like with switch?)?

    Thanks for the replies so far.
     
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    4,280
    https://guavaman.com/projects/rewired/docs/KnownIssues.html#serialized-data-corruption-after-import
    https://guavaman.com/projects/rewir...ialized-data-corruption-after-upgrading-unity

    Data corruption caused by editing of the serialized data in the prefab/scene text files caused by source control can only be managed by not merging the files.

    There is no ETA for Xbox One Series X support. This requires a completely different SDK. I'm getting this question almost every day along with a slew of other platforms / distribution systems (PS5, iOS 14, Mac GCController framework for Apple Arcade, Unity 2020). I have to get the time to add support for all these new platforms, which I currently do not have. The best you can do is to use Custom Controllers.
     
  49. JMCamacho

    JMCamacho

    Joined:
    Oct 3, 2018
    Posts:
    2
    Hello! First of all, congratulations for this plugin. It's so awesome!

    I'm trying to make my navigation a bit more reliable. I'm having a little problem and I hope you can help me:
    If I press D-Pad button or move joystick button up/down, the focus jumps to the next possible item in my screen (imagine a 2D menu). The thing is that if I keep pressing the d-pad or joystick, the focus keeps changing. Is there a way to stop the focus at the next item and don't continue navigating until you release and press the D-Pad/joystick again?

    Thanks in advance!

    Regards,
    JMCamacho.

    P.S. Alright! I found the "Move One Element Per Axis Press" in the Rewired Standalone Input Module" component :D. Thanks!
     
    Last edited: Jul 29, 2020
  50. the_mr_matt

    the_mr_matt

    Joined:
    Jul 21, 2015
    Posts:
    95
    Hello!

    Thank you for your help earlier. I have scrapped my plan of serializing my own data and gone with the simple provided player prefs system.

    Some more questions:
    1. Is there a way to remove a binding?
    2. I know about LoadDefaultMaps, but is there a way to revert to default for one specific action element map?
    3. I've just recently had difficulty with UserDataStore_PlayerPrefs not saving my data. I can see in the debug information that new bindings are indeed being set but they are not saved to player prefs. Is there a known error here or is likely to just be something weird in my setup?
     
unityunity