Skip to content

Commit

Permalink
OSK and MM keyboard modes should bypass Backslash/F11 option.
Browse files Browse the repository at this point in the history
  • Loading branch information
tonioni committed Dec 9, 2023
1 parent 4c7b2c7 commit af2e568
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 46 deletions.
4 changes: 2 additions & 2 deletions consolehook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ static void console_thread (void *v)
c[0] = 0;
c[1] = 0;
ua_copy (c, 1, &wc);
record_key_direct ((0x10 << 1) | 0);
record_key_direct ((0x10 << 1) | 1);
record_key_direct((0x10 << 1) | 0, false);
record_key_direct((0x10 << 1) | 1, false);
}
}

Expand Down
14 changes: 7 additions & 7 deletions include/keybuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
#ifndef UAE_KEYBUF_H
#define UAE_KEYBUF_H

extern int get_next_key (void);
extern int keys_available (void);
extern int record_key (int);
extern int record_key_direct (int);
extern void keybuf_init (void);
extern int getcapslockstate (void);
extern void setcapslockstate (int);
extern int get_next_key(void);
extern int keys_available(void);
extern int record_key(int, bool);
extern int record_key_direct(int, bool);
extern void keybuf_init(void);
extern int getcapslockstate(void);
extern void setcapslockstate(int);
extern void keybuf_inject(const uae_char*);
extern void keybuf_ignore_next_release(void);
extern void keybuf_vsync(void);
Expand Down
22 changes: 11 additions & 11 deletions inputdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3467,9 +3467,9 @@ static void mouseupdate (int pct, bool vsync)
/* if v != 0, record mouse wheel key presses
* according to the NewMouse standard */
if (v3 > 0)
record_key (0x7a << 1);
record_key(0x7a << 1, true);
else if (v3 < 0)
record_key (0x7b << 1);
record_key(0x7b << 1, true);
if (!mouse_deltanoreset[i][2])
mouse_delta[i][2] = 0;

Expand Down Expand Up @@ -4100,7 +4100,7 @@ static void inject_events (const TCHAR *str)
}
if (kc != 0xff) {
//write_log (_T("%s\n"), cf);
record_key (kc);
record_key(kc, false);
}
}
}
Expand All @@ -4109,8 +4109,8 @@ static void inject_events (const TCHAR *str)
if ((ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9')) {
for (int i = 1; events[i].name; i++) {
if (events[i].allow_mask == AM_K && events[i].name[1] == 0 && events[i].name[0] == ch) {
record_key (events[i].data << 1);
record_key ((events[i].data << 1) | 0x01);
record_key(events[i].data << 1, false);
record_key((events[i].data << 1) | 0x01, false);
//write_log (_T("%c\n"), ch);
}
}
Expand All @@ -4121,7 +4121,7 @@ static void inject_events (const TCHAR *str)
while (--keycnt >= 0) {
uae_u8 kc = keys[keycnt];
if (kc != 0xff)
record_key (kc | 0x01);
record_key(kc | 0x01, false);
}
}

Expand Down Expand Up @@ -4608,7 +4608,7 @@ void inputdevice_do_keyboard(int code, int state)
}
}
if (!keyboard_reset_seq_mode) {
if (record_key((uae_u8)((key << 1) | (key >> 7)))) {
if (record_key((uae_u8)((key << 1) | (key >> 7)), false)) {
if (inputdevice_logging & 1)
write_log(_T("Amiga key %02X %d\n"), key & 0x7f, key >> 7);
}
Expand Down Expand Up @@ -8462,19 +8462,19 @@ static void sendmmcodes (int code, int newstate)
uae_u8 b;

b = RAW_STEALTH | IECODE_UP_PREFIX;
record_key (((b << 1) | (b >> 7)) & 0xff);
record_key(((b << 1) | (b >> 7)) & 0xff, true);
b = IECODE_UP_PREFIX;
if ((code >> 8) == 0x01)
b |= STEALTHF_E0KEY;
if ((code >> 8) == 0x02)
b |= STEALTHF_E1KEY;
if (!newstate)
b |= STEALTHF_UPSTROKE;
record_key(((b << 1) | (b >> 7)) & 0xff);
record_key(((b << 1) | (b >> 7)) & 0xff, true);
b = ((code >> 4) & 0x0f) | IECODE_UP_PREFIX;
record_key(((b << 1) | (b >> 7)) & 0xff);
record_key(((b << 1) | (b >> 7)) & 0xff, true);
b = (code & 0x0f) | IECODE_UP_PREFIX;
record_key(((b << 1) | (b >> 7)) & 0xff);
record_key(((b << 1) | (b >> 7)) & 0xff, true);
}

// main keyboard press/release entry point
Expand Down
42 changes: 22 additions & 20 deletions keybuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,17 @@ static void keytoscancode(int key, bool release)
v = (v << 1) | (v >> 7);
q |= mask;
if (release) {
record_key(v);
record_key(v, false);
if (q & 0x7f) {
q = (q << 1) | (q >> 7);
record_key(q);
record_key(q, false);
}
} else {
if (q & 0x7f) {
q = (q << 1) | (q >> 7);
record_key(q);
record_key(q, false);
}
record_key(v);
record_key(v, false);
}
}

