Commit Graph

102 Commits

Author SHA1 Message Date
Vas Crabb
c751a5348a -emu/natkeyboard.cpp: Allow keyboard devices to be enabled/disabled.
This fixes the "typing on all keyboards at once" issue.  You can now
enable and disable keyboard/keypad inputs per device in the Keyboard
Mode menu.  Default is to enable the first device with keyboard inputs,
and all device with keypad inputs but no keyboard inputs.  The settings
are saved in the CFG file for the machine.

Typing in natural keyboard mode only ever types on one keyboard at a
time, but now you can control which keyboard it types on, as it will be
the first enabled keyboard.

You can easily try this out with something like:
mame64d zorba -rs232 terminal cpm

-ui/inputmap.cpp: Show device descriptions as well as tag paths.

-mac128.cpp: Fixed mouse axis wrap compensation, cleaned up mouse code,
eliminated static variables for mouse input state.

You could see the issue with wrap detection easily enough just by
running mac128k/mac512k/macplus and tapping the arrow keys to move the
mouse one pixel at a time.  As you moved past the point where the axis
count wrapped, it would move one pixel in the opposite direction.

There were two function static variables related to mouse input state,
probably still lurking from when the code was initially made to use a
driver state class.  This obviously messes with save states and prevents
multiple instances.

- bus/a2bus/mouse.cpp: Fixed mouse axis wrap compensation.

This device had the same bug with wrap compensation as mac128k.cpp.
2020-10-11 02:58:46 +11:00
Vas Crabb
4f05917494 Got rid of global_alloc/global_free.
The global_alloc/global_free functions have outlived their usefulness.
They don't allow consistently overriding the default memory allocation
behaviour because they aren't used consistently, and we don't have
standard library allocator wrappers for them that we'd need to use them
consistently with all the standard library containers we're using.  If
you need to change the default allocator behaviour, you can override the
new/delete operators, and there are ways to get more fine-grained
control that way.  We're already doing that to pre-fill memory in debug
builds.

Code was already starting to depend on global_alloc/global_free wrapping
new/delete.  For example some parts of the code (including the UI and
Windows debugger) was putting the result of global_alloc in a
std::unique_ptr wrappers without custom deleters, and the SPU sound
device was assuming it could use global_free to release memory allocated
with operator new.  There was also code misunderstanding the behaviour
of global_alloc, for example the GROM port cartridge code was checking
for nullptr when a failure will actually throw std::bad_alloc.

As well as substituting new/delete, I've made several things use smart
pointers to reduce the chance of leaks, and fixed a couple of leaks,
too.
2020-10-03 03:00:24 +10:00
AJR
35f708384d ioport: Transfer crosshair polling loop to render_crosshair 2020-08-30 23:34:27 -04:00
Vas Crabb
802de3995d Slotified Mac 128k/512k/512ke/Plus keyboard port.
Available keyboards are us (M0110, U.S.), gb (M0110B, British), fr
(M0110F, French), pad (M0120F, numeric keypad with passthrough port)
and plus (M0110A, U.S. with integrated numeric keypad).  The mac128k,
mac512k and mac512ke drivers default to the numeric keypad with the
U.S. keyboard connected to the passthrough port; the macplus driver
defaults to the U.S. keyboard with integrated numeric keypad.

Note that the numeric keypad may seem strange.  Four of the operators
work as cursor arrows if you don't hold shift.  There is a comma on one
of the keys, but by the time System 6 was released, Apple had decided
an equals sign was more useful, so that's what it will produces on
newer system versions.  The U.S. keyboard with integrated numeric
keypad emulates these aspects of the stand-alone keypad - pressing the
operator keys on the keypad sends fake shit key down/up events, and
using the arrow keys while holding shift will produces operator
characters rather than selecting text.

The ISO layout keyboards (M0110B and M0110F) produce different scan
codes to the ANSI keyboards (M0110 and M0110A) but they don't report a
different identification byte.  To use an ISO keyboard, you must open
the Keyboard control panel and change the layout to International (and
change it back to Domestic if you switch back to an ANSI keyboard).

