mirror of
https://github.com/lutris/lutris
synced 2024-10-07 08:19:07 +00:00
Initial support for xboxdrv
This commit is contained in:
parent
e28c75ad2b
commit
b4295cbe54
21
data/net.lutris.xboxdrv.policy
Normal file
21
data/net.lutris.xboxdrv.policy
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE policyconfig PUBLIC
|
||||
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
|
||||
<policyconfig>
|
||||
|
||||
<vendor>Lutris</vendor>
|
||||
<vendor_url>http://lutris.net</vendor_url>
|
||||
|
||||
<action id="net.lutris.xboxdrv.pkexec.run">
|
||||
<description>Run xboxdrv</description>
|
||||
<message>Authentication is required to run xboxdrv</message>
|
||||
<defaults>
|
||||
<allow_any>yes</allow_any>
|
||||
<allow_inactive>yes</allow_inactive>
|
||||
<allow_active>yes</allow_active>
|
||||
</defaults>
|
||||
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/xboxdrv</annotate>
|
||||
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
|
||||
</action>
|
||||
</policyconfig>
|
21
data/net.lutris.xboxdrvctl.policy
Normal file
21
data/net.lutris.xboxdrvctl.policy
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE policyconfig PUBLIC
|
||||
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
|
||||
<policyconfig>
|
||||
|
||||
<vendor>Lutris</vendor>
|
||||
<vendor_url>http://lutris.net</vendor_url>
|
||||
|
||||
<action id="net.lutris.xboxdrvctl.pkexec.run">
|
||||
<description>Run xboxdrvctl</description>
|
||||
<message>Authentication is required to run xboxdrvctl</message>
|
||||
<defaults>
|
||||
<allow_any>yes</allow_any>
|
||||
<allow_inactive>yes</allow_inactive>
|
||||
<allow_active>yes</allow_active>
|
||||
</defaults>
|
||||
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/xboxdrvctl</annotate>
|
||||
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
|
||||
</action>
|
||||
</policyconfig>
|
|
@ -48,6 +48,7 @@ def get_current_resolution():
|
|||
|
||||
def change_resolution(resolution):
|
||||
"""change desktop resolution"""
|
||||
logger.debug("Switching resolution to %s", resolution)
|
||||
if resolution not in get_resolutions():
|
||||
logger.warning("Resolution %s doesn't exist.")
|
||||
else:
|
||||
|
@ -105,7 +106,8 @@ def set_keyboard_repeat(value=False):
|
|||
def reset_desktop():
|
||||
"""Restore the desktop to its original state."""
|
||||
#Restore resolution
|
||||
os.popen("xrandr -s 0")
|
||||
resolution = get_resolutions()[0]
|
||||
change_resolution(resolution)
|
||||
#Restore gamma
|
||||
os.popen("xgamma -gamma 1.0")
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
# -*- coding:Utf-8 -*-
|
||||
""" Module that actually runs the games. """
|
||||
import os
|
||||
import shutil
|
||||
import time
|
||||
import shutil
|
||||
|
||||
from signal import SIGKILL
|
||||
from gi.repository import Gtk, GLib
|
||||
|
@ -146,9 +146,12 @@ class Game(object):
|
|||
self.game_thread = LutrisThread(command, path, killswitch)
|
||||
self.game_thread.start()
|
||||
if 'joy2key' in gameplay_info:
|
||||
self.run_joy2key(gameplay_info['joy2key'])
|
||||
self.joy2key(gameplay_info['joy2key'])
|
||||
xboxdrv_config = self.game_config.get_system('xboxdrv')
|
||||
if xboxdrv_config:
|
||||
self.xboxdrv(xboxdrv_config)
|
||||
|
||||
def run_joy2key(self, config):
|
||||
def joy2key(self, config):
|
||||
""" Run a joy2key thread. """
|
||||
win = "grep %s" % config['window']
|
||||
if 'notwindow' in config:
|
||||
|
@ -165,6 +168,14 @@ class Game(object):
|
|||
self.game_thread.attach_thread(joy2key_thread)
|
||||
joy2key_thread.start()
|
||||
|
||||
def xboxdrv(self, config):
|
||||
command = ("pkexec xboxdrv --daemon --detach-kernel-driver "
|
||||
"--dbus session --silent %s"
|
||||
% config)
|
||||
logger.debug("xboxdrv command: %s", command)
|
||||
thread = LutrisThread(command, "/tmp")
|
||||
thread.start()
|
||||
|
||||
def poke_process(self):
|
||||
""" Watch game's process. """
|
||||
if not self.game_thread.pid:
|
||||
|
@ -178,9 +189,18 @@ class Game(object):
|
|||
self.heartbeat = None
|
||||
quit_time = time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())
|
||||
logger.debug("game has quit at %s" % quit_time)
|
||||
|
||||
if self.game_config.get_system('resolution'):
|
||||
desktop_control.reset_desktop()
|
||||
|
||||
if self.game_config.get_system('xboxdrv'):
|
||||
os.system("pkexec xboxdrvctl --shutdown")
|
||||
|
||||
if self.game_thread is not None and self.game_thread.pid:
|
||||
for child in self.game_thread:
|
||||
child.kill()
|
||||
os.kill(self.game_thread.pid + 1, SIGKILL)
|
||||
if self.game_config.get_system('reset_desktop'):
|
||||
desktop_control.reset_desktop()
|
||||
pid = self.game_thread.pid + 1
|
||||
try:
|
||||
os.kill(pid, SIGKILL)
|
||||
except OSError:
|
||||
logger.error("Could not kill PID %s", pid)
|
||||
|
|
|
@ -43,33 +43,58 @@ class SystemConfigVBox(ConfigVBox):
|
|||
|
||||
resolution_list = get_resolutions()
|
||||
|
||||
self.options = [{'option': 'game_path',
|
||||
'type': 'directory_chooser',
|
||||
'label': 'Default game path'},
|
||||
{'option': 'resolution',
|
||||
'type': 'one_choice',
|
||||
'label': 'Resolution',
|
||||
'choices': resolution_list},
|
||||
{'option': 'oss_wrapper',
|
||||
'type': 'one_choice',
|
||||
'label': 'OSS Wrapper',
|
||||
'choices': oss_list},
|
||||
{'option': 'reset_pulse',
|
||||
'type': 'bool',
|
||||
'label': 'Reset PulseAudio'},
|
||||
{'option': 'hide_panels',
|
||||
'type': 'bool',
|
||||
'label': 'Hide Gnome Panels'},
|
||||
{'option': 'reset_desktop',
|
||||
'type': 'bool',
|
||||
'label': 'Reset resolution when game quits'},
|
||||
{'option': 'compiz_nodecoration',
|
||||
'type': 'string',
|
||||
'label': 'Remove window decoration with compiz'},
|
||||
{'option': 'compiz_fullscreen',
|
||||
'type': 'string',
|
||||
'label': 'Make a fullscreen window with compiz'},
|
||||
{'option': 'killswitch',
|
||||
'type': 'string',
|
||||
'label': 'Killswitch file'}]
|
||||
self.options = [
|
||||
{
|
||||
'option': 'game_path',
|
||||
'type': 'directory_chooser',
|
||||
'label': 'Default game path'
|
||||
},
|
||||
{
|
||||
'option': 'resolution',
|
||||
'type': 'one_choice',
|
||||
'label': 'Resolution',
|
||||
'choices': resolution_list
|
||||
},
|
||||
{
|
||||
'option': 'oss_wrapper',
|
||||
'type': 'one_choice',
|
||||
'label': 'OSS Wrapper',
|
||||
'choices': oss_list
|
||||
},
|
||||
{
|
||||
'option': 'reset_pulse',
|
||||
'type': 'bool',
|
||||
'label': 'Reset PulseAudio'
|
||||
},
|
||||
{
|
||||
'option': 'hide_panels',
|
||||
'type': 'bool',
|
||||
'label': 'Hide Gnome Panels'
|
||||
},
|
||||
{
|
||||
'option': 'reset_desktop',
|
||||
'type': 'bool',
|
||||
'label': 'Reset resolution when game quits'
|
||||
},
|
||||
{
|
||||
'option': 'compiz_nodecoration',
|
||||
'type': 'string',
|
||||
'label': 'Remove window decoration with compiz'
|
||||
},
|
||||
{
|
||||
'option': 'compiz_fullscreen',
|
||||
'type': 'string',
|
||||
'label': 'Make a fullscreen window with compiz'
|
||||
},
|
||||
{
|
||||
'option': 'killswitch',
|
||||
'type': 'string',
|
||||
'label': 'Killswitch file'
|
||||
},
|
||||
{
|
||||
'option': 'xboxdrv',
|
||||
'type': 'string',
|
||||
'label': 'xboxdrv config'
|
||||
}
|
||||
]
|
||||
self.generate_widgets()
|
||||
|
|
12
setup.py
12
setup.py
|
@ -74,10 +74,20 @@ for directory, _, filenames in os.walk(u'data'):
|
|||
filename = os.path.join(directory, filename)
|
||||
files.append(filename)
|
||||
data_files.append((os.path.join('share/lutris', dest), files))
|
||||
data_files.append(('share/icons/hicolor/scalable/apps', ['data/media/lutris.svg']))
|
||||
data_files.append((
|
||||
'share/icons/hicolor/scalable/apps',
|
||||
['data/media/lutris.svg']
|
||||
))
|
||||
data_files.append(('share/pixmaps', ['data/media/lutris.png']))
|
||||
data_files.append(('share/applications', ['lutris.desktop']))
|
||||
data_files.append(('share/glib-2.0/schemas', ['data/apps.lutris.gschema.xml']))
|
||||
data_files.append((
|
||||
'share/polkit-1/actions', [
|
||||
'data/net.lutris.xboxdrv.policy',
|
||||
'data/net.lutris.xboxdrvctl.policy'
|
||||
]
|
||||
))
|
||||
|
||||
|
||||
setup(
|
||||
name='lutris',
|
||||
|
|
Loading…
Reference in a new issue