Toukiden 2

Toukiden 2

Not enough ratings
Mouse Emulation V2
By kei10 and 1 collaborators
Mouse emulation version 2, using FreePie, VJoy, and X360CE.
   
Award
Favorite
Favorited
Unfavorite
Introduction
... Greetings...

My friend was raving about not having mouse support about the game. He has a controller now, but I don't -- bah.

This is made possible using FreePie 1.9.629, VJoy 2.1.6, and x360ce.

The scripts are programmed for efficiency. So far, the mouse emulation script algorithm is the best I could think of -- and very complicated, for many reasons. If you have any better approaches, please feel free to modify it, and/or share!

Additionally, if you're following the game, please disregard of what keyboard controls you are going to remap, since it only relies on the Controller buttons...

But be sure to set the Camera and Target Camera settings, which I will be explaining at the next sections...

Also, all of these are tested in windowed, 30 framerate. Tweaks will be needed for the script itself, which it will be explained thoroughly.
Problems with vJoy/x360ce
WARNING!
In case x360ce does not work, try each 32 bit and 64 bit version of x360ce.

WARNING!
vJoy virtual controller device can interfere with games!
As the device itself may bug out and causes one of its buttons and/or joystick to be held down, and games that supports controller will detect it.

However, once you are not using the mouse emulation script for Toukiden 2, open up Configure vJoy (vJoyConf.exe within the vJoy install directory), and untick "Enable vJoy", If enabled, the [1] tab will appear as green.

That will disable the virtual controller device, and games will not detect the virtual controller anymore.

WARNING! Make sure you've closed any application that has detected the virtual controller, or you won't able to disable it!

To use it, just tick again the "Enable vJoy".

WARNING! For some unknown reason, vJoy/x360ce isn't working properly with Toukiden 2. The button that binds to the Demon Hand seems to bug out.

To fix, go into X360CE, and remove the binding of Right Trigger as shown in the screenshot below.

The Left Trigger also seems to be held down for some reason, therefore you may remove that as well, although I have no idea what that is binded to, it didn't affect the game or anything.
Problems with the game
There are a few breahtroughs of the game that we have to concern about before then...
  • Controller Camera Sensitivity Thresholds
    • There is a sh*t problem with the in-game camera using the game controller. The camera sensitivity is split into multiple thresholds, there are; slow, medium, fast, and max depending on how much you push the joystick. This causes jittery camera movement with the mouse emulation v2...

      I have spent as much time as possible to make the camera as smooth as possible, but then the whole algorithm became a nightmare...

  • Steam Overlay
    • For some strange reason, Steam Overlay doesn't want to work. I haven't got time to test it.

  • Hard-coded controls
    • Many controls weren't rebindable in the game, they're probably hard-coded into the game, as I have no idea how to change them. This guide will begin with default control settings.
The required files
To begin, five (5) files are required.

  1. vJoy 2.1.6 (for FreePie 1.9.629)

  2. x360ce
    • http://www.x360ce.com/
      WARNING!
      In case x360ce does not work, try each 32 bit and 64 bit version of x360ce.

    • This software is required to convert and feed the emulated joystick into XBox Controller (XInput).

  3. FreePie 1.9.629 (vJoy 2.1.6 support)

  4. Toukiden 2 FreePie Mouse Camera Script (python)
Video tutorial

sorry for the quality. ♥♥♥♥♥♥♥ youtube
Getting started
Here are the steps to make the mouse emulation work...

  1. Download the required files from the previous section...

  2. Install vJoy 2.1.6. (if it says driver install fails, that means that the driver might be no longer be signed... I hope it won't become like PPJoy, which I didn't bother with it as it is required to enter test mode to install it...)

  3. Install FreePie 1.9.629.

  4. Extract the x360ce.exe from the x360ce compressed file into your Toukiden 2 game directory (where the main executable is located). The XInput dll is required to be loaded by the game to work -- however, it does not exist yet, so...
    WARNING!
    In case x360ce does not work, try each 32 bit and 64 bit version of x360ce.

  5. Launch the x360ce.exe. It should pop up an error saying...
    'xinput1_3.dll' was not found.
    This file is required for emulator to function properly.

    Do you want to create this file?
    Click Create, you baffoon (just kidding). Next it will load up and says...
    New device with unique instance id was detected. How do you want to search for settings?
    If this did not came up, please make sure that you've installed vJoy 2.1.6 correctly.
    Now, don't touch anything, just... click Next... It will search for best settings from the internet. Hopefully...

    Give it a wait, and once it is done, click Finish. If you do not wait, it will explode with a error. Actually I am not sure if search for best settings from the internet is preferred -- well, not matter...

  6. Warning! Remove the binding of the Right Trigger from the x360ce, as vJoy/x360ce has some kind of problem with Toukiden 2, it will bug the Demon Hand control.

  7. Now you can close x360ce.exe.

  8. Launch FreePie.

  9. Load the Toukiden 2 FreePie Mouse Camera script into FreePie (toukiden2_freepie-mouse-to-vjoy.py) by the context menu > file > open and locate the script.

  10. Launch the game.

  11. In FreePie window, run the script by context menu > script > run script, or press F5. To stop, hold Shift + F5, or stop it from the same context menu.

  12. Return to the game, load your save, and press Equals (=) key to toggle the mouse camera emulation!

  13. ???

  14. Profit!

  15. Toggle the script to disable when typing to chat, as it interferes and delays input.
