Ecore_Input: define data type for joysticks

Summary: This adds support for joysticks for ecore_input

Reviewers: cedric, devilhorns, Sergeant_Whitespace, raster, thiepha, zmike, jpeg

Reviewed By: thiepha, zmike, jpeg

Subscribers: thiepha, stefan_schmidt, zmike, singh.amitesh, Sergeant_Whitespace, jgerecke, cedric, seoz

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D1538
This commit is contained in:
Shinwoo Kim 2016-06-13 19:41:38 +09:00 committed by Jean-Philippe Andre
parent 638a1d7e2e
commit 6978d707d6
1 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,61 @@
//Compile with:
// gcc -g -Wall -o ecore_input_joystick_example ecore_input_joystick_example.c `pkg-config --cflags --libs ecore ecore-input`
#include <Ecore.h>
#include <Ecore_Input.h>
static Eina_Bool
_joystick_event_handler_cb(void *data, int type EINA_UNUSED, void *event)
{
Ecore_Event_Joystick *ev = event;
switch (ev->type)
{
case ECORE_EVENT_JOYSTICK_EVENT_TYPE_CONNECTED:
printf("joystick is connected: %d\n", ev->index);
break;
case ECORE_EVENT_JOYSTICK_EVENT_TYPE_DISCONNECTED:
printf("joystick is disconnected: %d\n", ev->index);
break;
case ECORE_EVENT_JOYSTICK_EVENT_TYPE_BUTTON:
printf("joystick(%d) button index: %d, value: %f, time: %u\n",
ev->index, ev->button.index,
ev->button.value, ev->timestamp);
break;
case ECORE_EVENT_JOYSTICK_EVENT_TYPE_AXIS:
printf("joystick(%d) axis index: %d, value: %f, time: %u\n",
ev->index, ev->axis.index,
ev->axis.value, ev->timestamp);
break;
default:
printf("unhandled event type: %d\n", ev->type);
break;
}
if (ev->type == ECORE_EVENT_JOYSTICK_EVENT_TYPE_BUTTON &&
ev->button.index == ECORE_EVENT_JOYSTICK_BUTTON_START)
ecore_main_loop_quit();
return ECORE_CALLBACK_DONE;
}
int
main(void)
{
if (!ecore_event_init())
{
printf("ERROR: Cannot init Ecore!\n");
return -1;
}
ecore_event_handler_add(ECORE_EVENT_JOYSTICK,
_joystick_event_handler_cb,
NULL);
printf("start the main loop.\n");
ecore_main_loop_begin();
ecore_shutdown();
return 0;
}