Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions contrib/translations/de/de_DE.lng
Original file line number Diff line number Diff line change
Expand Up @@ -2619,6 +2619,9 @@ Schnellstartprogramm...
:MENU:mapper_shutdown
Beende DOSBox-X
.
:MENU:mapper_capkeyboard
Capture keyboard
.
:MENU:mapper_capmouse
Maus einfangen
.
Expand Down
3 changes: 3 additions & 0 deletions contrib/translations/de/de_pc98.lng
Original file line number Diff line number Diff line change
Expand Up @@ -2609,6 +2609,9 @@ Schnellstartprogramm...
:MENU:mapper_shutdown
Beende DOSBox-X
.
:MENU:mapper_capkeyboard
Capture keyboard
.
:MENU:mapper_capmouse
Maus einfangen
.
Expand Down
3 changes: 3 additions & 0 deletions contrib/translations/en/en_US.lng
Original file line number Diff line number Diff line change
Expand Up @@ -2406,6 +2406,9 @@ Quick launch program...
:MENU:mapper_shutdown
Quit from DOSBox-X
.
:MENU:mapper_capkeyboard
Capture keyboard
.
:MENU:mapper_capmouse
Capture mouse
.
Expand Down
3 changes: 3 additions & 0 deletions contrib/translations/es/es_ES.lng
Original file line number Diff line number Diff line change
Expand Up @@ -2433,6 +2433,9 @@ Inicio rápido de programa...
:MENU:mapper_shutdown
Salir de DOSBox-X
.
:MENU:mapper_capkeyboard
Capture keyboard
.
:MENU:mapper_capmouse
Capturar ratón
.
Expand Down
3 changes: 3 additions & 0 deletions contrib/translations/fr/fr_FR.lng
Original file line number Diff line number Diff line change
Expand Up @@ -2421,6 +2421,9 @@ Programme de lancement rapide...
:MENU:mapper_shutdown
Quitter
.
:MENU:mapper_capkeyboard
Capturer le clavier
.
:MENU:mapper_capmouse
Capturer la souris
.
Expand Down
3 changes: 3 additions & 0 deletions contrib/translations/hu/hu_HU.lng
Original file line number Diff line number Diff line change
Expand Up @@ -2414,6 +2414,9 @@ Gyors program indítás...
:MENU:mapper_shutdown
Kilépés a DOSBox-X-ből
.
:MENU:mapper_capkeyboard
Capture keyboard
.
:MENU:mapper_capmouse
Az egér DOSBOX-X-hez rendelése (ALT+Tab a feloldáshoz)
.
Expand Down
3 changes: 3 additions & 0 deletions contrib/translations/it/it_IT.lng
Original file line number Diff line number Diff line change
Expand Up @@ -2425,6 +2425,9 @@ Avvio rapido programma...
:MENU:mapper_shutdown
Esci da DOSBox-X
.
:MENU:mapper_capkeyboard
Capture keyboard
.
:MENU:mapper_capmouse
Cattura mouse
.
Expand Down
3 changes: 3 additions & 0 deletions contrib/translations/ja/ja_JP.lng
Original file line number Diff line number Diff line change
Expand Up @@ -2414,6 +2414,9 @@ DOSBox-X コマンド・シェルの起動
:MENU:mapper_shutdown
DOSBox-Xを終了する
.
:MENU:mapper_capkeyboard
Capture keyboard
.
:MENU:mapper_capmouse
マウスをキャプチャ
.
Expand Down
3 changes: 3 additions & 0 deletions contrib/translations/ko/ko_KR.lng
Original file line number Diff line number Diff line change
Expand Up @@ -2424,6 +2424,9 @@ DOSBox-X 명령 쉘을 시작합니다.
:MENU:mapper_shutdown
DOSBox-X를 종료
.
:MENU:mapper_capkeyboard
Capture keyboard
.
:MENU:mapper_capmouse
마우스를 갈무리
.
Expand Down
3 changes: 3 additions & 0 deletions contrib/translations/nl/nl_NL.lng
Original file line number Diff line number Diff line change
Expand Up @@ -2411,6 +2411,9 @@ Snelstartprogramma...
:MENU:mapper_shutdown
Afsluiten van DOSBox-X
.
:MENU:mapper_capkeyboard
Capture keyboard
.
:MENU:mapper_capmouse
Muis vastleggen
.
Expand Down
3 changes: 3 additions & 0 deletions contrib/translations/pt/pt_BR.lng
Original file line number Diff line number Diff line change
Expand Up @@ -2446,6 +2446,9 @@ Início rápido de programa...
:MENU:mapper_shutdown
Sair do DOSBox-X
.
:MENU:mapper_capkeyboard
Capture keyboard
.
:MENU:mapper_capmouse
Capturar mouse
.
Expand Down
3 changes: 3 additions & 0 deletions contrib/translations/ru/ru_RU.lng
Original file line number Diff line number Diff line change
Expand Up @@ -2558,6 +2558,9 @@ DEBUGBOX [команда] [опции]
:MENU:mapper_shutdown
Выйти из DOSBox-X
.
:MENU:mapper_capkeyboard
Capture keyboard
.
:MENU:mapper_capmouse
Захват мыши
.
Expand Down
3 changes: 3 additions & 0 deletions contrib/translations/tr/tr_TR.lng
Original file line number Diff line number Diff line change
Expand Up @@ -2433,6 +2433,9 @@ Hızlı program başlat...
:MENU:mapper_shutdown
DOSBox-X'ten çık
.
:MENU:mapper_capkeyboard
Capture keyboard
.
:MENU:mapper_capmouse
Fareyi yakala
.
Expand Down
3 changes: 3 additions & 0 deletions contrib/translations/zh/zh_CN.lng
Original file line number Diff line number Diff line change
Expand Up @@ -2395,6 +2395,9 @@ To adjust the emulated CPU speed, use host+Plus and host+Minus[3
:MENU:mapper_shutdown
退出 DOSBox-X
.
:MENU:mapper_capkeyboard
Capture keyboard
.
:MENU:mapper_capmouse
捕获鼠标
.
Expand Down
3 changes: 3 additions & 0 deletions contrib/translations/zh/zh_TW.lng
Original file line number Diff line number Diff line change
Expand Up @@ -2385,6 +2385,9 @@ DEBUGBOX [命令] [選項]
:MENU:mapper_shutdown
結束 DOSBox-X
.
:MENU:mapper_capkeyboard
Capture keyboard
.
:MENU:mapper_capmouse
擷取滑鼠
.
Expand Down
7 changes: 7 additions & 0 deletions include/sdlmain.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ struct SDL_Block {
int ysensitivity = 0;
MOUSE_EMULATION emulation = (MOUSE_EMULATION)0;
} mouse;
#if defined(C_SDL2)
bool capture_keyboard = false;
#endif
SDL_Rect updateRects[1024] = {};
Bitu overscan_color = 0;
Bitu overscan_width = 0;
Expand Down Expand Up @@ -240,6 +243,10 @@ SDL_Window* GFX_SetSDLWindowMode(uint16_t width, uint16_t height, SCREEN_TYPES s
void SDL_GL_SwapBuffers(void);
#endif

#if defined(C_SDL2)
void GFX_KeyboardCapture(bool enabled);
#endif

#if defined(WIN32) && !defined(HX_DOS)
extern int curscreen;
extern RECT monrect;
Expand Down
3 changes: 3 additions & 0 deletions src/gui/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ static const char *def_menu_main[] =
"MainHostKey",
"SharedClipboard",
"--",
#if defined(C_SDL2)
"mapper_capkeyboard",
#endif
"mapper_capmouse",
"auto_lock_mouse",
"WheelToArrow",
Expand Down
56 changes: 56 additions & 0 deletions src/gui/sdlmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2686,6 +2686,14 @@ static void CaptureMouse(bool pressed) {
GFX_CaptureMouse();
}

#if defined(C_SDL2)
static void CaptureKeyboard(bool pressed) {
if (pressed) {
GFX_KeyboardCapture(!sdl.capture_keyboard);
}
}
#endif

#if defined (WIN32)
STICKYKEYS stick_keys = {sizeof(STICKYKEYS), 0};
void sticky_keys(bool restore){
Expand Down Expand Up @@ -3770,6 +3778,11 @@ static void GUI_StartUp() {
sdl.mouse.ysensitivity = p3->GetSection()->Get_int("ysens");

#if defined(C_SDL2)
// Because we have the option of a dedicated keyboard shortcut to exit
// fullscreen, we don't need an Alt+Tab escape hatch. This lets us
// block it along with everything else, so you can use it in Windows etc.
SDL_SetHint(SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED, "0");

// Apply raw mouse input setting
SDL_SetHintWithPriority(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, section->Get_bool("raw_mouse_input") ? "0" : "1", SDL_HINT_OVERRIDE);
#endif
Expand Down Expand Up @@ -3815,6 +3828,11 @@ static void GUI_StartUp() {
item->set_text("Capture mouse");
}

#if defined(C_SDL2)
MAPPER_AddHandler(CaptureKeyboard,MK_f11,MMOD1,"capkeyboard","Capture keyboard", &item);
item->set_text("Capture keyboard");
#endif

#if defined(C_SDL2) || defined(WIN32) || defined(MACOSX)
MAPPER_AddHandler(QuickEdit,MK_nothing, 0,"fastedit", "Quick edit mode", &item);
item->set_text("Quick edit: copy on select and paste text");
Expand Down Expand Up @@ -4144,6 +4162,10 @@ static void GUI_StartUp() {
SDL_WM_SetCaption("DOSBox-X",VERSION);
#endif

#if defined(C_SDL2)
GFX_KeyboardCapture(section->Get_bool("keyboard_capture"));
#endif

/* Please leave the Splash screen stuff in working order in DOSBox-X. We spend a lot of time making DOSBox-X. */
//ShowSplashScreen(); /* I will keep the splash screen alive. But now, the BIOS will do it --J.C. */

Expand Down Expand Up @@ -4180,6 +4202,28 @@ bool Mouse_IsLocked()
return sdl.mouse.locked;
}

#if defined(C_SDL2)
void GFX_KeyboardCapture(bool enable) {
if (sdl.window) {
SDL_SetWindowKeyboardGrab(sdl.window, enable ? SDL_TRUE : SDL_FALSE);

// Make sure we're using the true value of the current grabbed state.
bool grabbed = SDL_GetWindowKeyboardGrab(sdl.window) == SDL_TRUE;
sdl.capture_keyboard = grabbed;

if (grabbed)
LOG_MSG("Capturing keyboard");
else
LOG_MSG("Releasing keyboard");
}

// Make sure our menu item is refreshed, to ensure the checkmark value next
// to the item is up-to-date.
if (mainMenu.item_exists("mapper_capkeyboard"))
mainMenu.get_item("mapper_capkeyboard").check(sdl.capture_keyboard).refresh_item(mainMenu);
}
#endif

static void RedrawScreen(uint32_t nWidth, uint32_t nHeight) {
(void)nWidth;//UNUSED
(void)nHeight;//UNUSED
Expand Down Expand Up @@ -6693,6 +6737,18 @@ void SDL_SetupConfigSection() {
"Putting a minus sign in front will disable the conversion for guest systems.");
Pint->SetBasic(true);

#if defined(C_SDL2)
Pbool = sdl_sec->Add_bool("keyboard_capture", Property::Changeable::Always, false);
Pbool->Set_help("Capture the keyboard, inhibiting window manager shortcuts.\n"
"Be warned, enabling this runs the risk of getting trapped inside "
"DOSBox-X, however it can be useful for passing combinations like Alt+F4 "
"through to DOS applications that use them, like WordPerfect.\n"
"Note that if another application attempts to grab the keyboard, DOSBox-X "
"will lose its grab over the keyboard. Additionally, not all shortcuts "
"can be inhibited on all platforms, for example Ctrl+Alt+Del on Windows.");
Pbool->SetBasic(true);
#endif

Pbool = sdl_sec->Add_bool("waitonerror",Property::Changeable::Always, true);
Pbool->Set_help("Wait before closing the console if DOSBox-X has an error.");
Pbool->SetBasic(true);
Expand Down