OSDN Git Service

Merge remote-tracking branch 'remotes/origin/For2.2.2-Fix-Hourier' into For2.2.2...
[hengband/hengband.git] / src / game-option / keymap-directory-getter.c
1 #include "game-option/keymap-directory-getter.h"
2 #include "game-option/input-options.h"
3 #include "io/input-key-requester.h"
4 #include "system/angband.h"
5 #include "util/int-char-converter.h"
6
7 /*
8  * GH
9  * Called from cmd4.c and a few other places. Just extracts
10  * a direction from the keymap for ch (the last direction,
11  * in fact) byte or char here? I'm thinking that keymaps should
12  * generally only apply to single keys, which makes it no more
13  * than 128, so a char should suffice... but keymap_act is 256...
14  */
15 int get_keymap_dir(char ch)
16 {
17     int d = 0;
18
19     if (isdigit(ch)) {
20         d = D2I(ch);
21     } else {
22         BIT_FLAGS mode;
23         if (rogue_like_commands) {
24             mode = KEYMAP_MODE_ROGUE;
25         } else {
26             mode = KEYMAP_MODE_ORIG;
27         }
28
29         concptr act = keymap_act[mode][(byte)(ch)];
30         if (act) {
31             for (concptr s = act; *s; ++s) {
32                 if (isdigit(*s))
33                     d = D2I(*s);
34             }
35         }
36     }
37
38     if (d == 5)
39         d = 0;
40
41     return (d);
42 }