OSDN Git Service

Merge pull request #3532 from sikabane-works/release/3.0.0.87-alpha
[hengbandforosx/hengbandosx.git] / src / game-option / keymap-directory-getter.cpp
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
39     if (d == 5) {
40         d = 0;
41     }
42
43     return d;
44 }