Search Unity

Rewired - Advanced Input for Unity

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

  1. DanjelRicci

    DanjelRicci

    Joined:
    Mar 8, 2010
    Posts:
    175
    When creating and running an InputMapper, is it possible to poll inputs for more than one controller when remapping an action? I'd like to give players the freedom to map most actions either to keyboard or mouse buttons, but as far as I found, I can only start the InputMapper with a context that contains (and listens to) only one controller type at time. Am I missing something, by chance?
     
  2. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    No. You are not missing anything. Input Mapper works on the concept of mapping for a single Controller Map at a time. A Controller Map always belongs to a specific Player and a specific controller. This is fundamental to the structure of Rewired. What you are trying to do is to use Rewired like other systems that are not designed around a Player and Controller Map system but are designed around a single static list of mappings. Rewired does not work this way and trying to make it do so will be very difficult because you will be working against the structure of the system. It is possible, but not recommended.
     
    DanjelRicci likes this.
  4. dearamy

    dearamy

    Joined:
    Mar 17, 2015
    Posts:
    68
    How can I add some custom events to the "TouchInteractable" component?
    Say, double-click event.

    And the OnTap event on TouchJoystick doesn't work.
     
    Last edited: Feb 26, 2018
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    You can't modify the TouchInteractable or any of the inheriting components. They are in Rewired_Core.dll which is not modifiable. If the included touch controls do not meet your needs, you have to replace them with your own touch controls. Rewired works with any touch control system on the asset store using the Custom Controller system.

    There are no known issues with the OnTap event on TouchJoystick. Did you check "Allow Tap" in the inspector?

     
  6. JasonJonesLASM

    JasonJonesLASM

    Joined:
    Sep 5, 2012
    Posts:
    141
    Just wanted to give a heads up, I am helping to test out the new version of Bolt, the folder structure has completely changed for 1.3 to a single folder for portability. In this case, adding the Bolt integration no longer works, I believe because of this. Getting that famous error, the modules cannot be loaded. Only on the integration though. Clean project as well. Once it's deleted, errors are cleared. Final version is supposed to be coming this week, but a second alpha is up in builds if you get time and want to check it out.
     
  7. impi2

    impi2

    Joined:
    Jul 3, 2015
    Posts:
    43
    Hi,

    Been watching this sometime waiting for a sale to tinker with it ... hopefully you have one planned soon ?
     
  8. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    No sales are planned. I declined to participate in several invitation sales such as Black Friday and cyber week and another upcoming sale. Rewired's price is already far too low for the amount of work I have put and continue to put into it. It will never be 50% off again. The max discount I will ever consider is 20% as I believe all these constant fire sales all the time devalue the entire software industry. I have no plans to put it on sale at this time.
     
  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    Thanks. I will have to watch out for this. This is sure to cause a lot of problems. For simplicity, I'm going to have to drop support for pre 1.3 because it would be too difficult to try to support integrations for multiple versions of Bolt.
     
    JasonJonesLASM likes this.
  10. Creepgin

    Creepgin

    Joined:
    Dec 14, 2010
    Posts:
    340
    Hi @guavaman ! I purchased Rewired a long time ago. It was able to process controller/gamepad inputs while game is running in background. Is it still the case now?

    I'm asking this for a couple friends who are trying to test their multiplayer game more easily (on a single machine running a server instance and multiple client instances).
     
  11. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    http://guavaman.com/projects/rewire...l#settings-ignore-input-when-app-not-in-focus

    The Unity Player settings must also be set to Run in Background.
     
    Creepgin likes this.
  12. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,174
    are you aware of the bugs on Unity 2018.1b9 for UWP compilation? It works fine on editor, but when you build on visual studio and run the game, the controllers many times get stuck and also the "Mouse X" and "Mouse Y" behave very differently from the editor.
     
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    I am not aware of any issues with UWP on the 2018 beta, but as a rule, I do not support beta versions of Unity or experimental features. There is currently no Unity 2018 version of Rewired. When 2018 launches, I will be creating a 2018 specific version and upload that to the asset store which will be used when you download from the asset store using 2018.

    Mouse X and Mouse Y would only behave differently in the editor or a build if you are using different settings between the two. This is 99% time due to not understanding how to use the Rewired Input Manager prefab correctly and using a Rewired Input Manager game object with a different configuration setup in the editor scene than the one you are using in a build. Another reason is when using UserDataStore_PlayerPrefs to save and load XML data, the editor or build may have different data saved. Clear PlayerPrefs in this case.
     
  14. DanjelRicci

    DanjelRicci

    Joined:
    Mar 8, 2010
    Posts:
    175
    I am trying to replace an ActionElementMap using this string:
    Code (CSharp):
    1. ReInput.players.GetPlayer(0).controllers.maps.GetMap(mapId).ReplaceElementMap(assignment)
    ReplaceElementMap returns true, but when I go to check what's the controller element for that element map, I get none. I believe the assignment is correct since I set .elementMapId, .elementIdentifierId and .actionId exactly as I get them by the default InputMapper when I poll for a button. What could be the cause?

    EDIT: apparently this works if I create an assignment specifying a KeyboardKey, but this won't do it for joypads and other controllers I believe.
    EDIT 2: passing an ActionElementMap in the out result field of ReplaceElementMap reveals that result.elementIdentifierId is 0, but I'm passing a non-zero value that I'm sure corresponds to a valid element on my keyboard controller.
     
    Last edited: Mar 5, 2018
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    Replacing an ActionElementMap can change its id (old AEM is deleted, new one is created). It will not always be the same after making the change. Do not store the Action Element Map id. Use Debug Information to see what Action Element Maps exist at runtime.

    Please post the code of how you are creating the assignment struct so I can see what values you are assigning.
     
    Last edited: Mar 6, 2018
  16. Kolyasisan

    Kolyasisan

    Joined:
    Feb 2, 2015
    Posts:
    269
    Hello! I recently bought ReWired and I am generally very happy with it. However, there is one incredibly annoying problem on Linux builds.Basically, the controls will "stutter". The game always randomly return "GetButtonDown" when the user is holding it, which should not happen at all. Do you happen to know this problem perhaps? I couldn't find it on your website's known problems section. Can you help me? I'm really struggling with it.
     
  17. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,174
    @Kolyasisan that also happens on UWP builds and it's driving me crazy. Controls will also get stuck for like 2 seconds, so if you are moving left... it will stay returning moving left until who knows what resets it
     
  18. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,459
    Please provide more information ...

    (1) What version of Rewired are you using?
    (2) What version of Unity are you using?
    (3) What operating system (Win/Mac) are you building your game on?
    (4) What distro/Linux version are you deploying to?
    (5) What controller are you working with?
     
    Last edited: Mar 11, 2018
  19. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,459

    Please provide more information ...

    (1) What version of Rewired are you using?
    (2) What version of Unity are you using?
    (3) What operating system (Win 7/8.x/10) are you building on?
    (4) What version of Visual Studio are you building with?
    (5) What controller are you working with?
     
  20. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,174
    Latest version of Rewired published as of today. Unity 2017.3 and 2018.1b10 (it happens on both), windows 10, visual studio 2017 and using the keyboard.
     
  21. Kolyasisan

    Kolyasisan

    Joined:
    Feb 2, 2015
    Posts:
    269
    I'm using version 1.1.10.0, the latest one. Using Unity 2017.3.f3. I'm building the game with Windows 10, latest update. Visual Studio version is 15.5.5. I'm not using any controllers on Linux, only the keyboard. On my Windows builds everything is okay with both the keyboard and DS3 emulated as an XInput X360 controller.
     
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    I have never heard of this problem before and absolutely nothing has changed in the ButtonDown calculation is a very, very long time.

    Because you say this occurs when using the keyboard, Unity would be the #1 suspect. On Linux, Rewired uses UnityEngine.Input.GetKey for all keyboard input on Linux. This is updated every single frame from the latest values provided by Unity.

    The only other thing that could possibly affect this is your Input Behavior settings for the Action in question. Button Repeat Rate and Button Down Buffer would both affect this.
     
  23. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    Again, never heard any reports of anything like this before.

    1) Is this when using a controller, the keyboard, or both?
    2) If a controller, what controller are you using?
    3) Have you used Debug Information to view the button/axis values in the controller/keyboard?
    4) Keyboard and mouse input are taken directly from UnityEngine.Input on UWP platform. Joystick input is obtained through native libraries if Native is set as the Primary Input Source for UWP. XInput-compatible gamepads use Windows.Gaming.Input.Gamepad which is polling-based and non-XInput-compatible joysticks use the HID system which is event-based. If Windows does not send a "not pressed" event for an axis/button for whatever reason, Rewired cannot know that the element is no longer active. Use Debug Information to view the controller level elements and see if they're getting stuck on.
     
  24. broesby

    broesby

    Joined:
    Oct 14, 2012
    Posts:
    112
    It was surprisingly easy to set up touch control (Touch Pad) for android even being a total novice on Rewired AND a non-coder ;)

    Now I have my hopes up, that it is possible to create multi touch so I can make pinch motion or opposite for zoom in/out... Is multi touch supported?

    Jesper, Denmark
     
  25. Jayme65

    Jayme65

    Joined:
    Dec 11, 2016
    Posts:
    73
    I'm basically testing with the script coming from "SimpleControlRemapping" in the "Example" folder...and it seems to perfectly suit my basic need!
    The only trouble I'm getting is that actions are laid out sorted by ID...when I would like to have them sorted the same way they are in the editor! (you can see on the picture that my 'Right' action ID is #26 ;) )
    Is there a way to have them sorted on the editor's order...or to edit the ID so that the ID would match the order?

    I other words, do we have access to the id I can see at the left of the action name?

    Thanks!!
     
    Last edited: Mar 13, 2018
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    Rewired does not have pinch, swipe, tap, rotate, or other gesture controls. Rewired's Touch Control support is only on-screen joysticks, not general touch and swipe input. Touch and swipe is done using Unity's input system. If you want to bind them to Actions, use a Custom Controller.
     
  27. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    You can only display Actions by sorted order if listing Actions by category:

    Code (csharp):
    1. foreach(var cat in ReInput.mapping.ActionCategories) {
    2.     foreach(var action in ReInput.mapping.ActionsInCategory(cat.id, true) {
    3.     }
    4. }
    Look through the API reference for ReInput.MappingHelper. All available functions are listed there.
     
  28. Patrascu

    Patrascu

    Joined:
    Jan 20, 2016
    Posts:
    59
    Hi @guavaman

    I have a Steam related problem regarding RawInput as Primary Input Source and Use XInput checked.

    When I connect a PS4 controller, 2 devices get detected: first as an RawInput device and shortly afterwards as an XInput device.
    Now from what I could gather from reading the documentation and forums, Steam will try to emulate a controller as an XInput device if any of the Steam Controller Configuration settings are enabled either in the front-end (Big Picture) or the back-end (Steamworks Application settings).
    However, all of these Steam Configurations settings are turned off for PS4, Xbox One and Generic Controllers. So I would expect Steam to let the game handle input devices.

    Is there any explanation for this behaviour? I've also noticed that the Xbox Controller also gets detected twice, both times as an XInput device, with different device ids and a different name.

    Since we want to display glyphs for both Xbox and PS4 controllers we need a consistent way of identifying a PS4 controller. And this can be difficult with the way things work right now.

    Btw, we are using the 1.1.10 version of the Rewired plugin if it's any help.
    Best regards,
     
  29. Patrascu

    Patrascu

    Joined:
    Jan 20, 2016
    Posts:
    59
    After some further tests, I can tell that the issue only occurs when Use XInput is enabled and the game is run through the Steam client. If the game is run outside the Steam client it works as expected.
     
  30. Jayme65

    Jayme65

    Joined:
    Dec 11, 2016
    Posts:
    73
    When using "SimpleControlRemapping" from the "Example" folder, is there a way to prevent the key to propagate when you're mapping a key used by the UI?
    In this gif, you can see that I'm choosing "Up Arrow" for binding...but just after entering it, the "Up Arrow" wants to do its job and navigate up (and I would like it no to do so..since, for me, the key should have been handled by the InputMapper and shouldn't propagate!?)

    Thanks!

    PS: Is there something similar to the "KeyEventArgs.Handled" from Windows.Forms?
     
    Last edited: Mar 14, 2018
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    As you've discovered from the documentation, this is purely a Steam issue and not a Rewired issue. There's nothing Rewired can do to detect or hide these controllers created by Steam. Steam creates them at the system level by hooking the Raw Input DLL and changing what all application see. You have to control this through Steam.

    I can't feasibly provide complete Steamworks documentation, but there's some documentation on the subject:
    http://guavaman.com/projects/rewired/docs/Troubleshooting.html#steam-gamepad-appears-as-two-devices

    Disable the PS4 controller configuration support in Steam both in your steam client user settings AND in the Steamworks backend.

    If you have any other 3rd party software installed that makes the DS4 appear as an XInput device, disable it.
     
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    Simple Control Remapping is meant to be extremely, extremely simple for the sake of just showing you the process of remapping and nothing else. Other examples such as the older ControlRemapping1 example are complete examples, but I got too many complaints from users who didn't want to read through 2000 lines of code to find what information they wanted so I made the simple version. Control Mapper shows a complete example using Unity UI, but has the same issue of complexity. Simple Control Remapping ignores all kinds of necessary processes such as ignoring input for a period before remapping begins in order to filter out stick releases, etc. This example is not meant to show you how to work with Unity UI, just the actual process of remapping a control using Input Mapper.

    No, there is no "use" event concept in Rewired. You would have to disable UI controls while mapping to prevent it from moving on the UI. You can do this any way you choose. You can disable all UI elements during polling using a Canvas Group (this is how Control Mapper does it) using a, disable your UI controller maps, disable input in the RewiredStandaloneInputModule component, or other methods.
     
  33. Jayme65

    Jayme65

    Joined:
    Dec 11, 2016
    Posts:
    73
    Ok, got the idea! Thanks for your reply!
    I did that at the button level (not Canvas Group)...and doing that way adds a graphical interest since the button is generally changing of color when not interactable! (giving a feedback to the user)

    To anyone willing to add that feature to the 'SimpleControlRemapping' script, simply edit that way
    Code (csharp):
    1. private Button selectedButton;
    2. // Called by the input field UI Button when pressed
    3. private void OnInputFieldClicked(int index, int actionElementMapToReplaceId)
    4. {
    5.     if (index < 0 || index >= rows.Count) return; // index out of range
    6.     if (controller == null) return; // there is no Controller selected
    7.     // Begin listening for input
    8.     inputMapper.Start(
    9.         new InputMapper.Context()
    10.         {
    11.             actionId = rows[index].action.id,
    12.             controllerMap = controllerMap,
    13.             actionRange = rows[index].actionRange,
    14.             actionElementMapToReplace = controllerMap.GetElementMap(actionElementMapToReplaceId)
    15.         }
    16.     );
    17.     selectedButton = rows[index].button;
    18.     selectedButton.interactable = false;
    19. }
    20. private void OnInputMapped(InputMapper.InputMappedEventData data)
    21. {
    22.     RedrawUI();    
    23.     StartCoroutine(SelectLastSelected());
    24. }
    25. private void OnStopped(InputMapper.StoppedEventData data)
    26. {
    27.     statusUIText.text = string.Empty;
    28.     StartCoroutine(SelectLastSelected());
    29. }
    30. IEnumerator SelectLastSelected()
    31. {
    32.     yield return new WaitForSeconds(0.1f);
    33.     selectedButton.interactable = true;
    34.     selectedButton.Select();
    35. }
     
    Last edited: Mar 15, 2018
    guavaman likes this.
  34. Mr_Dan_O

    Mr_Dan_O

    Joined:
    Oct 12, 2013
    Posts:
    347
    Hello.
    I'd like to know how to deal with wheel controllers (eg Logitec G27 Wheel) using Rewired, please tell me how to add force feedback? I use Unity 2017.3.1f1.
    Best.
     
    Last edited: Mar 18, 2018
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    Mr_Dan_O likes this.
  36. xelanoimis

    xelanoimis

    Joined:
    Oct 29, 2013
    Posts:
    30
    I'm investigating Rewired for my 4 players local party game and I have a few questions (sorry for the long post)

    The main issue is that Rewired works by assigning mapping (category+layout) to current controller (id) of a given player. This should be nice as long as that player always "receives" that controller. But since on Windows, controllers come in any order this may lead to complications.

    There are 2 cases where players must remap their controller:
    A. The controller is "unknown" and the default mapping is wrong, so every player wants/needs to remap it.
    B. The player prefers a different buttons configuration or likes dpad over stick and he needs to remap every time he is assigned a different controller.

    But let me list my questions:

    1. I wonder if there's a good practice and if it's supported to allow players to map an "unknown" joystick by creating a mapping for the joystick type, save it in an XML string, and every player that gets that particular joystick (based on hardware guid) connected, to load that mapping. Like allowing players to tell the system how a particular unknown joystick should be mapped. This will cover case A. Are joystick hardware guid consistent and enough for this kind of check? Or device names need to be tested as well?

    2. How the "keep controllers assigned to players" option work internally? Is it based on guid? I may need to emulate it.

    3. In the editor, we assign Mappings (category and layout) for Keyboard and Joystick types, to every player. But at runtime we can only Load mappings to a player's specific controller based on the controller id. Considering that inside a (Device Type + Mapping Category + Layout) set we have multiple controller kinds (generic, unknown, etc.), shouldn't we be able to Load the whole set and have it working with any future controller that gets connected to that player?

    4. When a controller is connected and I manually add it to a player, do I need to re-enable the mapping (category and layout) for that controller? I think if mappings were assigned from editor, they are selected automatically for the newly connected controller. What about if I did some re-mapping (redefined some buttons) then I disconnect and connect a different joystick (makes sense to be able to use it with the old re-mapping even if not perfectly matching)

    5. The .controllerId works like the joystick id in unity even if not using Unity as input system? It is like the "slot" where the joystick was given at the connection time. If I disconnect and reconnect it gets the same slot. If I disconnect 2 controllers and connect them in reverse (second disconnected is connected first), the slots are indeed reversed. Is this always the expected behavior with Rewired?


    I also need some advice with my approach, if you spot any major problems with it. The main things I try to achieve are:

    - allow the players start the game directly with whatever controllers are connected
    - allow them to change their assigned controller in a config page, only if they want.
    - keep the assigned controllers during the game session
    - allow a player to remove a controller, connect a new one and have it assigned to himself automatically
    - keep the assigned controllers when restarting the game (as much as possible)
    - remember if a player was using keyboard or joystick and keep this preference.
    - support different layouts to allow 2 players on the same controller (left/right side)

    So far, each of my 4 game player profile saves a config with the selected controller, not as an unique id or hardware guid, but as the "order" of that controller. If a controller is disconnected and reconnected this order is kept. I use .controllerId mentioned before to determine the previous "order" of a re-connected controllers.

    The downside is if you have 5 controllers connected and one player uses C5 and then the game restarts with 4 controllers connected he will have to reconnect the 5th or to select a different. Also it's bad for people who remap an unknown controller on their slot and then are assigned a different one - they need to reassign it in the menu.

    Anyone using Rewired is welcomed to comment on this, especially if you have experience with what players expect from a local party game for 4 players.

    Thanks!
     
  37. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    Which is the reason for Rewired's Player-based system with intelligent controller re-assignment. This is meant to avoid issues with the underlying OS numbering system and re-assign controllers to the right Player based on all kinds of criteria.

    Joysticks do not have hardware guids. The Joystick.hardwareTypeGuid is entirely a Rewired construct and only represents the type of the joystick if recognized.

    One of the major problems with HID joysticks across all platforms is that there's no easy or consistent way to determine a particular joystick's identity precisely. How this is done or if it's even possible depends on the platform in question and the input sources being used for that joystick.

    As for saving the remapping to XML as a universal user-defined mapping as opposed to a per-Player mapping:
    That's definitely possible. It's all up to you how to decide to save and load XML user data. Saving and loading of user data is not part of the core of Rewired. It's done in the UserDataStore component if you're using it, which is fully customizable. You can implement your own version and save/load data however you see fit.

    The reason the default implementation saves per-Player and not globally is so you can have multiple Players using identical joystick types yet have different mappings for each. This effectively makes a Player a form of a profile. Changing this system to a global system means all Players using the same joystick type will have to share configurations.

    Not based on guid. It's a quite complex heuristic that works differently on every platform and input source.

    Loading mappings is a process that happens immediately either when a new Joystick is assigned to a Player or when a load function is called.

    Categories and Layouts are not a setting in the Player that causes it to start using some set of mappings. They are simply keys used to look up a particular Controller Map you have defined in the Rewired Input Manager. When you load a Controller Map, you use the Category Id and the Layout Id to determine which map to load. After that, it's loaded into the Player. You cannot set a "current category" in the Player after which all maps will be loaded from that category.

    The Controller Map system is purposely a very manual system that you manage so that you can use it however you want.

    You have to use the Controller Id when loading a Controller Map because each Controller assigned to the Player has its own set of Controller Maps.

    If you want to enforce that a certain category is used when a new controller is attached, you have to load the maps on the controller connected event.

    If you assign a new Joystick to a Player and you want that Joystick to use maps from a specific category or layout, you must load them. Otherwise, it will just load controller maps with whatever cat/layout you've defined in the Rewired Input Manager -> Players page. This page describes the default Controller Maps to use when a device is connected.

    If a device is disconnected and re-connected during a runtime session, it will use whatever maps were last used instead of loading the defaults again.

    Controller.id is a unique id assigned by Rewired when the Controller is first created. If a controller is disconnected and re-connected, if at all possible, it will be re-assigned the same id it had before. This is not always possible depending on the platform and input source in use. In that case, it will be assigned a new id. Id's are not consistent between runs.

    All of this is possible but will require a lot of management of data. Everything you mention above except split controller layouts is done in UserDataStore_PlayerPreferences which is used by Control Mapper.

    I wouldn't use controller.id for this. It's not consistent between sessions, only during the same session. Use Joystick.deviceInstanceGuid if you need something that may persist between sessions. See the UserDataStore_PlayerPrefs code to see how this is used to try to save controller assignments between sessions. Note the use of "may" and "try" -- this is not always possible depending on the platform, input sources, and controllers used.
     
  38. Rockwall33

    Rockwall33

    Joined:
    Mar 4, 2016
    Posts:
    186
    Hello!

    I am going to buy rewired soon, it will help me with my networked arena fps, with splitscreen like 4 players for 1 pc, 8 players for 2 pc etc.

    Will there be Forge Networking Remastered support?

    Thank you!
    XaloX
     
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    Rewired is a local input manager. It does not support networking directly. Only the input devices attached to a single system are relevant to that system. In most cases, you would send the result of the input across the network instead of the input itself.
     
    Rockwall33 likes this.
  40. Rockwall33

    Rockwall33

    Joined:
    Mar 4, 2016
    Posts:
    186
    Yeah it is already networked and playable. So I would be changing a few inputs, not that much (with rewired).

    Thank you!! :D
     
  41. Rockwall33

    Rockwall33

    Joined:
    Mar 4, 2016
    Posts:
    186
    I bought rewired! Seems awesome!! :D

    I want to use Unity Input override script taking out my previous Unity Input, do I just drag the script onto my player?

    I also want 4 players to play on 1 pc, but networked to 8 players for 2 pcs. Would I make a few players (in the rewired input manager), but keep my player prefab the same, but assign those players to that prefab? I know I would still do the input over the network, but what would be the best way of going of having a sort of 4 local party on 1 client input wise (I will have 4 controllers per pc/client)? I have splitscreen done.

    Thank you!! :D
     
    Last edited: Mar 24, 2018
  42. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    No. See the documentation for usage:
    http://guavaman.com/projects/rewired/docs/UnityInputOverride.html

    If you are making a multiplayer game, do not use Unity Input Override. It is not for that purpose. The only purpose it has is to allow you to use Rewired for a one-player game without changing any code. If you are making a multiplayer game, you have to use the Rewired Player-based API.

    Read the documentation and the Quick Start for information on how to set up Rewired.

    1. Create Players in the Rewired Input Manager.
    2. Set up Controller Maps in the Rewired Input Manager and assign defaults to your Players.
    3. Write a script to process input for your player. Create a public Player Id variable in your script which exposes the Player Id in the inspector. Use this Player Id to get the Rewired Player. Set the Player Id in the inspector in each of your player GameObjects so input is taken from the correct Rewired Player.

    Create 4 Players in the Rewired Input Manager. Use them as described above. As far as Rewired is concerned, each client PC only needs to be concerned with its own 4 players, not 8.

    Rewired Players are only for input and nothing else. You will likely have your own player class for tracking all 8 of your players in other ways, but as far as Rewired, you only need as many Players as it is handling locally.
     
    Rockwall33 likes this.
  43. Rockwall33

    Rockwall33

    Joined:
    Mar 4, 2016
    Posts:
    186
    Ah I get it now!!! Will do!! Thank you for answering my questions!! :D

    Thank you!! :D
     
  44. xelanoimis

    xelanoimis

    Joined:
    Oct 29, 2013
    Posts:
    30
    @guavaman: Thank you for your answer!
    I covered my previous functionality and I'll consider the things you mentioned for a more optimized flow.

    One more thing. I have assigned default joystick and keyboard maps in the Players menu. Each player has a "full scheme", a "shared left scheme", a "shared right scheme" and a "custom scheme" for joystick and for keyboard (8 in total). At runtime, when a joystick is connected (callback event) I enable the current scheme that the user has selected, and disable the rest. Is this the way to do it? Is it faster to use enable instead of Load? Or the default player maps system calls the same Load function when a default map is enabled?

    When selecting the "custom scheme" I let the user remap the buttons for his game actions. I export this in XML (ToXmlString) and keep this simple string (saved in a config for that player). Now I apply it back with AddMapFromXml, every time I enable the "custom scheme", which I do when the controller is connected (callback event). Is this correct use?

    And a question about the configuration of Rewired because I would like to expose them in an Input config for the user, to try in case something is not working for him. The docs say that Rewired is "reset" if the input source or if useXInput is toggled. What is the impact of such a change? Are any dlls loaded/unloaded? Right now i read the user setting from my config when my input wrapper is initialized (awake). I give those settings to Rewired at this point but this is after Rewired was initialized (with settings selected as default in Unity). Can this be an issue? Like if Rewired load dlls used for default config (dinput or xinput) and the user config changes it to raw and loads again. If he has a problem with the default setting (missing dll) I don't want him stuck before I get the chance to change the input source. So far it seems I can't give these settings to Rewired before it's initialized. Any thoughts on this?

    What is the safest / recommended default config for Windows? (like disableNativeInput=true, windowsStandalonePrimaryInputSource=Raw, useXInput=true, nativeKeyboardSupport=true)

    Thanks!
     
  45. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    Loading as needed is better IMO. Clear or remove the maps when switching modes and load the maps you want to use instead. Load is called when 1) the Player is created and defaults are loaded 2) when a Joystick is assigned to the Player. In the case of saved XML user data, this is loaded after the defaults are loaded and replaces them when using UserDataStore.

    Yes. The entire system is flexible enough to use it how you want, but that's the same way I use it in the examples and add-ons such as Control Mapper.

    Although, instead of "enabling" the custom scheme, I would think of it as switching to the custom scheme.

    This is explained in the API documentation of Rewired.Reset:
    http://guavaman.com/projects/rewired/docs/api-reference/html/M_Rewired_ReInput_Reset.htm

    Giving Rewired settings before it's loaded is done through the Rewired Input Manager configuration UI. This is instead of a manual ini file. I do not recommend you try to replace Rewired's configuration system with an ini system of your own.

    I see no way the user could get stuck. Neither Direct Input nor XInput will initialize if the DLLs are not preset. The system will fall back to lesser settings in that case and log it. This is already handled by Rewired.

    The default settings that appear in the Rewired Input Manager are the recommended settings for each platform. Windows is Raw Input, XInput, Native Mouse Handling, Native Keyboard Handling, Enhanced Device Support.
     
  46. xelanoimis

    xelanoimis

    Joined:
    Oct 29, 2013
    Posts:
    30
    thank you for your detailed answer!
     
  47. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,459
    Hi @guavaman and @Steve-Tack

    What happens when you cross a Puma controller and a Farm controller? This is cool.

     
    Rockwall33 and guavaman like this.
  48. Rockwall33

    Rockwall33

    Joined:
    Mar 4, 2016
    Posts:
    186
    Hey @guavaman,

    So I understand alot of it, thank you for your help!! :D

    Though how can I get one input line into a script, when a few input buttons are in a few different scripts? I put using rewired; My code is all there (excluding rewired), but I cant get GetButtonDown (or GetAnyButtonDown). I looked at the example and api reference. Is there a way to distribute inputs through different scripts on the same player prefab?

    Thank you!! :D
     
  49. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    I don't understand your question.

    To get input:
    1. Your script needs a Player Id. Ideally set this in a public variable so it can be set in the inspector.

    2. Your script needs to get input from the Rewired Player:

    bool fireDown = ReInput.players.GetPlayer(playerId).GetButtonDown("Fire");

    3. Your script processes the input:
    if(fireDown) {
    // Check permissions to see if your unit is allowed to fire first
    // Fire
    }

    Getting input is covered in the documentation here:
    http://guavaman.com/projects/rewired/docs/HowTos.html#get-input
     
    Rockwall33 likes this.
  50. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    3,886
    That's fascinating and strangely mesmerizing.