Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input Functions Not Working with TES4JaPatch016_beta3 #198

Closed
kuroko137 opened this issue Feb 15, 2023 · 10 comments
Closed

Input Functions Not Working with TES4JaPatch016_beta3 #198

kuroko137 opened this issue Feb 15, 2023 · 10 comments

Comments

@kuroko137
Copy link
Contributor

kuroko137 commented Feb 15, 2023

Since xOBSE22.2, there is an issue that some input functions of xOBSE cannot be used when TES4JaPatch016_beta3 (the Unofficial Japanese patch v016.beta3 for Oblivion.exe) is installed.

The following functions are affected:

  • OnControlDown
  • GetAltControl2
  • IsKeyPressed3
  • SetEventHandler "OnKeyEvent"
  • SetEventHandler "OnControlEvent"

It appears that the function InputPollFakeHandle() in Hooks_Input.cpp is no longer called when TES4JaPatch016_beta3 is installed, possibly due to a conflict between the patch and xOBSE. Removing the patch and reverting to the English version allows InputPollFakeHandle() to be called normally, enabling all the above functions to work correctly.

You can download TES4JaPatch016_beta3 from here.
However, the original TES4JaPatch016_beta3 does not work due to a bug on Windows 10 or later. If you want to investigate the issue, please use the following link where I have applied the recently discovered fix.
https://1drv.ms/u/s!Ap8qkjiHTZQ0k1RyPYcgc7tTV0Jl?e=K9c3Gj
(I am temporarily storing it and will remove it later.)

I have created an ESP plugin to check for this problem, which logs to the console when certain controls are performed. By default, it logs when the "B" key is pressed or a "grab" control is performed.

Confirmed environment:

  • Windows 10 64bit 19045.2364, Oblivion 1.2.0416 (package version) / xOBSE 22.2, xOBSE 22.7
  • Windows 11 64bit 22000.1455, Oblivion 1.2.0416 (Steam version) / xOBSE 22.2, xOBSE 22.7

Note that the issue does not occur with Japanese patches prior to v016.beta3 (like v0.15c) and xOBSE 22.2 or later. It also does not occur with v016.beta3 and xOBSE 22.1 or earlier.


TES4JaPatch016_beta3 is an essential tool for playing Oblivion in Japanese on the Steam platform, but it had a compatibility issue with Windows 10 and later, causing it to malfunction for about six years due to a bug. TES4JaPatch016_beta3 was released quite a long time ago, and it was thought to be impossible to fix because the source code did not exist. However, just a few months ago, someone discovered a way to fix it, so it is now possible to make it work again.

@llde
Copy link
Owner

llde commented Feb 15, 2023

Note that the reported issue does not occur with Japanese patches prior to v016.beta3 (like v0.15c) and xOBSE 22.2 or later. It also does not occur with v016.beta3 and xOBSE 22.1 or earlier.

At this point I have to ask, what do this new beta provide that the older version didn't?
The fact they choose to not provide the source code is so goddammit horrible.
It's unfortunate that the original license didn't state that plugins must publish the source.

I will still try to fix, however if they replace the input function I'm not sure it will be possible unless extreme hackery.

@kuroko137
Copy link
Contributor Author

kuroko137 commented Feb 15, 2023

Sorry, I should have written it as you suggested. The changelog (in ReadMe.txt) for version 0.16 is as follows:

  • Added "UI" and "Blur" settings to the settings dialog.
  • Modified to work as an OBSE plugin.
  • Integrated obja.dll for the UI MOD and made it selectable from the settings dialog.
  • Changed the "Density" setting value in the settings dialog to allow negative numbers to be selected.
  • Fixed a bug where some characters may not be displayed correctly depending on the font.
  • Fixed a bug where fonts with internal reddings may be displayed smaller.
  • Fixed a bug where the subtitle background display sometimes does not disappear when DarNified UI is installed.
  • Fixed a bug where, when DarNified UI is installed and the fonts attached to DarNified UI are not installed, character Y-coordinates were shifted.

(The changelog for subsequent beta versions does not exist.)

As you can see, there is no mention of any input-related changes, but the fact that it says "Modified to work as an OBSE plugin." suggests that this may be a major rewrite compared to v0.15c and earlier versions, which were distributed as patch files directly replacing Oblivion.exe itself.
Unfortunately, I could not find any other information that might be useful in searching past forums.

"I will still try to fix, however if they replace the input function I'm not sure it will be possible unless extreme hackery."

Thank you for letting me know. It was helpful to know that it may be difficult to fix.
If it's too much work, you can leave it as it is, since fortunately we still have the option of using xOBSE22.1.
I appreciate your quick reply.

@llde
Copy link
Owner

llde commented Feb 18, 2023

This is a mess. First of all the address of the fix isn't 00003B91 but 10004791 (1000000 being the base). it's not using baseful addresses for it's hooks, the hooks themselves are a mess.

@llde
Copy link
Owner

llde commented Feb 18, 2023

The reason of the crash is bewcouse there is a null pointer access, after
.text:1000479D lea ecx, [eax+20h]
.text:100047A0 mov edx, [ecx]
caused by accessing an member of an invalid non -null object.

