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:
authorBuildTools <unconfigured@null.spigotmc.org>2015-12-08 23:32:22 +0300
committerBuildTools <unconfigured@null.spigotmc.org>2015-12-08 23:32:22 +0300
commitb9219c1e11de02866e4393065062d2b9f8c360ce (patch)
treeda716f258c5df474199b1b6a96a061ca658f415b
parent973db31eb95c635ac070052614d4c4b52ba40ee9 (diff)
added callback mode and a simple example script
-rw-r--r--scripts/sc-callbacks.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/scripts/sc-callbacks.py b/scripts/sc-callbacks.py
new file mode 100644
index 0000000..bb279e5
--- /dev/null
+++ b/scripts/sc-callbacks.py
@@ -0,0 +1,68 @@
+#!/usr/bin/env python
+
+# The MIT License (MIT)
+#
+# Copyright (c) 2015 Paul Wachendorf <paul.wachendorf@web.de>
+#
+# 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 Callback Mode example"""
+import sys
+
+from steamcontroller import SteamController, SCButtons
+from steamcontroller.events import EventMapper, Pos
+from steamcontroller.uinput import Keys
+
+
+def button_pressed_callback(evm, btn, pressed):
+ print "Button {} was {}.".format(btn, 'pressed' if pressed else 'released')
+
+ if btn == SCButtons.STEAM and not pressed:
+ print "pressing the STEAM button terminates the programm"
+ sys.exit()
+
+def touchpad_click_callback(evm, pos, pressed):
+ print "Tochpad {} was {}".format(pos, 'pressed' if pressed else 'released')
+
+def evminit():
+ evm = EventMapper()
+ evm.setButtonCallback(SCButtons.STEAM, button_pressed_callback)
+ evm.setButtonCallback(SCButtons.A, button_pressed_callback)
+ evm.setButtonCallback(SCButtons.B, button_pressed_callback)
+ evm.setButtonCallback(SCButtons.X, button_pressed_callback)
+ evm.setButtonCallback(SCButtons.Y, button_pressed_callback)
+ evm.setButtonCallback(SCButtons.LB, button_pressed_callback)
+ evm.setButtonCallback(SCButtons.RB, button_pressed_callback)
+ evm.setButtonCallback(SCButtons.LT, button_pressed_callback)
+ evm.setButtonCallback(SCButtons.RT, button_pressed_callback)
+ evm.setButtonCallback(SCButtons.LGRIP, button_pressed_callback)
+ evm.setButtonCallback(SCButtons.RGRIP, button_pressed_callback)
+ evm.setButtonCallback(SCButtons.START, button_pressed_callback)
+ evm.setButtonCallback(SCButtons.BACK, button_pressed_callback)
+ evm.setPadButtonCallback(SCButtons.LPAD, touchpad_click_callback)
+ evm.setPadButtonCallback(SCButtons.RPAD, touchpad_click_callback)
+ return evm
+
+
+if __name__ == '__main__':
+ evm = evminit()
+ sc = SteamController(callback=evm.process)
+ sc.run()
+
+