2012-12-20 11:24:49 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 00:50:59 +00:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2017-01-22 12:40:32 +00:00
|
|
|
* Copyright (C) 2011-2017 - Daniel De Matteis
|
2017-12-12 07:55:31 +00:00
|
|
|
*
|
2012-12-20 11:24:49 +00:00
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INPUT_OVERLAY_H__
|
|
|
|
#define INPUT_OVERLAY_H__
|
|
|
|
|
2015-02-21 08:41:29 +00:00
|
|
|
#include <stdint.h>
|
2014-10-21 03:05:52 +00:00
|
|
|
#include <boolean.h>
|
2015-07-11 06:07:14 +00:00
|
|
|
|
2016-06-03 03:54:21 +00:00
|
|
|
#include <retro_common_api.h>
|
2015-02-23 17:53:13 +00:00
|
|
|
#include <retro_miscellaneous.h>
|
2015-11-23 17:15:19 +00:00
|
|
|
#include <formats/image.h>
|
2012-12-20 11:24:49 +00:00
|
|
|
|
2017-08-08 02:59:05 +00:00
|
|
|
#include "input_driver.h"
|
|
|
|
|
2016-06-03 03:54:21 +00:00
|
|
|
RETRO_BEGIN_DECLS
|
2013-06-05 08:47:19 +00:00
|
|
|
|
2017-12-12 07:55:31 +00:00
|
|
|
/* Overlay driver acts as a medium between input drivers
|
2014-09-09 15:34:28 +00:00
|
|
|
* and video driver.
|
2014-09-02 14:50:28 +00:00
|
|
|
*
|
2017-12-12 07:55:31 +00:00
|
|
|
* Coordinates are fetched from input driver, and an
|
2014-09-09 15:34:28 +00:00
|
|
|
* overlay with pressable actions are displayed on-screen.
|
|
|
|
*
|
2017-12-12 07:55:31 +00:00
|
|
|
* This interface requires that the video driver has support
|
2014-09-09 15:34:28 +00:00
|
|
|
* for the overlay interface.
|
2014-09-02 14:50:28 +00:00
|
|
|
*/
|
2014-12-29 09:44:35 +00:00
|
|
|
|
|
|
|
typedef struct video_overlay_interface
|
|
|
|
{
|
|
|
|
void (*enable)(void *data, bool state);
|
|
|
|
bool (*load)(void *data,
|
2015-07-11 06:14:39 +00:00
|
|
|
const void *images, unsigned num_images);
|
2014-12-29 09:44:35 +00:00
|
|
|
void (*tex_geom)(void *data, unsigned image,
|
|
|
|
float x, float y, float w, float h);
|
|
|
|
void (*vertex_geom)(void *data, unsigned image,
|
|
|
|
float x, float y, float w, float h);
|
|
|
|
void (*full_screen)(void *data, bool enable);
|
|
|
|
void (*set_alpha)(void *data, unsigned image, float mod);
|
|
|
|
} video_overlay_interface_t;
|
|
|
|
|
|
|
|
enum overlay_hitbox
|
|
|
|
{
|
|
|
|
OVERLAY_HITBOX_RADIAL = 0,
|
|
|
|
OVERLAY_HITBOX_RECT
|
|
|
|
};
|
|
|
|
|
|
|
|
enum overlay_type
|
|
|
|
{
|
|
|
|
OVERLAY_TYPE_BUTTONS = 0,
|
|
|
|
OVERLAY_TYPE_ANALOG_LEFT,
|
|
|
|
OVERLAY_TYPE_ANALOG_RIGHT,
|
|
|
|
OVERLAY_TYPE_KEYBOARD
|
|
|
|
};
|
|
|
|
|
2015-02-21 06:29:13 +00:00
|
|
|
enum overlay_status
|
|
|
|
{
|
|
|
|
OVERLAY_STATUS_NONE = 0,
|
|
|
|
OVERLAY_STATUS_DEFERRED_LOAD,
|
2015-02-21 21:00:12 +00:00
|
|
|
OVERLAY_STATUS_DEFERRED_LOADING_IMAGE,
|
2015-02-23 05:03:53 +00:00
|
|
|
OVERLAY_STATUS_DEFERRED_LOADING_IMAGE_PROCESS,
|
2015-02-21 08:26:52 +00:00
|
|
|
OVERLAY_STATUS_DEFERRED_LOADING,
|
2015-02-27 00:25:08 +00:00
|
|
|
OVERLAY_STATUS_DEFERRED_LOADING_RESOLVE,
|
2015-02-21 06:29:13 +00:00
|
|
|
OVERLAY_STATUS_DEFERRED_DONE,
|
2015-07-11 21:45:23 +00:00
|
|
|
OVERLAY_STATUS_DEFERRED_ERROR
|
2015-02-21 06:29:13 +00:00
|
|
|
};
|
|
|
|
|
2015-02-23 05:03:53 +00:00
|
|
|
enum overlay_image_transfer_status
|
|
|
|
{
|
|
|
|
OVERLAY_IMAGE_TRANSFER_NONE = 0,
|
|
|
|
OVERLAY_IMAGE_TRANSFER_BUSY,
|
|
|
|
OVERLAY_IMAGE_TRANSFER_DONE,
|
2015-03-19 22:13:25 +00:00
|
|
|
OVERLAY_IMAGE_TRANSFER_DESC_IMAGE_ITERATE,
|
2015-02-23 19:57:49 +00:00
|
|
|
OVERLAY_IMAGE_TRANSFER_DESC_ITERATE,
|
|
|
|
OVERLAY_IMAGE_TRANSFER_DESC_DONE,
|
2015-06-26 13:53:18 +00:00
|
|
|
OVERLAY_IMAGE_TRANSFER_ERROR
|
2015-02-23 05:03:53 +00:00
|
|
|
};
|
|
|
|
|
2018-01-04 17:45:01 +00:00
|
|
|
enum overlay_visibility
|
|
|
|
{
|
|
|
|
OVERLAY_VISIBILITY_DEFAULT = 0,
|
|
|
|
OVERLAY_VISIBILITY_VISIBLE,
|
|
|
|
OVERLAY_VISIBILITY_HIDDEN
|
|
|
|
};
|
|
|
|
|
2015-11-23 17:15:19 +00:00
|
|
|
struct overlay
|
|
|
|
{
|
2017-09-29 15:11:42 +00:00
|
|
|
bool full_screen;
|
|
|
|
bool block_scale;
|
|
|
|
|
|
|
|
unsigned load_images_size;
|
2016-11-21 14:00:57 +00:00
|
|
|
unsigned id;
|
2017-09-29 15:11:42 +00:00
|
|
|
unsigned pos_increment;
|
2016-11-21 14:00:57 +00:00
|
|
|
|
2015-11-23 17:15:19 +00:00
|
|
|
size_t size;
|
|
|
|
size_t pos;
|
|
|
|
|
|
|
|
float mod_x, mod_y, mod_w, mod_h;
|
|
|
|
float x, y, w, h;
|
|
|
|
float scale;
|
|
|
|
float center_x, center_y;
|
|
|
|
|
2017-09-29 15:11:42 +00:00
|
|
|
struct overlay_desc *descs;
|
|
|
|
struct texture_image *load_images;
|
|
|
|
|
|
|
|
struct texture_image image;
|
2015-11-23 17:15:19 +00:00
|
|
|
|
|
|
|
char name[64];
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
2017-09-29 15:11:42 +00:00
|
|
|
bool normalized;
|
|
|
|
float alpha_mod;
|
|
|
|
float range_mod;
|
|
|
|
|
2015-11-23 17:15:19 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
char key[64];
|
|
|
|
char path[PATH_MAX_LENGTH];
|
|
|
|
} paths;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
char key[64];
|
|
|
|
} names;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
char array[256];
|
|
|
|
char key[64];
|
|
|
|
} rect;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
char key[64];
|
|
|
|
unsigned size;
|
|
|
|
} descs;
|
|
|
|
|
|
|
|
} config;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
struct overlay_desc
|
|
|
|
{
|
|
|
|
enum overlay_hitbox hitbox;
|
2017-09-29 15:11:42 +00:00
|
|
|
enum overlay_type type;
|
|
|
|
|
|
|
|
bool updated;
|
|
|
|
bool movable;
|
|
|
|
|
|
|
|
unsigned next_index;
|
|
|
|
unsigned image_index;
|
|
|
|
|
|
|
|
float alpha_mod;
|
|
|
|
float range_mod;
|
|
|
|
float analog_saturate_pct;
|
2015-11-23 17:15:19 +00:00
|
|
|
float range_x, range_y;
|
|
|
|
float range_x_mod, range_y_mod;
|
|
|
|
float mod_x, mod_y, mod_w, mod_h;
|
|
|
|
float delta_x, delta_y;
|
2017-09-29 15:11:42 +00:00
|
|
|
float x;
|
|
|
|
float y;
|
2015-11-23 17:15:19 +00:00
|
|
|
|
2017-12-17 12:36:18 +00:00
|
|
|
/* This is a retro_key value for keyboards */
|
|
|
|
unsigned retro_key_idx;
|
|
|
|
|
|
|
|
/* This is a bit mask of all input binds to set with this overlay control */
|
2018-04-08 18:21:12 +00:00
|
|
|
input_bits_t button_mask;
|
2015-11-23 17:15:19 +00:00
|
|
|
|
|
|
|
char next_index_name[64];
|
|
|
|
|
|
|
|
struct texture_image image;
|
|
|
|
};
|
|
|
|
|
2015-07-11 06:07:14 +00:00
|
|
|
typedef struct overlay_desc overlay_desc_t;
|
2014-12-29 09:44:35 +00:00
|
|
|
|
2012-12-20 11:24:49 +00:00
|
|
|
typedef struct input_overlay input_overlay_t;
|
|
|
|
|
2015-11-23 17:15:19 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2017-01-01 03:12:24 +00:00
|
|
|
bool hide_in_menu;
|
|
|
|
bool overlay_enable;
|
2017-09-29 15:11:42 +00:00
|
|
|
size_t size;
|
2017-01-01 03:12:24 +00:00
|
|
|
float overlay_opacity;
|
|
|
|
float overlay_scale;
|
2017-09-29 15:11:42 +00:00
|
|
|
struct overlay *overlays;
|
|
|
|
struct overlay *active;
|
2015-11-23 17:15:19 +00:00
|
|
|
} overlay_task_data_t;
|
|
|
|
|
2015-01-09 23:59:05 +00:00
|
|
|
/**
|
|
|
|
* input_overlay_free:
|
|
|
|
*
|
|
|
|
* Frees overlay handle.
|
|
|
|
**/
|
2016-11-27 14:21:53 +00:00
|
|
|
void input_overlay_free(input_overlay_t *ol);
|
2012-12-20 11:24:49 +00:00
|
|
|
|
2015-11-25 01:17:38 +00:00
|
|
|
void input_overlay_free_overlay(struct overlay *overlay);
|
2015-11-23 17:15:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* input_overlay_init
|
|
|
|
*
|
|
|
|
* Initializes the overlay system.
|
|
|
|
*/
|
|
|
|
void input_overlay_init(void);
|
2015-01-09 23:59:05 +00:00
|
|
|
/**
|
|
|
|
* input_overlay_set_alpha_mod:
|
|
|
|
* @mod : New modulating factor to apply.
|
|
|
|
*
|
|
|
|
* Sets a modulating factor for alpha channel. Default is 1.0.
|
|
|
|
* The alpha factor is applied for all overlays.
|
|
|
|
**/
|
2016-11-27 14:17:44 +00:00
|
|
|
void input_overlay_set_alpha_mod(input_overlay_t *ol, float mod);
|
2013-01-29 20:51:15 +00:00
|
|
|
|
2015-01-09 23:59:05 +00:00
|
|
|
/**
|
|
|
|
* input_overlay_set_scale_factor:
|
|
|
|
* @scale : Factor of scale to apply.
|
|
|
|
*
|
|
|
|
* Scales the overlay by a factor of scale.
|
|
|
|
**/
|
2016-05-24 21:15:19 +00:00
|
|
|
void input_overlay_set_scale_factor(input_overlay_t *ol, float scale);
|
2013-02-03 22:35:55 +00:00
|
|
|
|
2015-01-09 23:59:05 +00:00
|
|
|
/**
|
|
|
|
* input_overlay_next:
|
|
|
|
*
|
|
|
|
* Switch to the next available overlay
|
|
|
|
* screen.
|
|
|
|
**/
|
2016-11-27 14:17:44 +00:00
|
|
|
void input_overlay_next(input_overlay_t *ol, float opacity);
|
2015-07-08 23:10:30 +00:00
|
|
|
|
2015-07-12 04:47:39 +00:00
|
|
|
/*
|
|
|
|
* input_poll_overlay:
|
2017-12-12 07:55:31 +00:00
|
|
|
* @ol : pointer to overlay
|
2015-07-12 04:47:39 +00:00
|
|
|
*
|
|
|
|
* Poll pressed buttons/keys on currently active overlay.
|
|
|
|
**/
|
2017-01-01 03:57:57 +00:00
|
|
|
void input_poll_overlay(input_overlay_t *ol, float opacity, unsigned analog_dpad_mode,
|
|
|
|
float axis_threshold);
|
2015-07-12 04:47:39 +00:00
|
|
|
|
2016-11-27 14:21:53 +00:00
|
|
|
void input_state_overlay(input_overlay_t *ol,
|
|
|
|
int16_t *ret, unsigned port, unsigned device, unsigned idx,
|
2015-07-12 04:47:39 +00:00
|
|
|
unsigned id);
|
|
|
|
|
2017-12-17 12:36:18 +00:00
|
|
|
bool input_overlay_key_pressed(input_overlay_t *ol, unsigned key);
|
2015-07-12 04:54:35 +00:00
|
|
|
|
2016-05-24 21:15:19 +00:00
|
|
|
bool input_overlay_is_alive(input_overlay_t *ol);
|
2015-07-12 05:03:39 +00:00
|
|
|
|
2016-05-24 22:57:58 +00:00
|
|
|
void input_overlay_loaded(void *task_data, void *user_data, const char *err);
|
|
|
|
|
2018-01-04 17:45:01 +00:00
|
|
|
void input_overlay_set_visibility(int overlay_idx,enum overlay_visibility vis);
|
|
|
|
|
2016-11-27 14:10:09 +00:00
|
|
|
/* FIXME - temporary. Globals are bad */
|
|
|
|
extern input_overlay_t *overlay_ptr;
|
|
|
|
|
2016-06-03 03:54:21 +00:00
|
|
|
RETRO_END_DECLS
|
2013-06-05 08:47:19 +00:00
|
|
|
|
2012-12-20 11:24:49 +00:00
|
|
|
#endif
|