Search Unity

Rewired - Advanced Input for Unity

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

  1. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Here's their controller support page I found:
    https://clone-hero.fandom.com/wiki/Compatible_Controllers
     
  2. bcjordan

    bcjordan

    Joined:
    Sep 23, 2013
    Posts:
    34
    Some players find the "First center or zero all sticks and axes" in the remapping to be a bit confusing (and want to start pressing their desired button immediately). Is it possible to disable this step?

    & is there a reason disabling that step would be very unwise?
     
  3. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    No. It's there for a very good reason. If you remove it, you WILL get users complaining about axes being bound on stick releases and trigger releases. Control Mapper was designed to allow you to map any possible device without regard to its mapping range, inversion, or even if it has buttons or not (think flight pedals). Timeouts and other techniques to try to hide the need for this step are inaccurate and WILL lead to failures.
     
    Last edited: Apr 3, 2019
    bcjordan likes this.
  4. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,838
    EDIT: Actually, I just found this thread:
    https://www.reddit.com/r/xboxone/comments/5860ug/xbox_one_controller_vibration_motors/
    So this might just be how the controller is supposed to operate
    (This might not be an issue after all)

    I'm using the controller vibration ability of Rewired. Running on Windows10
    I tested it out using two different controllers: XBox360 controller(wired) and XBoxOne controller (wireless).
    For both controllers, the left and right motors seem to react differently.
    The right motor vibration is very smooth. But the left motor vibration is very jerky and motor feels to rotating slower.

    I'm using:
    rewiredPlayer.SetVibration (0, 1f, 5f);// for testing left motor
    rewiredPlayer.SetVibration (1, 1f, 5f); //for testing right motor
    Doing the test, I retrieve the vibration to verify the retrieve current vibration intensity is the same as what is specified when calling SetVibration.

    Running an additional test with very low vibration:
    rewiredPlayer.SetVibration (0, 0.10f, 5f);// for testing left motor
    rewiredPlayer.SetVibration (1, 0.10f, 5f); //for testing right motor
    Again, the right motor is smooth. But the left motor will feel to jerk on at full intensity for fraction of a second, then go to the specified intensity. The right motor operates as expected.

    Do you know if this is just the way the xbox controllers operate on windows? Or is there something else I should look at?
    Thanks.
    xboxOneController.jpg
     
    Last edited: Apr 3, 2019
  5. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Yes that is how the motors are designed. There is one strong motor and one weak motor in the device. The Dual Shock 4 is the same. This is pretty standard fare in gamepad vibration.

    The left motor should not jerk on for a fraction of a second. Are you setting these values every frame?
     
    ArachnidAnimal likes this.
  6. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,838
    Further test: this only occurs with my xbox360 controller. The XboxOne controller is fine.
    I conclude now it is just an issue with my particular controller.
    Thank You.
     
  7. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
  8. bcjordan

    bcjordan

    Joined:
    Sep 23, 2013
    Posts:
    34
    A prime example of why you and this project are awesome :) Thanks for the info!
     
    guavaman likes this.
  9. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    I just did testing on an Xbox 360 controller and an Xbox One and can't reproduce any problems so it may be faulty hardware.
     
    ArachnidAnimal likes this.
  10. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    I just finished testing this in Mojave 10.4.3. Sorry about the delay in checking this. It took me 19 solid hours to get Mojave up and running (and I ultimately wasn't able to do it on my Mac dev system which is on its last legs I think). I do not find any issue with the DS4 in either normal or Enhanced Device Support modes. The D-Pad works in both just as always. Could there be some new driver on your system affecting it? Did you check if the D-Pad worked using the Rewired/DevTools/JoystickElementIdentifier? (This doesn't show Enhanced Device Support version -- use Debug Information for that.) Or is it possible your controller is having a hardware issue?
     
  11. mdsitton

    mdsitton

    Joined:
    Jan 27, 2018
    Posts:
    66
    The game supports basically any guitars you can get connected to your pc in some way. Through various adapters and the like. Wii guitars with the raphnet classic controller adapter being one other popular choice. Most of these people have to map themselfs in-game. I think the issue with the GH:L guitar is that in order to get it working on windows you need to force the xbox 360 controller driver onto the device which if it was totally meant for the device it would automatically pick it up.
     
  12. GordGames

    GordGames

    Joined:
    Nov 7, 2016
    Posts:
    32
    Hello!

    I get the warning "Rewired: Only one Rewired Input Manager may exist in a scene. This additional Rewired Input Manager game object will be deleted. You may see this warning if you are loading a new level that contains a Rewired Input Manager. If that's the case, you can safely ignore this warning. This warning will never be logged in a build." which I ignore as instructed, but then get an error: "You cannot have multiple Rewired Cinemachine Bridges enabled in the scene."

    Is there something I should be doing?


    EDIT: Nevermind! As per the input manager documentation (http://guavaman.com/projects/rewired/docs/InputManager.html) I should have added a Rewired Initializer to each scene. That took care of my problem.

    TL;DR: RTFM
     
    Last edited: Apr 3, 2019
  13. Radu392

    Radu392

    Joined:
    Jan 6, 2016
    Posts:
    210
    Hey, first off, great asset!

    I'm currently localizing the game using I2 Localization from the asset store. Is there any proper way in localizing the rewired asset?

    The languages will be many: English, French and other latin languages, cyrillic based languages and asian languages.
     
  14. atariboy

    atariboy

    Joined:
    Aug 21, 2013
    Posts:
    12
    Hi, I'm making a game for obscure chinese Android TV box, and it uses KEYCODE_CLEAR (28) for OK button. I tried using keyboard map and assign Clear button to action, but it doesn't work. Can I somehow specify the android keycode for action?
     
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    There is no reason why KeyCode.Clear wouldn't work if the device is returning KeyCode.Clear through UnityEngine.Input. As always:
    http://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information

    1. Determine what is being activated on the Keyboard.
    2. Determine if the Keyboard is assigned to the Player.
    3. Determine if the Controller Map you think is being used is actually being loaded, is enabled, and is assigned to the Player.
     
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    No. There is no localization system in Rewired. One of a billion things on the wish list.

    You get the string or id values from whatever you want to localize, make a lookup table, and get the value from the lookup table before displaying it on the screen.
     
  17. bcjordan

    bcjordan

    Joined:
    Sep 23, 2013
    Posts:
    34
    What's the best way to slow down the repeat rate for the analog stick when used for UI navigation? Having a bit of trouble finding the right setting. The D-pad navigation feels good as-is though.
     
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    The settings in the Rewired Standalone Input Manager inspector which mirror and are taken directly from Unity's system:
    http://guavaman.com/projects/rewired/docs/RewiredStandaloneInputModule.html#inspector-options
    Input Actions Per Second
    Repeat Delay

    Also here:
    https://docs.unity3d.com/Manual/script-StandaloneInputModule.html
     
    LDSdev likes this.
  19. OldYawn

    OldYawn

    Joined:
    Oct 23, 2016
    Posts:
    1
    Hi, how does your add-on handle different types of keyboards? My primary concern is having the game ready for people in foreign countries. Will someone with a QWERTY keyboard have the same seamless experience as a user with a QWERTZ keyboard by default, or would the user need to go in and swap the Y and Z key for example? Will someone who is French need to go digging and reassigning into the options just because they naturally own a keyboard with a different layout?
     
  20. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    I believe it just wraps unity input for keyboard handling.

    You can download the free trial version of Rewired and see how it works.

    http://guavaman.com/projects/rewired/trial.html
     
  21. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    606
    Last edited: Apr 4, 2019
  22. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    @longroadhwy is correct. Rewired does not have special handling for non-standard layouts. Its keyboard handling is designed to mirror UnityEngine.Input's keyboard handling exactly including the use of their same KeyCodes. The only platform that offers native keyboard input is Windows. All others wrap UnityEngine.Input.
     
  23. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Hi,

    Thanks for posting the video.

    Rewired's editor system doesn't use a single bit of native code and therefore any crash like this is something going wrong in Unity or some underlying system (System.IO or one some other core dependency.)

    Your video shows it initially crashing during the first installation step. Absolutely nothing happens in this step except the creation of a single, very small asset file using the Asset Database in Unity that contains nothing but version numbers. Then you show in another attempt it getting up to Control Mapper install and it crashing on importation of a prefab. Both of those indicate to me (I'm basically guessing based on symptoms) Unity is having a serious problem writing assets to its asset database. This is clearly a problem in Unity and not Rewired. The process of importing assets or creating assets is completely in the hands of Unity.

    The only possibility you're going to have to figure out why its crashing is trial and error. All of this is just blind guessing:
    1. Reboot the computer
    2. Disable anti-virus
    3. Close all other applications running in the background
    4. Unplug any unnecessary devices
    5. Reset the Unity editor's window layout (Yes, I saw a message from Hippocoder saying Unity 2019 was a crash a minute. A few days later he posted that resetting the editor UI layout solved all his problems.)
    6. Close the editor, delete the Library folder.
    7. Search the forum for crashes on file or asset import.
    8. Report the crashes to Unity.
     
  24. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    606
    Thanks for the response. It had to do with a 3rd party shader.
     
  25. bcjordan

    bcjordan

    Joined:
    Sep 23, 2013
    Posts:
    34
    I believe this is a Unity-level controller question but wonder if anyone here might have ideas -- is there a way to lower the step size of a controller-interactable Slider? Having an issue where the default step size makes it hard to really fine tune a value with a controller. Not a huge deal if players need to fall back to mouse for fine-tuning.

    One person on Unity Answers suggested it might require a custom slider component. Hm!
     
  26. bcjordan

    bcjordan

    Joined:
    Sep 23, 2013
    Posts:
    34
    Thanks for this.

    One somewhat odd thing I'm seeing, when navigating with the left joystick, the delay occurs only on the first movement (desired), so it goes move, initial wait, move @ repeat speed.

    When navigating holding down a D-pad direction, the delay occurs both on the first movement AND on the second movement (so it seems to go move, initial wait, move, initial wait [possibly half the duration?], move @ repeat speed).

    Thinking about ways to have a separate setting for D-pad vs. Joystick, since D-pad feels better with delay=0, and joystick feels better with delay between 0.2 and 0.4.

    Any thoughts on alternative approaches to resolve this discrepancy?

    Definitely usable as-is, possible there's some other issue with my setup or I'm over-optimizing here.
     
  27. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Disable Digital Axis Simulation on the Input Behavior assigned to your UI Actions:
    http://guavaman.com/projects/rewired/docs/RewiredEditor.html#InputBehaviors

    http://guavaman.com/projects/rewired/docs/Troubleshooting.html#digital-axis-smoothing
     
  28. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Glad you figured it out.
     
  29. NobleRobot

    NobleRobot

    Joined:
    Jan 14, 2016
    Posts:
    56
    I have a feature request for
    Player.GetAnyButton()
    .

    I was trying to implement a function that monitors for any device input from any assigned device, in order to change on-screen button prompts if a user switches between devices mid-game. `GetAnyButton()` seems designed for this, and it also captures Axis input, however, it only returns `true` if the value of the input is a positive value, which is easy enough for gamepad buttons and keyboard keys, but it means that axis and d-pad input return `false` when pressing left or down (because the value is -1).

    It drove me crazy until I discovered
    GetAnyNegativeButton()
    which seems to be designed to solve this for me. In general, I find that there's always something available to solve any problem I have (which is why I love Rewired!)

    But ultimately, I don't understand the use-case for this implementation. I can see a use case to collect "all buttons but no axis" or "all buttons and all non-zero axis values," but why would anyone ever want to collect "all buttons plus 'up' and 'right' on all axis"?

    This should be easy enough to abstract this in my project, but wouldn't it be better if `Player.GetAnyButton()` could accept an argument, like a bool called
    includeNegativeValues
    (defaulted to false in order to not break existing projects)?

    Alternately, perhaps
    Player.GetAnyButton()
    could exclude "axis used as buttons" and a separate
    GetAnyAxis(bool includeNegativeValues = true)
    could supplement it?
     
  30. mdsitton

    mdsitton

    Joined:
    Jan 27, 2018
    Posts:
    66
    We certainly support way more than just Windows 10. Windows 7 - 10, macOS, Linux, and we're experimenting with android support now. But there is way way way to many issues with guitar controllers on android right now for us to really recommend it lol. That wiki page is community maintained and is quite out of date.
     
  31. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    The problem is, you are thinking of Player.GetAnyButton as meaning "any button on any controller assigned to the Player." That's not what it does. All Player input functions are referring to the Player as the controller, not the underlying controllers being used to provide input to that Player. Player.GetAnyButton is the exact same thing as iterating over every Action and querying Player.GetButton. This is getting the virtual "button" state of the Player's Action, not the physical buttons on the device. As explained here, "GetButton" functions in a Player are inherently tied to a positive total Action value. That's why the Negative Button methods exist. If you don't like this, enable "Activate Buttons on Negative Value" - http://guavaman.com/projects/rewired/docs/RewiredEditor.html#Settings.

    If you want actual Controller button values, don't use Player.GetAnyButton. Use ReInput.controllers.GetAnyButton or Controller.GetAnyButton.
     
  32. NobleRobot

    NobleRobot

    Joined:
    Jan 14, 2016
    Posts:
    56
    Right, that's what I wanted, I don't want to query devices specifically, but player actions (the terminology is easily conflated, I didn't mean to confuse the two, sorry).

    That's more or less exactly what I was looking for! Thanks! :-D

    However, I still think adding an argument to
    Player.GetAnyButton()
    to allow case-by-case usage would be a good idea.
     
  33. shadiradio

    shadiradio

    Joined:
    Jun 22, 2013
    Posts:
    83
    I apologize, sorry for wasting all that time. It was a combination of several things that led me down this road, and I learned some things. Basically my DS4 at home was not showing dpad inputs on my mac, AND my separate dev kit DS4 at work was not showing dpad inputs on html5gamepad.com. Anyway, it turns out that the DS4 will not show all inputs in Firefox, but will in Chrome! Not only that, but you're right - my DS4 at home IS broken (the dpad suddenly doesn't work at all on any system). I was chasing red herring after red herring. Conclusions:
    • DS4 & Rewired is just fine (sorry about that)
    • DS4 + Firefox + html5gamepad.com is unreliable
    • DS4 + Chrome + html5gamepad.com is more reliable
    • DS4's are a bit flaky
     
  34. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    No worries. I only mentioned it because it made it take so long for me to get back to you on the issue which is not my modus operandi. I had to set up the OSX system for 3 other Apple-related support questions in the same week. I haven't had one that required me to do any testing in over a year. (Those platforms are generally quite stable.) The Apple ecosystem always requires you have the latest tools at all levels. It's getting more difficult to keep things up to date, especially now that they've dropped support for many old devices (Nvidia video card issue). The lesson is, I need to get a modern system. It's just that I rarely use it and it's been fine for my purposes until now.

    FWIW, red herring support issues eat up the vast majority of my time and have been doing so for the past 4.5 years. It's just the reality of supporting a complex system that spans so many platforms and devices. It's unbelievable how many systems Rewired touches or is used in conjunction with (hardware, software, platforms, distribution platforms, systems within Unity, drivers, etc., at all levels). Anything Rewired touches even remotely (or has a dependency on) can and does trigger support requests about issues that on the surface may appear to be Rewired related. But 98% of the time (not a statistical measurement, but just an off-hand guess), it turns out to not be a problem in Rewired. It's a multiple-times-a-day occurrence. So don't worry about it. I really don't think there's anything that can be done about it. I can only imagine what support at Unity must be like, 25+ platforms now, a gazillion constantly-changing API's they're wrapping...
     
    Last edited: Apr 5, 2019
    shadiradio likes this.
  35. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Thanks for the suggestion, but I won't be adding that. It's not only GetAnyButton, but every single GetButtonXXX and variant that would have to have an extra overload to allow you to specify ignoring the Button = Positive Value standard. It would also require changes to the event-driven input system. Negative buttons were an early design decision that I've stuck with because it made sense for getting the maximum control over axes used as buttons even though it's pretty unusual. (I've never seen it before.) Adding overloads around the API to essentially undo this design decision isn't something I want to get into. That's what the global option is for. And you can always call the combination of GetButton and GetNegativeButton to achieve the same result on an as-needed basis if you don't want to use the global option.
     
    Last edited: Apr 5, 2019
  36. Kufufami

    Kufufami

    Joined:
    Feb 24, 2017
    Posts:
    6
    Hi Guavaman!

    Im trying to add Rewired to my 2017.4.11f1 project. But when i do i get the following errors upload_2019-4-5_11-12-24.png

    If i then try implementing those interfaces i get this error:

    upload_2019-4-5_11-13-30.png

    Have tried removing it, and installing it again. It also won't run the installer etc.

    Im not sure what to do anymore, tried googling around, but don't see anyone with same problem
     
  37. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    It sounds like this issue based on the documentation.

    http://guavaman.com/projects/rewire...tml#installation-problems-and-compiler-errors

    Rewired does not install or has compiler errors immediately after installation
    A very common error users make is to install a version of Rewired built for a newer major version of Unity in an older version of Unity. This happens because of Unity’s very poor choice to save Asset Store downloads from the Unity 5, 2017, and 2018 branches of Unity in the exact same folder in %appdata%\Unity\Asset Store-5x (on Windows). If you download the Unity 2018 version of Rewired from the Asset Store in Unity 2018, then go back to Unity 2017 and press Install without downloading Rewired again, Unity will install the 2017 version of Rewired which contains asset files that were saved in Unity 2018 and are therefore incompatible with 2017. Download Rewired again from the Unity Asset Store in Unity 2017 before installing Rewired and you won’t have any issues.

    You will get the following compiler error if you install Rewired for Unity 2018 in Unity 2017:

    Assets/Rewired/Internal/Scripts/Misc/ExternalTools.cs (80,18): error CS0535: `Rewired.Utils.ExternalTools' does not implement interface member 'Rewired.Utils.Interfaces.IExternalTools.PS4Input_GetSpecialControllerInformation (int, int, object )'`
     
    Last edited: Apr 5, 2019
    Kufufami and guavaman like this.
  38. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    @Kufufami @longroadhwy is exactly correct. You're installing Rewired for Unity 2018 into Rewired 2017 which will not work.
     
    Kufufami likes this.
  39. Tony-Lovell

    Tony-Lovell

    Joined:
    Jul 14, 2014
    Posts:
    127
    I have two main questions before trying it out:
    • does it include any support for creating control mapping panels for use by your game's players? That is, I would ideally like if this created a skinnable "input options panel" for my game's main menu.
    • Is there support for an Input Map stack, so that, for instance, if a player has "M" mapped to his "show map" function and he opens up the chatbar to send a message, pressing M would add that letter to his composed chat and not pull up the Map, but if F1 were assigned to the "show map" function, the player would still be able to display the map while composing a chat?
    Thanks in advance!

    tone
     
  40. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    http://guavaman.com/projects/rewired/docs/HowTos.html#controller-mapping-screen

    This would be done using the Controller Map system:
    http://guavaman.com/projects/rewired/docs/ControllerMaps.html

    It's not an opaque layered stack. You enable/disable maps or bindings individually. All enabled maps and bindings are processed.
     
    Last edited: Apr 7, 2019
  41. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Thanks for the clarification.

    Does it support real midi devices too? Having support for Rockband Pro MIDI Adapter (XBOX 360 version) support would be nice. It shows up as a game controller (at least in guitar mode). Have not seen anything in terms of PC driver support however.

    This topic was interesting about building a similar type of converter with a Rhaspberry Pi.
    https://www.reddit.com/r/Rockband/comments/97roqd/building_your_own_ps34_midi_pro_adapter_with_a/

    It would be cool if you could support something like jamstick+ guitar.

    https://jamstik.com/products/jamstik
     
    Last edited: Apr 7, 2019
  42. FolkvangStudios

    FolkvangStudios

    Joined:
    Aug 25, 2017
    Posts:
    91
    Can't find the answer anywhere. I'm using NGUI for all my interface panels but I cannot get the Gamepad to control the mouse pointer. I copied over the settings from the "PlayerMouseUnityUI" and dropped the mouse pointer Icon into the NGUI scene as an NGUI Sprite with the proper UIPointer script attached.

    When I do any input the unity mouse vanishes off to center, but the Rewired mouse does not work.

    I've created the MouseX, MouseY... mappings, I have it attached to the "DoNotDestroyOnLoad" Rewired Gameobject. So the controller is loaded as the game loads and then persists through the game.

     
  43. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    PlayerMouseUnityUI is made for Unity UI, not NGUI. There is no built-in support for NGUI or any examples that use NGUI. You will have to make your own NGUI-compatible mouse controller using the PlayerMouse class. The Player Mouse Sprite example shows you how to use the Player Mouse class to move a Unity sprite around. You should be able to adapt this to NGUI:
    http://guavaman.com/projects/rewired/docs/Examples.html#player-mouse-sprite

    The example UIPointer script included with Rewired in the PlayerMouseUnityUI example is a Unity UI pointer. It's not going to work with NGUI either. All of these examples are just that -- examples -- and are not meant for you to drop in your project and use. They're there to learn from to implement your own.

    Any problems you are having such as the mouse pointer popping to the center of the screen, etc, can be debugged by logging the output of the PlayerMouse.screenPosition.

    Player Mouse consumes input from the Player as the documentation states to drive the screenPosition. It doesn't care what input device this comes from. Every element on the PlayerMouse is bound to an Action in the Player by you when you created the Player Mouse. Those Actions must provide input values to the Player Mouse so it can calculate the screen position. If those Actions in the Player are returning no value, your Player Mouse isn't going to move. You can easily debug what values are coming from those Actions using Debug Information:
    http://guavaman.com/projects/rewired/docs/Troubleshooting.html#debug-information
     
    Last edited: Apr 7, 2019
  44. f1chris

    f1chris

    Joined:
    Sep 21, 2013
    Posts:
    335
    I really love you've added the copy map feature. Very handy but I have a little issue with it.....

    Once I selected the map and click copy I can't see the dialog box. It stays in lower right corner if if I resize or dock the window.

    I'm using 2019.1.0b10

    thx
     

    Attached Files:

    • bug1.png
      bug1.png
      File size:
      366.5 KB
      Views:
      598
  45. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,838
    Is there any way to force rewired to restore default values via script when running a build?
     
    Last edited: Apr 8, 2019
  46. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    guavaman likes this.
  47. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Well it looks like the same code that works in Unity Windows doesn't work in Unity OSX (or is that Linux?) since I can see from your picture it's not Windows. That's really annoying. There shouldn't be any special code cludges requried for one vs any other editor. How can code that centers the window in the middle of the surrounding editor window possibly not work the same on all editor platforms? :mad: It's the same code that is used to draw the keyboard polling popup dialog.

    And as you likely haven't been able to use the Copy feature because that editor doesn't work correctly, FYI, you cannot copy a Controller Map from one Joystick to another. It only copies from one Category/Layout to another on the same Controller.
     
    Last edited: Apr 9, 2019
    f1chris likes this.
  48. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    I do not understand what you mean. Default values of what? Values of mappings are always default unless you've overwritten them by loading saved XML/JSON. If you are referring that that, it's entirely dependent on whatever saving/loading system you are using. UserDataStore_PlayerPrefs saves to PlayerPrefs as the name implies. Clear PlayerPrefs if you're using that. If you're using something else, clear whatever data you're storing in whatever system you're storing it. Either that or disable the system that's loading the data in the first place. Rewired's core saves zero data whatsoever. Data saving/loading is entirely up to your implementation of choice.

    You can reset a Player's Controller Maps to the defaults:
    http://guavaman.com/projects/rewired/docs/HowTos.html#loading-controller-maps-runtime

    But that only applies for the Controllers currently assigned to the Player. The next time you assign one, if you are using something like UserDataStore_PlayerPrefs, it's just going to load the user mappings. That also will not restore defaults for Input Behaviors, Joystick calibrations, or Joystick Assignments, or any other data that may be saved/loaded.
     
    Last edited: Apr 8, 2019
    ArachnidAnimal likes this.
  49. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    Rewired 1.1.25.0 is now available on the Unity Asset Store.

    Please see Updating Rewired before updating.

    Important Additions:

    Release Notes:

    1.1.25.0:

    Changes:
    - Added Unity 2019 branch.
    - Added Controller Map Enabler system for Controller Map enabled state management.
    - Added Controller Map Layout Manager system for Controller Map Layout management.
    - Changed UserDataStore_PlayerPrefs to utilize Controller Map Layout Manager.
    - Control Mapper: Made changes to support Unity 2019.1 UI system.
    - Control Mapper: Added support for Power axis sensitivity type.
    - Editor: Debug Information open foldouts now remember previous settings.
    - Rewired Editor: Custom Controller Type Guid.
    - Rewired Editor: Added Copy Map button to Controller Maps pages.
    - Rewired Editor: Added Default Axis Sensitivity Type option to Settings page.
    - Rewired Editor: Added Sensitivity settings to Custom Controller Axes.
    - Rewired Standalone Input Module: Removed checks of UnityEngine.Input.mousePresent because it is unreliable and reports inaccurate values on some platforms. isMouseSupported will now always return true.
    - Windows Standalone, Direct Input, Use XInput disabled: Added workarounds for issues with Steam-configured devices not connected or disconnected properly due to Steam's lack of sending proper device events for emulated devices.
    - Made various changes to Debug Information.

    API Changes:
    - Added ControllerMapEnabler class.
    - Added ControllerMapLayoutManager class.
    - Added ControllerSetSelector class.
    - Added ControllerIdentifier struct.
    - Added Interfaces.IControllerMapStore interface.
    - Added ReInput.ConfigHelper.defaultAxisSensitivityType property.
    - Added Controller.identifier property.
    - UserDataStore class now implements Interfaces.IControllerMapStore interface.
    - Added UserDataStore.SaveControllerMap method.
    - Added UserDataStore.LoadControllerMap method.
    - Added Player.ControllerHelper.MapHelper.layoutManager property.
    - Added Player.ControllerHelper.MapHelper.mapEnabler property.
    - Added ReInput.ControllerHelper.GetController(ControllerIdentifier controllerIdentifier) method overload.
    - Added ReInput.MappingHelper.GetControllerMapInstanceSavedOrDefault method.
    - Added ReInput.MappingHelper.GetJoystickMapInstanceSavedOrDefault method.
    - Added ReInput.MappingHelper.GetKeyboardMapInstanceSavedOrDefault method.
    - Added ReInput.MappingHelper.GetMouseMapInstanceSavedOrDefault method.
    - Added ReInput.MappingHelper.GetCustomControllerMapInstanceSavedOrDefault method.
    - Added ReInput.MappingHelper.GetControllerMapLayoutManagerRuleSetInstance method.
    - Added ReInput.MappingHelper.GetControllerMapEnablerRuleSetInstance method.

    New PlayMaker Actions:
    - RewiredConfigGetDefaultJoystickAxis2DSensitivityType
    - RewiredConfigSetDefaultJoystickAxis2DSensitivityType
    - RewiredConfigGetDefaultAxisSensitivityType
    - RewiredConfigSetDefaultAxisSensitivityType
    - RewiredControllerGetHardwareTypeGuidString
    - RewiredControllerGetDeviceInstanceGuidString
    - RewiredPlayerControllerAddedEvent
    - RewiredPlayerControllerRemovedEvent
    - RewiredPlayerLayoutManagerGetEnabled
    - RewiredPlayerLayoutManagerSetEnabled
    - RewiredPlayerLayoutManagerGetLoadFromUserDataStore
    - RewiredPlayerLayoutManagerSetLoadFromUserDataStore
    - RewiredPlayerLayoutManagerApply
    - RewiredPlayerLayoutManagerLoadDefaults
    - RewiredPlayerLayoutManagerRuleSetGetEnabled
    - RewiredPlayerLayoutManagerRuleSetSetEnabled
    - RewiredPlayerMapEnablerGetEnabled
    - RewiredPlayerMapEnablerSetEnabled
    - RewiredPlayerMapEnablerApply
    - RewiredPlayerMapEnablerLoadDefaults
    - RewiredPlayerMapEnablerRuleSetGetEnabled
    - RewiredPlayerMapEnablerRuleSetSetEnabled

    New Behvior Designer Tasks:
    - RewiredConfigGetDefaultJoystickAxis2DSensitivityType
    - RewiredConfigSetDefaultJoystickAxis2DSensitivityType
    - RewiredConfigGetDefaultAxisSensitivityType
    - RewiredConfigSetDefaultAxisSensitivityType
    - RewiredControllerGetHardwareTypeGuidString
    - RewiredControllerGetDeviceInstanceGuidString
    - RewiredPlayerControllerAddedEvent
    - RewiredPlayerControllerRemovedEvent
    - RewiredPlayerLayoutManagerGetEnabled
    - RewiredPlayerLayoutManagerSetEnabled
    - RewiredPlayerLayoutManagerGetLoadFromUserDataStore
    - RewiredPlayerLayoutManagerSetLoadFromUserDataStore
    - RewiredPlayerLayoutManagerApply
    - RewiredPlayerLayoutManagerLoadDefaults
    - RewiredPlayerLayoutManagerGetRuleSets
    - RewiredPlayerLayoutManagerGetRuleSet
    - RewiredPlayerMapEnablerGetEnabled
    - RewiredPlayerMapEnablerSetEnabled
    - RewiredPlayerMapEnablerGetLoadFromUserDataStore
    - RewiredPlayerMapEnablerSetLoadFromUserDataStore
    - RewiredPlayerMapEnablerApply
    - RewiredPlayerMapEnablerLoadDefaults
    - RewiredPlayerMapEnablerGetRuleSets
    - RewiredPlayerMapEnablerGetRuleSet
    - RewiredLayoutManagerRuleSetGetEnabled
    - RewiredLayoutManagerRuleSetSetEnabled
    - RewiredLayoutManagerRuleSetGetTag
    - RewiredLayoutManagerRuleSetSetTag
    - RewiredMapEnablerRuleSetGetEnabled
    - RewiredMapEnablerRuleSetSetEnabled
    - RewiredMapEnablerRuleSetGetTag
    - RewiredMapEnablerRuleSetSetTag

    New Bolt Events:
    - Player_ControllerAddedEvent
    - Player_ControllerRemovedEvent

    New Controller Definitions:
    - XInput Guitar

    Bug Fixes:
    - Windows Standalone, Raw Input, Native Mouse Handling: Mouse wheel Values smaller than the Windows constant detent tick value are now rounded up to the nearest tick.
    - Windows Standalone, Direct Input, Use XInput disabled: Steam-configured controllers now appear when Use XInput is diasabled.
    - Rewired Cinemachine Bridge: Added #if directives to make new keyword on runInEditMode property only be used in the editor to avoid compiler warnings in builds.
    - Windows Standalone, XInput: All non-gamepad XInput device sub types are handled as Gamepads again.
     
    Bartolomeus755 likes this.
  50. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,633
    I cannot reproduce any issue on Unity 2019.1.0b10 on Windows or OSX. If one of those are the platform you are on, there has to be some other factor in play that I am not aware of. Some kind of weird dark skin editor bug?

    Here's the code:

    Code (csharp):
    1. width = 300;
    2. height = 120;
    3. popupWindowRect = new Rect(Screen.width * 0.5f - width * 0.5f, Screen.height * 0.5f - height * 0.5f, width, height);
    4. popupWindowRect = GUILayout.Window((int)type, popupWindowRect, DrawCopyControllerMapWindow, "Copy Controller Map");
    5. popupWindowOpen = true;
    6. GUI.FocusWindow((int)PopupWindowType.CopyControllerMap);
    For this code to be failing as you are showing, Screen.width and Screen.height must be returning the wrong values. This is clearly some kind of Unity editor bug that I'm not going to be able to work around without changing my system to use some fixed position instead of screen center. (Screen.width and height are supposed to return the size of the editor window when called in there and have done so for years and years.) It's also possible Screen.width and Screen.height are returning the correct values but GUILayout.Window is just ignoring them and drawing it where it wants to. If that's the case, there is no possible work around.

    The only thing I can do is replace the centering with a fixed position in space. This will be done in the next update. If this doesn't fix it for you, nothing will. Regardless, this is a Unity bug and you should report it to them because I cannot reproduce it.

    Here's the result:

    copymap.png

    Resized the window. It stays centered:

    copymap2.png
     
    Last edited: Apr 8, 2019
    f1chris likes this.