2022-12-23 10:18:26 +01:00
|
|
|
// Copyright (C) 2022 RozK
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
#ifndef _RK_ENGINE_EVENTS_H
|
|
|
|
#define _RK_ENGINE_EVENTS_H
|
|
|
|
|
|
|
|
#include "types.hpp"
|
2022-12-24 11:27:53 +01:00
|
|
|
#include "display.hpp"
|
|
|
|
|
|
|
|
typedef rk_handle_t rk_events_t;
|
2022-12-23 10:18:26 +01:00
|
|
|
|
|
|
|
enum rk_event_type : rk_uint {
|
2022-12-24 06:36:20 +01:00
|
|
|
RK_EVENT_FOCUS_IN = 0,
|
|
|
|
RK_EVENT_FOCUS_OUT = 1,
|
|
|
|
RK_EVENT_KEY_PRESS = 2,
|
|
|
|
RK_EVENT_KEY_RELEASE = 3,
|
|
|
|
RK_EVENT_BUTTON_PRESS = 4,
|
|
|
|
RK_EVENT_BUTTON_RELEASE = 5,
|
|
|
|
RK_EVENT_MOTION = 6
|
2022-12-23 10:18:26 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct rk_event_key {
|
2022-12-23 13:28:29 +01:00
|
|
|
rk_uint code;
|
2022-12-24 06:36:20 +01:00
|
|
|
rk_uint symbol;
|
|
|
|
rk_wchar character;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct rk_event_button {
|
|
|
|
rk_uint index;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct rk_event_motion {
|
|
|
|
rk_int x;
|
|
|
|
rk_int y;
|
2022-12-23 10:18:26 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct rk_event {
|
|
|
|
rk_event_type type;
|
|
|
|
union {
|
|
|
|
rk_event_key key;
|
2022-12-24 06:36:20 +01:00
|
|
|
rk_event_button button;
|
|
|
|
rk_event_motion motion;
|
2022-12-23 10:18:26 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-12-24 11:27:53 +01:00
|
|
|
RK_EXPORT rk_events_t rk_create_events(
|
|
|
|
rk_display_t display);
|
|
|
|
|
|
|
|
RK_EXPORT void rk_destroy_events(
|
|
|
|
rk_display_t display,
|
|
|
|
rk_events_t events);
|
2022-12-24 06:36:20 +01:00
|
|
|
|
2022-12-24 11:27:53 +01:00
|
|
|
RK_EXPORT void rk_set_key_autorepeat(
|
|
|
|
rk_events_t events,
|
2022-12-24 06:36:20 +01:00
|
|
|
rk_bool autorepeat);
|
|
|
|
|
2022-12-24 11:27:53 +01:00
|
|
|
RK_EXPORT void rk_set_motion_acceleration(
|
|
|
|
rk_events_t events,
|
2022-12-24 06:36:20 +01:00
|
|
|
rk_uint numerator,
|
|
|
|
rk_uint denominator,
|
|
|
|
rk_uint threshold);
|
|
|
|
|
2022-12-23 10:18:26 +01:00
|
|
|
RK_EXPORT rk_uint rk_consume_events(
|
2022-12-24 11:27:53 +01:00
|
|
|
rk_events_t events,
|
|
|
|
rk_event * buffer,
|
2022-12-23 10:18:26 +01:00
|
|
|
rk_uint max_events);
|
|
|
|
|
|
|
|
#endif // _RK_ENGINE_EVENTS_H
|