OSDN Git Service

[Refactor] #40413 Separated keymap-directory-getter.c/h from util.c/h
[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
5 /*
6  * GH
7  * Called from cmd4.c and a few other places. Just extracts
8  * a direction from the keymap for ch (the last direction,
9  * in fact) byte or char here? I'm thinking that keymaps should
10  * generally only apply to single keys, which makes it no more
11  * than 128, so a char should suffice... but keymap_act is 256...
12  */
13 int get_keymap_dir(char ch)
14 {
15     int d = 0;
16
17     if (isdigit(ch)) {
18         d = D2I(ch);
19     } else {
20         BIT_FLAGS mode;
21         if (rogue_like_commands) {
22             mode = KEYMAP_MODE_ROGUE;
23         } else {
24             mode = KEYMAP_MODE_ORIG;
25         }
26
27         concptr act = keymap_act[mode][(byte)(ch)];
28         if (act) {
29             for (concptr s = act; *s; ++s) {
30                 if (isdigit(*s))
31                     d = D2I(*s);
32             }
33         }
34     }
35
36     if (d == 5)
37         d = 0;
38
39     return (d);
40 }