Gamestudio Links
Zorro Links
Newest Posts
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
Data from CSV not parsed correctly
by jcl. 04/20/24 08:32
Zorro FIX plugin - Experimental
by jcl. 04/20/24 08:30
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (7th_zorro, 1 invisible), 581 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
inkey and Unicode #470699
01/31/18 11:07
01/31/18 11:07
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Hello!
I've been trying to implement Unicode keyboard input in my regular lite-C Pure game.
Using on_message I receive WM_CHAR events, including characters sent by a Japanese IME thing for testing. However, it seems like I cannot convert those to actual Unicode characters (the lParam is just 1 which probably is not right for any subsequent ToUnicode calls...?).
I assume this might be because IsWindowUnicode(hWnd) returns 0 and WM_CHAR messages are transformed to ANSI before they are sent to the application.
I've thought about creating my own hWnd with RegisterClassExW (which is not supported in GStudio8/include/windows.h, only RegisterClassEx, so maybe via a DLL) but I couldn't figure that one out yet. Would that be the right way?

Alternatively, I've tried to call
SetWindowsHookEx(WH_KEYBOARD_LL, HookCallback, NULL, 0);
in a DLL or directly in lite-C, then do the Unicode translation there and send the Unicode characters to the engine.
However, it seems like the callback function is not triggered correctly, in particular no response to/ from IME input. WH_KEYBOARD_LL may or may not be the wrong HookID but I did not have luck with any other mode.

Do you have any advice?
Thanks for reading.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: inkey and Unicode [Re: Superku] #470707
01/31/18 21:42
01/31/18 21:42
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
I gave it a shot and jap. IME does indeed not trigger KEYDOWN events. You might need some other functions to retrieve IME text since it's not really a key press/release but a string of characters that's sent to the window.


POTATO-MAN saves the day! - Random
Re: inkey and Unicode [Re: Kartoffel] #470731
02/03/18 17:26
02/03/18 17:26
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Yes, the hook is destroying the inputs. (EDIT: Oh, and thanks for giving it a shot!)

I've created a new Unicode hWnd window with the same/ default on_message engine message loop. That one is receiving the same messages as the default engine window, so the issue must be somewhere else (in the message loop itself?).

I don't think I can do this on my own.
Mr. Lotter, do you have any advice?

Thanks.

Last edited by Superku; 02/03/18 17:36.

"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: inkey and Unicode [Re: Superku] #471089
02/19/18 12:56
02/19/18 12:56
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Anyone got an idea how to get Unicode input running in A8? confused


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: inkey and Unicode [Re: Superku] #472152
04/12/18 13:32
04/12/18 13:32
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Mr. Lotter, can you do something about this, if necessary, release an official/ inoffical interim version with Unicode support? That would be amazing!

The issue in short: on_messages receives only ANSI WM_CHAR input (for IME input which is received as a sequence of multiple WM_CHAR messages, which is correct, this means they oftentimes all have the same values although it's different characters).


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: inkey and Unicode [Re: Superku] #472242
04/17/18 22:30
04/17/18 22:30
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
So you never actually catch a WM_UNICHAR message, only WM_CHAR?

https://msdn.microsoft.com/de-de/library/windows/desktop/ms646288(v=vs.85).aspx

See comment concerning wParam:
Quote:
The Unicode DefWindowProc posts a WM_CHAR message with the same parameters and the ANSI DefWindowProc function posts either one or two WM_CHAR messages with the corresponding ANSI character(s).
Sounds like what is happening to you.

Then you could build your own inkeyw based on custom message handling.

Code:
#include <acknex.h>
#include <windows.h>

LRESULT CALLBACK OriginalHandler(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);

LRESULT CALLBACK MyMessageHandler(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
   if (WM_UNICHAR == message)
   { 
       printf("OMG it's Unicode!");
       return 0;
   }
   return OriginalHandler(hwnd,message,wParam,lParam);   	  
}

function main() 
{
   OriginalHandler = on_message;	// store the original message loop
   on_message = MyMessageHandler; // and replace it by your own
   ...
}


Last edited by Firoball; 04/17/18 22:45.
Re: inkey and Unicode [Re: FBL] #472285
04/18/18 16:56
04/18/18 16:56
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Thanks for the suggestion, I actually hadn't found WM_UNICHAR yet, always only looked at WM_CHAR or non-filtered input. :-X
However, I cannot seem to trigger WM_UNICHAR at all.
I found WM_IME_CHAR which gets fired N times before N characters from an IME arrive, however they are converted to ANSI as far as I can tell before I get my dirty fingers on them. Even when I CreateWindowExW() a new Unicode window (IsWindowUnicode() returns 1 then) I cannot extract or combine WM_CHAR events into unicode digits. confused


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: inkey and Unicode [Re: Superku] #472286
04/18/18 17:20
04/18/18 17:20
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
So if you add your own lessage handling and WM_IME_CHAR message fires, what does wParam contain then? Is this value already truncated?

Re: inkey and Unicode [Re: FBL] #472287
04/18/18 17:38
04/18/18 17:38
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline OP
Senior Expert
Superku  Offline OP
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
wParam contains a bunch of values, most often 63. Currently I'm only receiving a single WM_CHAR event for each Unicode character - I thought I could trigger multiple calls some time ago -, all of them in the 8 bit range.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: inkey and Unicode [Re: Superku] #472288
04/18/18 18:49
04/18/18 18:49
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
Hm... 63 is a '?' .... supsicious somehow.
All values for wparam are always in 8 bit range? Strange.

According to the msdn you may receive both single and double byte characters, but this is not Unicode then and requires conversion - which is not trivial at all.

Page 1 of 2 1 2

Moderated by  old_bill, Tobias 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1