Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old February 21, 2010, 10: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
 


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 22:19


All times are GMT +1. The time now is 15:51.


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