Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old February 21, 2010, 09:47   #1
jsv
Scout
 
Join Date: Feb 2010
Location: Russia
Posts: 27
jsv is on a distinguished road
[sdl][S/O/FA/other]Alt and Meta keypress modifiers are ignored.

Greetings.

There is a bug in the SDL port that prevents alt/meta modifiers from being recognized. As the code in question is shared by many variants, I think here is a good place for a bug report. Correct me if I'm wrong.

In the sdl_keypress function (main-sdl.c) we find this innocently looking code:

Code:
        /* Store the value of various modifier keys */
        bool mc = (bool)(keysym.mod & (KMOD_CTRL));
        bool ms = (bool)(keysym.mod & (KMOD_SHIFT));
        bool ma = (bool)(keysym.mod & (KMOD_ALT));
        bool mm = (bool)(keysym.mod & (KMOD_META));
It looks correct and it would work correctly if only there were built-in bool type in (pre-C99) C. But there is none and in many *bands bool is defined as char (Vanilla uses built-in boolean type when it's available, so it is not affected by this bug -- but only if compiled with something conforming to C99 standard). Values of KMOD_ALT and KMOD_META exceed 0x100. When cast to char they are truncated, so ma and mm are always zero.

This can be fixed either by using int instead of bool for flags:
Code:
    ...
    int mc = (keysym.mod & (KMOD_CTRL));
    ...
or by explicit comparison with KMOD_NONE:
Code:
    ...
    bool mc = (bool)((keysym.mod & (KMOD_CTRL) != KMOD_NONE);
    ...
IMHO, even better solution would be to get rid of bool type entirely, removing it both from *band code and C standards -- the language just do not need it. But that would be too much work.
jsv is offline   Reply With Quote
Old February 21, 2010, 11:21   #2
Nick
Vanilla maintainer
 
Nick's Avatar
 
Join Date: Apr 2007
Location: Canberra, Australia
Age: 53
Posts: 7,573
Donated: $60
Nick is on a distinguished road
Thanks - fixed in FA and O dev versions.
__________________
One for the Dark Lord on his dark throne
In the Land of Mordor where the Shadows lie.
Nick is offline   Reply With Quote
Old November 22, 2010, 20:32   #3
Magnate
Angband Devteam member
 
Join Date: May 2007
Location: London, UK
Posts: 5,057
Magnate is on a distinguished road
Send a message via MSN to Magnate Send a message via Yahoo to Magnate
Finally fixed in V (staging branch - will be in nightlies shortly).
Magnate is offline   Reply With Quote
Old November 22, 2010, 20:36   #4
camlost
Sangband 1.x Maintainer
 
camlost's Avatar
 
Join Date: Apr 2007
Posts: 522
camlost is on a distinguished road
I guess I'm slow on the uptake; I guess I can fix this tonight when I get home
__________________
a chunk of Bronze {These look tastier than they are. !E}
3 blank Parchments (Vellum) {No french novels please.}
camlost 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
Down with the SDL! Pete Mack Development 0 August 13, 2009 04:26
feature request: add home inventory stat modifiers/flags/etc bebo Vanilla 2 July 17, 2009 00:36
SDL sound Nick Development 1 July 16, 2009 21:14
Ubuntu SDL Help? benhamill Vanilla 12 February 24, 2009 21:19


All times are GMT +1. The time now is 01:35.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.