mirror of
https://github.com/holub/mame
synced 2025-04-23 08:49:55 +03:00
Merge pull request #1537 from ajrhacker/natkeyboard_use
Lock out ioport_fields independently of natural keyboard state (nw)
This commit is contained in:
commit
5bdb4f7a89
@ -1075,8 +1075,8 @@ void ioport_field::frame_update(ioport_value &result)
|
||||
if (machine().ui().is_menu_active())
|
||||
return;
|
||||
|
||||
// if we're a keyboard type and using natural keyboard, bail
|
||||
if (m_type == IPT_KEYBOARD && machine().ui().use_natural_keyboard())
|
||||
// if user input is locked out here, bail
|
||||
if (m_live->lockout)
|
||||
{
|
||||
// use just the digital value
|
||||
if (m_digital_value)
|
||||
@ -1349,7 +1349,8 @@ ioport_field_live::ioport_field_live(ioport_field &field, analog_field *analog)
|
||||
toggle(field.toggle()),
|
||||
joydir(digital_joystick::JOYDIR_COUNT),
|
||||
autofire(false),
|
||||
autopressed(0)
|
||||
autopressed(0),
|
||||
lockout(false)
|
||||
{
|
||||
// fill in the basic values
|
||||
for (input_seq_type seqtype = SEQ_TYPE_STANDARD; seqtype < SEQ_TYPE_TOTAL; ++seqtype)
|
||||
|
@ -1182,6 +1182,7 @@ struct ioport_field_live
|
||||
digital_joystick::direction_t joydir; // digital joystick direction index
|
||||
bool autofire; // autofire
|
||||
int autopressed; // autofire status
|
||||
bool lockout; // user lockout
|
||||
std::string name; // overridden name
|
||||
};
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include "emu.h"
|
||||
#include "natkeyboard.h"
|
||||
#include "emuopts.h"
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
@ -314,6 +315,7 @@ const char_info charinfo[] =
|
||||
|
||||
natural_keyboard::natural_keyboard(running_machine &machine)
|
||||
: m_machine(machine),
|
||||
m_in_use(false),
|
||||
m_bufbegin(0),
|
||||
m_bufend(0),
|
||||
m_status_keydown(false),
|
||||
@ -331,6 +333,9 @@ natural_keyboard::natural_keyboard(running_machine &machine)
|
||||
m_buffer.resize(KEY_BUFFER_SIZE);
|
||||
m_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(natural_keyboard::timer), this));
|
||||
}
|
||||
|
||||
// retrieve option setting
|
||||
set_in_use(machine.options().natural_keyboard());
|
||||
}
|
||||
|
||||
|
||||
@ -348,6 +353,30 @@ void natural_keyboard::configure(ioport_queue_chars_delegate queue_chars, ioport
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// set_in_use - specify whether the natural
|
||||
// keyboard is active
|
||||
//-------------------------------------------------
|
||||
|
||||
void natural_keyboard::set_in_use(bool usage)
|
||||
{
|
||||
if (m_in_use != usage)
|
||||
{
|
||||
// update active usage
|
||||
m_in_use = usage;
|
||||
std::string error;
|
||||
machine().options().set_value(OPTION_NATURAL_KEYBOARD, usage, OPTION_PRIORITY_CMDLINE, error);
|
||||
assert(error.empty());
|
||||
|
||||
// lock out (or unlock) all keyboard inputs
|
||||
for (auto &port : machine().ioport().ports())
|
||||
for (ioport_field &field : port.second->fields())
|
||||
if (field.type() == IPT_KEYBOARD)
|
||||
field.live().lockout = usage;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// post - post a single character
|
||||
//-------------------------------------------------
|
||||
|
@ -41,9 +41,11 @@ public:
|
||||
bool full() const { return ((m_bufend + 1) % m_buffer.size()) == m_bufbegin; }
|
||||
bool can_post() const { return (!m_queue_chars.isnull() || !m_keycode_map.empty()); }
|
||||
bool is_posting() const { return (!empty() || (!m_charqueue_empty.isnull() && !m_charqueue_empty())); }
|
||||
bool in_use() const { return m_in_use; }
|
||||
|
||||
// configuration
|
||||
void configure(ioport_queue_chars_delegate queue_chars, ioport_accept_char_delegate accept_char, ioport_charqueue_empty_delegate charqueue_empty);
|
||||
void set_in_use(bool usage);
|
||||
|
||||
// posting
|
||||
void post(unicode_char ch);
|
||||
@ -74,6 +76,7 @@ private:
|
||||
|
||||
// internal state
|
||||
running_machine & m_machine; // reference to our machine
|
||||
bool m_in_use; // is natural keyboard in use?
|
||||
UINT32 m_bufbegin; // index of starting character
|
||||
UINT32 m_bufend; // index of ending character
|
||||
std::vector<unicode_char> m_buffer; // actual buffer
|
||||
|
@ -23,7 +23,7 @@ class ui_manager
|
||||
{
|
||||
public:
|
||||
// construction/destruction
|
||||
ui_manager(running_machine &machine) : m_machine(machine),m_use_natural_keyboard(false),m_show_timecode_counter(false),m_show_timecode_total(false) { }
|
||||
ui_manager(running_machine &machine) : m_machine(machine),m_show_timecode_counter(false),m_show_timecode_total(false) { }
|
||||
|
||||
virtual ~ui_manager() { }
|
||||
|
||||
@ -32,8 +32,6 @@ public:
|
||||
// is a menuing system active? we want to disable certain keyboard/mouse inputs under such context
|
||||
virtual bool is_menu_active() { return false; }
|
||||
|
||||
bool use_natural_keyboard() const { return m_use_natural_keyboard; }
|
||||
|
||||
void set_show_timecode_counter(bool value) { m_show_timecode_counter = value; m_show_timecode_total = true; }
|
||||
|
||||
bool show_timecode_counter() const { return m_show_timecode_counter; }
|
||||
@ -48,7 +46,6 @@ public:
|
||||
protected:
|
||||
// instance variables
|
||||
running_machine & m_machine;
|
||||
bool m_use_natural_keyboard;
|
||||
bool m_show_timecode_counter;
|
||||
bool m_show_timecode_total;
|
||||
};
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "mameopts.h"
|
||||
#include "pluginopts.h"
|
||||
#include "drivenum.h"
|
||||
#include "natkeyboard.h"
|
||||
|
||||
#include "uiinput.h"
|
||||
#include "ui/ui.h"
|
||||
@ -38,7 +39,7 @@ menu_keyboard_mode::menu_keyboard_mode(mame_ui_manager &mui, render_container &c
|
||||
|
||||
void menu_keyboard_mode::populate()
|
||||
{
|
||||
bool natural = ui().use_natural_keyboard();
|
||||
bool natural = machine().ioport().natkeyboard().in_use();
|
||||
item_append(_("Keyboard Mode:"), natural ? _("Natural") : _("Emulated"), natural ? FLAG_LEFT_ARROW : FLAG_RIGHT_ARROW, nullptr);
|
||||
}
|
||||
|
||||
@ -48,7 +49,7 @@ menu_keyboard_mode::~menu_keyboard_mode()
|
||||
|
||||
void menu_keyboard_mode::handle()
|
||||
{
|
||||
bool natural = ui().use_natural_keyboard();
|
||||
bool natural = machine().ioport().natkeyboard().in_use();
|
||||
|
||||
/* process the menu */
|
||||
const event *menu_event = process(0);
|
||||
@ -57,7 +58,7 @@ void menu_keyboard_mode::handle()
|
||||
{
|
||||
if (menu_event->iptkey == IPT_UI_LEFT || menu_event->iptkey == IPT_UI_RIGHT)
|
||||
{
|
||||
ui().set_use_natural_keyboard(natural ^ true);
|
||||
machine().ioport().natkeyboard().set_in_use(!natural);
|
||||
reset(reset_options::REMEMBER_REF);
|
||||
}
|
||||
}
|
||||
|
@ -210,8 +210,7 @@ void mame_ui_manager::init()
|
||||
// request a callback upon exiting
|
||||
machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(mame_ui_manager::exit), this));
|
||||
|
||||
// retrieve options
|
||||
m_use_natural_keyboard = machine().options().natural_keyboard();
|
||||
// create mouse bitmap
|
||||
bitmap_argb32 *ui_mouse_bitmap = auto_alloc(machine(), bitmap_argb32(32, 32));
|
||||
UINT32 *dst = &ui_mouse_bitmap->pix32(0);
|
||||
memcpy(dst,mouse_bitmap,32*32*sizeof(UINT32));
|
||||
@ -1107,7 +1106,7 @@ UINT32 mame_ui_manager::handler_ingame(render_container &container)
|
||||
}
|
||||
|
||||
// is the natural keyboard enabled?
|
||||
if (use_natural_keyboard() && (machine().phase() == MACHINE_PHASE_RUNNING))
|
||||
if (machine().ioport().natkeyboard().in_use() && (machine().phase() == MACHINE_PHASE_RUNNING))
|
||||
process_natural_keyboard();
|
||||
|
||||
if (!ui_disabled)
|
||||
@ -2117,19 +2116,6 @@ INT32 mame_ui_manager::slider_crossoffset(running_machine &machine, void *arg, i
|
||||
}
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------
|
||||
// set_use_natural_keyboard - specifies
|
||||
// whether the natural keyboard is active
|
||||
//-------------------------------------------------
|
||||
|
||||
void mame_ui_manager::set_use_natural_keyboard(bool use_natural_keyboard)
|
||||
{
|
||||
m_use_natural_keyboard = use_natural_keyboard;
|
||||
std::string error;
|
||||
machine().options().set_value(OPTION_NATURAL_KEYBOARD, use_natural_keyboard, OPTION_PRIORITY_CMDLINE, error);
|
||||
assert(error.empty());
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// wrap_text
|
||||
|
@ -204,7 +204,6 @@ public:
|
||||
virtual bool is_menu_active() override;
|
||||
bool can_paste();
|
||||
void paste();
|
||||
void set_use_natural_keyboard(bool use_natural_keyboard);
|
||||
void image_handler_ingame();
|
||||
void increase_frameskip();
|
||||
void decrease_frameskip();
|
||||
|
Loading…
Reference in New Issue
Block a user