This doesn't actually work at the moment due to issues with 6522 VIA
emulation, but it will work with macplus sys603 if applied on top of
revision 963a2c166d.
-----------------------------------------------------------------------
2020-07-01 02:37:55 +10:00
Vas Crabb
01661be41c srcclean and cleanup (nw) 2020-06-21 14:59:50 +10:00
hap
128640144a emu: correct some file headers (nw) 2020-06-19 12:38:41 +02:00
tim lindner
e0715320f7
Setting analog inputs don't work in LUA (#6812)
* fixed set_value for analog inputs.
2020-06-12 14:44:27 +02:00
Mirko
956c2bd661 new machines marked as working
-----------------------------
Super Motor (prototype) [Mirko Buffoni, Roberto Fresca, Retromaniacs, recreativas.org]
2020-06-11 16:07:04 +02:00
R. Belmont
1a5b900759
Merge pull request #6195 from firewave/includes
use C++ library includes (nw)
2020-01-22 22:04:35 -05:00
Oliver Stöneberg
7c3aea8928 fixed some clang-tidy warnings (nw) (#6197)
* fixed some bugprone-throw-keyword-missing clang-tidy warnings (nw)

* fixed some modernize-use-nullptr clang-tidy warnings (nw)

* fixed some readability-delete-null-pointer clang-tidy warnings (nw)

* fixed some performance-faster-string-find clang-tidy warnings (nw)

* fixed some performance-for-range-copy clang-tidy warnings (nw)

* fixed some readability-redundant-string-cstr clang-tidy warnings (nw)
2020-01-22 22:03:35 -05:00
firewave
399515c7a7 use C++ library includes (nw) 2020-01-22 13:31:52 +01:00
AJR
35f45085fe Eliminate simple_list_wrapper and replace its only use (nw)
The replacement of append with emplace_front alters the sequence, but that should cause no difference in behavior here.
2020-01-18 23:08:04 -05:00
Vas Crabb
eaf07fffa3 UI input menu: treat codes containing a postive and negative of the same thing as invalid (e.g. A S not A)
ioport.cpp:
* better than 50% reduction in compile time, and better locality for static data
* better encapsulation, const correctness and noexcept usage
2019-11-21 16:07:04 +11:00
Vas Crabb
6c61aa61d2 UI input mapping menu updates:
* When a switch-type input is selected, show feedback when it's pressed
* If an invalid code is entered (e.g. only negatives) abandon the change rather than cycling default/none
* If an invalid code is entered display a message until the user takes some other action

input.cpp updates:
* constexpr crusade on input_code and input_seq and some very slight optimisation to input_seq
* seq_poll* is a frontend function and had no business being in the core, so it's a utility class now
* seq_poll* now exposes a bit more detail, enabling improved interaction on the UI inputs menu
* global state is reduced a little, but the poll_* functions are still members of the input manager with global state

(nw) The Lua engine has been updated in a way that maintains source compatibility with existing Lua
scripts.  This is less than ideal, but it minimises impact.  Ideally someone (possibly me) will be
able to expose the input sequence poller helper properly.  I tested the changes with the cheat and
autofire plugins and I was able to assign sequences.  However I found two issues: it's seems
impossible to assign a more complex sequence than a single key/button in the autofire plugin (i.e.
no AND or NOT conditions, I confirmed this is pre-existing, not a regression), and in both the cheat
and autofire plugins I found it a bit unwieldy trying to enter a complex sequence without live
feedback of the sequence as it's built (this was also applicable to MAME's own input mapping menu
until I added the live display yesterday).
2019-11-21 03:36:19 +11:00
Vas Crabb
a0d110e5f6 ioport.cpp: small cleanup (nw) 2019-11-19 01:33:46 +11:00
Vas Crabb
90fe1e649a Remove internal autofire functionality as there's a plugin for that now (#5802) 2019-11-17 17:10:07 +11:00
Vas Crabb
f81fbdb8d4 Make devdelegate more like devcb for configuration. This is a
fundamental change to show device delegates are configured.

