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 <paul.wachendorf@web.de>2015-12-09 23:10:11 +0300
committerBuildTools <paul.wachendorf@web.de>2015-12-09 23:10:11 +0300
commit2342e9dc5c55c3c7b2e2909f39c7d31bf4eaf12c (patch)
treeacff0fb7a85efcc3a729281f06c7f373bd3ed2b4
parent5008552221978260eab1611801f2cc94ffb95c8f (diff)
added setStickPressedCallback and actalized example script
-rw-r--r--scripts/sc-callbacks.py4
-rw-r--r--src/events.py19
2 files changed, 20 insertions, 3 deletions
diff --git a/scripts/sc-callbacks.py b/scripts/sc-callbacks.py
index 7482faa..042df21 100644
--- a/scripts/sc-callbacks.py
+++ b/scripts/sc-callbacks.py
@@ -43,6 +43,9 @@ def touchpad_click_callback(evm, pad, pressed):
def touchpad_touch_callback(evm, pad, x, y):
print "Tochpad {} was touched @{},{}".format(pad, x, y)
+def stick_pressed_callback(evm):
+ print "Stick pressed"
+
def evminit():
evm = EventMapper()
evm.setButtonCallback(SCButtons.STEAM, button_pressed_callback)
@@ -60,6 +63,7 @@ def evminit():
evm.setButtonCallback(SCButtons.BACK, button_pressed_callback)
evm.setPadButtonCallback(Pos.LEFT, touchpad_touch_callback)
evm.setPadButtonCallback(Pos.RIGHT, touchpad_click_callback, clicked=True)
+ evm.setStickPressedCallback(stick_pressed_callback)
return evm
diff --git a/src/events.py b/src/events.py
index 60bad6b..e3552f7 100644
--- a/src/events.py
+++ b/src/events.py
@@ -111,7 +111,8 @@ class EventMapper(object):
self._stick_lxs = None
self._stick_bys = None
self._stick_rxs = None
-
+ self._stick_pressed_callback = None
+
self._trig_s = [None, None]
self._moved = [0, 0]
@@ -435,6 +436,9 @@ class EventMapper(object):
elif self._stick_rxs is not None and x <= self._stick_rxs:
self._stick_rxs = None
_keyreleased(rmode, rev)
+ if sci.buttons & SCButtons.LPAD == SCButtons.LPAD:
+ if self._stick_pressed_callback is not None:
+ self._stick_pressed_callback(self)
if len(_pressed):
@@ -459,8 +463,8 @@ class EventMapper(object):
callback is called with parameters self(EventMapper), btn
and pushed (boollean True -> Button pressed, False -> Button released)
- @param btn Button
- @param callback Callback function
+ @param btn Button
+ @param function callback Callback function
"""
self._btn_map[btn] = (Modes.CALLBACK, callback)
@@ -607,3 +611,12 @@ class EventMapper(object):
if self._uip[mode].keyManaged(ev):
self._stick_evts.append((mode, ev))
break
+
+ def setStickPressedCallback(self, callback):
+ """
+ Set callback on StickPressed event.
+ the function will be called with EventMapper as first (and only) argument
+
+ @param function Callback function function that is called on buton press.
+ """
+ self._stick_pressed_callback = callback \ No newline at end of file