Commit Graph

48 Commits

Author SHA1 Message Date
AJR
cb1c49df0b Make "Keypad ," and "Keypad =" standard keys 2018-05-11 10:31:01 -04:00
hap
f407c55459 input: make xinput analog triggers half-axes and default IPT_PEDAL2 to RZ- instead of Z+, placing IPT_PEDAL and IPT_PEDAL2 on separate axes. (nw) 2017-10-17 19:58:38 +02:00
Vas Crabb
a11d1fe266 convenience macro for enum bitwise operators (nw) 2017-07-22 14:32:29 +10:00
Vas Crabb
96c9112785 general cleanup:
* move rarely-used output and pty interfaces out of emu.h
* consolidate and de-duplicate forward declarations, also remove some obsolete ones
* clean up more #include guard macros
* scope down a few more things

(nw) Everyone, please keep forward declarations for src/emu in src/emu/emufwd.h -
this will make it far easier to keep them in sync with declarations than having
them scattered through all the other files.
2017-05-23 15:01:11 +10: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
AJR
99c705f9de Polymorphize input_device and input_class; move to separate source file (nw) 2016-10-24 17:28:35 -04: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
AJR
0e55a0bfc0 Misc. keyboard input improvements
- Add BS, Tab, 00, 000 keys common on add-on keypads as input items; SDL may recognize these, but DirectInput does not
- Assign Keypad 00 and Keypad 000 in several drivers' input lists
- Add SDL keycode for "cancel" key
- Add keypad keys as alternates to natural keyboard
- Move has_keyboard() out of the core; enabled() test is unnecessary now that all optional keyboards are slot devices (nw)
2016-10-08 21:13:12 -04:00
Tomer Verona
845b36dae2 Adding id() property to input_device
This change adds id() property to input_device, which represents the
unique device id. This allows the osd layer when creating a device to
pass a friendly display name along with a unique identifier.

Currently the device id is only used to map a physical controller device
to controller id, but can be used more generally in the future. For raw
input devices, we use the full raw input name as the device id. For all
other devices, we fall back to device name as the device id. The
"uniqueness" of the device id is not currently enforced in code.
2016-09-20 12:19:58 -07:00
Tomer Verona
2bd18d5fea Support for configuring device to conrtoller id
This change adds support for configuring device to conrtoller id. This
allows for stable controller ids even if USB devices are plugged /
unplugged, system is rebooted, etc.

See documentation for additional context.
2016-09-12 18:35:36 -07:00
Sergey Svishchev
e86fd713e7 keyboard: add F16..F20 keys (present on DEC LK201 keyboard and its clones) 2016-07-30 16:26:00 +03:00
AJR
115db95642 Return std::string objects by value rather than pass by reference
- strprintf is unaltered, but strformat now takes one fewer argument
- state_string_export still fills a buffer, but has been made const
- get_default_card_software now takes no arguments but returns a string
2016-01-10 16:36:18 -05:00
Miodrag Milanovic
91605d3f4d clang-modernize part 1 (nw) 2015-12-03 18:17:25 +01:00
Miodrag Milanovic
92f81361d6 Initial conversion of core to C++14. Note that compilers are now limited to GCC 4.9.0 and up, Clang 3.4.0 and up, and VS2013 and up [Miodrag Milanovic] 2015-12-03 11:40:45 +01:00
Miodrag Milanovic
54f8b3ae5d moved all to std::string (nw) 2015-04-22 11:30:45 +02:00
Miodrag Milanovic
87f705b984 string -> str rename due to future conflicts (nw) 2015-04-12 16:54:10 +02:00
Miodrag Milanovic
7faba31b1b There is no implicit conversion to char* in std::string (nw) 2015-04-12 08:05:43 +02:00
Quench0
354bd957d0 Improve responsiveness of 8-way joysticks default behaviour on 4-way games when moves unintentionally become diagonal by favouring the new direction change. 2015-02-21 01:42:08 +11:00
Alex W. Jackson
0a7b3daaaf Move destructor definitions out of header files included by emu.h; clean some obsolete junk out of machine.h [Alex Jackson] 2014-03-27 00:14:25 +00:00
Aaron Giles
4ea9df02a1 Moved core template container classes up from emutempl.h to coretmpl.h:
[Aaron Giles]
 * these classes now no longer take a resource_pool; everything is
    managed globally -- this means that objects added to lists must be
    allocated with global_alloc
 * added new auto_pointer<> template which wraps a pointer and auto-frees
    it upon destruction; it also defaults to NULL so it doesn't need to
    be explicitly initialized
 * moved tagged_list template to tagmap.h

