Angband.oook.cz
Angband.oook.cz
AboutDownloadVariantsLadderForumCompetitionSpoilersComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old November 11, 2010, 23:38   #1
chris
Knight
 
Join Date: Jan 2008
Posts: 561
chris is on a distinguished road
Scandinavian Keyboard Layouts

Well, I'm trying to debug a problem with regard to alternative keyboard layouts and Hengband. I'm not sure if this has been fixed in Angband or not.

Take a look at: http://freepages.genealogy.rootsweb....ers/index.html

Especially the pictures at the bottom. To press the '@' key on the Icelandic layout, for example, one presses the right alt key and the Q key simultaneously.

Windows generates the following messages in a normal app:
Code:
WM_KEYDOWN : 0-17 1900545    //17 is 0x11 CONTROL
WM_KEYDOWN : 0-18 557318145  //18 is 0x12 ALT
WM_KEYDOWN : 0-81 537919489  //81 is 0x51 Q
WM_CHAR : 0-64 537919489     //Bingo ... 64 is ASCII speak for '@'
The problem is in Main-Win.c, we take that last WM_KEYDOWN for the Q key and pass it off to process_keydown() which says, yup, I got it. So we return 0 back to Windows for the WM_KEYDOWN, and Windows says OK, guess you don't need that WM_CHAR after all.

I'm just starting to debug this, and am in over my head. I'm wondering if this rings any bells with anybody. I need to get Angband (well, Hengband) to not think it likes that Ctl+Alt+Q on the WM_KEYDOWN so that Windows will oblige me with a WM_CHAR for the '@' key, which is correct for this keyboard layout.

Any thoughts?

Thanks in advance,
--Chris
chris is offline   Reply With Quote
Old November 12, 2010, 00:07   #2
chris
Knight
 
Join Date: Jan 2008
Posts: 561
chris is on a distinguished road
Vanilla code looks fine. Hengband has extra code, probably to support Japanese Keyboard layouts. Essentially, any time the Alt key is pressed, they send keys to the Angband Terminal. So while Vanilla has:

Code:
case WM_KEYDOWN:
{
	bool mc = FALSE;
	bool ms = FALSE;
	bool ma = FALSE;

	/* Extract the modifiers */
	if (GetKeyState(VK_CONTROL) & 0x8000) mc = TRUE;
	if (GetKeyState(VK_SHIFT)   & 0x8000) ms = TRUE;
	if (GetKeyState(VK_MENU)    & 0x8000) ma = TRUE;

	/* Handle "special" keys */
	if (special_key[(byte)(wParam)])
	{
		/* blah */
	}
}
Hengband had extra code like:

Code:
if (special_key[(byte)(wParam)] || (ma && !ignore_key[(byte)(wParam)]) )
where ignore_key is hardcoded to just a handful of keys to ignore for the Alt. 'Q' and '2' are definitely not in that list, and hardcoding is a bad idea anyway.

I just added some conditional compilation and now my Icelandic layout seems to work just fine.

Sorry for the premature bother. I did the whole "Hey, I'm stuck! Let me post on a forum hoping for a quick answer!" thing rather than just grunting it out.
chris is offline   Reply With Quote
Old November 12, 2010, 00:57   #3
Derakon
Prophet
 
Derakon's Avatar
 
Join Date: Dec 2009
Posts: 5,960
Derakon is on a distinguished road
No worries, now if someone else runs into this problem they can search and find your post with a solution. It's not like we're short on space for posts.
Derakon is offline   Reply With Quote
Old November 12, 2010, 02:06   #4
chris
Knight
 
Join Date: Jan 2008
Posts: 561
chris is on a distinguished road
Good Point. Here's a patch that should work on Hengband. To be truly useful, I should at least give that

Code:
diff -r 4db84295fa31 src/main-win.c
--- a/src/main-win.c	Thu Nov 11 14:05:23 2010 -0700
+++ b/src/main-win.c	Thu Nov 11 19:02:51 2010 -0700
@@ -4248,10 +4248,14 @@
 	if (GetKeyState(VK_SHIFT)   & 0x8000) ms = TRUE;
 	if (GetKeyState(VK_MENU)    & 0x8000) ma = TRUE;
 
+	/* Handle "special" keys */
+#if defined JP
 	Term_no_press = (ma) ? TRUE : FALSE;
-
-	/* Handle "special" keys */
 	if (special_key[(byte)(wParam)] || (ma && !ignore_key[(byte)(wParam)]) )
+#else
+	Term_no_press = FALSE;
+	if (special_key[(byte)(wParam)])
+#endif
 	{
 		bool ext_key = (lParam & 0x1000000L) ? TRUE : FALSE;
 		bool numpad = FALSE;
chris is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[All] Keyboard interface and keymaps Remuz Vanilla 12 April 17, 2008 23:24


All times are GMT +1. The time now is 08:02.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.