RetroArch/input/overlay.h

84 lines
2.8 KiB
C
Raw Normal View History

/* RetroArch - A frontend for libretro.
2014-01-01 00:50:59 +00:00
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
*
* 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__
#include "../boolean.h"
#include "../libretro.h"
#include <stdint.h>
2013-06-05 08:47:19 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2014-09-02 14:50:28 +00:00
/* 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 input_overlay input_overlay_t;
2013-09-05 22:19:07 +00:00
typedef struct input_overlay_state
{
2014-09-02 14:50:28 +00:00
/* This is a bitmask of (1 << key_bind_id). */
uint64_t buttons;
/* Left X, Left Y, Right X, Right Y */
int16_t analog[4];
uint32_t keys[RETROK_LAST / 32 + 1];
2013-09-05 22:19:07 +00:00
} input_overlay_state_t;
#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))
input_overlay_t *input_overlay_new(const char *overlay);
void input_overlay_free(input_overlay_t *ol);
2012-12-20 14:37:04 +00:00
void input_overlay_enable(input_overlay_t *ol, bool enable);
2013-01-11 15:23:04 +00:00
bool input_overlay_full_screen(input_overlay_t *ol);
2014-09-02 14:50:28 +00:00
/* norm_x and norm_y are the result of
* input_translate_coord_viewport(). */
void input_overlay_poll(input_overlay_t *ol,
input_overlay_state_t *out, int16_t norm_x, int16_t norm_y);
2014-09-02 14:50:28 +00:00
/* called after all the input_overlay_poll calls to
* update the range modifiers for pressed/unpressed regions
* and alpha mods */
void input_overlay_post_poll(input_overlay_t *ol);
2014-09-02 14:50:28 +00:00
/* Call when there is nothing to poll. Allows overlay to
* clear certain state. */
void input_overlay_poll_clear(input_overlay_t *ol);
2014-09-02 14:50:28 +00:00
/* Sets a modulating factor for alpha channel. Default is 1.0.
* The alpha factor is applied for all overlays. */
2013-01-29 20:51:15 +00:00
void input_overlay_set_alpha_mod(input_overlay_t *ol, float mod);
2014-09-02 14:50:28 +00:00
/* Scales the overlay by a factor of scale. */
2013-02-03 22:35:55 +00:00
void input_overlay_set_scale_factor(input_overlay_t *ol, float scale);
void input_overlay_next(input_overlay_t *ol);
2013-06-05 08:47:19 +00:00
#ifdef __cplusplus
}
#endif
#endif