Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
b66ba6a
+ scripts/sc-configurable.py: An exact copy of scripts/sc-desktop.py…
mcronce Jan 21, 2017
e4b015d
scripts/sc-configurable.py: Changed copyright line and description c…
mcronce Jan 21, 2017
1570cb1
scripts/sc-configurable.py: Tabs and whitespace!
mcronce Jan 21, 2017
f681c73
scripts/vdf2json.py: Added "json" package import, join_duplicate_key…
mcronce Jan 21, 2017
fe0b289
Revert "scripts/vdf2json.py: Added "json" package import, join_dupli…
mcronce Jan 21, 2017
a4c43f6
scripts/sc-configurable.py: Added json and vdf2json imports, along w…
mcronce Jan 21, 2017
5586193
scripts/sc-configurable.py: Added -c/--config-file argument (require…
mcronce Jan 21, 2017
0bf9d02
scripts/sc-configurable.py: More spaces!
mcronce Jan 21, 2017
2f2e42f
scripts/sc-configurable.py: Moved load_vdf() call into evminit()
mcronce Jan 21, 2017
f5f3c66
scripts/sc-configurable.py: Use python3 instead of python
mcronce Jan 21, 2017
47c2480
scripts/sc-configurable.py: Flip /controller_mappings/preset/group_s…
mcronce Jan 21, 2017
7907cb2
scripts/sc-configurable.py: Added get_binding()
mcronce Jan 22, 2017
30caa9b
scripts/sc-configurable.py: get_binding() now returns the correct en…
mcronce Jan 22, 2017
44273b3
scripts/sc-configurable.py: evminit(): Added config support for but…
mcronce Jan 22, 2017
b155a22
scripts/sc-configurable.py: evminit(): Added config support for joy…
mcronce Jan 22, 2017
8b1783d
scripts/sc-configurable.py: evminit(): Added config support for rig…
mcronce Jan 22, 2017
d4fa646
scripts/sc-configurable.py: Moved trackpad setup to its own function…
mcronce Jan 22, 2017
c4644f5
scripts/sc-configurable.py: set_trackpad_config(): Fixed syntax
mcronce Jan 22, 2017
5b7dee3
scripts/sc-configurable.py: get_binding(): getattr() -> __getattr__()
mcronce Jan 22, 2017
0c7e415
scripts/sc-configurable.py: set_trackpad_config(): Put back missing…
mcronce Jan 22, 2017
9024cfa
scripts/sc-configurable.py: set_trackpad_config(): Added mostly-com…
mcronce Jan 22, 2017
3ac8d86
scripts/sc-configurable.py: get_binding(): Added try/except block
mcronce Jan 22, 2017
debe38c
scripts/sc-configurable.py: get_binding(): Added fallback return None
mcronce Jan 22, 2017
6888261
scripts/sc-configurable.py: set_trackpad_config(): Now that get_bin…
mcronce Jan 22, 2017
f3a0204
scripts/sc-configurable.py: set_trackpad_config(): Added support fo…
mcronce Jan 22, 2017
9099deb
scripts/sc-configurable.py: evminit(): Added config support for lef…
mcronce Jan 22, 2017
d0922a8
scripts/sc-configurable.py: get_binding(): Added translation for ar…
mcronce Jan 22, 2017
38ad476
scripts/sc-configurable.py: get_binding(): Added translation which …
mcronce Jan 22, 2017
d607f07
scripts/sc-configurable.py: get_binding(): Fixed comma issues
mcronce Jan 22, 2017
2ca7001
scripts/sc-configurable.py: get_binding(): Added mouse_wheel stub e…
mcronce Jan 22, 2017
da3b39d
scripts/sc-configurable.py: get_binding(): Added mouse_button support
mcronce Jan 22, 2017
b6b1796
scripts/sc-configurable.py: evminit(): Added config support for lef…
mcronce Jan 22, 2017
292ce29
scripts/sc-configurable.py: evminit(): Added config support for bum…
mcronce Jan 22, 2017
0539397
scripts/sc-configurable.py: evminit(): Took out LPAD/RPAD lines, th…
mcronce Jan 22, 2017
a7fc654
scripts/sc-configurable.py: evminit(): Moved assignments around
mcronce Jan 22, 2017
1c7d547
scripts/sc-configurable.py: evminit(): Added comment on steam butto…
mcronce Jan 22, 2017
75acc25
scripts/sc-configurable.py: evminit(): Added some basic logging
mcronce Jan 22, 2017
54bf61d
scripts/sc-configurable.py: get_binding(): Added hack around PERIOD…
mcronce Jan 22, 2017
be77bd0
scripts/sc-configurable.py: get_binding(): Added hack for when ther…
mcronce Jan 22, 2017
dd9e386
src/events.py: setButtonAction() will clear the event if None is pas…
mcronce Jan 22, 2017
fb81610
src/uinput.py: Added optional gamepad_definition parameter - this de…
mcronce Jan 22, 2017
aed1b20
src/events.py: Exposed gamepad_definition parameter to Gamepad.__ini…
mcronce Jan 22, 2017
21cb84d
scripts/sc-configurable.py: Added thumb stick press support
mcronce Jan 22, 2017
f1dc9e3
scripts/sc-configurable.py: Added gamepad_definition for Steam Contr…
mcronce Jan 22, 2017
a927b98
scripts/sc-configurable.py: evminit() Added TODO
mcronce Jan 22, 2017
3f9d660
scripts/sc-configurable.py: Added Axes import
mcronce Jan 22, 2017
4497f5c
scripts/sc-configurable.py: evminit(): Add missing comma
mcronce Jan 22, 2017
e75831f
src/events.py: EventMapper.__init__(): Fixed typo in gamepad_defini…
mcronce Jan 22, 2017
84020be
scripts/sc-configurable.py: evminit(): Switched "keys" in gamepad_d…
mcronce Jan 23, 2017
4b2330b
scripts/sc-configurable.py: Refactored to separate reading the VDF f…
mcronce Jan 28, 2017
0a7073f
src/events.py: Added some fold markers to EventMapper.process() to i…
mcronce Jan 28, 2017
6ee77fc
src/events.py: Added optional "mode" parameter to setButtonAction();…
mcronce Jan 28, 2017
2b5409a
scripts/sc-configurable.py: parse_config(): Fixed button_diamond an…
mcronce Jan 29, 2017
eb93af1
src/events.py: EventMapper.process(): Removed a few strategic blank…
mcronce Jan 29, 2017
e769066
src/events.py: Cleaned up an if statement
mcronce Jan 31, 2017
fbf9771
src/events.py: Added stick click functionality
mcronce Jan 31, 2017
fa539ab
Revert "src/events.py: Added stick click functionality"
mcronce Jan 31, 2017
8d3e036
src/events.py: Added ugly LPAD/LPADTOUCH hack for properly identifyi…
mcronce Jan 31, 2017
688dfae
scripts/sc-configurable.py: parse_config(): Added joystick click su…
mcronce Jan 31, 2017
61fd695
scripts/sc-configurable.py: evminit(): Hurr durr
mcronce Jan 31, 2017
a0ee8ac
src/events.py: EventMapper::setButtonAction(): Fixed action removal
mcronce Jan 31, 2017
6407242
src/events.py: Fixed LPAD/LPADTOUCH hack!
mcronce Jan 31, 2017
f48a0fd
scripts/sc-configurable.py: parse_config(): Fixed joystick click as…
mcronce Jan 31, 2017
cb0d353
scripts/sc-configurable.py: Dynamic gamepad definition for keys
mcronce Feb 1, 2017
ee5be61
scripts/sc-configurable.py: Added Modes.GAMEPAD specification to all…
mcronce Feb 4, 2017
7c5fe4f
src/events.py: Added mode specification support to setTrigButton() a…
mcronce Feb 4, 2017
6fe5de5
scripts/sc-configurable.py: Added Modes.GAMEPAD specification to evm…
mcronce Feb 4, 2017
2497241
src/events.py: Added mode specification support to setPadButtons()
mcronce Feb 4, 2017
3e4c4b0
scripts/sc-configurable.py: Added Modes.GAMEPAD specification to evm…
mcronce Feb 4, 2017
d1340c9
src/events.py: EventMapper::_uip is no longer hardcoded to (sui.Game…
mcronce Feb 4, 2017
2993f47
scripts/sc-configurable.py: Added modes specification to EventMapper…
mcronce Feb 5, 2017
172d492
scripts/sc-configurable.py: Added another ridiculous hack; this time…
mcronce Feb 5, 2017
37c6830
scripts/sc-configurable.py: Added get_modes_from_config(), to genera…
mcronce Feb 5, 2017
6d6b08c
scripts/sc-configurable.py: Added get_axes_from_config() (currently …
mcronce Feb 5, 2017
f258d50
scripts/sc-configurable.py: Added name of config file to gamepad_def…
mcronce Feb 5, 2017
287cf23
scripts/sc-configurable.py: Moved get_*_from_config() functions to a…
mcronce Feb 5, 2017
d234f37
scripts/sc-configurable.py: Split parse_analog_config() into parse_t…
mcronce Feb 6, 2017
7caf984
scripts/sc-configurable.py: Refined parse_joystick_config() somewhat
mcronce Feb 6, 2017
fb82b4c
scripts/sc-configurable.py: DRY on analog dpad/diamond inputs; refin…
mcronce Feb 6, 2017
3f097f2
scripts/sc-configurable.py: Fixed joystick input
mcronce Feb 12, 2017
7ac593b
scripts/sc-configurable.py: Fixed axis modes for joystick and trackpads
mcronce Feb 12, 2017
a5bb3d6
scripts/sc-configurable.py: Moved joystick, button diamond, and "swi…
mcronce Feb 12, 2017
9f23fa3
scripts/sc-configurable.py: Added most of modeshifting support
mcronce Feb 12, 2017
67cfb6b
scripts/sc-configurable.py: Added a few more hardcoded hacks to get_…
mcronce Feb 12, 2017
a96d5fa
scripts/sc-configurable.py: Fixed button diamond mode in parse_track…
mcronce Feb 12, 2017
64b8e20
+ src/config.py; currently, this only contains json2vdf() and vdf2json()
mcronce Feb 12, 2017
efe6ed9
scripts/json2vdf.py and scripts/vdf2json.py: Changed these to call s…
mcronce Feb 12, 2017
d9ee327
Refactored such that all the business logic from scripts/sc-configura…
mcronce Feb 12, 2017
f9dbb4b
src/config.py: Fixed Configurator::get_modes() for MOUSE mode detection
mcronce Feb 12, 2017
e1b5f18
src/daemon.py: Added logfile support
mcronce Feb 12, 2017
eebc31b
scripts/sc-configurable.py: Added logfile argument to SCDaemon::__in…
mcronce Feb 12, 2017
2686129
src/config.py: Adjusted trackpad axes for a bit more granularity
mcronce Feb 12, 2017
150592e
src/events.py: Fixed issue with joystick also triggering LPAD axis w…
mcronce Feb 13, 2017
b4db577
src/config.py: Pad axes broadened to (-32768, 32768, 16, 128)
mcronce Feb 13, 2017
d85e4b7
src/config.py: Fixed KEYBOARD mode detection
mcronce Feb 13, 2017
fb567ff
src/config.py: Replaced long if-else ladder in get_binding() with a …
mcronce Feb 13, 2017
faf1433
src/config.py: Will no longer crash on startup if a section is missing
mcronce Feb 14, 2017
4c5b0d2
src/config.py: No longer forcing GAMEPAD mode for all button assignm…
mcronce Feb 14, 2017
7cde38f
src/config.py: Added Configurator::import_config() which sets self.c…
mcronce Feb 14, 2017
01f0c22
src/config.py: Added support for PadModes.BUTTONTOUCH in set_trackpa…
mcronce Feb 14, 2017
e8a02d6
src/config.py: Configurator::get_modes() is now a stub that just ret…
mcronce Feb 14, 2017
e1fb176
src/config.py: Like the rest, Configurator::set_trackpad_config() is…
mcronce Feb 14, 2017
708a512
src/config.py: Changed hardcoded STEAM button from KEY_HOMEPAGE to t…
mcronce Feb 14, 2017
5a52d35
src/config.py: Fixed a python2 incompatibility
mcronce Feb 16, 2017
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
31 changes: 2 additions & 29 deletions scripts/json2vdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,40 +24,13 @@

import json

def json2vdf(stream):

"""
Read a json file and return a string in Steam vdf format
"""

def _istr(ident, string):
return (ident * '\t') + string

data = json.loads(stream.read(), object_pairs_hook=list)

def _json2vdf(data, indent):
out = ''
for k, val in data:
if isinstance(val, list):
if indent:
out += '\n'
out += _istr(indent, '"{}"\n'.format(k))
out += _istr(indent, '{\n')
out += _json2vdf(val, indent + 1)
out += _istr(indent, '}\n')
else:
out += _istr(indent, '"{}" "{}"\n'.format(k, val))
return out

return _json2vdf(data, 0)


def main():
"""
Read json and write Steam vdf conversion
"""
import sys
import argparse
import steamcontroller.config
parser = argparse.ArgumentParser(prog='json2vdf', description=main.__doc__)
parser.add_argument('-i', '--input',
default=sys.stdin,
Expand All @@ -69,7 +42,7 @@ def main():
help='output vdf file (stdout if not specified)')

args = parser.parse_args()
args.output.write(json2vdf(args.input))
args.output.write(steamcontroller.config.json2vdf(args.input))

if __name__ == '__main__':
main()
77 changes: 77 additions & 0 deletions scripts/sc-configurable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env python3

# The MIT License (MIT)
#
# Copyright (c) 2016 Mike Cronce <mike@quadra-tec.net>
# Stany MARCEL <stanypub@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

"""Steam Controller VDF-configurable mode"""

from steamcontroller import SteamController
from steamcontroller.config import Configurator
from steamcontroller.daemon import Daemon

import gc

class SCDaemon(Daemon):
def __init__(self, pidfile, config_file):
self.pidfile = pidfile
self.config_file = config_file
self.logfile = '/var/log/steam-controller.log'

def run(self):
config = Configurator('Steam Controller', self.config_file)
sc = SteamController(callback = config.evm.process)
sc.run()
del sc
del config
gc.collect()

if __name__ == '__main__':
import argparse

def _main():
parser = argparse.ArgumentParser(description = __doc__)
parser.add_argument('command', type = str, choices = ['start', 'stop', 'restart', 'debug'])
parser.add_argument('-c', '--config-file', type = str, required = True)
parser.add_argument('-i', '--index', type = int, choices = [0,1,2,3], default = None)
args = parser.parse_args()

if args.index != None:
daemon = SCDaemon('/tmp/steamcontroller{:d}.pid'.format(args.index), args.config_file)
else:
daemon = SCDaemon('/tmp/steamcontroller.pid', args.config_file)

if 'start' == args.command:
daemon.start()
elif 'stop' == args.command:
daemon.stop()
elif 'restart' == args.command:
daemon.restart()
elif 'debug' == args.command:
try:
config = Configurator('Steam Controller', args.config_file)
sc = SteamController(callback = config.evm.process)
sc.run()
except KeyboardInterrupt:
return

_main()
42 changes: 2 additions & 40 deletions scripts/vdf2json.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,51 +22,13 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

from shlex import shlex

def vdf2json(stream):

"""
Read a Steam vdf file and return a string in json format
"""

def _istr(ident, string):
return (ident * ' ') + string

jbuf = '{\n'
lex = shlex(stream)
indent = 1

while True:
tok = lex.get_token()
if not tok:
return jbuf + '}\n'
if tok == '}':
indent -= 1
jbuf += _istr(indent, '}')
ntok = lex.get_token()
lex.push_token(ntok)
if ntok and ntok != '}':
jbuf += ','
jbuf += '\n'
else:
ntok = lex.get_token()
if ntok == '{':
jbuf += _istr(indent, tok + ': {\n')
indent += 1
else:
jbuf += _istr(indent, tok + ': ' + ntok)
ntok = lex.get_token()
lex.push_token(ntok)
if ntok != '}':
jbuf += ','
jbuf += '\n'
def main():
"""
Read Steam vdf and write json compatible conversion
"""
import sys
import argparse
import steamcontroller.config

parser = argparse.ArgumentParser(prog='vdf2json', description=main.__doc__)
parser.add_argument('-i', '--input',
Expand All @@ -79,7 +41,7 @@ def main():
help='output json file (stdout if not specified)')

args = parser.parse_args()
args.output.write(vdf2json(args.input))
args.output.write(steamcontroller.config.vdf2json(args.input))

if __name__ == '__main__':
main()
Loading