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:31:14 +0300
committerBuildTools <paul.wachendorf@web.de>2015-12-09 23:31:14 +0300
commitf5a25af5e9f635cc7db6b906090eb7c52f7a6790 (patch)
tree12776e601dd66711bc27514651c744eff7b0a844
parent2342e9dc5c55c3c7b2e2909f39c7d31bf4eaf12c (diff)
added callback fir stick movement
-rw-r--r--scripts/sc-callbacks.py4
-rw-r--r--src/events.py15
2 files changed, 19 insertions, 0 deletions
diff --git a/scripts/sc-callbacks.py b/scripts/sc-callbacks.py
index 042df21..41d4078 100644
--- a/scripts/sc-callbacks.py
+++ b/scripts/sc-callbacks.py
@@ -46,6 +46,9 @@ def touchpad_touch_callback(evm, pad, x, y):
def stick_pressed_callback(evm):
print "Stick pressed"
+def stick_axes_callback(evm, x, y):
+ print "Stick Position is {}, {}".format(x, y)
+
def evminit():
evm = EventMapper()
evm.setButtonCallback(SCButtons.STEAM, button_pressed_callback)
@@ -63,6 +66,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.setStickAxesCallback(stick_axes_callback)
evm.setStickPressedCallback(stick_pressed_callback)
return evm
diff --git a/src/events.py b/src/events.py
index e3552f7..14b06a5 100644
--- a/src/events.py
+++ b/src/events.py
@@ -111,6 +111,7 @@ class EventMapper(object):
self._stick_lxs = None
self._stick_bys = None
self._stick_rxs = None
+ self._stick_axes_callback = None
self._stick_pressed_callback = None
self._trig_s = [None, None]
@@ -389,6 +390,9 @@ class EventMapper(object):
x, y = sci.lpad_x, sci.lpad_y
x_p, y_p = sci_p.lpad_x, sci_p.lpad_y
+ if self._stick_axes_callback is not None and (x != x_p or y != y_p):
+ self._stick_axes_callback(self, x, y)
+
if self._stick_mode == StickModes.AXIS:
revert = self._stick_rev
(xmode, xev), (ymode, yev) = self._stick_evts # pylint: disable=E0632
@@ -398,6 +402,7 @@ class EventMapper(object):
if y != y_p:
syn.add(ymode)
self._uip[ymode].axisEvent(yev, y if not revert else -y)
+
elif self._stick_mode == StickModes.BUTTON:
tmode, tev = self._stick_evts[0]
@@ -594,6 +599,16 @@ class EventMapper(object):
(Modes.GAMEPAD, abs_y_event)]
self._stick_rev = revert
+ def setStickAxesCallback(self, callback):
+ """
+ Set Callback on StickAxes Movement
+ the function will be called with EventMapper, pos_x, pos_y
+
+ @param function callback the callback function
+ """
+ self._stick_axes_callback = callback
+
+
def setStickButtons(self, key_events):
"""
Set stick as buttons