summaryrefslogtreecommitdiffstats
path: root/src/ui_input.c
blob: 1de5e4ea847fd338496d59f378efb8d7a376596d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * functions, callbacks and data types for user input
 *
 * Copyright (c) 2015 Ultimaker B.V.
 * Author: Olliver Schinagl <o.schinagl@ultimaker.com>
 *
 * SPDX-License-Identifier:	AGPL-3.0+
 */

#include <Ecore.h>
#include <Elementary.h>
#include <Evas.h>

#include "ui_input.h"

int INPUT_MOUSE_WHEEL_UP = 0; /* For custom ecore_event handling */
int INPUT_MOUSE_WHEEL_DOWN = 0; /* For custom ecore_event handling */

/* Function to make the Z-axis of any wheel focus the next/previous focusable widget */
void input_mouse_wheel_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
{
	Evas_Event_Mouse_Wheel *ev = event_info;
	Ecore_Event *event = NULL;

	if (ev->z > 0) {
		elm_object_focus_next((Evas_Object *)data, ELM_FOCUS_NEXT);
		event = ecore_event_add(INPUT_MOUSE_WHEEL_DOWN, NULL, NULL, NULL);
	} else {
		elm_object_focus_next((Evas_Object *)data, ELM_FOCUS_PREVIOUS);
		event = ecore_event_add(INPUT_MOUSE_WHEEL_UP, NULL, NULL, NULL);
	}
	if (!event)
		EINA_LOG_ERR("Wheel event failed to queue.");
}

void input_init()
{
	INPUT_MOUSE_WHEEL_UP = ecore_event_type_new();
	INPUT_MOUSE_WHEEL_DOWN = ecore_event_type_new();
}