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
2016-06-13 03:41:38 -07:00
|
|
|
//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
|
2018-08-22 02:38:37 -07:00
|
|
|
_joystick_event_handler_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
|
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
2016-06-13 03:41:38 -07:00
|
|
|
{
|
2017-02-14 20:00:13 -08:00
|
|
|
printf("deadzone: %d\n", ecore_input_joystick_event_axis_deadzone_get());
|
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
2016-06-13 03:41:38 -07:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-04-12 22:53:47 -07:00
|
|
|
const char *joystick_name;
|
|
|
|
joystick_name = ecore_input_joystick_name_get(ev->index);
|
|
|
|
printf("joystick name is: %s (index: %d)\n", joystick_name, ev->index);
|
|
|
|
|
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
2016-06-13 03:41:38 -07:00
|
|
|
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);
|
2017-02-14 20:00:13 -08:00
|
|
|
ecore_input_joystick_event_axis_deadzone_set(300);
|
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
2016-06-13 03:41:38 -07:00
|
|
|
|
|
|
|
printf("start the main loop.\n");
|
|
|
|
|
|
|
|
ecore_main_loop_begin();
|
|
|
|
|
|
|
|
ecore_shutdown();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|