summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/uiinput.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/emu/uiinput.h')
-rw-r--r--src/emu/uiinput.h175
1 files changed, 51 insertions, 124 deletions
diff --git a/src/emu/uiinput.h b/src/emu/uiinput.h
index 3b7a63d420d..963e54cc6ed 100644
--- a/src/emu/uiinput.h
+++ b/src/emu/uiinput.h
@@ -16,6 +16,12 @@
/***************************************************************************
+ CONSTANTS
+***************************************************************************/
+
+#define EVENT_QUEUE_SIZE 128
+
+/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
@@ -30,7 +36,6 @@ enum ui_event_type
UI_EVENT_CHAR
};
-
struct ui_event
{
ui_event_type event_type;
@@ -41,145 +46,67 @@ struct ui_event
unicode_char ch;
};
+// ======================> ui_input_manager
+class ui_input_manager
+{
+public:
+ // construction/destruction
+ ui_input_manager(running_machine &machine);
-/***************************************************************************
- FUNCTION PROTOTYPES
-***************************************************************************/
-
-
-/* ----- core system management ----- */
-
-/* initialization */
-void ui_input_init(running_machine &machine);
-
-
-
-/* ----- event handling ----- */
-
-void ui_input_frame_update(running_machine &machine);
-
-/* pushes a single event onto the queue */
-bool ui_input_push_event(running_machine &machine, ui_event event);
-
-/* pops an event off of the queue */
-bool 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, bool *button);
-
-
-
-/* ----- user interface sequence reading ----- */
-
-/* return TRUE if a key down for the given user interface sequence is detected */
-bool 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 */
-bool ui_input_pressed_repeat(running_machine &machine, int code, int speed);
-
-
-
-/***************************************************************************
- INLINE FUNCTIONS
-***************************************************************************/
+ void frame_update();
-/*-------------------------------------------------
- ui_input_push_mouse_move_event - pushes a mouse
- move event to the specified render_target
--------------------------------------------------*/
+ /* pushes a single event onto the queue */
+ bool push_event(ui_event event);
-static 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);
-}
+ /* pops an event off of the queue */
+ bool pop_event(ui_event *event);
+ /* clears all outstanding events */
+ void reset();
-/*-------------------------------------------------
- ui_input_push_mouse_leave_event - pushes a
- mouse leave event to the specified render_target
--------------------------------------------------*/
+ /* retrieves the current location of the mouse */
+ render_target *find_mouse(INT32 *x, INT32 *y, bool *button);
-static 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);
-}
+ /* return TRUE if a key down for the given user interface sequence is detected */
+ bool pressed(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 */
+ bool pressed_repeat(int code, int speed);
-/*-------------------------------------------------
- ui_input_push_mouse_down_event - pushes a mouse
- down event to the specified render_target
--------------------------------------------------*/
+ // getters
+ running_machine &machine() const { return m_machine; }
-static 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);
-}
+ void push_mouse_move_event(render_target* target, INT32 x, INT32 y);
+ void push_mouse_leave_event(render_target* target);
+ void push_mouse_down_event(render_target* target, INT32 x, INT32 y);
+ void push_mouse_up_event(render_target* target, INT32 x, INT32 y);
+ void push_mouse_double_click_event(render_target* target, INT32 x, INT32 y);
+ void push_char_event(render_target* target, unicode_char ch);
-/*-------------------------------------------------
- ui_input_push_mouse_down_event - pushes a mouse
- down event to the specified render_target
--------------------------------------------------*/
+private:
-static 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
--------------------------------------------------*/
-
-static 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);
-}
+ // internal state
+ running_machine & m_machine; // reference to our machine
+ /* pressed states; retrieved with ui_input_pressed() */
+ osd_ticks_t m_next_repeat[IPT_COUNT];
+ UINT8 m_seqpressed[IPT_COUNT];
-/*-------------------------------------------------
- ui_input_push_char_event - pushes a char event
- to the specified render_target
--------------------------------------------------*/
+ /* mouse position/info */
+ render_target * m_current_mouse_target;
+ INT32 m_current_mouse_x;
+ INT32 m_current_mouse_y;
+ bool m_current_mouse_down;
-static 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);
-}
+ /* popped states; ring buffer of ui_events */
+ ui_event m_events[EVENT_QUEUE_SIZE];
+ int m_events_start;
+ int m_events_end;
+ bool m_initialized;
+};
#endif /* __UIINPUT_H__ */