--- uae/src/od-win32/keyboard.c 2018/04/24 16:42:56 1.1 +++ uae/src/od-win32/keyboard.c 2018/04/24 17:17:38 1.1.1.3 @@ -4,9 +4,10 @@ * Additional Win32 helper functions not calling any system routines * * (c) 1997 Mathias Ortmann + * (c) 1999-2001 Brian King + * (c) 2000-2001 Bernd Roesch */ -#include "config.h" #include "sysconfig.h" #include @@ -17,18 +18,23 @@ #include "sysdeps.h" #include "uae.h" #include "options.h" -#include "threaddep/penguin.h" -#include "include/memory.h" +#include "memory.h" #include "custom.h" -#include "readcpu.h" #include "newcpu.h" #include "keyboard.h" #include "xwin.h" +#include "drawing.h" #include "disk.h" #include "keybuf.h" #include "gui.h" - -static int keystate[256]; +#include "osdep/win32.h" +#include "osdep/win32gui.h" +#include "debug.h" + +//#define DBG_KEYBD 1 +static int keystate[AK_RCTRL+1]; +static HKL keyboardlayoutid; +static WORD keyboardlangid; static int helppressed (void) { @@ -43,31 +49,115 @@ static int shiftpressed (void) static int getcapslock (void) { BYTE keyState[256]; - +#ifdef _WIN32_WCE + return( GetKeyState( VK_CAPITAL ) & 1 ); +#else GetKeyboardState (keyState); return keyState[VK_CAPITAL] & 1; +#endif } +static char getascii( UINT vk, UINT scancode ) +{ + BYTE keyState[256]; + char buffer[2]; + int result; +#ifndef _WIN32_WCE + GetKeyboardState (keyState); + result = ToAscii( vk, scancode, keyState, (LPWORD)buffer, 0 ); + if( result == 1 ) + result = buffer[0]; +#endif + return result; +} /* there's a problem remaining with the semantics of the '#' key on U.S. keyboards */ static int scancode2amiga (int keycode, int scancode) { - switch (keycode & 0xff) { + static int firstscan=0; + if (!firstscan) + { + keyboardlayoutid=GetKeyboardLayout(0); + keyboardlangid=LOWORD(keyboardlayoutid); + firstscan=1; + } +#if DEBUG_KBD + write_log( "keycode = 0x%x, scancode = 0x%x\n", keycode, scancode ); +#endif + + if(keyboardlangid==MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN)) + { + if (keystate[AK_CTRL] && + keystate[AK_RALT]) + { + switch (keycode & 0xff) + { + case 0xdb: + return AK_BACKSLASH; + case 0x51: //@ + record_key ((AK_CTRL << 1)+1); + return 0x10; + case 0xbb: //~ + record_key ((AK_CTRL << 1)+1); + return 0x1b; + + } + } + } + +#define USE_OLD_SHIFT_CODE + + switch (keycode & 0xff) + { +#ifndef USE_OLD_SHIFT_CODE + case VK_SHIFT: + { + SHORT lsh, rsh; + lsh = GetKeyState( VK_LSHIFT ); + rsh = GetKeyState( VK_RSHIFT ); + if( !keystate[AK_RSH] && (rsh & 0x8000)) + return AK_RSH; + if( keystate[AK_RSH] && !(rsh & 0x8000)) + return AK_RSH; + if( !keystate[AK_LSH] && (lsh & 0x8000)) + return AK_LSH; + if( keystate[AK_LSH] && !(lsh & 0x8000)) + return AK_LSH; + } +#endif case VK_INSERT: case VK_LWIN: return AK_LAMI; case VK_HOME: case VK_RWIN: return AK_RAMI; - case VK_DECIMAL: - return 0x3c; + case VK_MENU: + return scancode & KF_EXTENDED ? AK_RALT:AK_LALT; + case VK_APPS: /* Map Windows "Menu" key to Right-Alt of Amiga, for Stefan Stuntz */ + return AK_RALT; case VK_SCROLL: return AK_inhibit; + case VK_F11: +#if 0 + if( currprefs.win32_ctrl_F11_is_quit ) + { + if (GetAsyncKeyState (VK_CONTROL)&0x8000) + uae_quit(); + } +#endif + return AK_BACKSLASH; case VK_F12: - case VK_APPS: - return -2; + if (GetAsyncKeyState (VK_CONTROL)&0x8000) + return -6; + if( shiftpressed() ) + return -5; + else + return -2; + break; case VK_PAUSE: return -3; + case VK_DECIMAL: + return AK_NPDEL; case VK_DIVIDE: return AK_NPDIV; case VK_MULTIPLY: @@ -105,41 +195,41 @@ static int scancode2amiga (int keycode, case VK_RIGHT: return AK_RT; case VK_CONTROL: - return scancode == 0x11d ? AK_RCTRL : AK_CTRL; + return scancode & KF_EXTENDED ? AK_RCTRL : AK_CTRL; case VK_RETURN: - return keycode > 0xff ? 0x43 : 0x44; + return scancode & KF_EXTENDED ? AK_ENT : AK_RET; case VK_CAPITAL: return -4; case VK_F1: if (helppressed ()) return -10 - shiftpressed (); - return 0x50; + return AK_F1; case VK_F2: if (helppressed ()) return -12 - shiftpressed (); - return 0x51; + return AK_F2; case VK_F3: if (helppressed ()) return -14 - shiftpressed (); - return 0x52; + return AK_F3; case VK_F4: if (helppressed ()) return -16 - shiftpressed (); - return 0x53; + return AK_F4; case VK_F5: - return 0x54; + return AK_F5; case VK_F6: - return 0x55; + return AK_F6; case VK_F7: - return 0x56; + return AK_F7; case VK_F8: - return 0x57; + return AK_F8; case VK_F9: - return 0x58; + return AK_F9; case VK_F10: - return 0x59; + return AK_F10; case VK_NEXT: - return 0x5f; + return AK_HELP; } switch (scancode) { @@ -171,8 +261,8 @@ static int scancode2amiga (int keycode, return 0x0b; case 0x0d: return 0x0c; - case 0x57: - return 0x0d; + case 0x57: /* This is F11 */ + return AK_BACKSLASH; case 0x0e: return 0x41; case 0x0f: @@ -223,15 +313,23 @@ static int scancode2amiga (int keycode, case 0x26: return 0x28; case 0x27: - return 0x29; + return AK_SEMICOLON; case 0x28: - return 0x2a; - case 0x2b: - return 0x2b; + return AK_QUOTE; + case 0x2b: /* This scancode is \ on US keyboards, but # on German ones - figure out which! */ + if( getascii( keycode & 0xFF, scancode ) == '#' ) + return AK_NUMBERSIGN; + else + return AK_BACKSLASH; + break; +#ifdef USE_OLD_SHIFT_CODE case 0x2a: - return 0x60; + return AK_LSH; + case 0x36: + return AK_RSH; +#endif case 0x56: - return 0x30; + return AK_LTGT; case 0x2c: return 0x31; case 0x2d: @@ -252,8 +350,6 @@ static int scancode2amiga (int keycode, return 0x39; case 0x35: return 0x3a; - case 0x36: - return 0x61; case 0x38: return 0x64; case 0x39: @@ -263,9 +359,9 @@ static int scancode2amiga (int keycode, case 0x51: return 0x5f; case 0x52: - return 0x66; + return AK_LAMI; case 0x47: - return 0x67; + return AK_RAMI; case 0x4b: return 0x4f; case 0x50: @@ -285,23 +381,40 @@ static int scancode2amiga (int keycode, return -1; } +void clearallkeys() +{ + int i; + for(i = 0; i = -17 && akey <= -10) { - char tmpbuf[80]; - akey = -10 - akey; - - if (akey & 1) { - akey >>= 1; - disk_eject (akey); - return 0; - } - akey >>= 1; - - sprintf (tmpbuf, "Insert disk into drive df%d:...", akey); - requestfname (tmpbuf, changed_prefs.df[akey]); - - } - return 0; + if (newstate && akey >= -17 && akey <= -10) + { + akey = -10 - akey; + + if (akey & 1) + { + akey >>= 1; + disk_eject (akey); + return 0; + } + akey >>= 1; + + WIN32GUI_DisplayGUI( akey ); + } + return 0; +#endif } } if (akey == AK_inhibit) { if (newstate) - inhibit_frame ^= 1; + toggle_inhibit_frame (IHF_SCROLLLOCK); return 0; } + if( akey > AK_RCTRL ) + return 0; if (keystate[akey] == newstate) return 0; keystate[akey] = newstate; @@ -344,8 +488,8 @@ int my_kbd_handler (int keycode, int sca record_key ((akey << 1) + 1); /* "Affengriff" */ - if (keystate[AK_CTRL] && keystate[AK_LAMI] && keystate[AK_RAMI]) - uae_reset (); + if( (keystate[AK_CTRL] || keystate[AK_RCTRL] ) && keystate[AK_LAMI] && keystate[AK_RAMI])uae_reset(); + //if( (keystate[AK_CTRL] || keystate[AK_RCTRL] ) && keystate[AK_RAMI])uae_reset(); return 0; }