Example behavior achieved with this method: Control the Camera in The Legend of Zelda: Majora's Mask 3D with the mouse and allow Right and Left Mouse buttons to have game functions. (e.g. swing your sword with Left Mouse button!).
This is a generic guide in order to make Citra use a mouse as a virtual joystick. Remaining keys can be bound to the keyboard with this method. It's mainly a proof of concept guide based on Majora's Mask: How to control the camera with a mouse and how to use the Right and Left Mouse keys as actual gaming keys.
All URLs are from official sources to avoid any suspicion.
Step 1 (required): Install the vJoy virtual joystick device if you haven't done that in the past.
Get vJoy from its official site. URL that auto-points to latest release: https://sourceforge.net/projects/vjoystick/files/latest/download
During the vJoy installation include at least the Configuration component too.
Step 2 (required): Set vJoy's 'Number of Buttons' to at least 19
If you can't find the configuration of vjoy with a search, it's probably at %ProgramFiles%\vJoy\x64\vJoyConf.exe
Increase the field 'Number of Buttons' to at least 19, e.g. set it to 24 or 32, it won't matter if they are more than enough.
Step 3 (required): Replace the [Controls] section of the Citra configuration:
Find your Citra config, it's usually in %appdata%/Citra/config/qt-config.ini
Replace the [Controls] section with this one for now:
While Citra is not running, save the file with the above change and close it.
This step in detail: It instructs Citra to use the SDL library's detected first joystick (0) (if you connect hardware controllers, vJoy might not be 0). Each main gaming function is assigned to the virtual joystick's button numbers in successive order starting from 0, the circle pad has the same fate with buttons 15 to 18 assigned to up/down/left/right respectively, and the c
_stick is assigned to the magic of being controlled by mouse motion.
Step 4 (optional but recommended): Get Autohotkey if you haven't got it installed. PS. You can completely avoid this step if you use the executable/compiled .ahk script later on but you may be interested in dealing directly with raw scripts.
Get it from their official site: https://autohotkey.com/download
Install it with either default or other options. It does not really matter for this method.
Step 5 (required): Get the latest mouse2joystick_citra script which translates mouse and keyboard input for vJoy
Official GitHub repository:
Extract it anywhere you like.
If you avoided Step 4 and don't have AutoHotkey installed, run the executable. If you have AutoHotkey you can alternatively run the .ahk file. If you run Citra with admin priviledges you must do the same with the mouse2joystick_citra script.
PS. I based mouse2joystick
_citra on a modified mouse2joystick for Cemu which was in turn based on an original mouse2joystick from the AutoHotkey forums, but it works better for camera control. Details on those older versions are in the .ahk file.
Step 6 (optional): Re-Configure the basics of the Autohotkey script if required
PS. You can avoid this step if the defaults suit you but make sure that they do
Right click the mouse2joystick task bar icon and go to settings.
On the General tab use the .exe name of the Citra frontend you run, e.g. Citra-qt.exe which is the default.
On the Hotkeys tab set up how you want to turn on and off the capturing of the mouse. e.g. by
pressing 'F1' without any modifier:
PS. This shortcut is VERY important for the use of this method because you need to use it both to start mouse capturing, and to get out of the game and use the touchscreen properly or other windows.
Step 7 (optional but recommended): Configure your own keys for a game
PS. You can avoid this Step temporarily if you are only doing a first test of the method but find out what keys I have as default and return to it to customize your own.
In Step 3, we replaced the [Controls] list in the configuration of Citra, and that corresponds to what we actually input in the mouse2joystick_citra script's configuration but in this case as a comma separated list. Using the [Controls] list as a reference we can replace what mouse2joystick_citra sends to Citra via vJoy with a comma separated list.
The keylist exists in the mouse2joystick_citra's options (and also in the mouse2joystick_citra's ini if you find that more appropriate):
You can automate this process with mouse2joystick_citra_keylist_automation.xlsx included in mouse2joystick_citra's folder.
Based on our Citra configuration the order is as follows:
(c_stick is autocontrolled by the AutoHotkey script and vJoy for the camera view)
e.g. on the mouse2joystick_citra list of "Space,LButton,q,e,Up,Down,Left,Right,RButton,MButton,Enter,RShift,1,3,g,w,s,a,d", circle_pad right is the last entry of "d" and "Space" corresponds to button_a as first entry.
Movement in the example game and config is done with the traditional "WSAD" keys.
Configure any other mouse2joystick_citra settings as you desire. It has several interesting options.
Step 8 (final step): Run the Emulator and actually play the game
a) Run Citra and load Majora's Mask (example game)
b) Important: Start capturing the mouse input by pressing "F1" or whatever you used as a hotkey in Step 6. If you are sure everything is correct but nothing happens, make sure that if you run Citra with admin privileges, the same is true for the mouse2joystick script.
c) Play the game. Now your camera in Majora's mask can move with the mouse and you can swing your sword with Left Mouse button and target with Right Mouse button. Woohoo!
d) Toggle out of mouse capturing with "F1" (or other hotkey) to use the touchscreen (Citra's 2nd emulated monitor that works by clicking on it with the mouse) or in order to use other windows.