Redo of the low-level memory tracking system: [Aaron Giles]
 * moved low-level tracking out of emu\emualloc into lib\util\corealloc
    so it can be shared among all components and used by core libraries
 * global_alloc and friends no longer use a resource pool to track
    allocations; turns out this was a wholly redundant system that wasted
    a lot of memory
 * removed global_resource_pool entirely
 * added global_free_array to delete arrays allocated with 
    global_alloc_array
 * added tracking of object versus array allocation; we will now error
    if you use global_free on an array, or global_free_array on an object

Added new utility helper const_string_pool which can be used to 
efficiently accumulate strings that are not intended to be modified.
Used by updated makelist and software list code. [Aaron Giles]

Updated png2bdc and makelist tools to not leak memory and use more modern
techniques (no more MAX_DRIVERS in makelist, for example). [Aaron Giles]

Deprecated auto_strdup and removed all uses by way of caller-managed 
astrings and the software list rewrite. [Aaron Giles]

Rewrote software list management: [Aaron Giles]
 * removed the notion of a software_list that is separate from a
    software_list_device; they are one and the same now
 * moved several functions into device_image_interface since they really
    didn't belong in the core software list class
 * lots of simplification as a result of the above changes

Additional notes (no whatsnew):

Moved definition of FPTR to osdcomm.h.

Some changes happened in the OSD code to fix issues, especially regarding
freeing arrays. SDL folks may need to fix up some of these.

