Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ynsta/steamcontroller.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStany MARCEL <stanypub@gmail.com>2015-11-16 02:53:07 +0300
committerStany MARCEL <stanypub@gmail.com>2015-11-16 02:53:07 +0300
commit86ed638d40c7dd551ebc1d5dc05447234dbaaaf7 (patch)
tree40780b3ab723a1390ee159c10dcccd879092d4c2 /scripts
parent2dc34e3c2fc36b6894d1c74fbae68013c13e262d (diff)
Add a new event mapper with mouse and keyboard support
Signed-off-by: Stany MARCEL <stanypub@gmail.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/sc-desktop.py96
-rwxr-xr-xscripts/sc-xbox.py14
2 files changed, 103 insertions, 7 deletions
diff --git a/scripts/sc-desktop.py b/scripts/sc-desktop.py
new file mode 100755
index 0000000..cbf9744
--- /dev/null
+++ b/scripts/sc-desktop.py
@@ -0,0 +1,96 @@
+#!/usr/bin/env python
+
+# The MIT License (MIT)
+#
+# Copyright (c) 2015 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 Mouse, Keyboard mode"""
+
+import sys
+from steamcontroller import SteamController, SCButtons
+from steamcontroller.events import EventMapper, Pos
+from steamcontroller.uinput import Keys, Axes, Rels
+
+from steamcontroller.daemon import Daemon
+
+def evminit():
+ evm = EventMapper()
+ evm.setPadMouse(Pos.Right)
+ evm.setPadScroll(Pos.Left)
+ evm.setStickButtons([Keys.KEY_UP,
+ Keys.KEY_LEFT,
+ Keys.KEY_DOWN,
+ Keys.KEY_RIGHT])
+
+ evm.setTrigButton(Pos.Left, Keys.BTN_RIGHT)
+ evm.setTrigButton(Pos.Right, Keys.BTN_LEFT)
+
+ evm.setButtonAction(SCButtons.LB, Keys.KEY_VOLUMEDOWN)
+ evm.setButtonAction(SCButtons.RB, Keys.KEY_VOLUMEUP)
+
+ evm.setButtonAction(SCButtons.Steam, Keys.KEY_HOMEPAGE)
+
+ evm.setButtonAction(SCButtons.A, Keys.KEY_ENTER)
+ evm.setButtonAction(SCButtons.B, Keys.KEY_BACKSPACE)
+ evm.setButtonAction(SCButtons.X, Keys.KEY_ESC)
+ evm.setButtonAction(SCButtons.Y, Keys.KEY_PLAYPAUSE)
+
+ evm.setButtonAction(SCButtons.Start, Keys.KEY_NEXTSONG)
+ evm.setButtonAction(SCButtons.Back, Keys.KEY_PREVIOUSSONG)
+
+ evm.setButtonAction(SCButtons.LGrip, Keys.KEY_BACK)
+ evm.setButtonAction(SCButtons.RGrip, Keys.KEY_FORWARD)
+ return evm
+
+class SCDaemon(Daemon):
+ def run(self):
+ while True:
+ try:
+ evm = evminit()
+ sc = SteamController(callback=evm.process)
+ sc.run()
+ except:
+ pass
+
+if __name__ == '__main__':
+ import argparse
+
+ def _main():
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument('command', type=str, choices=['start', 'stop', 'restart', 'debug'])
+ args = parser.parse_args()
+ daemon = SCDaemon('/tmp/steamcontroller.pid')
+
+ if 'start' == args.command:
+ daemon.start()
+ elif 'stop' == args.command:
+ daemon.stop()
+ elif 'restart' == args.command:
+ daemon.restart()
+ elif 'debug' == args.command:
+ try:
+ evm = evminit()
+ sc = SteamController(callback=evm.process)
+ sc.run()
+ except KeyboardInterrupt:
+ return
+
+ _main()
diff --git a/scripts/sc-xbox.py b/scripts/sc-xbox.py
index 43ee64a..a6c2b56 100755
--- a/scripts/sc-xbox.py
+++ b/scripts/sc-xbox.py
@@ -157,11 +157,9 @@ class SCDaemon(Daemon):
def run(self):
while True:
try:
- xb = steamcontroller.uinput.Xbox360()
+ xb = steamcontroller.uinput.Gamepad()
sc = SteamController(callback=scInput2Uinput, callback_args=[xb, ])
sc.run()
- except KeyboardInterrupt:
- return
except:
pass
@@ -181,8 +179,10 @@ if __name__ == '__main__':
elif 'restart' == args.command:
daemon.restart()
elif 'debug' == args.command:
- xb = steamcontroller.uinput.Xbox360()
- sc = SteamController(callback=scInput2Uinput, callback_args=[xb, ])
- sc.run()
-
+ try:
+ xb = steamcontroller.uinput.Gamepad()
+ sc = SteamController(callback=scInput2Uinput, callback_args=[xb, ])
+ sc.run()
+ except KeyboardInterrupt:
+ return
_main()