summaryrefslogtreecommitdiff
path: root/src/lib/ecore_input
diff options
context:
space:
mode:
authorShinwoo Kim <cinoo.kim@samsung.com>2017-04-13 14:53:47 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-04-13 14:53:48 +0900
commit4f6873905be8f28971d5cf89bf395f6a4e6e7518 (patch)
tree87638a70943f107785a665f1cb4b745a7b1ffbb7 /src/lib/ecore_input
parentb04f584346eb7415d7df6e9abfe6abc6477bebaf (diff)
ecore_input: add API to get name of joystick.
Summary: The Ecore_Event_Joystick would be not enough information on user side. Because the button index such as ECORE_EVENT_JOYSTICK_BUTTON_SELECT/START/META, etc could be mapped to different button for different named joystick. Test Plan: Using example Reviewers: raster, cedric, jpeg Reviewed By: raster Differential Revision: https://phab.enlightenment.org/D4669
Diffstat (limited to 'src/lib/ecore_input')
-rw-r--r--src/lib/ecore_input/Ecore_Input.h11
-rw-r--r--src/lib/ecore_input/ecore_input_joystick.c25
2 files changed, 36 insertions, 0 deletions
diff --git a/src/lib/ecore_input/Ecore_Input.h b/src/lib/ecore_input/Ecore_Input.h
index 4949ff7d59..c701301aac 100644
--- a/src/lib/ecore_input/Ecore_Input.h
+++ b/src/lib/ecore_input/Ecore_Input.h
@@ -478,6 +478,17 @@ extern "C" {
478 */ 478 */
479 EAPI int ecore_input_joystick_event_axis_deadzone_get(void); 479 EAPI int ecore_input_joystick_event_axis_deadzone_get(void);
480 480
481 /**
482 * Get name of joystick
483 *
484 * This function returns the name string of the joysitck. If @p index
485 * does not exist, or on error, this function returns NULL.
486 *
487 * @param index The index of joystick.
488 * @return name of joystick.
489 * @since 1.20
490 */
491 EAPI Eina_Slstr *ecore_input_joystick_name_get(int index);
481#ifdef __cplusplus 492#ifdef __cplusplus
482} 493}
483#endif 494#endif
diff --git a/src/lib/ecore_input/ecore_input_joystick.c b/src/lib/ecore_input/ecore_input_joystick.c
index 4f2fd11b0e..7051597f7e 100644
--- a/src/lib/ecore_input/ecore_input_joystick.c
+++ b/src/lib/ecore_input/ecore_input_joystick.c
@@ -621,3 +621,28 @@ ecore_input_joystick_event_axis_deadzone_get(void)
621{ 621{
622 return _event_axis_deadzone; 622 return _event_axis_deadzone;
623} 623}
624
625EAPI Eina_Slstr *
626ecore_input_joystick_name_get(int index)
627{
628#ifdef JSIOCGNAME
629 int fd;
630 char name[128];
631 Eina_List *l;
632 Joystick_Info *ji;
633
634 EINA_LIST_FOREACH(joystick_list, l, ji)
635 {
636 if (index == ji->index)
637 {
638 fd = ecore_main_fd_handler_fd_get(ji->fd_handler);
639 if (fd < 0) return NULL;
640
641 if (ioctl(fd, JSIOCGNAME(sizeof(name)), name) < 0)
642 strncpy(name, "Unknown", sizeof(name));
643 return eina_slstr_copy_new(name);
644 }
645 }
646#endif
647 return NULL;
648}