Getting started (tl;dr)
Mouse camera emulation, and mouse buttons for attacks

The keybinding toggle for FreePie toukiden2-freepie-mouse-to-vjoy script is Equals (=) key, use it to toggle the mouse camera movement and mouse clicks LButton, RButton, and MButton which is binded to Attack1, Attack2, and Attack 3 respectively.

Warning! When the mouse camera is enabled, your mouse will be kept centered to the screen for detection purposes. FreePie came with mouse.DeltaX and mouse.DeltaY, but I find them unreliable.
How it works and Configurations
*Takes a deep breath* ...

Within the FreePie mouse camera emulation script (toukiden2-freepie-mouse-to-vjoy.py), there are roughly twelve (12) variables that are responsible for making the whole sh*t work properly.

WARNING! Make sure all values are type float, FreePie uses Python 2.7.5, which means the division is *not* a true division, true multiplication, or something. There will be errors. However, the script has been programmed to ensure that the variables will not be accidentally assigned as anything else beside floating point values.

FreePie vJoy variables

  1. v = vJoy[0]
    • For simplification and performance purposes, the object vJoy[0] is assigned to a single-letter variable called v. The [0] stands for getting the first activated virtual device of vJoy, which is initialized after installation of vJoy 2.1.6.

  2. v.rx and v.ry
    • First and foremost, these two are the vJoy feed that are responsible for reponding the in-game camera.

  3. v.axisMax
    • vJoy came with something called axisMax, which defines how much the joystick can push to the maximum. The value is defaulted at 16,328, which means it has a range between -16,328 to 16,328, and 0 is the neutral value (center).

Terminology

  1. Mouse Delta, mc_mouse_delta...
    • This refers to the delta distance acquired from comparing the distance between the mouse position and the center of the screen. This is important to know which direction and how much your mouse has moved.

  2. Mouse Camera Delta, Camera Delta, just Delta, mc_delta...
    • This refers to the accumulation of delta values acquired from the Mouse Delta. Many variables and operations are performed together into the main mc_delta to make sure the camera is smooth and calibrated.

Configuration

  1. mc_framerate (default: 30.0 fps)
    • FreePie comes with a setting called system.threadExecutionInterval, which allows the user to define how fast the script will run in each interval in miliseconds. Since MY GAME is set to be at framerate of 30, the variable mc_framerate is meant the script to be in sync with the game framerate, for accuracy purposes. Changing this will affect the entire mouse camera emulation.

  2. mc_mouse_delta_start_threshold (default: x = 0.0, y = 0.0)
    • This is the main concern for Target Lock. A slight movement to the mouse may cause the Target Lock to lock onto the next target. This variable was created for Toukiden: Kiwami, but it appears that the Target Lock isn't an issue in Toukiden 2.

  3. mc_sensitivity (default: x = 32.0, y = 32.0)
    • This is the base multiplier for the Mouse Delta to be added to the Camera Delta. This is working alongside with mc_sensitivity2.

  4. mc_delta_damping (range: 0.0 <= k <= 1.0, default: x = 0.0, y = 0.0)
    • This is the base damping for the Camera Delta to be slowed down to a stop. This is working alongside with mc_delta_damping2.

  5. mc_delta_max (default: x = v.axisMax * 2.0, y = v.axisMax * 2.0)
    • This is the maximum Camera Delta that can reach. Since the v.axisMax is the max, we can define this variable above the v.axisMax to allow the camera to move longer for mouse camera acceleration.

  6. mc_delta_initial (default: x = v.axisMax * 0.5, y = v.axisMax * 0.5)
    • The camera does not move until the v.rx or v.ry is above or below v.axisMax * 0.36 or -v.axisMax * 0.36, without an initial value, the camera will not move and extremely annoying no matter how hard to fling your mouse across the room through the window all the way to the white house...

  7. mc_delta_stop_threshold (default: x = v.axisMax * 0.49, y = v.axisMax * 0.49)
    • Since the sh*t in-game camera doesn't response beneath v.axisMax * 0.37, a threshold is used to stop the Camera Delta early, this variable is very important to make sure the mouse camera doesn't go too smooth, or too strict -- beside the damping.

  8. mc_delta_damping_origin (range: mc_delta_stop_threshold < k < v.axisMax ,default: y = v.axisMax * 0.4, y = v.axisMax * 0.4)
    • This is the Delta Camera value that it will attempt to dampen towards. This is used to smoothen the damping and prevent jittery camera when the mouse camera is moving at slow.

  9. mc_delta_sensitivity_sigmoid_constant (range: -1.0 < k < 1.0, default: x = -0.5, y = -0.5)
    • As the in-game camera has some sh*t implementation for its camera movement using the controller joystick, I have to go through this effort to add curve-based sensitivity output to enhance the calibration.

      The constant is for the formula used is by Dino Dini's Tunable Sigmoid:
      # Sigmoid Tunable def sigmoid_tunable(k, x): return (x - x * k) / (k - abs(x) * 2.0 * k + 1.0)
      The default value is graphed as follows:

      The high output at the beginning is to prevent jittery camera movement when it moves at slow. Then it slows down to normalize the sensitivity output.

  10. mc_sensitivity2 (default: x = 32.0, y = 32.0)
    • This is the secondary multiplier which is fed into the sigmoid of mc_delta_sensitivity_sigmoid_constant to produce a curved sensitivity for the Camera Delta. As mentioned, this works alongside with mc_sensitivity.

  11. mc_delta_damping_sigmoid_constant (range: -1.0 < k < 1.0, default: x = 0.5, y = 0.5)
    • Once again, due to the sh*t implementation of the in-game camera, I have to add a sigmoid-based damping for the Camera Delta as well.

      The default value is graphed as follows:

      The low output at the beginning is, again, to stop the god forsaken jittery camera when it moves at slow. Then it increases up to normalize the damping.

  12. mc_delta_damping2 (range: 0.0 <= k <= 1.0, default: x = 0.1, y = 0.1)
    • This is the secondary damping which is fed into the sigmoid of mc_delta_damping_sigmoid_constant to produce a curved damping for the Camera Delta. As mentioned, this works alongside with mc_delta_damping.