Device delegates are now aware of the current device during
configuration and will resolve string tags relative to it.  This means
that device delegates need a device to be supplied on construction so
they can find the machine configuration object.  There's a
one-dimensional array helper to make it easier to construct arrays of
device delegates with the same owner.  (I didn't make an n-dimensional
one because I didn't hit a use case, but it would be a simple addition.)

There's no more bind_relative_to member - just call resolve() like you
would for a devcb.  There's also no need to cast nullptr when creating a
late bind device delegate.  The flip side is that for an overloaded or
non-capturing lambda you'll need to cast to the desired type.

There is one less conditional branch in the hot path for calls for
delegates bound to a function pointer of member function pointer.  This
comes at the cost of one additional unconditional branch in the hot
path for calls to delegates bound to functoids (lambdas, functions that
don't take an object reference, other callable objects).  This applies
to all delegates, not just device delegates.

Address spaces will now print an error message if a late bind error is
encountered while installing a handler.  This will give the range and
address range, hopefully making it easier to guess which memory map is
faulty.

For the simple case of allowing a device_delegate member to be
configured, use a member like this:

    template <typename... T> void set_foo(T &&...args) { m_foo_cb.set(std::forward<T>(args)...); }

For a case where different delegates need to be used depending on the
function signature, see src/emu/screen.h (the screen update function
setters).

Device delegates now take a target specification and function pointer.
The target may be:
* Target omitted, implying the current device being configured.  This
  can only be used during configuration.  It will work as long as the
  current device is not removed/replaced.
* A tag string relative to the current device being configured.  This
  can only be used during configuration.  It will not be callable until
  .resolve() is called.  It will work as long as the current device is
  not removed/replaced.
* A device finder (required_device/optional_device).  The delegate will
  late bind to the current target of the device finder.  It will not
  be callable until .resolve() is called.  It will work properly if the
  target device is replaced, as long as the device finder's base object
  isn't removed/replaced.
* A reference to an object.  It will be callable immediately.  It will
  work as long as the target object is not removed/replaced.

The target types and restrictions are pretty similar to what you already
have on object finders and devcb, so it shouldn't cause any surprises.
Note that dereferencing a device finder will changes the effect.  To
illustrate this:

    ...
    required_device<some_device> m_dev;
    ...
    m_dev(*this, "dev")
    ...
    // will late bind to "dev" relative to *this
    // will work if "dev" hasn't been created yet or is replaced later
    // won't work if *this is removed/replaced
    // won't be callable until resolve() is called
    cb1.set(m_dev, FUNC(some_device::w));
    ...
    // will bind to current target of m_dev
    // will not work if m_dev is not resolved
    // will not work if "dev" is replaced later
    // will be callable immediately
    cb2.set(*m_dev, FUNC(some_device::w));
    ...

The order of the target and name has been reversed for functoids
(lambdas and other callable objects).  This allows the NAME macro to
be used on lambdas and functoids.  For example:

    foo.set_something(NAME([this] (u8 data) { m_something = data; }));

I realise the diagnostic messages get ugly if you use NAME on a large
lambda.  You can still give a literal name, you just have to place it
after the lambda rather than before.  This is uglier, but it's
intentional.  I'm trying to drive developers away from a certain style.
While it's nice that you can put half the driver code in the memory map,
it detracts from readability.  It's hard to visualise the memory range
mappings if the memory map functions are punctuated by large lambdas.
There's also slightly higher overhead for calling a delegate bound to a
functoid.

If the code is prettier for trivial lambdas but uglier for non-trivial
lambdas in address maps, it will hopefully steer people away from
putting non-trivial lambdas in memory maps.

There were some devices that were converted from using plain delegates
without adding bind_relative_to calls.  I fixed some of them (e.g.
LaserDisc) but I probably missed some.  These will likely crash on
unresolved delegate calls.

There are some devices that reset delegates at configuration complete or
start time, preventing them from being set up during configuration (e.g.
src/devices/video/ppu2c0x.cpp and src/devices/machine/68307.cpp).  This
goes against the design principles of how device delegates should be
used, but I didn't change them because I don't trust myself to find all
the places they're used.

I've definitely broken some stuff with this (I know about asterix), so
report issues and bear with me until I get it all fixed.
2019-10-26 12:47:04 +11:00
Vas Crabb
9a12ab37af Make osd_printf_* use util/strformat semantics.
(nw) This has been a long time coming but it's here at last.  It should
be easier now that logerror, popmessage and osd_printf_* behave like
string_format and stream_format.  Remember the differences from printf:
* Any object with a stream out operator works with %s
* %d, %i, %o, %x, %X, etc. work out the size by magic
* No sign extending promotion to int for short/char
* No widening/narrowing conversions for characters/strings
* Same rules on all platforms, insulated from C runtime library
* No format warnings from compiler
* Assert in debug builds if number of arguments doesn't match format

(nw) Also removed a pile of redundant c_str and string_format, and some
workarounds for not being able to portably format 64-bit integers or
long long.
2019-09-26 20:53:06 +10:00
Vas Crabb
8b233839ba (nw) get rid of the rest of assert_always - it's better to be explicit about what this thing is supposed to do 2019-09-20 02:26:16 +10:00
AJR
6fab769298 PORT_CUSTOM simplification (nw)
- Remove both arguments from CUSTOM_INPUT_MEMBER (adding template parameters as necessary)
- Remove 'param' from PORT_CUSTOM_MEMBER and assume 'device' is DEVICE_SELF (use PORT_CUSTOM_DEVICE_MEMBER if it isn't)
- Replace PORT_CUSTOM_MEMBER with PORT_READ_LINE_MEMBER where applicable

Add implicit DEVICE_SELF variants of PORT_READ_LINE_DEVICE_MEMBER and PORT_WRITE_LINE_DEVICE_MEMBER (nw)

Remove ioport_field argument from PORT_CROSSHAIR_MAPPER (nw)

captflag, gmgalax: Separate driver classes from base (nw)
2019-09-14 15:37:04 -04:00
AJR
211bda4a53 ioport: Change PORT_CHANGED_MEMBER param type from void * to u32 (nw) 2019-08-15 12:21:42 -04:00
hap
8b018d198c New working machine added
---------
Great Game Machine [hap, bataais]
2019-04-15 00:59:26 +02:00
AJR
cb1c49df0b Make "Keypad ," and "Keypad =" standard keys 2018-05-11 10:31:01 -04:00
AJR
377c4371f2 Stop including random strings of question marks in key names 2017-12-19 10:07:53 -05:00
AJR
03b46122de Fix core rounding error with analog input sensitivity scaling (nw) 2017-11-21 14:04:20 -05:00
AJR
dcfdab2735 Better wraparound handling for relative inputs 2017-11-13 18:13:58 -05:00
angelosa
9033470d20 Hit save (nw) 2017-10-17 05:39:42 +02:00
angelosa
798035cde3 Proposed fix for MT #06154 (nw) 2017-10-17 05:39:40 +02:00
Nathan Woods
d850afa605 Added support for multiple PORT_CHAR() bindings, and adopted in the CoCo driver (addresses MT#2618) 2017-09-24 11:50:30 -04:00
hap
573380fb4d Merge pull request #2647 from npwoods/key_name_switch_formatting
Changing switch statement in ioport_field::key_name() to MAME favored formatting
2017-09-16 19:47:09 +02:00
hap
b117f75925 ioport: remove really bad usage of machine->rand() (nw) 2017-09-15 00:03:07 +02:00
Nathan Woods
fa4b823125 Changing switch statement in ioport_field::key_name() to MAME favored formatting 2017-09-10 09:20:28 -04:00
Nathan Woods
3f24d4173c Using a better overload of utf8_from_uchar() in ioport_field::key_name (nw) 2017-09-10 09:17:55 -04:00
npwoods
67ddfe302c Added a natural keyboard validation to check for valid natural keyboard (uni)codes (#2618) 2017-09-05 17:27:45 +10:00
angelosa
6a3c352a8d ioport.cpp: return explicit "file not found" error if inp file isn't found on playback, added error code number to any other error found [Angelo Salese] 2017-08-25 04:44:46 +02:00
Vas Crabb
fb8b69545f Amiga keyboard updates:
* Fixed Shift-Alt combinations with natural keyboard
* Fixed crash on keyboard inputs with four characters
* Corrected polarity of KB_DATA from Amiga to keyboard
* Completely rewrote 68HC05CxA-based A1200 keyboard device, now working
* Fixed KB_DATA mixing in A500 keyboard
* Made A500 keyboard caps lock LED output name consistent with A1200
* Added Alt- and Alt-Shift- characters to A500 US keyboard
* Fixed natural keyboard modifiers with LLE keyboards
2017-02-05 12:04:35 +11:00
AJR
e624a3cd38 Service mode DIP switch adjustments
- Changed how input sequences are assigned to service mode DIP switches. The frontend now assigns them the default sequence for the non-toggle service mode/test switch (not necessarily the F2 key, the previously hardcoded default) unless the machine happens to have one of those as well (as is somewhat common with gambling games).
- All DIP and configuration switches are automatically defined as toggle fields to make assigning input codes to them easier.
2017-01-02 21:39:49 -05:00
Vas Crabb
c8f1954467 XML refactoring:
* move stuff to namespace util::xml
* scope down some enums
* split config load/save delegate types
* make config load take const so it can't mangle data
2016-12-11 18:15:41 +11:00
Vas Crabb
8179a84458 Introduce u8/u16/u32/u64/s8/s16/s32/s64
* New abbreviated types are in osd and util namespaces, and also in global namespace for things that #include "emu.h"
* Get rid of import of cstdint types to global namespace (C99 does this anyway)
* Remove the cstdint types from everything in emu
* Get rid of U64/S64 macros
* Fix a bug in dps16 caused by incorrect use of macro
* Fix debugcon not checking for "do " prefix case-insensitively
* Fix a lot of messed up tabulation
* More constexpr
* Fix up many __names
2016-11-19 05:38:48 +11:00
Vas Crabb
2354a42010 Turn xmlfile API into something that looks like C++
It's still a bit quirky but it's far better encapsulated before, and it plays nice with const (nw)
2016-11-17 01:44:03 +11:00
Miodrag Milanovic
6b18f90438 Revert "Added IS_ENABLED, so we have compiler check for non used part, it is checked but not compiled in (nw)"
This reverts commit c0407f073b.
2016-11-12 09:12:36 +01:00
Miodrag Milanovic
c0407f073b Added IS_ENABLED, so we have compiler check for non used part, it is checked but not compiled in (nw)
false and true now used instead of integer where used as bool
2016-11-11 18:50:14 +01:00
Miodrag Milanovic
2027d59e7f Do not use FUNC in delegate where applicable (nw) 2016-11-06 14:11:55 +01:00
R. Belmont
86548bc507 Merge pull request #1557 from ajrhacker/inputdev
Polymorphize input_device and input_class; move to separate source fi…
2016-10-29 20:41:28 -04:00
therealmogminer@gmail.com
5611934cf2 Not for the release branch: remove all ioport and address map macros from tranz330 driver, just as a test to play around with, (nw) 2016-10-25 13:35:25 +02:00
AJR
99c705f9de Polymorphize input_device and input_class; move to separate source file (nw) 2016-10-24 17:28:35 -04:00
Miodrag Milanovic
aa2e6f9df3 Reverting part of changes from previous commits as described in mail on list (nw) 2016-10-23 09:11:47 +02:00
Miodrag Milanovic
e42ed88254 there you go (nw) 2016-10-22 21:37:06 +02:00
Miodrag Milanovic
a6bdefec8c more TRUE/FALSE cleanup (nw) 2016-10-22 16:37:12 +02:00
Miodrag Milanovic
ddb290d5f6 NOTICE (TYPE NAME CONSOLIDATION)
Use standard uint64_t, uint32_t, uint16_t or uint8_t instead of UINT64, UINT32, UINT16 or UINT8
also use standard int64_t, int32_t, int16_t or int8_t instead of INT64, INT32, INT16 or INT8
2016-10-22 13:13:17 +02:00