[HELP] Controller mapping

Discuss modding questions and implementation details.
Post Reply
Zakariagatter
Posts: 8
Joined: Thu Dec 12, 2024 4:10 pm

[HELP] Controller mapping

Post by Zakariagatter »

i use controller to play daggerfall unity and i want to map my controller in a couple on mods but i dont know what code should i use ??

can anyone help

User avatar
bigDunmer
Posts: 11
Joined: Sun Apr 06, 2025 7:38 pm

Re: [HELP] Controller mapping

Post by bigDunmer »

Hi there, a quick search returned me this post. Is this what you were looking for?

viewtopic.php?p=68698&hilit=controller#p68698

Zakariagatter
Posts: 8
Joined: Thu Dec 12, 2024 4:10 pm

Re: [HELP] Controller mapping

Post by Zakariagatter »

Thank you so much! This GitHub account helped me in the beginning with mapping the main key to a controller. However, what I’m asking is how to add a controller key inside a mod, like in basicroads/traveloptions. Specifically, how can I make R2 + X start a travel on the road?

I tried using the Unity code, but nothing happened.

User avatar
bigDunmer
Posts: 11
Joined: Sun Apr 06, 2025 7:38 pm

Re: [HELP] Controller mapping

Post by bigDunmer »

Alright, let's see if I got this right.

In the settings of the TravelOptions mod the developer used the following block in their modesettings.json file. This helps you set either a hardcoded key stroke to an action or custom keybind which then is read from a string text field. I think you're trying to do the same BUT you want to combine two keys on your controller. Right?

Image

Let's see where in the TravelOptions mod codebase the custom value is being read. Look below:

Image

And then...

Image

If you google this will lead us to the documentation of Unity v2019.4.40f1 since this is what DFU is using atm, where KeyCode.TryParse, which can try to parse key codes from string values uses the following gigantic table. https://docs.unity3d.com/2019.4/Documen ... yCode.html

You're looking for one of the JoystickButton ones. JoystickButton1 or JoystickButton2 should be X for example although I'm not sure. You should perhaps Debug.Log your controller keys to see which one is which.

For reading the R2, since this is seen as an axis and not a button we need another way to read that. Something like float r2Value = Input.GetAxis("RightTrigger"); should work but I don't see this axis declared in the playersettings. :( I wonder if ur mod can add this on the fly then read from it? Probably not since the DFU uses the old input system.

Below is the screenshot of the input axis that DFU uses from the Unity engine. One of these also could be your RightTrigger.

Image

My final advice here is to use a debug log to see if u can read anything from your R2 and to see which axis it even belongs to. If you have this information then you can do the thing you like to do.
Last edited by bigDunmer on Wed Apr 16, 2025 8:48 pm, edited 1 time in total.

Zakariagatter
Posts: 8
Joined: Thu Dec 12, 2024 4:10 pm

Re: [HELP] Controller mapping

Post by Zakariagatter »

Thank you so much for this incredibly detailed post—it’s been a huge help!

I’m not a programmer, and I don’t know how to create mods or work with C++, but I feel like something might be missing. In the main actions of DFU, my controller is detected automatically, so I’m wondering if I made a mistake with the mods. However, it seems like this could be a new function on its own, and it sounds like a great idea for a mod to be developed.

Post Reply