summaryrefslogtreecommitdiff
path: root/src/lib/ecore_input/ecore_input_joystick.c
diff options
context:
space:
mode:
authorShinwoo Kim <cinoo.kim@samsung.com>2017-02-15 13:00:13 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2017-02-15 13:03:02 +0900
commit32fbf64d285b0d3172f305c6fe0392c7e2624c2b (patch)
tree0c2d3e11d17a0e1b3ab62dc203a5d5765fff3188 /src/lib/ecore_input/ecore_input_joystick.c
parent6210bab777a4c9d84807efd1901c6d13a8079a38 (diff)
ecore_input: add API to set/get deadzone of joystick event for an axis.
Summary: The axis type joystick event could occur without user's control if joystick is too sensitive. The deadzone prevents this unnecessary event. The default value is 200. The event value for an axis is a signed integer between -32767 and +32767. Test Plan: Using example Reviewers: raster, cedric, jpeg Reviewed By: jpeg Subscribers: stefan_schmidt Differential Revision: https://phab.enlightenment.org/D4654
Diffstat (limited to 'src/lib/ecore_input/ecore_input_joystick.c')
-rw-r--r--src/lib/ecore_input/ecore_input_joystick.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/lib/ecore_input/ecore_input_joystick.c b/src/lib/ecore_input/ecore_input_joystick.c
index 33ce129f3a..4f2fd11b0e 100644
--- a/src/lib/ecore_input/ecore_input_joystick.c
+++ b/src/lib/ecore_input/ecore_input_joystick.c
@@ -19,6 +19,7 @@
19#include "ecore_input_private.h" 19#include "ecore_input_private.h"
20 20
21static int _ecore_input_joystick_init_count = 0; 21static int _ecore_input_joystick_init_count = 0;
22static int _event_axis_deadzone = 200;
22 23
23#ifdef HAVE_EEZE 24#ifdef HAVE_EEZE
24 25
@@ -382,8 +383,14 @@ _joystick_event_add(struct js_event *event, Joystick_Info *ji)
382 Ecore_Event_Joystick *e; 383 Ecore_Event_Joystick *e;
383 384
384 if ((event->type != JS_EVENT_BUTTON) && (event->type != JS_EVENT_AXIS)) return; 385 if ((event->type != JS_EVENT_BUTTON) && (event->type != JS_EVENT_AXIS)) return;
386 if ((event->type == JS_EVENT_AXIS) &&
387 ((event->value != 0) && (abs(event->value) < _event_axis_deadzone)))
388 {
389 INF("axis event value(%d) is less than deadzone(%d)\n",
390 event->value,_event_axis_deadzone);
391 return;
392 }
385 if (!(e = calloc(1, sizeof(Ecore_Event_Joystick)))) return; 393 if (!(e = calloc(1, sizeof(Ecore_Event_Joystick)))) return;
386
387 e->index = ji->index; 394 e->index = ji->index;
388 e->timestamp = event->time; 395 e->timestamp = event->time;
389 396
@@ -599,3 +606,18 @@ ecore_input_joystick_shutdown(void)
599 606
600 return _ecore_input_joystick_init_count; 607 return _ecore_input_joystick_init_count;
601} 608}
609
610EAPI void
611ecore_input_joystick_event_axis_deadzone_set(int event_axis_deadzone)
612{
613 event_axis_deadzone = abs(event_axis_deadzone);
614 if (event_axis_deadzone > 32767) event_axis_deadzone = 32767;
615
616 _event_axis_deadzone = event_axis_deadzone;
617}
618
619EAPI int
620ecore_input_joystick_event_axis_deadzone_get(void)
621{
622 return _event_axis_deadzone;
623}