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

Posibility to Change Keyboard Layout? #17

Open
heroesiiifan opened this issue Mar 1, 2021 · 20 comments · Fixed by #19
Open

Posibility to Change Keyboard Layout? #17

heroesiiifan opened this issue Mar 1, 2021 · 20 comments · Fixed by #19
Assignees
Labels
enhancement New feature or request

Comments

@heroesiiifan
Copy link

Hello,

I'm working currently on an complete german translation of H3 Complete. Normally only RoE exists in german.

But there are some things I can't fix.

Is it possible to modify the Keyboard-Layout of H3 Complete?
The german RoE is the correct QWERTZ Layout. While the Complete is fixed to QWERTY.

Another problem to be perfect - Heroes III seems to automatically lowercase resources in the windows right. Is there a way to fix this?
example

@RoseKavalier RoseKavalier added the off-topic Unrelated to H3Plugins label Mar 1, 2021
@RoseKavalier RoseKavalier self-assigned this Mar 1, 2021
@RoseKavalier
Copy link
Owner

"Keyboard" is mostly handled through the .FNT files.
Heroes3 doesn't generally change text casing, check the game assets.

@heroesiiifan
Copy link
Author

heroesiiifan commented Mar 1, 2021

Thanks for your answer.

Keyboard:
When I open the savegame-dialog and I type "zzz" it displays "yyy" and will save it as "yyy" (file manager in windows). There should be any hard coded Layout. If I do this in the german RoE it will work correctly (uses same fonts).

Casing:
My ResTypes.txt looks like following:

Holz
Quecksilber
Erz
Schwefel
Kristalle
Edelsteine
Gold
Verlassen

I searched with Notepad++ in all files for an lowercase "holz". But nothing found. This is quite strange...

Edit: I've confirmed it: If I change "Holz" to "AAAHolz" in ResTypes.txt it will display "aAAHolz" in the Box on the right. Sadly there is an lowercasing (at least in the box after picking up e.g. wood; I've don't seen this anywhere else yet).

@RoseKavalier
Copy link
Owner

Learn something new every day looking at that exe... the first letter of resource names is transformed to lowercase before displaying. A localization plugin could take care of that.

I'm not familiar enough with heroes3's handling of keyboard styles and I don't have the German RoE version handy.

Repository owner deleted a comment from heroesiiifan Mar 3, 2021
@RoseKavalier
Copy link
Owner

Your message contained copyrighted content, I deleted it.

@RoseKavalier
Copy link
Owner

RoseKavalier commented Mar 3, 2021

I can think of two possible solutions:
1- use LoadKeyboardLayoutA to tell the application to use a specific locale. This is an intrusive call after Windows 8 so not a preferred option.
2- hack input manager and swap key presses

I'm not sure what kind of impact this would have overall to be honest.

EDIT
3- figure out where the input manager is switching between QWERTY and QWERTZ layout.

Simple enough it could be done with a hex edit patch, but I think it's a worthwhile thing to be set via plugin.

@RoseKavalier RoseKavalier added enhancement New feature or request and removed off-topic Unrelated to H3Plugins labels Mar 3, 2021
@heroesiiifan
Copy link
Author

Amazing results. Thank you. 3. looks very interesting.

With my Hex-Editor I don't find the values. Is the data encoded?

@RoseKavalier
Copy link
Owner

That's the memory layout of InputManager, you won't find it as is with a hex editor. I'll have a bit of free time this weekend, I can make a plugin for QWERTZ keyboard layout then.

@heroesiiifan
Copy link
Author

I edited my memory with cheat engine. It seems to work. Very nice.
Yes, a plugin would be the best way. :)

@RoseKavalier RoseKavalier linked a pull request Mar 7, 2021 that will close this issue
@heroesiiifan
Copy link
Author

Thank you very much.

The only thing that won't work is uppercase at the "new" chars.
E.g Shift+Y for a big Y
or for example SHIFT+Ä for Ä

@RoseKavalier RoseKavalier reopened this Mar 7, 2021
@RoseKavalier
Copy link
Owner

Was it working correctly in RoE?

@heroesiiifan
Copy link
Author

heroesiiifan commented Mar 7, 2021

Okay, really strange. The german RoE has the same behavior.
It looks like the translator-team has worked improperly. :)

SHIFT+Z works -> uppercase
SHIFT+ Y, Ä, Ö, Ü not -> it's lowercase

@RoseKavalier
Copy link
Owner

Probably just need to get the correct capitalized unicode characters, these 4 look like lowercase.
image

@RoseKavalier
Copy link
Owner

RoseKavalier commented Mar 8, 2021

Give this one a try.

Essentially changed to this:

    WordPatch(0x4ECA0E + 1, 0xFFDF); // ß unicode replacement
    WordPatch(0x4ECA23 + 7, '@');
    WordPatch(0x4ECA6B + 7, 'Z');
    WordPatch(0x4ECA98 + 7, 0xFFDC); // Ü unicode replacement
    WordPatch(0x4ECAA1 + 7, '+');
    WordPatch(0x4ECB0D + 7, 0xFFD6); // Ö unicode replacement
    WordPatch(0x4ECB16 + 7, 0xFFC4); // Ä unicode replacement
    WordPatch(0x4ECB31 + 7, '#');
    WordPatch(0x4ECB3A + 7, 'Y');
    WordPatch(0x4ECB8B + 7, '-');

It looks ok in memory but I have no clue if it will work since it's not proper OBJECT REPLACEMENT CHARACTER type.

@heroesiiifan
Copy link
Author

X and Y works correct now.
But ÄÖÜ are only uppercase now.
ß is working. But if you type SHIFT+ß it is still ß but it should be ?.

@RoseKavalier
Copy link
Owner

Okay, that's a good step forward. Now I can look in making the lowercase-uppercase conversion actually do its job instead of naively converting with +/- 0x20 which only works for ascii characters.

The issue I see with Shift+ß is that this behaviour would lock the plugin in German version of QWERTZ. For now I suppose it can be a German-QWERTZ layout... if other people want to test their keyboard layout then the plugin can become customizable.

@heroesiiifan
Copy link
Author

I've found the adresses for the other problem.

If I change the 20 to 0 the values stay uppercase.
patch

How can I patch one byte with plugins?

@RoseKavalier
Copy link
Owner

That's to_lower() you don't want to touch that. The correct procedure is to remove the call to to_lower() for the controls that use resources, I have all the necessary info just not the time... I'll get around to it at some point.

@heroesiiifan
Copy link
Author

heroesiiifan commented Mar 11, 2021

Thank you.

Yes, that is correct.
But I'm very happy that I managed to find the correct function. :)

@heroesiiifan
Copy link
Author

heroesiiifan commented Aug 29, 2021

Note: The Keyboard issue is completely fixed with HoMM3 HD 5.2 R54.

@RoseKavalier
Copy link
Owner

Hmm, I'll still do it at some point when I get time for it.
Thanks for letting me know.

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

Successfully merging a pull request may close this issue.

2 participants