37
37
#include "resources.h" // resource_value_t
40
41
/* 40/80 column key. */
41
42
static key_ctrl_column4080_func_t key_ctrl_column4080_func = NULL;
43
45
static key_ctrl_caps_func_t key_ctrl_caps_func = NULL;
46
48
// -----------------------------------------------------------------
48
inline void kbd_set_key(const CHAR code1, const CHAR code2,
49
const USHORT release, const USHORT shift)
50
inline void kbd_set_key(const CHAR code1, const CHAR code2, const USHORT release, const USHORT shift)
52
53
// Serach for the key in the list
55
for (nr=0; nr<keyconvmap.entries; nr++)
57
if (keyconvmap.map[shift][nr].code==(code1 | code2<<8))
57
for (nr = 0; nr < keyconvmap.entries; nr++) {
58
if (keyconvmap.map[shift][nr].code == (code1 | code2 << 8)) {
62
64
// if the key wasn't found in the list don't do any action
64
if (nr==keyconvmap.entries)
66
if (nr == keyconvmap.entries) {
67
68
log_message(LOG_DEFAULT, "proc.c: Unknown key %d %d pressed by user.", code1, code2);
72
74
// Pass pressed and mapped key to Vice
74
keyboard_set_keyarr(keyconvmap.map[shift][nr].row,
75
keyconvmap.map[shift][nr].column,
79
log_debug("key %3i %3i -%d-> %3i %3i %i",
80
code1, code2, fsFlags&KC_CHAR,
81
keyconvmap.map[shift][nr].row,
82
keyconvmap.map[shift][nr].column,
83
keyconvmap.map[shift][nr].vshift);
76
keyboard_set_keyarr(keyconvmap.map[shift][nr].row, keyconvmap.map[shift][nr].column, release);
87
79
// process virtual shift key
89
switch (keyconvmap.map[shift][nr].vshift)
91
case 0x1: // left shifted, press/release left shift
92
keyboard_set_keyarr(keyconvmap.lshift_row,
93
keyconvmap.lshift_col,
96
case 0x2: // right shifted, press/release right shift
97
keyboard_set_keyarr(keyconvmap.rshift_row,
98
keyconvmap.rshift_col,
101
case 0x3: // unshifted, release virtual shift keys
102
keyboard_set_keyarr(keyconvmap.lshift_row,
103
keyconvmap.lshift_col,
105
keyboard_set_keyarr(keyconvmap.rshift_row,
106
keyconvmap.rshift_col,
81
switch (keyconvmap.map[shift][nr].vshift) {
82
case 0x1: // left shifted, press/release left shift
83
keyboard_set_keyarr(keyconvmap.lshift_row, keyconvmap.lshift_col, release);
85
case 0x2: // right shifted, press/release right shift
86
keyboard_set_keyarr(keyconvmap.rshift_row, keyconvmap.rshift_col, release);
88
case 0x3: // unshifted, release virtual shift keys
89
keyboard_set_keyarr(keyconvmap.lshift_row, keyconvmap.lshift_col, 0);
90
keyboard_set_keyarr(keyconvmap.rshift_row, keyconvmap.rshift_col, 0);
112
95
void kbd_proc(HWND hwnd, MPARAM mp1, MPARAM mp2)
114
USHORT fsFlags = SHORT1FROMMP(mp1);
115
CHAR usScancode = CHAR4FROMMP(mp1); //fsFlags&KC_SCANCODE
116
CHAR usKeycode = SHORT1FROMMP(mp2); //fsFlags&KC_CHAR
117
CHAR usVK = SHORT2FROMMP(mp2); //fsFlags&KC_VIRTUALKEY VK_TAB/LEFT/RIGHT/UP/DOWN
118
USHORT release = !(fsFlags&KC_KEYUP);
97
USHORT fsFlags = SHORT1FROMMP(mp1);
98
CHAR usScancode = CHAR4FROMMP(mp1);
99
CHAR usKeycode = SHORT1FROMMP(mp2);
100
CHAR usVK = SHORT2FROMMP(mp2);
101
USHORT release = !(fsFlags & KC_KEYUP);
121
104
// ----- Process virtual keys -----
123
if (fsFlags&KC_VIRTUALKEY)
106
if (fsFlags & KC_VIRTUALKEY) {
128
case VK_F10: // press/release caps key
129
if (key_ctrl_caps_func)
130
key_ctrl_caps_func();
132
case VK_F11: // press/release 40/80-key
133
if (key_ctrl_column4080_func)
134
key_ctrl_column4080_func();
109
case VK_F10: // press/release caps key
110
if (key_ctrl_caps_func) {
111
key_ctrl_caps_func();
114
case VK_F11: // press/release 40/80-key
115
if (key_ctrl_column4080_func) {
116
key_ctrl_column4080_func();
137
case VK_F12: // restore key pressed
138
machine_set_restore_key(release);
140
case VK_SCRLLOCK: // toggle warp mode if ScrlLock is pressed
141
resources_set_int("WarpMode",
142
(int)(fsFlags&KC_TOGGLE));
144
case VK_CAPSLOCK: // turn capslock led off if capslock is pressed
146
/* This is not a beautiful way, but the one I know :-) */
148
WinSetKeyboardStateTable(HWND_DESKTOP, keyState, FALSE);
149
keyState[VK_CAPSLOCK] &= ~1;
150
WinSetKeyboardStateTable(HWND_DESKTOP, keyState, TRUE);
120
case VK_F12: // restore key pressed
121
machine_set_restore_key(release);
123
case VK_SCRLLOCK: // toggle warp mode if ScrlLock is pressed
124
resources_set_int("WarpMode", (int)(fsFlags & KC_TOGGLE));
126
case VK_CAPSLOCK: // turn capslock led off if capslock is pressed
128
/* This is not a beautiful way, but the one I know :-) */
131
WinSetKeyboardStateTable(HWND_DESKTOP, keyState, FALSE);
132
keyState[VK_CAPSLOCK] &= ~1;
133
WinSetKeyboardStateTable(HWND_DESKTOP, keyState, TRUE);
157
140
// ----- give all keypresses without Alt to Vice -----
159
if (!(fsFlags&KC_ALT))
142
if (!(fsFlags & KC_ALT)) {
162
144
// repeats are handled by vice itself
164
if (fsFlags&KC_PREVDOWN)
146
if (fsFlags & KC_PREVDOWN) {
168
151
// check if the key is defined as joystick action
170
if (joystick_handle_key((kbd_code_t)usScancode, release))
153
if (joystick_handle_key((kbd_code_t)usScancode, release)) {
174
158
// this is a good canidate to be passed to vice
176
kbd_set_key(keyconvmap.symbolic?usKeycode:usScancode,
177
keyconvmap.symbolic?usVK:0,
178
release, fsFlags&KC_SHIFT?1:0);
160
kbd_set_key(keyconvmap.symbolic ? usKeycode : usScancode, keyconvmap.symbolic ? usVK : 0, release, fsFlags & KC_SHIFT ? 1 : 0);
183
165
// if key is released: return
188
// Process all keys whichs are pressed together with Alt.
190
if (usScancode==K_V && key_ctrl_column4080_func)
191
key_ctrl_column4080_func(); // press/release 40/80-key
192
if (usScancode==K_V && key_ctrl_caps_func)
193
key_ctrl_caps_func(); // press/release caps key
197
172
// ------------------------------------------------------------------