On Fri, 2007-02-23 at 16:05 +0100, Jörg Hinrichs wrote:
> Hi guys,
> 
> i have no idea why someone thinks i am able to solve that problem :-P
> 
> Anyway, since this was assigned to me i did some searching. The
> problemis related to unicode and i can tell what's going wrong but i
> have noidea how to fix it (well, at least not with keeping the
> desiredfunctionality). So here is the malfunctioning code
> withinhotkeys::set_key(...):
> 
>     if (character < 64 && ctrl) {
>         if (shift)
>             character += 64;
>         else
>             character += 96;
>         INFO_C << "Mapped tocharacter " << 
> lexical_cast<std::string>(character)<< "\n";
>     }
> 
>     // We handle simple cases by character, others by the actual key.
>     if (isprint(character) && !isspace(character)) {
>         type_ = BY_CHARACTER;
>         character_ = character;
>         ctrl_ = ctrl;
>         alt_ = alt;
>         cmd_ = cmd;
>         INFO_C << "type = BY_CHARACTER\n";
>     } else {
>         type_ = BY_KEYCODE;
>         keycode_ = keycode;
>         shift_ = shift;
>         ctrl_ = ctrl;
>         alt_ = alt;
>         cmd_ = cmd;
>         INFO_C << "type = BY_KEYCODE\n";
>     }
> 
> You see that if this is a printable character the shift key does
> notget evaluated in contrast to the other branch. I don't know if this
> ison purpose or just forgotten. Also you won't see the desired
> characteras the character variable is shifted in the if-statement
> above. Itested this and it happens for "normal" characters. If you
> type"ctrl+shift+g" for example, the value of the character
> variableentering the function is 8 and such it is shifted by 64 to
> "@". I don'tunderstand the reasoning behind that. To me it looks like
> this codeshould examine the keycode but i don't know much about
> unicode and ihave no idea what the character variable really
> represents.
> 
> So if someone who knows better can take care of that, please...?

Hmm, what platform were you experiencing this on?  This was my code, but
it was some time ago.

Control-A comes out as character 1, so this logic converts it back into
Control + a.  Control+shift+g comes in as 7, so gets mapped to 7+64 = 71
(capital G).  It should go down the first path, and come out as
"Control-G" (as separate from "Control-g").

Hope that helps?
Rusty.



_______________________________________________
Wesnoth-dev mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-dev

Reply via email to