The call to this object is masked by an indirect call (vtable access)

Also it seems to be partially incompatble with MenuQue, crashing intermittently inside obja (calls started from MenuQue modules)

@llde
Copy link
Owner

llde commented Feb 18, 2023

Obja hook inside the function just before xOBSE hook:
.text:00404835 jmp sub_3DA1040 //Obja
.text:0040483A ; ---------------------------------------------------------------------------
.text:0040483A jmp near ptr unk_1000CBB0 //OBSE

Now the question is what do OBJA do with the input hook? Do you have any idea on what feature it's used for?
@kuroko137

I imagine that I can either stub the hooks, or save and replay the instruction later. I however don't know wethever the replacer is doing something important

@llde
Copy link
Owner

llde commented Feb 18, 2023

Ok the function in obja, basically reimplement the input handling for the mouse, in addition it do some processing

If the key related to DX scancode 0x91 (DIK_AT) then set 0x21 (DIK_GRAVE), if 0x7D (DIK_YEN) put a variable to 0 and call a function, if 0x90 (DIK_CIRCUMFLEX) call another function and store it's result.

maybe it's realted to these you wrote in the readme for the fix

Press the "\" key in the game to open the input screen for Japanese strings.
Press the "^" key in the game to open the settings screen, but it seems to crash the game if the OS locale is not Japanese.

Also for the way this hook is made it doesn't work if there is no mouse detected

@kuroko137
Copy link
Contributor Author

kuroko137 commented Feb 19, 2023

Thank you very much for going over all the details. I'm really glad!

This is a mess. First of all the address of the fix isn't 00003B91 but 10004791 (1000000 being the base). it's not using baseful addresses for it's hooks, the hooks themselves are a mess.

I'm not entirely sure about my understanding, but I believe that 00003B91 refers to the address that needs to be edited when opening obja_12416.dll in the binary editor to fix the bug, and not the address for the obja_12416.dll hooks. I apologize if I'm mistaken.

Also it seems to be partially incompatble with MenuQue, crashing intermittently inside obja (calls started from MenuQue modules)

In my case, MenuQue itself does not cause crashes, but when I add mods that use their own fonts (such as HUD Status Bars), it crashes. I have been able to work around it by modifying the mod to not use those fonts.

Ok the function in obja, basically reimplement the input handling for the mouse, in addition it do some processing

If the key related to DX scancode 0x91 (DIK_AT) then set 0x21 (DIK_GRAVE), if 0x7D (DIK_YEN) put a variable to 0 and call a function, if 0x90 (DIK_CIRCUMFLEX) call another function and store it's result.

The mouse input process may be used on a Japanese input screen that can be opened with the key of DIK_CIRCUMFLEX. On this screen, you can click and drag to select characters with the mouse cursor.
jp_input

One thing I forgot to mention is that obja_12416.dll uses the "@/`" key, which is a unique key on the Japanese keyboard ("[/{" key on the English keyboard), to open the console. In TES4JaPatch, 0x91 (DIK_AT, JP = "@/`" : EN = "[/{") is the console open key, 0x90 (DIK_CIRCUMFLEX, JP = "^/~" : EN = "=/+") is the configuration screen open key, and 0x7D (DIK_YEN, JP = "/|" : EN = None) is used as the Japanese input screen open key.

The set to 0x21 (DIK_GRAVE, JP = E/J : EN = "`/~") is probably a measure to open the console with a Japanese keyboard. On Japanese keyboards, the "`/~" key is replaced by a special key called the E/J key (a language input key, also called halfwidth/fullwidth or 半角/全角 key), so the "`/~" key is not available. Without TES4JaPatch on a Japanese keyboard, the console cannot be opened in-game.

I think that the only keys used in TES4JaPatch are the three that you mentioned. If necessary, it would not be a major inconvenience to disable these overrides that TES4JaPatch016_beta3 does.
The configuration screen is available from outside the game by running obja_config.exe, and there is a workaround to temporarily uninstall xOBSE it is not a frequently used feature. Japanese input is provided for naming the player character, magic items, and potions in Japanese, but it is not a major inconvenience if it is not available. The problem of not being able to open the console can be solved by installing the Change Console Key mod.

llde added a commit that referenced this issue Feb 21, 2023
@llde
Copy link
Owner

llde commented Feb 21, 2023

@kuroko137 Can you try with this artifact: https://github.com/llde/xOBSE/actions/runs/4237735184
(Wait for the build if it still isn't ready)

Test for the functionality added by OBJA and check if it works

@kuroko137
Copy link
Contributor Author

I just tried your fix and the problem is solved! All inputs are now detected not only in the test ESP I provided, but in other mods.
And of course all OBJA features continue to work. You are my savior!

Now, I want others to try this, so I have asked users to try it on the Japanese forum where the fix method (00003B91: 75 to EB) was found. If they find any problems, I will report them here.
Thank you for the great work! @llde

There aren't as many people playing Oblivion in Japan as there used to be, so the number of people who will benefit from this fix may be small, but at least for me, your fix has been a lifesaver.

@llde
Copy link
Owner

llde commented Feb 22, 2023

Glad it's working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants