mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 05:40:04 +00:00 
			
		
		
		
	Port yuzu-emu/yuzu#11946: "Enable (Feral Interactive) Gamemode on Linux" (#7245)
This commit is contained in:
		
							parent
							
								
									2e369c03b8
								
							
						
					
					
						commit
						c7e9f8449e
					
				
					 14 changed files with 540 additions and 3 deletions
				
			
		|  | @ -154,6 +154,15 @@ add_library(citra_common STATIC | |||
|     zstd_compression.h | ||||
| ) | ||||
| 
 | ||||
| if (UNIX AND NOT APPLE) | ||||
|   target_sources(citra_common PRIVATE | ||||
|     linux/gamemode.cpp | ||||
|     linux/gamemode.h | ||||
|   ) | ||||
| 
 | ||||
|   target_link_libraries(citra_common PRIVATE gamemode) | ||||
| endif() | ||||
| 
 | ||||
| if (APPLE) | ||||
|     target_sources(citra_common PUBLIC | ||||
|         apple_authorization.h | ||||
|  |  | |||
							
								
								
									
										39
									
								
								src/common/linux/gamemode.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								src/common/linux/gamemode.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,39 @@ | |||
| // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
 | ||||
| // SPDX-License-Identifier: GPL-2.0-or-later
 | ||||
| 
 | ||||
| #include <gamemode_client.h> | ||||
| 
 | ||||
| #include "common/linux/gamemode.h" | ||||
| #include "common/settings.h" | ||||
| 
 | ||||
| namespace Common::Linux { | ||||
| 
 | ||||
| void StartGamemode() { | ||||
|     if (Settings::values.enable_gamemode) { | ||||
|         if (gamemode_request_start() < 0) { | ||||
|             LOG_WARNING(Frontend, "Failed to start gamemode: {}", gamemode_error_string()); | ||||
|         } else { | ||||
|             LOG_INFO(Frontend, "Started gamemode"); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void StopGamemode() { | ||||
|     if (Settings::values.enable_gamemode) { | ||||
|         if (gamemode_request_end() < 0) { | ||||
|             LOG_WARNING(Frontend, "Failed to stop gamemode: {}", gamemode_error_string()); | ||||
|         } else { | ||||
|             LOG_INFO(Frontend, "Stopped gamemode"); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void SetGamemodeState(bool state) { | ||||
|     if (state) { | ||||
|         StartGamemode(); | ||||
|     } else { | ||||
|         StopGamemode(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| } // namespace Common::Linux
 | ||||
							
								
								
									
										24
									
								
								src/common/linux/gamemode.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								src/common/linux/gamemode.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,24 @@ | |||
| // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
 | ||||
| // SPDX-License-Identifier: GPL-2.0-or-later
 | ||||
| 
 | ||||
| #pragma once | ||||
| 
 | ||||
| namespace Common::Linux { | ||||
| 
 | ||||
| /**
 | ||||
|  * Start the (Feral Interactive) Linux gamemode if it is installed and it is activated | ||||
|  */ | ||||
| void StartGamemode(); | ||||
| 
 | ||||
| /**
 | ||||
|  * Stop the (Feral Interactive) Linux gamemode if it is installed and it is activated | ||||
|  */ | ||||
| void StopGamemode(); | ||||
| 
 | ||||
| /**
 | ||||
|  * Start or stop the (Feral Interactive) Linux gamemode if it is installed and it is activated | ||||
|  * @param state The new state the gamemode should have | ||||
|  */ | ||||
| void SetGamemodeState(bool state); | ||||
| 
 | ||||
| } // namespace Common::Linux
 | ||||
|  | @ -421,6 +421,8 @@ struct Values { | |||
|     std::vector<InputProfile> input_profiles; ///< The list of input profiles
 | ||||
|     std::vector<TouchFromButtonMap> touch_from_button_maps; | ||||
| 
 | ||||
|     SwitchableSetting<bool> enable_gamemode{true, "enable_gamemode"}; | ||||
| 
 | ||||
|     // Core
 | ||||
|     Setting<bool> use_cpu_jit{true, "use_cpu_jit"}; | ||||
|     SwitchableSetting<s32, true> cpu_clock_percentage{100, 5, 400, "cpu_clock_percentage"}; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue