/* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2015 - Daniel De Matteis * * 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 . */ #ifndef INPUT_OVERLAY_H__ #define INPUT_OVERLAY_H__ #include #include #include #include "../libretro.h" #ifdef __cplusplus extern "C" { #endif #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)) /* Overlay driver acts as a medium between input drivers * and video driver. * * 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. */ typedef struct video_overlay_interface { void (*enable)(void *data, bool state); bool (*load)(void *data, const void *images, unsigned num_images); 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 }; enum overlay_status { OVERLAY_STATUS_NONE = 0, OVERLAY_STATUS_DEFERRED_LOAD, OVERLAY_STATUS_DEFERRED_LOADING_IMAGE, OVERLAY_STATUS_DEFERRED_LOADING_IMAGE_PROCESS, OVERLAY_STATUS_DEFERRED_LOADING, OVERLAY_STATUS_DEFERRED_LOADING_RESOLVE, OVERLAY_STATUS_DEFERRED_DONE, OVERLAY_STATUS_DEFERRED_ERROR }; enum overlay_image_transfer_status { OVERLAY_IMAGE_TRANSFER_NONE = 0, OVERLAY_IMAGE_TRANSFER_BUSY, OVERLAY_IMAGE_TRANSFER_DONE, OVERLAY_IMAGE_TRANSFER_DESC_IMAGE_ITERATE, OVERLAY_IMAGE_TRANSFER_DESC_ITERATE, OVERLAY_IMAGE_TRANSFER_DESC_DONE, OVERLAY_IMAGE_TRANSFER_ERROR }; typedef struct overlay_desc overlay_desc_t; typedef struct input_overlay input_overlay_t; /** * input_overlay_new: * @path : Path to overlay file. * @enable : Enable the overlay after initializing it? * * Creates and initializes an overlay handle. * * Returns: Overlay handle on success, otherwise NULL. **/ input_overlay_t *input_overlay_new(const char *path, bool enable, float alpha_mod, float scale_factor); bool input_overlay_load_overlays(void); bool input_overlay_load_overlays_iterate(void); bool input_overlay_load_overlays_resolve_iterate(void); bool input_overlay_new_done(void); /** * input_overlay_free: * * Frees overlay handle. **/ void input_overlay_free(void); /** * 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. **/ void input_overlay_set_alpha_mod(float mod); /** * input_overlay_set_scale_factor: * @scale : Factor of scale to apply. * * Scales the overlay by a factor of scale. **/ void input_overlay_set_scale_factor(float scale); /** * input_overlay_next: * * Switch to the next available overlay * screen. **/ void input_overlay_next(float opacity); bool input_overlay_data_is_active(void); void input_overlay_free_ptr(void); int input_overlay_new_ptr(void); enum overlay_status input_overlay_status(void); /* * 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); bool input_overlay_key_pressed(int key); bool input_overlay_is_alive(void); #ifdef __cplusplus } #endif #endif