mirror of
https://github.com/holub/mame
synced 2025-05-24 23:05:32 +03:00

- Created new central header "emu.h"; this should be included by pretty much any driver or device as the first include. This file in turn includes pretty much everything a driver or device will need, minus any other devices it references. Note that emu.h should *never* be included by another header file. - Updated all files in the core (src/emu) to use emu.h. - Removed a ton of redundant and poorly-tracked header includes from within other header files. - Temporarily changed driver.h to map to emu.h until we update files outside of the core. Added class wrapper around tagmap so it can be directly included and accessed within objects that need it. Updated all users to embed tagmap objects and changed them to call through the class. Added nicer functions for finding devices, ports, and regions in a machine: machine->device("tag") -- return the named device, or NULL machine->port("tag") -- return the named port, or NULL machine->region("tag"[, &length[, &flags]]) -- return the named region and optionally its length and flags Made the device tag an astring. This required touching a lot of code that printed the device to explicitly fetch the C-string from it. (Thank you gcc for flagging that issue!)
188 lines
5.2 KiB
C
188 lines
5.2 KiB
C
/***************************************************************************
|
|
|
|
uiinput.h
|
|
|
|
Internal MAME user interface input state.
|
|
|
|
Copyright Nicola Salmoria and the MAME Team.
|
|
Visit http://mamedev.org for licensing and usage restrictions.
|
|
|
|
***************************************************************************/
|
|
|
|
#pragma once
|
|
|
|
#ifndef __UIINPUT_H__
|
|
#define __UIINPUT_H__
|
|
|
|
#include "render.h"
|
|
|
|
|
|
/***************************************************************************
|
|
TYPE DEFINITIONS
|
|
***************************************************************************/
|
|
|
|
enum _ui_event_type
|
|
{
|
|
UI_EVENT_NONE,
|
|
UI_EVENT_MOUSE_MOVE,
|
|
UI_EVENT_MOUSE_LEAVE,
|
|
UI_EVENT_MOUSE_DOWN,
|
|
UI_EVENT_MOUSE_UP,
|
|
UI_EVENT_MOUSE_DOUBLE_CLICK,
|
|
UI_EVENT_CHAR
|
|
};
|
|
typedef enum _ui_event_type ui_event_type;
|
|
|
|
|
|
typedef struct _ui_event ui_event;
|
|
struct _ui_event
|
|
{
|
|
ui_event_type event_type;
|
|
render_target * target;
|
|
INT32 mouse_x;
|
|
INT32 mouse_y;
|
|
input_item_id key;
|
|
unicode_char ch;
|
|
};
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
FUNCTION PROTOTYPES
|
|
***************************************************************************/
|
|
|
|
|
|
/* ----- core system management ----- */
|
|
|
|
/* initialization */
|
|
void ui_input_init(running_machine *machine);
|
|
|
|
|
|
|
|
/* ----- event handling ----- */
|
|
|
|
/* pushes a single event onto the queue */
|
|
int ui_input_push_event(running_machine *machine, ui_event event);
|
|
|
|
/* pops an event off of the queue */
|
|
int ui_input_pop_event(running_machine *machine, ui_event *event);
|
|
|
|
/* clears all outstanding events */
|
|
void ui_input_reset(running_machine *machine);
|
|
|
|
/* retrieves the current location of the mouse */
|
|
render_target *ui_input_find_mouse(running_machine *machine, INT32 *x, INT32 *y, int *button);
|
|
|
|
|
|
|
|
/* ----- user interface sequence reading ----- */
|
|
|
|
/* return TRUE if a key down for the given user interface sequence is detected */
|
|
int ui_input_pressed(running_machine *machine, int code);
|
|
|
|
/* return TRUE if a key down for the given user interface sequence is detected, or if
|
|
autorepeat at the given speed is triggered */
|
|
int ui_input_pressed_repeat(running_machine *machine, int code, int speed);
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
INLINE FUNCTIONS
|
|
***************************************************************************/
|
|
|
|
/*-------------------------------------------------
|
|
ui_input_push_mouse_move_event - pushes a mouse
|
|
move event to the specified render_target
|
|
-------------------------------------------------*/
|
|
|
|
INLINE void ui_input_push_mouse_move_event(running_machine *machine, render_target *target, INT32 x, INT32 y)
|
|
{
|
|
ui_event event = { UI_EVENT_NONE };
|
|
event.event_type = UI_EVENT_MOUSE_MOVE;
|
|
event.target = target;
|
|
event.mouse_x = x;
|
|
event.mouse_y = y;
|
|
ui_input_push_event(machine, event);
|
|
}
|
|
|
|
|
|
/*-------------------------------------------------
|
|
ui_input_push_mouse_leave_event - pushes a
|
|
mouse leave event to the specified render_target
|
|
-------------------------------------------------*/
|
|
|
|
INLINE void ui_input_push_mouse_leave_event(running_machine *machine, render_target *target)
|
|
{
|
|
ui_event event = { UI_EVENT_NONE };
|
|
event.event_type = UI_EVENT_MOUSE_LEAVE;
|
|
event.target = target;
|
|
ui_input_push_event(machine, event);
|
|
}
|
|
|
|
|
|
/*-------------------------------------------------
|
|
ui_input_push_mouse_down_event - pushes a mouse
|
|
down event to the specified render_target
|
|
-------------------------------------------------*/
|
|
|
|
INLINE void ui_input_push_mouse_down_event(running_machine *machine, render_target *target, INT32 x, INT32 y)
|
|
{
|
|
ui_event event = { UI_EVENT_NONE };
|
|
event.event_type = UI_EVENT_MOUSE_DOWN;
|
|
event.target = target;
|
|
event.mouse_x = x;
|
|
event.mouse_y = y;
|
|
ui_input_push_event(machine, event);
|
|
}
|
|
|
|
|
|
/*-------------------------------------------------
|
|
ui_input_push_mouse_down_event - pushes a mouse
|
|
down event to the specified render_target
|
|
-------------------------------------------------*/
|
|
|
|
INLINE void ui_input_push_mouse_up_event(running_machine *machine, render_target *target, INT32 x, INT32 y)
|
|
{
|
|
ui_event event = { UI_EVENT_NONE };
|
|
event.event_type = UI_EVENT_MOUSE_UP;
|
|
event.target = target;
|
|
event.mouse_x = x;
|
|
event.mouse_y = y;
|
|
ui_input_push_event(machine, event);
|
|
}
|
|
|
|
|
|
/*-------------------------------------------------
|
|
ui_input_push_mouse_double_click_event - pushes
|
|
a mouse double-click event to the specified
|
|
render_target
|
|
-------------------------------------------------*/
|
|
|
|
INLINE void ui_input_push_mouse_double_click_event(running_machine *machine, render_target *target, INT32 x, INT32 y)
|
|
{
|
|
ui_event event = { UI_EVENT_NONE };
|
|
event.event_type = UI_EVENT_MOUSE_DOUBLE_CLICK;
|
|
event.target = target;
|
|
event.mouse_x = x;
|
|
event.mouse_y = y;
|
|
ui_input_push_event(machine, event);
|
|
}
|
|
|
|
|
|
/*-------------------------------------------------
|
|
ui_input_push_char_event - pushes a char event
|
|
to the specified render_target
|
|
-------------------------------------------------*/
|
|
|
|
INLINE void ui_input_push_char_event(running_machine *machine, render_target *target, unicode_char ch)
|
|
{
|
|
ui_event event = { UI_EVENT_NONE };
|
|
event.event_type = UI_EVENT_CHAR;
|
|
event.target = target;
|
|
event.ch = ch;
|
|
ui_input_push_event(machine, event);
|
|
}
|
|
|
|
|
|
#endif /* __UIINPUT_H__ */
|