Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add confirmation popup support on Exit App key, libretro buildfix #20023

Merged
merged 3 commits into from
Feb 24, 2025
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
5 changes: 4 additions & 1 deletion Common/GPU/D3D11/thin3d_d3d11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ class D3D11DrawContext : public DrawContext {
case InfoField::DRIVER: return "-";
case InfoField::SHADELANGVERSION:
switch (featureLevel_) {
case D3D_FEATURE_LEVEL_1_0_CORE: return "Feature Level 1.0 Core";
case D3D_FEATURE_LEVEL_9_1: return "Feature Level 9.1";
case D3D_FEATURE_LEVEL_9_2: return "Feature Level 9.2";
case D3D_FEATURE_LEVEL_9_3: return "Feature Level 9.3";
Expand All @@ -182,7 +181,11 @@ class D3D11DrawContext : public DrawContext {
case D3D_FEATURE_LEVEL_11_1: return "Feature Level 11.1";
case D3D_FEATURE_LEVEL_12_0: return "Feature Level 12.0";
case D3D_FEATURE_LEVEL_12_1: return "Feature Level 12.1";
#ifndef __LIBRETRO__
case D3D_FEATURE_LEVEL_1_0_CORE: return "Feature Level 1.0 Core"; // This is for compute-only devices. Useless for us.
case D3D_FEATURE_LEVEL_12_2: return "Feature Level 12.2";
#endif
default: return "Feature Level X.X";
}
return "Unknown feature level";
case InfoField::APINAME: return "Direct3D 11";
Expand Down
22 changes: 11 additions & 11 deletions Core/ControlMapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ void ConvertAnalogStick(float x, float y, float *outX, float *outY) {
}

void ControlMapper::SetCallbacks(
std::function<void(int, bool)> onVKey,
std::function<void(int, float)> onVKeyAnalog,
std::function<void(VirtKey, bool)> onVKey,
std::function<void(VirtKey, float)> onVKeyAnalog,
std::function<void(uint32_t, uint32_t)> updatePSPButtons,
std::function<void(int, float, float)> setPSPAnalog,
std::function<void(int, float, float)> setRawAnalog) {
Expand Down Expand Up @@ -421,7 +421,7 @@ bool ControlMapper::UpdatePSPState(const InputMapping &changedMapping, double no
// OK, handle all the virtual keys next. For these we need to do deltas here and send events.
// Note that virtual keys include the analog directions, as they are driven by them.
for (int i = 0; i < VIRTKEY_COUNT; i++) {
int vkId = i + VIRTKEY_FIRST;
VirtKey vkId = (VirtKey)(i + VIRTKEY_FIRST);

uint32_t idForMapping = vkId;
SwapMappingIfEnabled(&idForMapping);
Expand Down Expand Up @@ -578,7 +578,7 @@ void ControlMapper::ToggleSwapAxes() {

updatePSPButtons_(0, CTRL_LEFT | CTRL_RIGHT | CTRL_UP | CTRL_DOWN);

for (uint32_t vkey = VIRTKEY_FIRST; vkey < VIRTKEY_LAST; vkey++) {
for (VirtKey vkey = VIRTKEY_FIRST; vkey < VIRTKEY_LAST; vkey = (VirtKey)(vkey + 1)) {
if (IsSwappableVKey(vkey)) {
if (virtKeyOn_[vkey - VIRTKEY_FIRST]) {
onVKey_(vkey, false);
Expand Down Expand Up @@ -668,13 +668,13 @@ void ControlMapper::PSPKey(int deviceId, int pspKeyCode, int flags) {
int vk = pspKeyCode - VIRTKEY_FIRST;
if (flags & KEY_DOWN) {
virtKeys_[vk] = 1.0f;
onVKey(pspKeyCode, true);
onVKeyAnalog(deviceId, pspKeyCode, 1.0f);
onVKey((VirtKey)pspKeyCode, true);
onVKeyAnalog(deviceId, (VirtKey)pspKeyCode, 1.0f);
}
if (flags & KEY_UP) {
virtKeys_[vk] = 0.0f;
onVKey(pspKeyCode, false);
onVKeyAnalog(deviceId, pspKeyCode, 0.0f);
onVKey((VirtKey)pspKeyCode, false);
onVKeyAnalog(deviceId, (VirtKey)pspKeyCode, 0.0f);
}
} else {
// INFO_LOG(Log::System, "pspKey %d %d", pspKeyCode, flags);
Expand All @@ -685,7 +685,7 @@ void ControlMapper::PSPKey(int deviceId, int pspKeyCode, int flags) {
}
}

void ControlMapper::onVKeyAnalog(int deviceId, int vkey, float value) {
void ControlMapper::onVKeyAnalog(int deviceId, VirtKey vkey, float value) {
// Unfortunately, for digital->analog inputs to work sanely, we need to sum up
// with the opposite value too.
int stick = 0;
Expand Down Expand Up @@ -716,7 +716,7 @@ void ControlMapper::onVKeyAnalog(int deviceId, int vkey, float value) {
SetPSPAxis(deviceId, stick, axis, sign * value);
}

void ControlMapper::onVKey(int vkey, bool down) {
void ControlMapper::onVKey(VirtKey vkey, bool down) {
switch (vkey) {
case VIRTKEY_ANALOG_ROTATE_CW:
if (down) {
Expand Down Expand Up @@ -745,7 +745,7 @@ void ControlMapper::onVKey(int vkey, bool down) {

void ControlMapper::GetDebugString(char *buffer, size_t bufSize) const {
std::stringstream str;
for (auto iter : curInput_) {
for (auto &iter : curInput_) {
char temp[256];
iter.first.FormatDebug(temp, sizeof(temp));
str << temp << ": " << iter.second.value << std::endl;
Expand Down
12 changes: 6 additions & 6 deletions Core/ControlMapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class ControlMapper {
// Required callbacks.
// TODO: These are so many now that a virtual interface might be more appropriate..
void SetCallbacks(
std::function<void(int, bool)> onVKey,
std::function<void(int, float)> onVKeyAnalog,
std::function<void(VirtKey, bool)> onVKey,
std::function<void(VirtKey, float)> onVKeyAnalog,
std::function<void(uint32_t, uint32_t)> updatePSPButtons,
std::function<void(int, float, float)> setPSPAnalog,
std::function<void(int, float, float)> setRawAnalog);
Expand Down Expand Up @@ -58,8 +58,8 @@ class ControlMapper {
void SetPSPAxis(int deviceId, int stick, char axis, float value);
void UpdateAnalogOutput(int stick);

void onVKey(int vkey, bool down);
void onVKeyAnalog(int deviceId, int vkey, float value);
void onVKey(VirtKey vkey, bool down);
void onVKeyAnalog(int deviceId, VirtKey vkey, float value);

void UpdateCurInputAxis(const InputMapping &mapping, float value, double timestamp);
float GetDeviceAxisThreshold(int device, const InputMapping &mapping);
Expand Down Expand Up @@ -93,8 +93,8 @@ class ControlMapper {
std::map<InputMapping, InputSample> curInput_;

// Callbacks
std::function<void(int, bool)> onVKey_;
std::function<void(int, float)> onVKeyAnalog_;
std::function<void(VirtKey, bool)> onVKey_;
std::function<void(VirtKey, float)> onVKeyAnalog_;
std::function<void(uint32_t, uint32_t)> updatePSPButtons_;
std::function<void(int, float, float)> setPSPAnalog_;
std::function<void(int, float, float)> setRawAnalog_;
Expand Down
2 changes: 1 addition & 1 deletion Core/KeyMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#define KEYMAP_ERROR_UNKNOWN_KEY 0

// Don't change any of these - it'll break backwards compatibility with configs.
enum {
enum VirtKey {
VIRTKEY_FIRST = 0x40000001,
VIRTKEY_AXIS_X_MIN = 0x40000001,
VIRTKEY_AXIS_Y_MIN = 0x40000002,
Expand Down
36 changes: 33 additions & 3 deletions UI/EmuScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ static void ShowFpsLimitNotice() {
g_OSD.Show(OSDType::TRANSPARENT_STATUS, temp, "", "I_FASTFORWARD", 1.5f, "altspeed");
}

void EmuScreen::onVKey(int virtualKeyCode, bool down) {
void EmuScreen::onVKey(VirtKey virtualKeyCode, bool down) {
auto sc = GetI18NCategory(I18NCat::SCREEN);
auto mc = GetI18NCategory(I18NCat::MAPPABLECONTROLS);

Expand Down Expand Up @@ -953,13 +953,41 @@ void EmuScreen::onVKey(int virtualKeyCode, bool down) {
"%s: %s", n->T("Enable networking"), g_Config.bEnableWlan ? di->T("Enabled") : di->T("Disabled")), 2.0, "toggle_wlan");
}
break;
default:
// To make sure we're not in an async context.
if (down) {
queuedVirtKey_ = virtualKeyCode;
}
break;
}
}

void EmuScreen::ProcessQueuedVKeys() {
switch (queuedVirtKey_) {
case VIRTKEY_EXIT_APP:
System_ExitApp();
{
std::string confirmExitMessage = GetConfirmExitMessage();
if (!confirmExitMessage.empty()) {
auto di = GetI18NCategory(I18NCat::DIALOG);
confirmExitMessage += '\n';
confirmExitMessage += di->T("Are you sure you want to exit?");
screenManager()->push(new PromptScreen(gamePath_, confirmExitMessage, di->T("Yes"), di->T("No"), [=](bool result) {
if (result) {
System_ExitApp();
}
}));
} else {
System_ExitApp();
}
break;
}
default:
break;
}
queuedVirtKey_ = (VirtKey)0;
}

void EmuScreen::onVKeyAnalog(int virtualKeyCode, float value) {
void EmuScreen::onVKeyAnalog(VirtKey virtualKeyCode, float value) {
if (virtualKeyCode != VIRTKEY_SPEED_ANALOG) {
return;
}
Expand Down Expand Up @@ -1478,6 +1506,8 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) {

GamepadUpdateOpacity();

ProcessQueuedVKeys();

bool skipBufferEffects = g_Config.bSkipBufferEffects;

bool framebufferBound = false;
Expand Down
8 changes: 6 additions & 2 deletions UI/EmuScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,14 @@ class EmuScreen : public UIScreen {
void runImDebugger();
void renderImDebugger();

void onVKey(int virtualKeyCode, bool down);
void onVKeyAnalog(int virtualKeyCode, float value);
void onVKey(VirtKey virtualKeyCode, bool down);
void onVKeyAnalog(VirtKey virtualKeyCode, float value);

void autoLoad();
bool checkPowerDown();

void ProcessQueuedVKeys();

UI::Event OnDevMenu;
UI::Event OnChatMenu;
bool bootPending_ = true;
Expand Down Expand Up @@ -144,6 +146,8 @@ class EmuScreen : public UIScreen {
bool keyAltRight_ = false;

bool lastImguiEnabled_ = false;

VirtKey queuedVirtKey_ = (VirtKey)0;
};

bool MustRunBehind();
Expand Down
2 changes: 1 addition & 1 deletion assets/lang/hu_HU.ini
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ Cardboard Screen Y Shift = Y irányú eltolás (üres terület %-ában kifejezve
Cardboard VR Settings = Google Cardboard VR beállítások
Cheats = Csalások
Copy to texture = Textúrába másolás
CPU texture upscaler (slow) = Felskálázás típusa
CPU texture upscaler (slow) = Felskálázás típusa (CPU)
Current GPU Driver = Current GPU Driver
Debugging = Hibakeresés
Default GPU driver = Default GPU driver
Expand Down
2 changes: 1 addition & 1 deletion assets/lang/id_ID.ini
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ Cardboard Screen Y Shift = Y shift (dalam % dari ruang kosong)
Cardboard VR Settings = Pengaturan Google Cardboard VR
Cheats = Pengecoh
Copy to texture = Salin ke tekstur
CPU texture upscaler (slow) = Jenis skala-atas
CPU texture upscaler (slow) = Jenis skala-atas (CPU)
Current GPU Driver = Driver GPU Saat Ini
Debugging = Awakutu
Default GPU driver = Driver GPU bawaan
Expand Down
2 changes: 1 addition & 1 deletion assets/lang/it_IT.ini
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ Cardboard Screen Y Shift = Spostamento verticale (in % di spazio vuoto)
Cardboard VR Settings = Impostazioni Google Cardboard VR
Cheats = Trucchi
Copy to texture = Copia nella texture
CPU texture upscaler (slow) = Tipo Ottimizzazione
CPU texture upscaler (slow) = Tipo Ottimizzazione (CPU)
Current GPU Driver = Driver GPU corrente
Debugging = Debugging
Default GPU driver = Driver GPU predefinito
Expand Down
2 changes: 1 addition & 1 deletion assets/lang/ja_JP.ini
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ Cardboard Screen Y Shift = Y軸の位置変更 (余白に対する%)
Cardboard VR Settings = Google Cardboard VRの設定
Cheats = チート
Copy to texture = テクスチャにコピー
CPU texture upscaler (slow) = アップスケールのタイプ
CPU texture upscaler (slow) = アップスケールのタイプ (CPU)
Current GPU Driver = 現在のGPUドライバ
Debugging = デバッグ
Default GPU driver = デフォルトのGPUドライバ
Expand Down
2 changes: 1 addition & 1 deletion assets/lang/jv_ID.ini
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ Cardboard Screen Y Shift = Y shift (in % of the blank space)
Cardboard VR Settings = Setelan Karton
Cheats = Cheats
Copy to texture = Copy to texture
CPU texture upscaler (slow) = Jenis Penaikan-skala
CPU texture upscaler (slow) = Jenis Penaikan-skala (CPU)
Current GPU Driver = Current GPU Driver
Debugging = Pilian debug
Default GPU driver = Default GPU driver
Expand Down
2 changes: 1 addition & 1 deletion assets/lang/lo_LA.ini
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ Cardboard Screen Y Shift = ປັບປ່ຽນແກນ Y (ໃນ % ຂອງ
Cardboard VR Settings = ການຕັ້ງຄ່າ Google Cardboard VR
Cheats = Cheats
Copy to texture = Copy to texture
CPU texture upscaler (slow) = ຮູບແບບການເພີ່ມສເກລພາບ
CPU texture upscaler (slow) = ຮູບແບບການເພີ່ມສເກລພາບ (CPU)
Current GPU Driver = Current GPU Driver
Debugging = ການແກ້ຈຸດບົກພ່ອງ
Default GPU driver = Default GPU driver
Expand Down
2 changes: 1 addition & 1 deletion assets/lang/lt-LT.ini
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ Cardboard Screen Y Shift = Y shift (in % of the blank space)
Cardboard VR Settings = Google Cardboard VR settings
Cheats = Cheats
Copy to texture = Copy to texture
CPU texture upscaler (slow) = "Pakėlimo" tipas
CPU texture upscaler (slow) = "Pakėlimo" tipas (CPU)
Current GPU Driver = Current GPU Driver
Debugging = Testinis režimas
Default GPU driver = Default GPU driver
Expand Down
2 changes: 1 addition & 1 deletion assets/lang/ms_MY.ini
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ Cardboard Screen Y Shift = Y shift (in % of the blank space)
Cardboard VR Settings = Google Cardboard VR settings
Cheats = Cheats
Copy to texture = Copy to texture
CPU texture upscaler (slow) = Jenis penskalaan
CPU texture upscaler (slow) = Jenis penskalaan (CPU)
Current GPU Driver = Current GPU Driver
Debugging = Pempepijat
Default GPU driver = Default GPU driver
Expand Down
2 changes: 1 addition & 1 deletion assets/lang/nl_NL.ini
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ Cardboard Screen Y Shift = Verschuiving Y-as (in % van de lege ruimte)
Cardboard VR Settings = Instellingen voor Google Cardboard VR
Cheats = Cheats
Copy to texture = Copy to texture
CPU texture upscaler (slow) = Upscaletype
CPU texture upscaler (slow) = Upscaletype (CPU)
Current GPU Driver = Current GPU Driver
Debugging = Fouten opsporen
Default GPU driver = Default GPU driver
Expand Down
2 changes: 1 addition & 1 deletion assets/lang/no_NO.ini
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ Cardboard Screen Y Shift = Y shift (in % of the blank space)
Cardboard VR Settings = Google Cardboard VR settings
Cheats = Cheats
Copy to texture = Copy to texture
CPU texture upscaler (slow) = Oppskaler type
CPU texture upscaler (slow) = Oppskaler type (CPU)
Current GPU Driver = Current GPU Driver
Debugging = Debugging
Default GPU driver = Default GPU driver
Expand Down
2 changes: 1 addition & 1 deletion assets/lang/pt_BR.ini
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ Backend = Backend
Balanced = Balanceado
Bicubic = Bi-cúbico
Copy to texture = Copiar pra textura
CPU texture upscaler (slow) = Tipo de ampliação
CPU texture upscaler (slow) = Tipo de ampliação (CPU)
Current GPU Driver = Driver da GPU Atual
Default GPU driver = Driver padrão da GPU
Disable culling = Desativar o culling
Expand Down
2 changes: 1 addition & 1 deletion assets/lang/pt_PT.ini
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ Cardboard Screen Y Shift = Deslocamento do Y (em % do espaço vazio)
Cardboard VR Settings = Definições do Google VR Cardboard
Cheats = Cheats
Copy to texture = Copy to texture
CPU texture upscaler (slow) = Tipo de ampliação
CPU texture upscaler (slow) = Tipo de ampliação (CPU)
Current GPU Driver = Current GPU Driver
Debugging = Debugging
Default GPU driver = Default GPU driver
Expand Down
2 changes: 1 addition & 1 deletion assets/lang/ro_RO.ini
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ Cardboard Screen Y Shift = mișcare Y (în % din spațiu gol)
Cardboard VR Settings = Setări Google Cardboard VR
Cheats = Cheats
Copy to texture = Copy to texture
CPU texture upscaler (slow) = Tip Suprascalare
CPU texture upscaler (slow) = Tip Suprascalare (CPU)
Current GPU Driver = Current GPU Driver
Debugging = Depanare
Default GPU driver = Default GPU driver
Expand Down
2 changes: 1 addition & 1 deletion assets/lang/tg_PH.ini
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ Cardboard Screen Y Shift = Y shift (in % of the blank space)
Cardboard VR Settings = Google Cardboard VR settings
Cheats = Cheats
Copy to texture = Copy to texture
CPU texture upscaler (slow) = Uri ng upscale
CPU texture upscaler (slow) = Uri ng upscale (CPU)
Current GPU Driver = Current GPU Driver
Debugging = Debugging
Default GPU driver = Default GPU driver
Expand Down
2 changes: 1 addition & 1 deletion assets/lang/tr_TR.ini
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ Cardboard Screen Y Shift = Y shift (boş alanın %'si olarak)
Cardboard VR Settings = Google Cardboard VR Ayarları
Cheats = Hileler
Copy to texture = Dokuya kopyala
CPU texture upscaler (slow) = Ölçeklendirme türü
CPU texture upscaler (slow) = Ölçeklendirme türü (CPU)
Current GPU Driver = Şimdiki GPU Sürücüsü
Debugging = Hata Ayıklama
Default GPU driver = Varsayılan GPU Sürücüsü
Expand Down
2 changes: 1 addition & 1 deletion assets/lang/uk_UA.ini
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ Cardboard Screen Y Shift = Налаштування - Y -
Cardboard VR Settings = Управління 3D кінотеатром
Cheats = Чит-коди
Copy to texture = Копіювати в текстуру
CPU texture upscaler (slow) = Тип масштабування
CPU texture upscaler (slow) = Тип масштабування (CPU)
Current GPU Driver = Поточний драйвер GPU
Debugging = Налагодження
Default GPU driver = звичайний драйвер CPU
Expand Down
2 changes: 1 addition & 1 deletion assets/lang/vi_VN.ini
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ Cardboard Screen Y Shift = Y shift (in % of the blank space)
Cardboard VR Settings = Google Cardboard VR settings
Cheats = Cheats
Copy to texture = Copy to texture
CPU texture upscaler (slow) = Loại cao cấp
CPU texture upscaler (slow) = Loại cao cấp (CPU)
Current GPU Driver = Current GPU Driver
Debugging = Debugging
Default GPU driver = Default GPU driver
Expand Down
Loading