Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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:
    5,605
    2020-05-09_23-43-07.gif

    Yes.
    • Every GameObject in the hierarcy must have a Rect Transform.
    • Every GameObject including the Canvas contained underneath the Control Mapper Game Object must have the Rect Transform settings set properly. This example has all Rect Transforms set to Stretch, Stretch with Left, Top, Right, and Bottom to 0.
    • Whatever settings you have for each Rect Transform determines where and how the rect of the containing Rect Transform will be rendered.
    Control Mapper exists on a Unity UI canvas. There isn't anything special about it. This is all bog standard Unity UI.
     
    Last edited: May 10, 2020
  2. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    331
    Thank you for the hint about time slicing. I guess it doesn't work though :D In all fixed updates I always get the same delta as in the last update...
     
  3. Why485

    Why485

    Joined:
    Jun 30, 2013
    Posts:
    45


    Is there something missing in this? This is the default ControlMapper prefab, but I changed out the ControlMapper to use a RectTransform. Nothing appears when it is a child of the Canvas, which is just a default new Canvas. It only appears when it's standalone.

    Even in a completely empty and fresh project with nothing other than Rewired in it, I see this same behavior. This is 2019.3.7f1.

    Edit:
    I found my mistake. I hadn't noticed that specifically the Canvas under the ControlMapper was set to lower left. When I set it to stretch with the correct settings. That fixed it. Thank you very much!



    Edit 2:
    Well, sort of. In the fresh test project, that seems to work, but for some reason a seemingly identical setup doesn't seem to work in my own project. This is probably my fault, but I'll update this post if I find something.

    Edit 3:
    Yeah I'm not sure what's different. I follow the exact same steps to create a brand new ControlMapper along with a brand new Canvas, do the same steps to convert it to RectTransform and then set the child canvas to the correct stretch settings, but for some reason it doesn't work in my own project. The only way I can make the canvas display, is by toggling the canvas on/off after the game has started. I'm not sure why that fixes it.

    Edit 4:
    I think I found the reason. For whatever reason, when I make a ControlMapper in my project, the scale of the Canvas under the ControlMapper is all zeroed out. Resetting this to 1, 1, 1 makes the ControlMapper canvas appear as it should, and as it does in the fresh test project. Maybe I accidentally messed up the prefab at some point. Either way, this is solved now. Thanks again!



     
    Last edited: May 10, 2020
  4. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    That's using Unity's new input system? Well that's always going to be the case if only one Fixed Update runs per Update. If Fixed Update is running slower than the render rate, you'll have 1 Fixed Update running for multiple Updates. In that case, Fixed Update should report the cumulative mouse delta value over all those Update Frames. If Fixed Update is running faster than the render rate, you'll have multiple Fixed Updates running for 1 Update. In that case, without timeslicing (Rewired) you should see the same Mouse delta value as the 1 Update that cycle in the first Fixed Update and 0 in all Fixed Updates after during that cycle. With timeslicing, you should see that value from Update divided up among the Fixed Update frames that cycle.

    If you really are just getting the same delta value in every FixedUpdate frame, then that's not going to work correctly and will lead to mouse input studdering as the frame rate changes because it's either throwing away data (when Fixed Update runs slow) or duplicating data (when Fixed Update runs fast). That's not going to work. If that's what you're seeing, Rewired will definitely handle it better than that.
     
    Last edited: May 10, 2020
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    It isn't by default. It's unmodifiable because of the Canvas component which sets those values for you and doesn't let you change them. The moment you drop the GameObject inside another parent Canvas, the child Canvas is invalidated and reverts to the default of lower left because the top-most Canvas becomes the master.

    You probably didn't mess it up. Most likely, Unity did. Ever since they moved to the new prefab workflow in 2018.3, people have been reporting (including myself) intermittent problems with data serialization, especially with Control Mapper, for some unknown reason. This almost always manifests as missing inspector references under the Advanced foldout, but it really could affect any serialized data. It especially seems to have problems with GameObjects that were created in old versions of Unity before the new prefab workflow, like Control Mapper. I've also seen similar problems happen with GameObjects that contain Text Mesh Pro components that were created or saved using an old version of Text Mesh Pro and then loaded in a new version. That was happening to me with the TMP version of Control Mapper and I was forced to find the oldest compatible combination of Unity + TMP I could find that wouldn't load incorrectly in the newest version and use that as the base minimum version. Trying to maintain compatibility with old and new versions of Unity, and now even moreso the Package Manager assets, it's pretty much a gigantic mess of trial and error.

    There are also other times serialized data can get corrupted like when upgrading the Unity project or when upgrading packages from UnityPackages (asset store).

    https://guavaman.com/projects/rewired/docs/KnownIssues.html#serialized-data-corruption-after-import
    https://guavaman.com/projects/rewir...ialized-data-corruption-after-upgrading-unity
     
    Last edited: May 10, 2020
    Why485 likes this.
  6. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Rewired 1.1.34.1 is available on the Unity Asset Store.

    See Updating Rewired before updating.

    Release Notes:

    1.1.34.1:

    Changes:
    - Added Rewired category to component menu.
    - UnityInputOverride: Made additional functions re-route to Rewired instead of passing through to UnityEngine.Input (anyKey, anyKeyDown, mousePosition, GetKey, GetKeyDown, GetKeyUp).
    - Windows Standalone, Raw Input: Added workarounds to try to prevent calling the Windows HidD_GetProductString function on HID devices until the device has been determined to be a supportable HID device in an attempt to avoid a 5-10 second stall when this function is called on certain problem HID devices. This issue is being reported with increasing frequency, I can only assume due to a new bug/change in a recent Windows update that affects a variety of different HID device types. This is not an issue with Rewired, it is an issue with the device, its driver, and/or Windows. This is merely an attempt to plaster over the problem so I don't keep getting this reported to me as an issue with Rewired.

    Bug Fixes:
    - Fixed bug when replacing an Action Element Map keyboard key binding with the same keyboard key causing ActionElementMap.elementIdentifierName to return a blank string. Bug was introduced in 1.1.33.0.
    - Fixed bug when changing Action Element Map modifier key values manually causing ActionElementMap.elementIdentifierName to not be updated. Bug was introduced in 1.1.33.0.
     
    AlejMC and Bartolomeus755 like this.
  7. AlejMC

    AlejMC

    Joined:
    Oct 15, 2013
    Posts:
    149
    EDIT: My bad, the notification alert was already late and didn't see your last message, I see that this has just been added.
    Thanks a lot for that!

    Well it really is just small suggestion, so maybe I wasn't clear enough, my bad. It is more about 'where to find things on the inspector' rather than class naming conventions.
    For example, adding attributes at the top of each Monobehaviour-based class:
    [AddComponentMenu("Rewired/Tilt Control")]


    Will start nicely grouping those classes inside a Rewired 'subfolder' without touching the class naming themselves (since it's done already for other tools like MenuBar at the top for installing, setup, etc...)


    At the same time, the 'parent' TouchController can start adding very easily child controls with one single clicks too, so there's that. It would mostly useful when working with detached deeply nested prefabs where an object might get a new controller attached.


    On another minor thing, is there a reason why Tilt Control doesn't have a 'GetValue or GetRawValue' interface like the others? I could use the gyroscope on my own and post process the values themselves but I would rather use the neatly packed and 'proof-ed' Rewired player/smoothing/etc flow.
    I guess I could also subscribe to an axis action 'on update' event and get the axis there, but it makes this class in particular a tad more convoluted to extend with custom sibling monobehaviours.
     
    Last edited: May 12, 2020
  8. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Tilt Control does not use the gyro. It is an extremely basic tilt control that uses the accelerometer only and therefore is not accurate. If you have access to a gyro, use it instead.

    All you would get out of a GetValue function is a joystick-like -1 to +1 value -- the same one you get from the Player's Actions. All you would get out the the raw value is the exact same thing that is input by the delegate assigned to SetAccelerationSourceCallback, which is by default, UnityEngine.Input.acceleration. Rewired's controls are intended to be used through Actions, not through directly using the value in the control. You can already do that with any touch/tilt control you get on the asset store. There's no reason to use Rewired's controls if you're just consuming the values from them directly.
     
    AlejMC likes this.
  9. funselektor

    funselektor

    Joined:
    Oct 11, 2013
    Posts:
    105
    Hey Guavaman, is it possible to detect if a connected controller is a racing wheel?
    Since there is a special racing wheel template, I'm hoping there is as I'd like to use special input settings only for wheels.
     
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Right on the documentation page about Controller Templates:
    https://guavaman.com/projects/rewir...determining-if-controller-implements-template

    This will not work with unrecognized wheels.
     
    funselektor likes this.
  11. funselektor

    funselektor

    Joined:
    Oct 11, 2013
    Posts:
    105
  12. funselektor

    funselektor

    Joined:
    Oct 11, 2013
    Posts:
    105
    Sorry to bug you again Guava, but I have a player on Windows 10 who's Xbox One controller won't accept input and it's running through steam.
    These are the relevant logs, but it looks like it's getting disconnected right away and also it looks like it can't find the XInput library. They are a unity dev so they may have a funky input system setup, but wanted to check in case.

    Joystick reconnected ("Controller (XBOX 360 For Windows)").

    Unloading 5 Unused Serialized files (Serialized files now loaded: 0)
    Joystick disconnected ("Controller (XBOX 360 For Windows)").

    UnloadTime: 1.833800 ms
    Searching for compatible XInput library...
     
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    None of this log information is useful.

    Those joystick connected messages are from Unity, not Rewired.
    Rewired no longer logs it when it finds an XInput library to use. The latest version doesn't even log the searching line.

    Every single Xbox controller / Steam issue turns out to be the same thing: Controller assignment. A virtual device is being assigned to the Player and not the controller they're trying to use. This happens over and over and over again. This recurring issue is why this is listed on the Best Practices page:

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

    Controller Assignment:
    • Always provide some means for your users to change controller assignments. It is especially important if you are making a multi-player game. You cannot know what devices, physical or virtual, will be present on a user's system, appear as Joysticks to Rewired, and be assigned to a Player. Device emulation software (VJoy, DS4Win, SCPToolkit, etc.) and certain device drivers can and frequently do cause problems by creating extra, non-functional virtual devices. Allowing the user to make their own controller assignments solves this issue as well as making it possible for users to swap controllers, etc. You can either include Control Mapper directly in your game or create your own system.
    • Max Joysticks Per Player to 100 so all controllers attached to the system may be used by the player.
     
  14. funselektor

    funselektor

    Joined:
    Oct 11, 2013
    Posts:
    105
    Hmm, I checked and the steamworks backend is using following the best practices including disabling the Generic Gamepad Configuration and has controller remapping already.
    Usually if their buttons are messed up I tell them to go remap them, but in this case not even the maps for the UI respond at all, so I'm a bit perplexed.
     
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    If the user has some software that is creating a virtual XInput device installed, that device is probably going to be assigned to the user making absolutely nothing work. Steam settings aren't going to change that. What I told is the most likely cause. Do you have a way for the user to choose which controller(s) they're using or are you just relying on auto-assignment?
     
  16. funselektor

    funselektor

    Joined:
    Oct 11, 2013
    Posts:
    105
    Ok noted, this issue is very rare but I'll ask about this. It's using auto-assignment, but choosing controllers might add complexity to the UI so I'd rather not. But I can ask them to plug in and unplug controllers to see if there's any other ones active (perhaps virtual too).
     
  17. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    I understand everyone wants their PC game UI's to appear like a console game, but this is a mistake, and unfortunately a very common one. It's just not feasible to treat a PC like a console because the PC controller situation is vastly more complicated than that of consoles with virtually unlimited unknowns about what software and hardware is being used by the user.

    This problem is not really that rare. I see complaints with the symptoms quite often on Steam support forums. If the game doesn't allow the user to choose which controllers to use, this problem is guaranteed to show up.

    The user may not even know they have a virtual device present on the system. For examples, the 3dconnexion space mouse line of 3d mice installs a virtual HID joystick as part of the driver. This device will be seen as a joystick and will be assigned to a Player. This HID device is present whether or not the space mouse is even plugged in. You simply cannot know what they will have installed on their systems so you have to provide them a means to work around these problems without resorting to having them search through Device Manager for devices to remove.
     
    Last edited: May 18, 2020
  18. a-t-hellboy

    a-t-hellboy

    Joined:
    Dec 6, 2013
    Posts:
    180
    Hey there,

    I want to show Gamepad Template keys according to category and action when joystick is not plugged into the PC.
    How can I do that ?

    I make an instance with this piece of code:
    Code (CSharp):
    1. var templateActions = ReInput.mapping.GetControllerTemplateMapInstance(GamepadTemplate.typeGuid, categoryName, "Default");
    Then access to ElementMaps but it is not like ActionElementMap which can access to action name and element name.

    BTW I can get action name by:
    Code (CSharp):
    1. ReInput.mapping.GetAction(ElementMaps[i].actionId)
    But I don't know how to access to element of each action on Gamepad Template.
     
  19. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    There is no way to do what you want to do without jumping through hoops.

    Rewired was never designed to give you access to Controllers when they are not present in the system. Why? Because Rewired cannot possibly know what controller definition and internal variant applies to that controller without it first being detected by the system and information provided by the system analyzed to figure out which Controller Definition applies to that Controller. It gets very complicated when you're using multiple input sources (XInput + Raw Input) and have many variants that may apply to that controller depending on all kinds of factors (driver, firmware, different revisions of a device, which input source will be used to handle that device, etc.). Each controller definition contains within it dozens of possible configurations depending on the platform, input source, and even things like Unity version, Android version, and other things depending on the specifics of the platform in question. The Controller recognition system is based on matching known, pre-defined metadata to a system-level device. Only when this device is present can that information from the device be obtained and used to find matching metadata in the Controller Definition.

    I have implemented various hacks over the years to try to make this seem possible because people wanted it, but it really simply isn't possible. The methods you call to get a Controller Map instance using a Guid cannot be guaranteed to match to the Controller that will actually be created were you to actually connect it. It can only make a best guess as to which variant might be applicable. When you do that, it generates a Controller Map and even bakes in fake element information like the element name and element indices. These are also not guaranteed to match what the actual device will have when connected.

    A Controller Template could conceivably be accessed when no Controller is present because the Template Identifiers are constant, but a Controller Template in Rewired is completely dependent upon and integrated with the Controller it belongs to. You access Controller Templates through Controller.GetTemplate<T>. It is not a standalone entity. It is also essentially a map, and if the Controller it belongs to cannot be loaded because it cannot be known beforehand, the mappings are invalid because it can't know what Template element should map to what Controller element.

    You have three options:
    1. Get the Element Identifier name from the element identifier CSV file: https://guavaman.com/projects/rewired/docs/HowTos.html#display-glyph-for-action-template-specific

    2. Match the element identifier id to the constants in the static class for the Template in question and provide your own string name based on this information: https://guavaman.com/projects/rewired/docs/api-reference/html/T_Rewired_GamepadTemplate.htm

    3. Access to the ControllerTemplate data file itself by linking it in the inspector to something and read the list of Template Element Identfitier names from it.
     
    Last edited: May 20, 2020
    a-t-hellboy likes this.
  20. a-t-hellboy

    a-t-hellboy

    Joined:
    Dec 6, 2013
    Posts:
    180
    But when we create Gamepad Template, everything is specified. Why can't access to exact element names ? Like Action Bottom Row 2.
     
  21. AlexisTB

    AlexisTB

    Joined:
    Jul 26, 2017
    Posts:
    20
    Hello, I am having an issue with trying to make single Joy-Con controllers maps be set for the vertical grip style (when connecting a controller with the applet, the only option seems to be the horizontal mode), I have tried multiple different arrangements of settings but nothing worked. If the only option is to do a remap i'll do that.
     
    Last edited: May 21, 2020
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Because I chose not to bake element identifier names into the map like was done for Action Element Map. This baking was only done in the first place to save lookups and be able to bake partial element mappings with the sign into the string name. This was never a great solution and makes things like translation more difficult, requires that the map contain a reference to the Controller so that this string can be baked when bindings change, etc.
     
    Last edited: May 21, 2020
  23. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    The Nintendo Switch plugin is covered by NDA. You are not supposed to be posting information from the plugin or asking for support in a public forum. Use the support form on the website for Nintendo Switch support.
     
  24. csofranz

    csofranz

    Joined:
    Apr 29, 2017
    Posts:
    1,556
    Hi, does rewired support the Virpil hi-end flight controls? We have just received a Constellation Alpha Stick and Mongoose 2 Throttle and I'm tasked with integration. Can't seem to find the any templates for them, though.

    Any help appreciated.
     
  25. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    The controllers with explicit support is here:
    https://guavaman.com/projects/rewired/docs/SupportedControllers.html

    It contains all the information about what controllers work with Rewired and what to do when they're not explicitly supported.

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

    Denchi_

    Joined:
    Dec 17, 2018
    Posts:
    23
    Hi!

    I'm looking for something that will let me read out pressed keys while the application window is not in focus.
    I've noticed the ignoreInputWhenAppNotInFocus-flag, but the documentation says:

    Is this going to work reliably on Windows and macOS for regular keyboards (laptop built-in and external USB) using Rewired?

    Also, have there been any issues with anti-virus software interfering with this (since it's keylogger-like behaviour)?

    Thanks!
     
  27. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    It will not work on Mac OS. See the chart to know what types of input are native and what rely on Unity Engine Input for each platform and input source:
    https://guavaman.com/projects/rewired/docs/Overview.html#tested-platforms

    It will only work on Windows with Raw Input and Native Keyboard Handling enabled. I cannot speak to anti-virus software.
     
  28. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    504
    Hello about this: https://guavaman.com/projects/rewired/docs/Integration.html#Cinemachine

    I want to be able to assign which rewired player has camera control. If I use extra mappings I would have to find a way to change the axis names at runtime.

    I guess its done this way for split screen where everyone controls their own camera but in this case in addition to doing split screen there will be times were only one camera is active and its control has to be switched from player to player.

    Is there a way to do this?

    Additionally, we even discussed messing with the players and giving them all control which would require extra mappings all set to the same axis names but the bridge complains about "duplicate axis names".
     
    Last edited: May 26, 2020
  29. Undertaker-Infinity

    Undertaker-Infinity

    Joined:
    May 2, 2014
    Posts:
    112
    I finally got around trying this out again!
    What I want is for a touch that begins at the center of the touchpad and slides towards the right, to yield 0,0 at the center and then 0,0 at the edge of the deadzone, then 1,0 at the right edge of the touchpad, linearly (so half of the way between the edge of the deadzone and the edge of the touchpad is 0.5,0).
    What I get right now with Vector+direction is 0,0 at the center (good!) then quickly slides to 0.998,0 (too soon, very close to the center) then slowly to 0.999,0; which sounds like it's the expected behavior with the direction setting. The other options are pixels (distance in actual pixels?), screen (distance in screen units) and physical (what is this?) and none seemed to give me the numbers I'm looking for (maybe I'm wrong?). On the mode setting: delta seems to be meant for controlling a cursor, while screen position just gives me an absolute screen position and Vector from Initial Touch is not what I'm looking for right now.

    EDIT FOR CLARITY: and if start a touch halfways between the right edge of the dead zone and the right edge of the touchpad, I want to get 0.5,0

    I did try joystick and worked beautifully until I tried to hide the actual stick. The behaviour I want is very close to the stick, but I want to show a d-pad instead and hiding the touch joystick (either disabling the image or removing the object) made it behave as if the indicators were just regular buttons, which didn't react outside of their sprites (so no diagonals, for example); I also wanted different sprites for indicator, as mine have some lighting hints to make them look like a physical d-pad.

    Thanks for your help :)
     
    Last edited: May 26, 2020
  30. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Trying to add multiple copies of the same Unity Action name to the Rewired Cinemachine Bridge cannot work. The bridge is nothing more than a delegate. Cinemachine calls GetAxis("Name") on this delegate to get the value of the axis it wants. The bridge contains a dictionary that maps from Unity axis to Rewired Action. When GetAxis("UnityAxis") is called on the bridge, it looks up GetAxis("RewiredAction") instead. You cannot have more than one Unity Axis per Action because a dictionary can only hold one copy of the same key. It is not written to give the result of Player-Action values from multiple Players for the same Unity Axis key.

    There is no way to change the bridge Player bindings at runtime. I suggest you copy and re-write the bridge to suit your needs. The only other way would be to use different Axis names for controlling the camera with different Players and change the Axis name the camera uses depending on the Player in control.
     
    Last edited: May 26, 2020
  31. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    @guavaman I'm using the Rewired Consts and it's worked well until I've now added new Actions and I'm attempting to export the consts again to overwrite the existing RewiredConsts.cs. I'm able to "export" and "overwrite" the file, but the new exported file does not contain the new Actions I've added...

    Any idea what I've done wrong?
     
  32. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    What you are describing IS a Joystick. It's not a Touch Pad. The Touch Pad is not an equivalent control to the Joystick. You're not going to get what you want using the Touch Pad.

    You cannot disable the Image component or the GameObject and expect it to continue working. That's not how Unity UI works. Unity UI uses raycasting to determine what object you're touching. Raycasting works through the Image component. An Image and its Game Object must be enabled in order for the raycast to hit the image so it detects what object you're touching. Rewired's TouchInteractableTransitioner Visible toggle changes the Image's alpha channel to determine visibility. The Image and GameObjects are never disabled.

    A Touch Joystick with Snap Stick To Touch and nothing set for Stick Transform will do exactly what you describe. Hide When Idle may or may not be applicable. Designing your effects is up to you. You can do that just as I did with the joystick examples using the events provided by the Touch Joystick to trigger some effect on a component below.
     
  33. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    That is not possible. Close your Rewired Input Manager and reopen the prefab or Game Object. If the Actions are missing, it's a serialization issue because of Unity's new prefab workflow which still has rare unsolved edge cases where the data won't get saved if you open the input manager without first manually opening the prefab and when you take some specific action that causes the data to be lost when you take some action it cannot detect while focus is still in the editor. A prime example of this was pressing Play directly after interacting in the editor without ever doing anything else like clicking out of the window. I caught this and many other edge cases, but I know there is still one out there. There was also the exact same edge case before of writing out the constants immediately after you made those Actions. The prefab has not been saved at that point and the moment you overwrite the CS script, Unity compiles, clearing the app domain, causing the unsaved prefab changes to be lost. Rewired cannot sit there saving the continuously, so it has to trigger saves off of certain detectable Actions. I already fixed this edge case, so I'm guessing you're using an old version of Rewired if this is what's happening to you. Had I known Unity would be changing this prefab workflow to work like this when I designed Rewired, I would have made the Rewired Input Manager store all its data in a scriptable object, not in the GameObject and would have avoided the entire mess of the new prefab workflow system. Too late to change that.

    The only other possibility is you are saving over a different file in a different directory.

    The Actions are written directly from the exact same serialized data displayed in the Rewired Input Manager with no steps or in-betweens. The data in the input manager is directly read and written to strings.
     
    Last edited: May 26, 2020
  34. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    353
    @guavaman I restarted my editor and still had the actions, so not a serialization issue it would seem. However, I updated to the latest release on the asset store and this time it exported the RewiredConsts.cs correctly. Just glad its working now! Thanks
     
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    The change was made in 1.1.29.2:

    1.1.29.2:

    Changes:
    - Improved detection of rapid button taps at lower frame rates.

    Bug Fixes:
    - Rewired Editor saves prefab before exporting constants so changes made before editor recompiles are not lost. (Unity 2018.3+)
    - Windows Standalone, XInput, Direct Input: Fixed issue causing fast button taps to be missed at high input thread frequency and low frame rates (increased buffer size).
     
    rxmarccall and f1chris like this.
  36. Derakon

    Derakon

    Joined:
    Jul 3, 2019
    Posts:
    20
    EDIT: fixed; see bottom of message. Rest preserved for posterity.

    I'm having trouble getting Rewired to enable the mouse map I set up. Keyboard and controller both work fine.

    Mouse map in the Rewired editor:
    https://i.imgur.com/ElERezX.png

    Code attempting to find the map:

    Code (CSharp):
    1.         player = ReInput.players.GetPlayer(0);
    2.         foreach (var map in player.controllers.maps.GetAllMaps()) {
    3.             Debug.Log($"Player has map {map} enabled? {map.enabled} type {map.controllerType.ToString()} category {map.categoryId}");
    4.         }
    5.         var mouse = player.controllers.maps.GetMap<MouseMap>(0, "Combat", "Default");
    6.         Debug.Log($"MOUSE? {mouse}");
    Output of that code:

    Code (CSharp):
    1. Player has map Rewired.JoystickMap enabled? True type Joystick category 0
    2. Player has map Rewired.JoystickMap enabled? True type Joystick category 2
    3. Player has map Rewired.JoystickMap enabled? True type Joystick category 3
    4. Player has map Rewired.KeyboardMap enabled? True type Keyboard category 0
    5. Player has map Rewired.KeyboardMap enabled? True type Keyboard category 2
    6. Player has map Rewired.KeyboardMap enabled? True type Keyboard category 3
    7. MOUSE?
    Is there something special I need to do to indicate to Rewired that the mouse should be enabled? I haven't had to do anything in particular to enable keyboard/joystick. Note that
    player.controllers.hasMouse
    is true.

    EDIT: I have been reminded that after you add a new input map, you have to assign it to a player in the Rewired Input Manager. It's been so long since I set up the keyboard and joystick maps that I'd completely forgotten about this step.
     
    Last edited: May 26, 2020
  37. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    504
    I will modify the bridge, thank you!
     
  38. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    That was what your output text was telling you. Enabling a controller map and loading a controller map into a Player are two different things. No Controller Map can be enabled in a Player if it doesn't contain that map. It won't contain that map unless you assign it to be loaded on start or load it yourself in a script.
     
  39. Derakon

    Derakon

    Joined:
    Jul 3, 2019
    Posts:
    20
    Yeah, the issue here mostly is that it's been many months since I set up a new controller map, and I'd forgotten all the steps involved. It'd be nice if there were some kind of validation tool in the input manager that would tell you things like "this input is mapped to two different actions" or "no player has this map". I understand that they're not necessarily errors, but such a tool could be helpful for the most common use cases.
     
  40. Undertaker-Infinity

    Undertaker-Infinity

    Joined:
    May 2, 2014
    Posts:
    112
    I had a feeling this was the case. I want it to feel like a joystick but look like a d-pad. I guess I could determine relative position within the rect myself and send that to a custom controller.
    Thanks!
     
  41. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    There is nothing stopping you from doing what you want to do. Make it look like a D-Pad. What it looks like doesn't matter to the code. Use a Touch Joystick,. create a square with an Image component that covers the area for input so it catches the raycasts, leave it enabled, set the alpha to 0, use that as the joystick base and put your D-Pad under it. That's why I mentioned the image alpha in my last message. You are only limited by what Unity UI allows.
     
    Last edited: May 28, 2020
  42. a-t-hellboy

    a-t-hellboy

    Joined:
    Dec 6, 2013
    Posts:
    180
    Hey there,
    How can I get
    ActionElementMap 
    id after creating the new one with
    ControllerMap.CreateElementMap()
    ?

    I use ReplaceElementMap but it doesn't work.
    Code (csharp):
    1. ReplaceElementMap(new ElementAssignment(element.Info.Id, inputAction.Action.Id, false, element.ElementMapId))
    . I'm sure all the information which I pass are correct.
     
    Last edited: May 28, 2020
  43. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    Use an overload with an out parameter.

    https://guavaman.com/projects/rewir..._Rewired_ControllerMap_CreateElementMap_7.htm
    https://guavaman.com/projects/rewir..._Rewired_ControllerMap_CreateElementMap_3.htm
    https://guavaman.com/projects/rewir..._Rewired_ControllerMap_CreateElementMap_5.htm
     
    Last edited: May 28, 2020
    a-t-hellboy likes this.
  44. loliconest

    loliconest

    Joined:
    Sep 21, 2015
    Posts:
    31
    Hi man great asset! Is there a way to not write my control logic in Unity's Update() or FixedUpdate()?

    I'm getting issue with low framerate not able to detecting multiple input instances like double click, and I heard your asset directly read input from the OS instead of using Unity's input system, which can fix my issue, but if I just replace the Unity system with Rewired inside my Update() loop, it won't make any difference, right?
     
  45. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    No.

    See the FAQ:
    https://guavaman.com/projects/rewired/docs/FAQ.html#framerate-independent-input
     
  46. a-t-hellboy

    a-t-hellboy

    Joined:
    Dec 6, 2013
    Posts:
    180
    Hey there,

    For checking conflicts (For any kind controllers) I should use which
    ElementAssignmentConflicts
    overload ?
    I need conflicted action too.

    Actually I have tried those which I had thought they may work but non of them works.
     
  47. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    What function exactly are you trying to call and where are you getting the data you're trying to supply it with in an ElementAssignmentConflict struct?
     
  48. a-t-hellboy

    a-t-hellboy

    Joined:
    Dec 6, 2013
    Posts:
    180
    Right now, I use this one: https://guavaman.com/projects/rewir...ed_ElementAssignmentConflictCheck__ctor_8.htm
    and then use it in https://guavaman.com/projects/rewir...CheckingHelper_ElementAssignmentConflicts.htm

    I get input element information from
    PollControllerForFirstButtonDown
    and then pass some of them to
    ElementAssignmentConflictCheck
    .

    Pass polled element ControllerType to ControllerType of
    ElementAssignmentConflictCheck
    .
    Pass id of
    player.controllers.maps.GetFirstMapInCategory
    to ControlMapId of
    ElementAssignmentConflictCheck
    .
    Pass id of polled element to elementIdentifierId of
    ElementAssignmentConflictCheck
    .
    For action id of
    ElementAssignmentConflictCheck
    I store action id of clicked action for assingning new element and pass it to
    ElementAssignmentConflictCheck
    .
    Pass polled element AxisContribution to AxisContribution of
    ElementAssignmentConflictCheck
    .
    For controllerId and playerId, I think there is no issue.
     
  49. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,605
    And what exactly is not working?

    That overload is specifically for button assignments. Each overload has a description of what it is for:
    https://guavaman.com/projects/rewir.../T_Rewired_ElementAssignmentConflictCheck.htm

    Every property relevant to that conflict check type must be supplied. Properties that say (Optional) are optional, otherwise they are required.

    Is there a reason you're not using Input Mapper and doing this all manually? Input Mapper is a wrapper for this API that is far easier to use than polling manually and checking for conflicts.
     
  50. a-t-hellboy

    a-t-hellboy

    Joined:
    Dec 6, 2013
    Posts:
    180
    There is a conflict in my tests but it doesn't return anything.

    So for mouse, keyboard and joystick, I should implement different overloads ? Or that method which I use can be used for all of them ?

    Yup, I don't want tight coupling with your API actually and there is a abstract layer on it. But I will check it.

    BTW I don't still understand why it doesn't work for me. I tested this conflict on keyboard keys.