17
17
OUTPUT_360_STICK_MIN , OUTPUT_360_STICK_MAX )
18
18
from scc .constants import STICK_PAD_MAX_HALF , TRIGGER_MIN , TRIGGER_HALF
19
19
from scc .constants import HIPFIRE_NORMAL , HIPFIRE_SENSIBLE , HIPFIRE_EXCLUSIVE
20
- from scc .constants import LEFT , RIGHT , CPAD , STICK , PITCH , YAW , ROLL
20
+ from scc .constants import LEFT , RIGHT , CPAD , STICK , RSTICK , PITCH , YAW , ROLL
21
21
from scc .constants import PARSER_CONSTANTS , ControllerFlags
22
22
from scc .constants import FE_STICK , FE_TRIGGER , FE_PAD
23
23
from scc .constants import TRIGGER_CLICK , TRIGGER_MAX
@@ -445,6 +445,13 @@ def __init__(self, what, op, value):
445
445
self .children = RangeOP (SCButtons .X , op , value ), RangeOP (SCButtons .Y , op , value )
446
446
self .min , self .max = float (STICK_PAD_MIN ), float (STICK_PAD_MAX )
447
447
self .op_method = self .cmp_or
448
+ elif what == RSTICK :
449
+ # Most special case of all special cases
450
+ self .axis_name = RSTICK
451
+ op = "ABS" + op .replace ("=" , "" )
452
+ self .children = RangeOP (SCButtons .X , op , value ), RangeOP (SCButtons .Y , op , value )
453
+ self .min , self .max = float (STICK_PAD_MIN ), float (STICK_PAD_MAX )
454
+ self .op_method = self .cmp_or
448
455
else :
449
456
raise ValueError ("'%s' is not trigger nor axis" % (nameof (what ), ))
450
457
@@ -915,6 +922,7 @@ def whole(self, mapper: Mapper, x, y, what):
915
922
# mapper.mouse_move(x * self.speed[0] * 0.01, y * self.speed[1] * 0.01)
916
923
# mapper.force_event.add(FE_STICK)
917
924
if ((what == STICK ) or
925
+ (what == RSTICK ) or
918
926
(what == RIGHT and mapper .controller_flags () & ControllerFlags .HAS_RSTICK )):
919
927
ratio_x = x / (STICK_PAD_MAX if x > 0 else STICK_PAD_MIN ) * copysign (1 , x )
920
928
ratio_y = y / (STICK_PAD_MAX if y > 0 else STICK_PAD_MIN ) * copysign (1 , y )
@@ -1609,7 +1617,7 @@ def button_release(self, mapper: Mapper):
1609
1617
1610
1618
1611
1619
def whole (self , mapper : Mapper , x , y , what ):
1612
- if what == STICK :
1620
+ if what == STICK or what == RSTICK :
1613
1621
# Stick used used as one big button (probably as part of ring bindings)
1614
1622
if abs (x ) < ButtonAction .STICK_DEADZONE and abs (y ) < ButtonAction .STICK_DEADZONE :
1615
1623
if self ._pressed_key == self .button :
@@ -2128,7 +2136,7 @@ def to_string(self, multiline=False, pad=0):
2128
2136
2129
2137
2130
2138
def whole (self , mapper : Mapper , x , y , what ):
2131
- if what == STICK or mapper .is_touched (what ):
2139
+ if what == STICK or what == RSTICK or mapper .is_touched (what ):
2132
2140
angle = atan2 (x , y )
2133
2141
distance = sqrt (x * x + y * y )
2134
2142
if distance < self ._radius_m :
@@ -2143,7 +2151,7 @@ def whole(self, mapper: Mapper, x, y, what):
2143
2151
2144
2152
if action == self ._active :
2145
2153
action .whole (mapper , x , y , what )
2146
- elif what == STICK :
2154
+ elif what == STICK or what == RSTICK :
2147
2155
# Stck crossed radius border, so active action is changing.
2148
2156
# Simulate centering stick for former...
2149
2157
self ._active .whole (mapper , 0 , 0 , what )
@@ -2166,7 +2174,7 @@ def whole(self, mapper: Mapper, x, y, what):
2166
2174
# Pad just released
2167
2175
self ._active .whole (mapper , x , y , what )
2168
2176
self ._active = NoAction ()
2169
- elif self ._active and what == STICK and x == 0 and y == 0 :
2177
+ elif self ._active and ( what == STICK or what == RSTICK ) and x == 0 and y == 0 :
2170
2178
# Stick is centered
2171
2179
self ._active .whole (mapper , x , y , what )
2172
2180
self ._active = NoAction ()
@@ -2292,7 +2300,7 @@ def whole(self, mapper: Mapper, x, y, what):
2292
2300
else :
2293
2301
self ._old_pos = None
2294
2302
2295
- if mapper .controller_flags () & ControllerFlags .HAS_RSTICK and what == RIGHT :
2303
+ if mapper .controller_flags () & ControllerFlags .HAS_RSTICK and ( what == RIGHT or what == RSTICK ) :
2296
2304
self .x .axis (mapper , x , what )
2297
2305
self .y .axis (mapper , y , what )
2298
2306
mapper .force_event .add (FE_PAD )
0 commit comments