RoseKavalier / H3Plugins

Plugins for Heroes of Might and Magic III using the H3API headers.
MIT License
80 stars 10 forks source link

Posibility to Change Keyboard Layout? #17

Open heroesiiifan opened 3 years ago

heroesiiifan commented 3 years ago

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 commented 3 years ago

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

heroesiiifan commented 3 years ago

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 commented 3 years ago

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.

RoseKavalier commented 3 years ago

Your message contained copyrighted content, I deleted it.

RoseKavalier commented 3 years ago

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.

heroesiiifan commented 3 years ago

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

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

RoseKavalier commented 3 years ago

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 commented 3 years ago

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

heroesiiifan commented 3 years ago

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 commented 3 years ago

Was it working correctly in RoE?

heroesiiifan commented 3 years ago

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 commented 3 years ago

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

RoseKavalier commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

Thank you.

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

heroesiiifan commented 3 years ago

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

RoseKavalier commented 3 years ago

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