summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/input/input_windows.h
blob: 7afc487fb6219a2135c50caefdb629b030f1213b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// license:BSD-3-Clause
// copyright-holders:Aaron Giles, Brad Hughes
//============================================================
//
//  input_windows.h - Common code used by Windows input modules
//
//============================================================

#ifndef INPUT_WIN_H_
#define INPUT_WIN_H_

// standard windows headers
#include <windows.h>
#undef interface

#include "window.h"
#include "winmain.h"

//============================================================
//  TYPEDEFS
//============================================================

// state information for a keyboard
struct keyboard_state
{
	uint8_t                   state[MAX_KEYS];
	int8_t                    oldkey[MAX_KEYS];
	int8_t                    currkey[MAX_KEYS];
};

// state information for a mouse (matches DIMOUSESTATE exactly)
struct mouse_state
{
	LONG                    lX;
	LONG                    lY;
	LONG                    lZ;
	BYTE                    rgbButtons[8];
};

class wininput_module : public input_module_base
{
protected:
	bool  m_global_inputs_enabled;

public:
	wininput_module(const char * type, const char * name)
		: input_module_base(type, name),
			m_global_inputs_enabled(false)
	{
	}

	virtual ~wininput_module() { }

	virtual bool should_hide_mouse()
	{
		if (winwindow_has_focus()  // has focus
			&& (!video_config.windowed || !osd_common_t::s_window_list.front()->win_has_menu()) // not windowed or doesn't have a menu
			&& (input_enabled() && !input_paused()) // input enabled and not paused
			&& (mouse_enabled() || lightgun_enabled())) // either mouse or lightgun enabled in the core
		{
			return true;
		}

		return false;
	}

	virtual bool handle_input_event(input_event eventid, void* data)
	{
		return false;
	}

protected:

	void before_poll(running_machine& machine) override
	{
		// periodically process events, in case they're not coming through
		// this also will make sure the mouse state is up-to-date
		winwindow_process_events_periodic(machine);
	}

	bool should_poll_devices(running_machine &machine) override
	{
		return input_enabled() && (m_global_inputs_enabled || winwindow_has_focus());
	}
};

#endif