How to use a Mouse as a Virtual Joystick in Citra, in order to control a Camera View or for custom Mouse Input


#1

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.

HOWTO:

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:

[Controls]
button_a="engine:sdl,joystick:0,button:0"
button_b="engine:sdl,joystick:0,button:1"
button_x="engine:sdl,joystick:0,button:2"
button_y="engine:sdl,joystick:0,button:3"
button_up="engine:sdl,joystick:0,button:4"
button_down="engine:sdl,joystick:0,button:5"
button_left="engine:sdl,joystick:0,button:6"
button_right="engine:sdl,joystick:0,button:7"
button_l="engine:sdl,joystick:0,button:8"
button_r="engine:sdl,joystick:0,button:9"
button_start="engine:sdl,joystick:0,button:10"
button_select="engine:sdl,joystick:0,button:11"
button_zl="engine:sdl,joystick:0,button:12"
button_zr="engine:sdl,joystick:0,button:13"
button_home="engine:sdl,joystick:0,button:14"
circle_pad="engine:analog_from_button,modifier_scale:0.5,up:engine$0sdl$1joystick$00$1button$015,left:engine$0sdl$1joystick$00$1button$017,down:engine$0sdl$1joystick$00$1button$016,right:engine$0sdl$1joystick$00$1button$018"
c_stick="axis_x:0,engine:sdl,joystick:0,axis_y:1"

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: https://github.com/epigramx/mouse2joystick_citra/releases

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:

button_a,
button_b,
button_x,
button_y,
button_up,
button_down,
button_left,
button_right,
button_l,
button_r,
button_start,
button_select,
button_zl,
button_zr,
button_home,
circle_pad up,
circle_pad down,
circle_pad left,
circle_pad right,

(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.

Have fun


Temporary: Controller Configurations for Citra
#2

Someone want to make a video demoing this neat feature?


#3

I’m not into making videos, but whoever does it might have a hard time showing it without external cameras, because the gameplay capture would be similar with only the controller being a mouse+keyboard instead of only keyboard or only hardware controller.


#4

Not that hard to do, you can even use a smartphone. I’ve made this kind of recording before with Citra (https://www.youtube.com/watch?v=bOPH5hxcJFs).


#5

Yes, they would need a setup of actually recording themselves operating hardware, some are comfortable with that.