Expand Down Expand Up @@ -263,16 +263,16 @@ void keybuf_vsync(void)
if (delayed_released_time > 0) {
delayed_released_time--;
if (delayed_released_time == 0) {
record_key(delayed_released_code);
record_key(delayed_released_code, false);
}
}
}

int record_key (int kc)
int record_key(int kc, bool direct)
{
if (pause_emulation)
return 0;
return record_key_direct (kc);
return record_key_direct(kc, direct);
}

static void keyswap(int *kcdp, int *kcp, uae_u8 k1, uae_u8 k2)
Expand All @@ -290,24 +290,26 @@ static void keyswap(int *kcdp, int *kcp, uae_u8 k1, uae_u8 k2)
*kcp = kc;
}

int record_key_direct (int kc)
int record_key_direct(int kc, bool direct)
{
int kpb_next = kpb_first + 1;
int kcd = (kc << 7) | (kc >> 1);

if (key_swap_hack2) {
// $0D <> $0C
keyswap(&kcd, &kc, 0x0d, 0x0c);
}
if (key_swap_hack == 2) {
// $2B <> $0D
keyswap(&kcd, &kc, 0x2b, 0x0d);
}
if (!direct) {
if (key_swap_hack2) {
// $0D <> $0C
keyswap(&kcd, &kc, 0x0d, 0x0c);
}
if (key_swap_hack == 2) {
// $2B <> $0D
keyswap(&kcd, &kc, 0x2b, 0x0d);
}

if (ignore_next_release) {
ignore_next_release = false;
if (kcd & 0x80) {
return 0;
if (ignore_next_release) {
ignore_next_release = false;
if (kcd & 0x80) {
return 0;
}
}
}

Expand Down
12 changes: 6 additions & 6 deletions od-win32/win32gfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4836,9 +4836,9 @@ void target_osk_control(int x, int y, int button, int buttonstate)
D3D_extoverlay(&osd_kb_eo, 0);
if ((kb->code & 0xf000) != 0xf000) {
if (kb->pressed) {
record_key((kb->code << 1) | 0);
record_key((kb->code << 1) | 0, true);
} else {
record_key((kb->code << 1) | 1);
record_key((kb->code << 1) | 1, true);
}
}
}
Expand All @@ -4851,7 +4851,7 @@ void target_osk_control(int x, int y, int button, int buttonstate)
highlight(&osd_kb_eo, kb, true);
D3D_extoverlay(&osd_kb_eo, 0);
if (kb->code != 0x62) {
record_key((kb->code << 1) | 1);
record_key((kb->code << 1) | 1, true);
}
}
if (buttonstate) {
Expand Down Expand Up @@ -4883,14 +4883,14 @@ void target_osk_control(int x, int y, int button, int buttonstate)
if (buttonstate) {
int capsstate = getcapslockstate();
capsstate = capsstate ? 0 : 1;
record_key((kb->code << 1) | capsstate);
record_key((kb->code << 1) | capsstate, true);
setcapslockstate(capsstate);
}
} else {
if (buttonstate) {
record_key((kb->code << 1) | 0);
record_key((kb->code << 1) | 0, true);
} else {
record_key((kb->code << 1) | 1);
record_key((kb->code << 1) | 1, true);
}
}
}
Expand Down

0 comments on commit af2e568

Please sign in to comment.