These aren't necessarily the best settings, if anyone have found a better settings or perhaps a better script as a replacement, please do kindly share.


In-Game Keybindings and Settings
You may set your controls to as you like. However, since the Dive/Dodge, Demon Hand, and Eye of Truth are nowhere near your WASD control settings, you may find it unable to perform certain actions combining with your mouse clicks, which is mapped to the attacks.

Here are my personal controls for the game that I find comfortable:
  • Dodge/Dive as Space
  • Demon Hand as Q
  • Eye of Truth as E
  • Communion/Purification/Run as Left Control
Set both Camera Rotation Speed to higest.

However, Targeting Rotation Camera Speed is the manual aiming, you can set this to whatever you desire.

Desktop Mouse Settings

My desktop mouse speed slider is set to max, with acceleration turned on when I created the mouse emulation script.
Credits
Thanks to these softwares that existed:
  • FreePie 1.9.629
  • VJoy 2.1.6
  • x360ce
  • Python
Thanks to Dino Dini's Tunable Sigmoid function!

And thanks to my friend for testing the script!

Thank you for reading!
< >
19 Comments
Akiawa Jun 28, 2023 @ 4:21pm 
Will using it nowadays cause us to eat vac ban?
geokit Feb 16, 2023 @ 7:04pm 
Anyway to work with the Xbox remote play app? on pc.
Demonite Jun 8, 2022 @ 4:04pm 
Well, guess I'm gonna have to play with an inferior input device... (Yeah, I just really like mouse & keyboard lol)
kei10  [author] Mar 9, 2021 @ 1:38am 
Technically yes, as long as the specified game works with x360ce and vJoy. Though, it's been so long, things may have been quite outdated in this guide.

Though it's best to get yourself a controller, it saves you both time and frustrations having to set up and customize this -- whatever this abysmal thing I made in the early days.

Plus I have no idea how I even did all these. Childhood days I guess. XD
Mark Fuckerberg Mar 7, 2021 @ 9:25am 
Could this script work with other games?
kei10  [author] Oct 18, 2018 @ 9:36am 
I haven't played the game for a long time since. I think I may recall that the mouse ocassionally do not disappear after refocusing, and alt+tabbing then returning to the game repeatedly fixes it. It can be annoying nevertheless.
Therefore to answer your question, no the freepie code is not coded to hide the mouse upon activation and requires the game's focus to make the mouse disappear.

Thanks.
TheElder Oct 14, 2018 @ 4:08pm 
The mouse is still there when activate the python. It should disppear, right?
Fostil Jul 1, 2018 @ 9:50am 
Yeah with this I can now play with Bows. I absolutely hate aiming with controller, so this guide helped me a lot. Thanks again! :)
Jepa.CaptPrice  [author] Jul 1, 2018 @ 3:25am 
Glad it worked for ya :D
Fostil Jul 1, 2018 @ 1:27am 
Found the problem. You need to use x360ce x64 version! Thanks for the guide.