The following devices still are using tokens and should be modernized
(I found them because they kept their token as void * and tried to
delete it, which you can't):

namco_52xx_device (mame/audio/namco52.c)
namco_54xx_device (mame/audio/namco54.c)
namco_06xx_device (mame/machine/namco06.c)
namco_50xx_device (mame/machine/namco50.c)
namco_51xx_device (mame/machine/namco51.c)
namco_53xx_device (mame/machine/namco53.c)
voodoo_device (emu/video/voodoo.c)
mos6581_device (emu/sound/mos6581.c)
aica_device (emu/sound/aica.c)
scsp_device (emu/sound/scsp.c)
dmadac_sound_device (emu/sound/dmadac.c)
s3c2440_device (emu/machine/s3c2440.c)
wd1770_device (emu/machine/wd17xx.c)
latch8_device (emu/machine/latch8.c)
duart68681_device (emu/machine/68681.c)
s3c2400_device (emu/machine/s3c2400.c)
s3c2410_device (emu/machine/s3c2410.c)
strataflash_device (mess/machine/strata.c)
hd63450_device (mess/machine/hd63450.c)
tap_990_device (mess/machine/ti99/990_tap.c)
omti8621_device (mess/machine/omti8621.c)
vdt911_device (mess/video/911_vdt.c)
apollo_graphics_15i (mess/video/apollo.c)
asr733_device (mess/video/733_asr.c)
2014-03-11 15:54:58 +00:00
Aaron Giles
5d0ce54f9e Bulk convert files that already had standard BSD license in my name
to new license tagged form.
2013-10-16 08:14:49 +00:00
R. Belmont
9a19f623fc input: Support up to 32 buttons and harmonize Windows and SDL behavior if you exceed the limit [Nick3092] 2013-02-18 17:18:00 +00:00
Miodrag Milanovic
0e19f641d3 Cleanups and version bump 2013-01-11 07:32:46 +00:00
Miodrag Milanovic
8e20ddb184 Fixed debug asserts (no whatsnew) 2012-02-23 15:36:18 +00:00
Aaron Giles
f77da42ef1 Death by static initialization order. Fixed declaration order at the
top of input.c.

Removed default_seq since all uses of it are covered by is_default()
and set_default().
2011-06-20 19:58:22 +00:00
Angelo Salese
a449c766a2 Cleanups and version bump 2011-06-05 22:35:20 +00:00
Aaron Giles
665d213ee4 (Finally found the time to finish this....)
Low-level input upgrade. Classes now exist for input_codes, input_items,
input_devices, and input_seqs. Also created an input_manager class to
hold machine-global state and made it accessible via machine.input().
Expanded the device index range (0-255, up from 0-16), and the OSD can
now specify the device index explicitly if they can better keep the 
indexes from varying run-to-run. [Aaron Giles]

Note that I've built and run SDL on Windows, but not all the code paths
were exercised. If you use mice/joysticks extensively double-check them
to be sure it all still works as expected.

This is mainly an OSD and core change. The only thing impacting drivers
is if they query for specific keys for debugging. The following S&Rs
took care of most of that:

S: input_code_pressed( *)\(( *)([^, ]+) *, *
R: \3\.input\(\)\.code_pressed\1\(\2

S: input_code_pressed_once( *)\(( *)([^, ]+) *, *
R: \3\.input\(\)\.code_pressed_once\1\(\2
2011-05-30 19:07:19 +00:00
Aaron Giles
d971ce8f36 Privatized most of the m_machine pointers in the system to prevent
direct use.
2011-04-19 06:02:01 +00:00
Aaron Giles
2ad5072023 BIG update.
Remove redundant machine items from address_space and device_t.
Neither machine nor m_machine are directly accessible anymore.
Instead a new getter machine() is available which returns a
machine reference. So:

  space->machine->xxx   ==>  space->machine().xxx
  device->machine->yyy  ==>  device->machine().yyy

Globally changed all running_machine pointers to running_machine
references. Any function/method that takes a running_machine takes
it as a required parameter (1 or 2 exceptions). Being consistent
here gets rid of a lot of odd &machine or *machine, but it does
mean a very large bulk change across the project.

Structs which have a running_machine * now have that variable
renamed to m_machine, and now have a shiny new machine() method
that works like the space and device methods above. Since most of
these are things that should eventually be devices anyway, consider
this a step in that direction.

98% of the update was done with regex searches. The changes are
architected such that the compiler will catch the remaining
errors:

// find things that use an embedded machine directly and replace
// with a machine() getter call
S: ->machine->
R: ->machine\(\)\.

// do the same if via a reference
S: \.machine->
R: \.machine\(\)\.

// convert function parameters to running_machine &
S: running_machine \*machine([^;])
R: running_machine \&machine\1

// replace machine-> with machine.
S: machine->
R: machine\.

// replace &machine() with machine()
S: \&([()->a-z0-9_]+machine\(\))
R: \1

// sanity check: look for this used as a cast
(running_machine &)
// and change to this:
*(running_machine *)
2011-03-29 15:50:04 +00:00
Angelo Salese
47be9f2fb8 Added debug_global_input_code_pressed_once() function to input.c [Angelo Salese] 2010-05-24 01:09:23 +00:00
Aaron Giles
4498faacd9 First round of an attempted cleanup of header files in the system.
- 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!)
2010-01-10 00:29:26 +00:00
Aaron Giles
a92de5930c Extended the astring class wrapper into something useful, and
useable as a stack object. Also designed the interfaces to allow
for chaining operations. And added a casting operator to const
char * for seamless use in most functions that take plain old C
strings.

Changed all uses of astring to use the object directly on the
stack or embedded in objects instead of explicitly allocating 
and deallocating it. Removed a lot of annoying memory management
code as a result.

Changed interfaces that accepted/returned an astring * to
use an astring & instead.

Removed auto_alloc_astring(machine). Use 
auto_alloc(machine, astring) instead.
2010-01-08 17:18:54 +00:00
Aaron Giles
91a1b8d634 NOTE: This change requires two new osd functions: osd_malloc() and
osd_free(). They take the same parameters as malloc() and free().

Renamed mamecore.h -> emucore.h.

New C++-aware memory manager, implemented in emualloc.*. This is a
simple manager that allows you to add any type of object to a
resource pool. Most commonly, allocated objects are added, and so
a set of allocation macros is provided to allow you to manage
objects in a particular pool:

  pool_alloc(p, t) = allocate object of type 't' and add to pool 'p'
  pool_alloc_clear(p, t) = same as above, but clear the memory first
  pool_alloc_array(p, t, c) = allocate an array of 'c' objects of type
                              't' and add to pool 'p'
  pool_alloc_array_clear(p, t, c) = same, but with clearing
  pool_free(p, v) = free object 'v' and remove it from the pool

Note that pool_alloc[_clear] is roughly equivalent to "new t" and
pool_alloc_array[_clear] is roughly equivalent to "new t[c]". Also
note that pool_free works for single objects and arrays.

There is a single global_resource_pool defined which should be used
for any global allocations. It has equivalent macros to the pool_*
macros above that automatically target the global pool.

In addition, the memory module defines global new/delete overrides
that access file and line number parameters so that allocations can
be tracked. Currently this tracking is only done if MAME_DEBUG is
enabled. In debug builds, any unfreed memory will be printed at
the end of the session.

emualloc.h also has #defines to disable malloc/free/realloc/calloc.
Since emualloc.h is included by emucore.h, this means pretty much
all code within the emulator is forced to use the new allocators.
Although straight new/delete do work, their use is discouraged, as
any allocations made with them will not be tracked.

Changed the familar auto_alloc_* macros to map to the resource pool
model described above. The running_machine is now a class and contains
a resource pool which is automatically destructed upon deletion. If
you are a driver writer, all your allocations should be done with
auto_alloc_*.

Changed all drivers and files in the core using malloc/realloc or the 
old alloc_*_or_die macros to use (preferably) the auto_alloc_* macros 
instead, or the global_alloc_* macros if necessary.

Added simple C++ wrappers for astring and bitmap_t, as these need
proper constructors/destructors to be used for auto_alloc_astring and
auto_alloc_bitmap.

Removed references to the winalloc prefix file. Most of its 
functionality has moved into the core, save for the guard page 
allocations, which are now implemented in osd_alloc and osd_free.
2010-01-08 06:05:29 +00:00
Aaron Giles
bd24fb23c1 Results of running the latest srcclean. 2009-12-28 09:04:00 +00:00
Aaron Giles
3d59122bb2 Added debug_global_input_code_pressed() for use in debugging.
Also some other small tweaks/cleanups.
2009-09-08 01:40:11 +00:00
Aaron Giles
191fe9cdc3 > From: Atari Ace [mailto:atari_ace@verizon.net]
> Sent: Sunday, September 06, 2009 7:25 AM
> To: submit@mamedev.org
> Cc: atariace@hotmail.com
> Subject: [patch] Deglobalize input.c
> 
> Hi mamedev,
> 
> These patches deglobalize input.c.  The first adds running_machine to
> some driver apis.  The (large) second patch adds the machine parameter
> to the most input_code_pressed apis (generated by script, not
> compilable).  The last patch then actually changes those apis and
> others to take running_machine, and adds struct _input_private to hold
> the input state variables.
> 
> ~aa
2009-09-06 22:28:58 +00:00
Aaron Giles
eb539cce9d Many casts added to the core files, and various other tweaks
to make them compile as either C or C++.
2009-03-12 07:43:03 +00:00
Aaron Giles
e2757c60d2 Modified the makefile to support experimental optional C++
compilation:
 - new option CPP_COMPILE to trigger this (off by default)
 - split CFLAGS into common, C-only, and C++-only flags
 - when enabled, CPP_COMPILE causes 'pp' to be appended to 
    the target name

NOTE THAT THE SYSTEM CANNOT ACTUALLY BE COMPILED THIS WAY 
YET. IT IS JUST AN EXPERIMENT.

Modified lib.mak to always build zlib/expat as C regardless 
of CPP_COMPILE.

Modified windows.mak to fix warnings with MAXOPT=1, and to 
leverage the new CFLAGs definitions.

Modified vconv.c to do appropriate conversions for new C++ 
options.

Updated sources so that libutil, libocore (Windows), and 
libosd (Windows) can be cleanly compiled as C or C++. This
was mostly adding some casts against void *.

Fixed a few more general obvious problems at random 
locations in the source:
 - device->class is now device->devclass
 - TYPES_COMPATIBLE uses typeid() when compiled for C++
 - some functions with reserved names ('xor' in particular)
    were renamed
 - nested enums and structs were pulled out into separate
    definitions (under C++ these would need to be scoped to
    be referenced)
 - TOKEN_VALUE cannot use .field=x initialization in C++ :(
2009-02-28 22:10:06 +00:00
Aaron Giles
3d1dbafcc2 From: Oliver Stoeneberg [mailto:oliverst@online.de]
Subject: Machine -> machine

This is a big patch adding running_machine* parameters and using 
"machine" where available.
2008-09-11 15:57:52 +00:00
Aaron Giles
517a24c0ef Robustified key behavior when the debugger is visible. Should now
properly ignore the "break into debugger" keypress and not allow
related characters to filter through. Removed some hacks related to
making that work in the past.

Changed osd_wait_for_debugger() to take a machine parameter and a
"firsttime" parameter, which is set to 1 the first time the function
is called after a break. The Windows debugger uses this to ensure
that the debugger has focus when you break into it.
2008-07-17 16:09:52 +00:00
Aaron Giles
d8715ab4ac Note: I have done some testing, but there are probably more bugs
lurking. If you run into anything odd, please let me know.

Added new module uiinput.c which manages input for the user interface.
The OSD is responsible for pushing mouse events and character events
to this interface in order to support mouse movement and text-based
input (currently only used for the select game menu). Added support
for navigating through the menus using the mouse. 
[Nathan Woods, Aaron Giles]

Redesigned the UI menus so that they can maintain a richer state. Now
the menus can be generated once and reused, rather than requiring them
to be regenerated on each frame. All menus also share a comment eventing
system and navigation through them is managed centrally. Rewrote all the 
menus to use the new system, apart from the cheat menus, which are now 
disabled. Reorganized the video menu to make it easier to understand.
[Aaron Giles]
2008-07-12 20:18:25 +00:00
Aaron Giles
31336e491e Cleanups and version bump to 0.124u1. 2008-04-03 07:57:25 +00:00
Couriersud
cac4d00e7d Add ITEM_IDs for additional axes and switches
Add ITEM_IDs for up to 4 hats/POVs
2008-03-30 14:28:08 +00:00
Aaron Giles
e31f9a6313 Normalized function pointer typedefs: they are now all
suffixed with _func. Did this throughout the core and
drivers I was familiar with.

Fixed gcc compiler error with recent render.c changes.
gcc does not like explicit (int) casts on float or
double functions. This is fracking annoying and stupid,
but there you have it.
2008-03-03 01:51:31 +00:00
Aaron Giles
ee9f88963c Copyright cleanup:
- removed years from copyright notices
 - removed redundant (c) from copyright notices
 - updated "the MAME Team" to be "Nicola Salmoria and the MAME Team"
2008-01-06 00:47:40 +00:00
Aaron Giles
ba9782dcec Added new function input_poll_keyboard_switches to poll for only key events.
Expanded the size of the maximum simultaneously pressed switches.
Should fix editableui0120u4red and cheat0118red.
2008-01-04 17:51:33 +00:00
Aaron Giles
507ca2d275 Changes for MAME 0.121u4. 2007-12-17 16:41:39 +00:00
Aaron Giles
7b77f12186 Initial checkin of MAME 0.121. 2007-12-17 15:19:59 +00:00