2012-12-20 12:24:49 +01:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 01:50:59 +01:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
2016-01-10 04:33:01 +01:00
|
|
|
* Copyright (C) 2011-2016 - Daniel De Matteis
|
2012-12-20 12:24:49 +01: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 09:41:29 +01:00
|
|
|
#include <stdint.h>
|
2014-10-21 05:05:52 +02:00
|
|
|
#include <boolean.h>
|
2015-07-11 08:07:14 +02:00
|
|
|
|
2015-02-23 18:53:13 +01:00
|
|
|
#include <retro_miscellaneous.h>
|
2015-11-23 14:15:19 -03:00
|
|
|
#include <formats/image.h>
|
2012-12-20 12:24:49 +01:00
|
|
|
|
2013-06-05 10:47:19 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-11-23 14:15:19 -03:00
|
|
|
#define BOX_RADIAL 0x18df06d2U
|
|
|
|
#define BOX_RECT 0x7c9d4d93U
|
|
|
|
|
|
|
|
#define KEY_ANALOG_LEFT 0x56b92e81U
|
|
|
|
#define KEY_ANALOG_RIGHT 0x2e4dc654U
|
|
|
|
|
2015-01-10 00:59:05 +01:00
|
|
|
#define OVERLAY_GET_KEY(state, key) (((state)->keys[(key) / 32] >> ((key) % 32)) & 1)
|
|
|
|
#define OVERLAY_SET_KEY(state, key) (state)->keys[(key) / 32] |= 1 << ((key) % 32)
|
|
|
|
#define OVERLAY_CLEAR_KEY(state, key) (state)->keys[(key) / 32] &= ~(1 << ((key) % 32))
|
|
|
|
|
2014-09-09 17:34:28 +02:00
|
|
|
/* Overlay driver acts as a medium between input drivers
|
|
|
|
* and video driver.
|
2014-09-02 16:50:28 +02:00
|
|
|
*
|
2014-09-09 17:34:28 +02:00
|
|
|
* Coordinates are fetched from input driver, and an
|
|
|
|
* overlay with pressable actions are displayed on-screen.
|
|
|
|
*
|
|
|
|
* This interface requires that the video driver has support
|
|
|
|
* for the overlay interface.
|
2014-09-02 16:50:28 +02:00
|
|
|
*/
|
2014-12-29 10:44:35 +01:00
|
|
|
|
|
|
|
typedef struct video_overlay_interface
|
|
|
|
{
|
|
|
|
void (*enable)(void *data, bool state);
|
|
|
|
bool (*load)(void *data,
|
2015-07-11 08:14:39 +02:00
|
|
|
const void *images, unsigned num_images);
|
2014-12-29 10:44:35 +01: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 07:29:13 +01:00
|
|
|
enum overlay_status
|
|
|
|
{
|
|
|
|
OVERLAY_STATUS_NONE = 0,
|
|
|
|
OVERLAY_STATUS_DEFERRED_LOAD,
|
2015-02-21 22:00:12 +01:00
|
|
|
OVERLAY_STATUS_DEFERRED_LOADING_IMAGE,
|
2015-02-23 06:03:53 +01:00
|
|
|
OVERLAY_STATUS_DEFERRED_LOADING_IMAGE_PROCESS,
|
2015-02-21 09:26:52 +01:00
|
|
|
OVERLAY_STATUS_DEFERRED_LOADING,
|
2015-02-27 01:25:08 +01:00
|
|
|
OVERLAY_STATUS_DEFERRED_LOADING_RESOLVE,
|
2015-02-21 07:29:13 +01:00
|
|
|
OVERLAY_STATUS_DEFERRED_DONE,
|
2015-07-11 23:45:23 +02:00
|
|
|
OVERLAY_STATUS_DEFERRED_ERROR
|
2015-02-21 07:29:13 +01:00
|
|
|
};
|
|
|
|
|
2015-02-23 06:03:53 +01:00
|
|
|
enum overlay_image_transfer_status
|
|
|
|
{
|
|
|
|
OVERLAY_IMAGE_TRANSFER_NONE = 0,
|
|
|
|
OVERLAY_IMAGE_TRANSFER_BUSY,
|
|
|
|
OVERLAY_IMAGE_TRANSFER_DONE,
|
2015-03-19 23:13:25 +01:00
|
|
|
OVERLAY_IMAGE_TRANSFER_DESC_IMAGE_ITERATE,
|
2015-02-23 20:57:49 +01:00
|
|
|
OVERLAY_IMAGE_TRANSFER_DESC_ITERATE,
|
|
|
|
OVERLAY_IMAGE_TRANSFER_DESC_DONE,
|
2015-06-26 15:53:18 +02:00
|
|
|
OVERLAY_IMAGE_TRANSFER_ERROR
|
2015-02-23 06:03:53 +01:00
|
|
|
};
|
|
|
|
|
2015-11-23 14:15:19 -03:00
|
|
|
|
|
|
|
struct overlay
|
|
|
|
{
|
|
|
|
struct overlay_desc *descs;
|
|
|
|
size_t size;
|
|
|
|
size_t pos;
|
|
|
|
unsigned pos_increment;
|
|
|
|
|
|
|
|
struct texture_image image;
|
|
|
|
|
|
|
|
bool block_scale;
|
|
|
|
float mod_x, mod_y, mod_w, mod_h;
|
|
|
|
float x, y, w, h;
|
|
|
|
float scale;
|
|
|
|
float center_x, center_y;
|
|
|
|
|
|
|
|
bool full_screen;
|
|
|
|
|
|
|
|
char name[64];
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
|
|
|
bool normalized;
|
|
|
|
float alpha_mod;
|
|
|
|
float range_mod;
|
|
|
|
} config;
|
|
|
|
|
|
|
|
struct texture_image *load_images;
|
|
|
|
unsigned load_images_size;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct overlay_desc
|
|
|
|
{
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
|
|
|
|
enum overlay_hitbox hitbox;
|
|
|
|
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;
|
|
|
|
|
|
|
|
enum overlay_type type;
|
|
|
|
uint64_t key_mask;
|
|
|
|
float analog_saturate_pct;
|
|
|
|
|
|
|
|
unsigned next_index;
|
|
|
|
char next_index_name[64];
|
|
|
|
|
|
|
|
struct texture_image image;
|
|
|
|
unsigned image_index;
|
|
|
|
|
|
|
|
float alpha_mod;
|
|
|
|
float range_mod;
|
|
|
|
|
|
|
|
bool updated;
|
|
|
|
bool movable;
|
|
|
|
};
|
|
|
|
|
2015-07-11 08:07:14 +02:00
|
|
|
typedef struct overlay_desc overlay_desc_t;
|
2014-12-29 10:44:35 +01:00
|
|
|
|
2012-12-20 12:24:49 +01:00
|
|
|
typedef struct input_overlay input_overlay_t;
|
|
|
|
|
2015-11-23 14:15:19 -03:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
struct overlay *overlays;
|
|
|
|
struct overlay *active;
|
|
|
|
size_t size;
|
|
|
|
} overlay_task_data_t;
|
|
|
|
|
2015-01-10 00:59:05 +01:00
|
|
|
/**
|
|
|
|
* input_overlay_free:
|
|
|
|
*
|
|
|
|
* Frees overlay handle.
|
|
|
|
**/
|
2015-07-12 07:12:33 +02:00
|
|
|
void input_overlay_free(void);
|
2012-12-20 12:24:49 +01:00
|
|
|
|
2015-11-24 22:17:38 -03:00
|
|
|
void input_overlay_free_overlay(struct overlay *overlay);
|
2015-11-23 14:15:19 -03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* input_overlay_init
|
|
|
|
*
|
|
|
|
* Initializes the overlay system.
|
|
|
|
*/
|
|
|
|
void input_overlay_init(void);
|
2015-01-10 00:59:05 +01: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.
|
|
|
|
**/
|
2015-07-12 07:22:52 +02:00
|
|
|
void input_overlay_set_alpha_mod(float mod);
|
2013-01-29 21:51:15 +01:00
|
|
|
|
2015-01-10 00:59:05 +01:00
|
|
|
/**
|
|
|
|
* input_overlay_set_scale_factor:
|
|
|
|
* @scale : Factor of scale to apply.
|
|
|
|
*
|
|
|
|
* Scales the overlay by a factor of scale.
|
|
|
|
**/
|
2015-07-12 07:22:52 +02:00
|
|
|
void input_overlay_set_scale_factor(float scale);
|
2013-02-03 23:35:55 +01:00
|
|
|
|
2015-01-10 00:59:05 +01:00
|
|
|
/**
|
|
|
|
* input_overlay_next:
|
|
|
|
*
|
|
|
|
* Switch to the next available overlay
|
|
|
|
* screen.
|
|
|
|
**/
|
2015-07-12 07:22:52 +02:00
|
|
|
void input_overlay_next(float opacity);
|
2015-07-09 01:10:30 +02:00
|
|
|
|
2015-07-12 06:47:39 +02:00
|
|
|
/*
|
|
|
|
* input_poll_overlay:
|
|
|
|
* @ol : pointer to overlay
|
|
|
|
*
|
|
|
|
* Poll pressed buttons/keys on currently active overlay.
|
|
|
|
**/
|
|
|
|
void input_poll_overlay(float opacity);
|
|
|
|
|
|
|
|
void input_state_overlay(int16_t *ret,
|
|
|
|
unsigned port, unsigned device, unsigned idx,
|
|
|
|
unsigned id);
|
|
|
|
|
2015-07-12 06:54:35 +02:00
|
|
|
bool input_overlay_key_pressed(int key);
|
|
|
|
|
2015-07-12 07:03:39 +02:00
|
|
|
bool input_overlay_is_alive(void);
|
|
|
|
|
2013-06-05 10:47:19 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-12-20 12:24:49 +01:00
|
|
|
#endif
|