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:
authorsyr1us <paul.wachendorf@web.de>2015-12-30 15:14:26 +0300
committersyr1us <paul.wachendorf@web.de>2015-12-30 15:14:26 +0300
commit367501629789ade29bc64f2d02d117f3124d6446 (patch)
tree5fac79524013a52d0d4cfbd057969357e0a55f08
parenta8c0b8ab6da60e3b6794db6ab139d0d19538440c (diff)
added forgotten callback for trigger callback
-rw-r--r--scripts/sc-callbacks.py7
-rw-r--r--src/events.py28
2 files changed, 24 insertions, 11 deletions
diff --git a/scripts/sc-callbacks.py b/scripts/sc-callbacks.py
index 41d4078..eaeb658 100644
--- a/scripts/sc-callbacks.py
+++ b/scripts/sc-callbacks.py
@@ -32,7 +32,7 @@ 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()
@@ -49,6 +49,9 @@ def stick_pressed_callback(evm):
def stick_axes_callback(evm, x, y):
print "Stick Position is {}, {}".format(x, y)
+def tigger_axes_callback(evm, pos, value):
+ print "Trigger axes {} has value {}".format(pos, value)
+
def evminit():
evm = EventMapper()
evm.setButtonCallback(SCButtons.STEAM, button_pressed_callback)
@@ -68,6 +71,8 @@ def evminit():
evm.setPadButtonCallback(Pos.RIGHT, touchpad_click_callback, clicked=True)
evm.setStickAxesCallback(stick_axes_callback)
evm.setStickPressedCallback(stick_pressed_callback)
+ evm.setTrigAxesCallback(Pos.RIGHT, tigger_axes_callback)
+ evm.setTrigAxesCallback(Pos.LEFT, tigger_axes_callback)
return evm
diff --git a/src/events.py b/src/events.py
index 14b06a5..72af453 100644
--- a/src/events.py
+++ b/src/events.py
@@ -113,8 +113,9 @@ class EventMapper(object):
self._stick_rxs = None
self._stick_axes_callback = None
self._stick_pressed_callback = None
-
+
self._trig_s = [None, None]
+ self._trig_axes_callbacks = [None, None]
self._moved = [0, 0]
@@ -374,8 +375,11 @@ class EventMapper(object):
mode, ev = self._trig_evts[pos]
if self._trig_modes[pos] == TrigModes.AXIS:
if trigval != trigval_prev:
- syn.add(mode)
- self._uip[mode].axisEvent(ev, trigval)
+ if self._trig_axes_callbacks[pos]:
+ self._trig_axes_callbacks[pos](self, pos, trigval)
+ else:
+ syn.add(mode)
+ self._uip[mode].axisEvent(ev, trigval)
elif self._trig_modes[pos] == TrigModes.BUTTON:
if self._trig_s[pos] is None and trigval > min(trigval_prev + 10, 200):
self._trig_s[pos] = max(0, min(trigval - 10, 180))
@@ -467,11 +471,11 @@ class EventMapper(object):
set callback function to be executed when button is clicked
callback is called with parameters self(EventMapper), btn
and pushed (boollean True -> Button pressed, False -> Button released)
-
+
@param btn Button
@param function callback Callback function
"""
-
+
self._btn_map[btn] = (Modes.CALLBACK, callback)
@@ -504,13 +508,13 @@ class EventMapper(object):
self._btn_map[SCButtons.LPAD] = (None, 0)
else:
self._btn_map[SCButtons.RPAD] = (None, 0)
-
+
def setPadButtonCallback(self, pos, callback, clicked=False):
"""
set callback function to be executed when Pad clicked or touched
if clicked is False callback will be called with pad, xpos and ypos
else with pad and boolean is_pressed
-
+
@param Pos pos designate left or right pad
@param callback Callback function
@param bool clicked callback on touch or on click event
@@ -593,6 +597,10 @@ class EventMapper(object):
self._trig_modes[pos] = TrigModes.AXIS
self._trig_evts[pos] = (Modes.GAMEPAD, abs_event)
+ def setTrigAxesCallback(self, pos, callback):
+ self._trig_modes[pos] = StickModes.AXIS
+ self._trig_axes_callbacks[pos] = callback
+
def setStickAxes(self, abs_x_event, abs_y_event, revert=True):
self._stick_mode = StickModes.AXIS
self._stick_evts = [(Modes.GAMEPAD, abs_x_event),
@@ -603,7 +611,7 @@ class EventMapper(object):
"""
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
@@ -631,7 +639,7 @@ class EventMapper(object):
"""
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
+ self._stick_pressed_callback = callback