-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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 libgamemode support #11996
Closed
Closed
Add libgamemode support #11996
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0c9a1d6
Implemented support for Gamemode
DavidHusicka d429333
Made internal functions private
DavidHusicka c319b71
Made gamemode a component
DavidHusicka 216f4f9
Merge branch 'master' into Gamemode
DavidHusicka ae71325
Improved code quality
DavidHusicka 81224dd
Merge branch 'master' into Gamemode
DavidHusicka fc65590
Merge branch 'master' into Gamemode
DavidHusicka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System.Runtime.InteropServices; | ||
|
||
namespace Gamemode | ||
{ | ||
public static class GamemodeRequest { | ||
|
||
[DllImport("libgamemode.so.0")] | ||
public static extern int real_gamemode_request_start(); | ||
|
||
[DllImport("libgamemode.so.0")] | ||
public static extern int real_gamemode_request_end(); | ||
|
||
public static int RequestStart() | ||
{ | ||
try { | ||
return real_gamemode_request_start(); | ||
} catch { | ||
return -1; | ||
} | ||
} | ||
|
||
public static int RequestEnd() | ||
{ | ||
try { | ||
return real_gamemode_request_end(); | ||
} catch { | ||
return -1; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Platform-specific stuff like this shouldn't reside in
osu.Game
project but rather inosu.Desktop
project and use a component that you insert into the drawable hierachy and which listens for value changes ofGame.LocalUserPlaying
field instead of calling it inPlayerLoader
(see the following link for an example https://github.com/ppy/osu/blob/master/osu.Desktop/Windows/GameplayWinKeyBlocker.cs).Also you may want to add platform checks to add this component only when the host runs linux and should add handling for cases where the DLL isn't locatable (as it'll cause a crash as it is right now when calling the PInvoke methods and the DLL isn't locatable).
(All what is said above assumes of course that support for gamemode is accepted.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will look into moving it to the osu.Desktop project.
It already checks whether the DLL is available on the system. Tried to run without gamemode on and it works without any issues.