summaryrefslogtreecommitdiffstats
path: root/core/variant_parser.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-01-02 09:37:16 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-01-02 09:37:16 -0300
commit432e2e77692e0c718b35ffddc0602a4193e13239 (patch)
tree05e893d7bfdb12e6afbd7a404d08d00226fbcc70 /core/variant_parser.cpp
parentdf5fa62ab955437f05bfd7acdf6ed61d6d9c827e (diff)
downloadredot-engine-432e2e77692e0c718b35ffddc0602a4193e13239.tar.gz
proper joy axis support as actions, can be configured and inquired, fixes #2317
Diffstat (limited to 'core/variant_parser.cpp')
-rw-r--r--core/variant_parser.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp
index 3c8c43f5b3..9f2727d33d 100644
--- a/core/variant_parser.cpp
+++ b/core/variant_parser.cpp
@@ -1072,8 +1072,24 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in
ie.joy_motion.axis = token.value;
get_token(p_stream,token,line,r_err_str);
+
+ if (token.type!=TK_COMMA) {
+ r_err_str="Expected ',' after axis index";
+ return ERR_PARSE_ERROR;
+ }
+
+ get_token(p_stream,token,line,r_err_str);
+ if (token.type!=TK_NUMBER) {
+ r_err_str="Expected axis sign";
+ return ERR_PARSE_ERROR;
+ }
+
+ ie.joy_motion.axis_value = token.value;
+
+ get_token(p_stream,token,line,r_err_str);
+
if (token.type!=TK_PARENTHESIS_CLOSE) {
- r_err_str="Expected ')'";
+ r_err_str="Expected ')' for jaxis";
return ERR_PARSE_ERROR;
}
@@ -1339,7 +1355,9 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in
InputEvent ie;
ie.type=InputEvent::JOYSTICK_MOTION;
ie.device=params[0].to_int();
- ie.joy_motion.axis=params[1].to_int();
+ int axis=params[1].to_int();
+ ie.joy_motion.axis=axis>>1;
+ ie.joy_motion.axis_value=axis&1?1:-1;
value= ie;