|
|
1.1 root 1: /*
2: Hatari - keymap.c
3:
4: This file is distributed under the GNU Public License, version 2 or at
5: your option any later version. Read the file gpl.txt for details.
6:
7: Here we process a key press and the remapping of the scancodes.
8: */
9: const char Keymap_fileid[] = "Hatari keymap.c : " __DATE__ " " __TIME__;
10:
11: #include <ctype.h>
12: #include "main.h"
13: #include "keymap.h"
14: #include "configuration.h"
15: #include "file.h"
16: #include "shortcut.h"
17: #include "str.h"
18: #include "screen.h"
19: #include "debugui.h"
20: #include "log.h"
21:
22:
23:
24: /*-----------------------------------------------------------------------*/
25: /**
26: * User press key down
27: */
28: void Keymap_KeyDown(SDL_keysym *sdlkey)
29: {
30: bool bPreviousKeyState;
31: char STScanCode;
32: int symkey = sdlkey->sym;
33: int modkey = sdlkey->mod;
34:
35: /*fprintf(stderr, "keydown: sym=%i scan=%i mod=$%x\n",symkey, sdlkey->scancode, modkey);*/
36:
37: if (ShortCut_CheckKeys(modkey, symkey, 1))
38: return;
39:
40: }
41:
42:
43: /*-----------------------------------------------------------------------*/
44: /**
45: * User released key
46: */
47: void Keymap_KeyUp(SDL_keysym *sdlkey)
48: {
49: char STScanCode;
50: int symkey = sdlkey->sym;
51: int modkey = sdlkey->mod;
52:
53: /*fprintf(stderr, "keyup: sym=%i scan=%i mod=$%x\n",symkey, sdlkey->scancode, modkey);*/
54:
55: /* Ignore short-cut keys here */
56:
57: if (ShortCut_CheckKeys(modkey, symkey, 0))
58: return;
59:
60:
61: }
62:
63: /*-----------------------------------------------------------------------*/
64: /**
65: * Simulate press or release of a key corresponding to given character
66: */
67: void Keymap_SimulateCharacter(char asckey, bool press)
68: {
69: SDL_keysym sdlkey;
70:
71: sdlkey.mod = KMOD_NONE;
72: sdlkey.scancode = 0;
73: if (isupper(asckey)) {
74: if (press) {
75: sdlkey.sym = SDLK_LSHIFT;
76: Keymap_KeyDown(&sdlkey);
77: }
78: sdlkey.sym = tolower(asckey);
79: sdlkey.mod = KMOD_LSHIFT;
80: } else {
81: sdlkey.sym = asckey;
82: }
83: if (press) {
84: Keymap_KeyDown(&sdlkey);
85: } else {
86: Keymap_KeyUp(&sdlkey);
87: if (isupper(asckey)) {
88: sdlkey.sym = SDLK_LSHIFT;
89: Keymap_KeyUp(&sdlkey);
90: }
91: }
92: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.