summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/input/input_dinput.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Initial touch input support: Vas Crabb2024-04-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Feed mouse/pen/touch pointer events through UI input manager with Win32 and SDL. * Started migrating UI code to use new API and reworking mouse/touch interaction. * emu/render.cpp: Support pressing multiple clickable layout items simultaneously. * emu/render.cpp: Allow UI elements to be drawn in any window. * emu/rendlay.cpp, luaengine_render.cpp: Added layout view events for pointer input. * ui/ui.cpp: Allow the UI handler to control pointer display. * ui/analogipt.cpp: Added mouse/touch and more keys for navigating field state list. * ui/menu.cpp: Use vertical swipe to scroll and horizontal swipe to adjust. * ui/menu.cpp: Draw after processing input - greatly improves responsiveness. * ui/menu.cpp: Ignore keyboard/gamepad input during pointer actions. * ui/selmenu.cpp: Made left/right info pane arrows repeat when held. * ui/selmenu.cpp: Use middle click to move keyboard focus. * ui/selmenu.cpp: Let filter list scroll if it's too tall, and use a bit of horizontal padding. * ui/selmenu.cpp: Improved divider sizing. * ui/state.cpp: Don't allow clicks to pass through the confirm deletion prompt to the menu. * ui/simpleselgame.cpp: Fixed error message display and graphics/sound status not showing. * ui/simpleselgame.cpp: Allow tap/click to dismiss error message. * ui/utils.cpp: Show UI for choice filters when there are no choices - it's less confusing. * modules/input/input_sdl.cpp: Made scaling for mouse scroll better match RawInput and DirectInput. * modules/input/input_rawinput.cpp: Added support for horizontal scroll axis. * modules/input/input_win32.cpp: Added support for scroll axes and more buttons to mouse/lightgun. * modules/debugger/debugimgui.cpp: Don't fight over events with the UI manager - it breaks menus. * osd/windows/window.cpp: Translate mouse position to window cooridinates for scroll wheel events. * osd/sdl/window.cpp: Supply last mouse position for scroll wheel events if possible. * scripts/build/complay.py: Made zero input mask an error - it was only being used to block clicks.
* osd/modules/input: Various cleanup and minor enhancements. Vas Crabb2024-03-041-1/+1
| | | | | | | | | | | | | | | | | | | input_common.h: Got rid of the DirectInput key code macros. DirectInput headers are always available on Windows - it's just an opportunity for bygs. input_common.cpp: Added default names for keys mapped to MAME's "other switch" type. input_rawinput.cpp: Simulate Pause key being held for 30ms, similarly to what's done for Caps Lock on macOS with SDL. Also added a gross hack to give "correct" names for Pause and Num Lock. input_sdl.cpp: Get default key names from SDL. Not really that useful as it isn't aware of the current keyboard layout. Key map files are still needed for anything other than a US ANSI layout. Also added some comments.
* osd/modules/input/input_dinput.cpp: Adjusted heuristics to work better with ↵ Vas Crabb2023-03-291-16/+16
| | | | newer DualShock/DualSense controllers.
* osd/modules/input: Always use DirectInput with desktop window in background ↵ Vas Crabb2023-02-281-4/+11
| | | | | | | | | | | | | | | | | | | mode. There are multiple issues with what MAME was doing, but the most glaring is that it violates the DirectInput interface contract that requires the window associated with an open device must not be destroyed. See documentation for IDirectInputDevice8::SetCooperativeLevel: "This parameter must be a valid top-level window handle that belongs to the process. The window associated with the device must not be destroyed while it is still active in a DirectInput device." The previous code also prevented DirectInput controllers from working when using multiple windows if any window other than the first window had focus. Also fixed SDL builds not correctly recognising when all windows lose focus, and save state menu not appearing.
* osd/modules/input: Modernised interface for enumerating DirectInput devices. Vas Crabb2023-02-281-17/+10
| | | | | Gets rid of some state in the winhybrid joystick module that's only used during initialisation.
* Update accumulating relative inputs exactly once per frame. Vas Crabb2023-02-241-6/+6
| | | | | | | | | | | | | This fixes "amplification" effects that would happen if the frame rate rose above 100 Hz (whether by unthrottling or otherwise). Synchronise with wall clock any time inputs are read. Not doing this has weird effects on relative inputs with frame skipping and contributes to unresponsiveness of menus. Reduce visual latency for mouse movement on menus when paused or skipping frames. The rest of the code changes to menus won't provide benefits until draw can happen after event handling.
* osd: Don't pump events when reading inputs. Vas Crabb2023-02-231-1/+0
| | | | | | This was a drain on performance. If anything is trying to poll inputs in a loop, it needs to call input_update() to ensure it gets up-to-date state.
* Input refactoring: Vas Crabb2023-02-181-139/+773
| | | | | | | | | | | | | | | | | | | | | | | | | | osd/modules/input, emu/inpttype.cpp: Made most default joystick assignments supplied by input modules. Input modules take available controls into consideration when generating default assignments. emu/inpttype.ipp: Added a separate "Back" UI input separate from Cancel. You may want an easier to hit combination for moving to the previous menu than for exiting or cancelling input. They both default to Escape. emu/inpttype.ipp: Added a UI Help control. Currently only used by analog inputs menu emu/inpttype.h: Moved I/O port field type enum to its own header and sorted UI controls so they appear in a more logical order. ui: Don't use UI Select to restore defaults - people should be getting used to the UI Clear input by now. UI Select cycles multi-value items instead. ui/inputmap.cpp: Don't use immediate cancel to cycle between clearing and restoring default assignment (use UI Clear instead). osd: Reduced the number of files needing to include the dreaded emu.h. Got some implementation out of headers.
* Small batch of input refactoring: Vas Crabb2023-02-051-3/+12
| | | | | | | | | | | | | | | | | | | | | emu/input.cpp: Fixed regression in display of some joystick inputs. osd/interface: Split up interface classes into a few more files to reduce where the input device interface class needs to be included. Made OSD independent of concrete input_device class. osd/modules/input, emu/inputdev.cpp, emu/ioport.cpp: Allow input devices to provide tokens for controls without standard item types and additional default input assignments. Fixes issues assigning Yen and Backslash on Japanese keyboards. ui/textbox.cpp: Added a fixed-content text box menu class for future use. Got main.h out of emu.h as it’s only used in a very small number of places, mostly for getting the application name. Added eminline.h to attotime.h as it's used without emu.h. Cleaned up forward declarations in emufwd.h a little.
* osd: Turned video modules into actual modules, fixed various issues. Vas Crabb2023-02-011-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Don't ignore the return status of OSD module initialisation. Attempt to fall back to an alternate module if the selected module fails to initialise. Log more useful diagnostic information at verbose level. Fixed BGFX crash on exit after toggling fullscreen. Also persist more settings than just the selected chains across toggling fullscreen. Turned video modules into OSD modules in the same sense as all the other OSD modules. They now use the same selection/fallback mechanism as all the other modules without special extra code in the OSD implementations. Untangled some object ownership mess. Windows own renderers, OSD objects own windows. Fixed a refrence loop that caused the first window object to always leak. Don't create renderer object until after underlying window has been created. Fixed issues with order of creation/destruction when toggling fullscreen or changing prescale in fullscreen with -switchres in SDL builds. Use more smart pointers in BGFX and Direct3D render modules. Most of the code now reutrns a smart pointer when handing over ownership or a naked pointer when retaining ownership. Fixed a few leaks and simplified cleanup code. Encapsulated various OSD modules better.
* osd/modules/input: Fixed Linux build. Vas Crabb2023-01-291-2/+0
|
* Various input and OSD refactoring: Vas Crabb2023-01-291-303/+407
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | osd: Supply OSD object to modules on initialisation. Encapsulated some event handling in the OSD objects rather than leaving it in free functions. Put various stuff in namespaces. osd/modules/input: Enabled dinput, xinput and winhybrid modules for Windows SDL builds, and enabled background input for dinput and xinput (and by extension winhybrid) modules. Also fixed some COM and X11 resource leaks. osd/modules/input/input_sdl.cpp: Flipped SDL mouse button order to match Windows, and exposed vertical and horizontal scroll as Z and rZ axes. Moved SDL UI event handling out of input devices into OSD object. osd/modules/input_rawinput.cpp: Changed lightgun Z axis token so it's correctly identified as a relative axis (it maps to the scroll wheel equivalent). osd: Added an option to choose the network provider module. Mostly useful if you build with both TUN/TAP and pcap support included, or if you want to disable emulated networking completely. emu/input.cpp: Use a better strategy for assembling input code names that uses fewer temporary strings and doesn't require use of the non-Unicode-aware space trimming function (fixes MT08552). osd/modules/input_dinput.cpp: Improved polling logic. osd: Made various parts of the input code less dependent on concrete emu objects, and reduced inappropriately passing around the machine object. Made input modules less dependent on OSD implementation. Encapsulated some stuff and got rid of some vestigial newui and SDL1 support code. Cleaned up some interfaces. Moved OSD options classes to their own files. Prepare to remove main.h from emu.h - it's mostly used to get the application name, which the vast majority of emulated devices don't need to do.
* Miscellaneous fixes and refactoring: Vas Crabb2023-01-281-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ui/analogipt.cpp: Fixed bar graph display for fields with ranges that wrap through zero. emu/inputdev.cpp: Separateed analog axis deadzone and switch threshold settings, reduced default deadzone, and fixed a potential division by zero if the deadzone and saturation settings are equal. emu/ioport.cpp: Fixed behaviour of absolute analog fields where range passes through zero - it previously only worked for specific combinations of mask, minimum and default. Removed a workaround from universal/getaway.cpp that is no longer necessary. emu/input.cpp: Fixed unintuitive behaviour when an absolute field is assigned an OR combination of a relative control folled by an absolute control (e.g. Mouse X or Joy 1 LSX). Also fixed reading axis input sequences where an axis code is followed by a switch code (these can only be produced by manually editing configuration files, not through MAME's UI), and fixed the returned type when multiple relative axes sum to zero. osd/modules/input_dinput.cpp: Fixed hat switches being stuck in up position when input is suspended in the background taito/taitoio_yoke.cpp: Give throttle control a distinct type, and don't auto-centre. osd: Added option to select MIDI provider module (currently only PortMidi and the dummy module are available). Also put various things in namespaces, and fixed builds including SDL sound module with native Windows OSD. emu/validity.cpp: Added check to catch I/O port fields using UI input types. emu/inpttype.ipp: Renamed inputs that were causing confusion. "Bill" and "Track" were causing confusion for translators and hence likely causing confusion for many users, especially those who are not native English speakers. "Track" as an abbreviation for "Trackball" was frequently being mistranslated, e.g. in the sense of a CD track selection button or even in the sense of a railway track. There's no reason to abbreviate it. "Bill" in the US English sense as a banknote is too ambiguous and was causing confusion for translators. It's better to use the less ambiguous "Banknote". Corrected Greek translations of "Trackball". Don't run GitHub Actions on issue template changes.
* -Input code cleanup: Vas Crabb2023-01-101-16/+32
| | | | | | | | | | | | | * dinput, xinput: Use proper item IDs for hat switches rather than "other switch". * xinput: Map right thumb stick to Z/rZ for consistency with SDL and DirectInput. * xinput: Map triggers to additional absolute axes 1 and 2. * xinput: Map start and back buttons to start and select. * Added default assignments for player 5-10 start/select. * Added default assignments for 5P-8P start and coin 5-8. -namco/namcos2.cpp: Changed collective pitch control to AD Stick Z.
* Optimisation, and baby steps towards untangling stuff: Vas Crabb2022-06-161-3/+3
| | | | | | | | | | Optimised the scheduler's handling of unscheduled timers - gives a 50% performance improvement in some timer-heavy drivers. Added better endianness swizzling helpers. Got rid of some of the OSD input modules' dependence on concrete input classes from emu.
* ui, docs: Added menus to fill a couple of gaps, improved consistency. (#9915) Vas Crabb2022-06-111-16/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added menus for controlling toggle inputs, and showing recognised input devices and control state. Moved input menu options off main menu to a submenu, as there are a lot of them now. Moved menu heading drawing into base class, added headings to more menus, and made headings more consistent with the menu items used to reach them. Also made terminology more consistent. Changed the default names for buttons and hat switches/D-pads to use 1-based numbering. DirectInput still returns 0-based button numbers for some devices. Removed local copy of MinGW xaudio2.h as it’s now included in the MSYS2 package. Also fixed building the DirectSound sound output module with the SDL OSD on Windows - the Windows headers are sensitive to include order. Started adding documentation for menus, to hopefully help people find menus they remember seeing but can't recall how to access. For translators, this makes terminology more consistent. In particular: * "Settings" is preferred over "configuration" in a number of places, as the latter can be construed as referring specifically to settings stored in .cfg files in the cfg_directory folder. Also, references to saving machine configuration could be interpreted as relating to the settings on the "Machine Configuration" menu. * The controls on host input devices (e.g. keys, buttons, joystick axes) are referred to as "controls", while emulated inputs are referred to as "inputs". * The menus for assigning host controls to emulated inputs are called "input assignments" menus to distinguish them from other input settings menus. * Combinations of controls that can be assigned to emulated inputs are referred to as "combinations" rather than "sequences". * The potentially confusing term "ROM set" has been removed altogether. Use "short name" to refer to a device or system's identifier. * "System" is used in almost places to refer to a complete, runnable system rather than "Machine". * "Driver" is now only used to refer to source files where systems or devices are defined - it is no longer used to refer to individual systems. * A few more menus have message context for the messages. This makes it a bit easier to guess where the messages are used. It also means you can use different translations in different places if necessary (e.g. if the same English text should be translated differently as an item in one menu and as a heading in another).
* Fix 9ce44fa048793de5e14d1e7af98e8b5ca148d0f3 for non-Windows builds AJR2022-05-251-0/+2
|
* osd: Cleaned up Windows API usage a little. Vas Crabb2022-05-261-21/+8
| | | | | | | | | * Bumped target windows version to 6.0.0 (Vista). * Use WRL COM pointers to manage some COM-like objects. * Cleaned up logging in DirectSound module. * Cleaned up includes in Windows input modules. * Switched to Common Item Dialogs in Windows debugger. * Replaced disabled code that never really worked with a TODO comment.
* osd/modules/input: Detect joystick reconnection with SDL. (#9605) Vas Crabb2022-04-241-4/+4
| | | Also improved display name scheme for joystick axes and buttons.
* fixes for building with clang 12.0.1 on windows smf-2021-09-041-2/+1
|
* Slightly cleaned up OSD input modules. Vas Crabb2021-07-291-258/+215
| | | | | | | | | | Removed support for DirectInput 7 and earlier. It hasn't been tested in years, and it's not relevant on any supported OS. DirectInput is effectively finalised at version 8, and is unlikely to get an API update in the future. Use more string[_view] and fewer C strings, and tightened up scope of a few things.
* Eliminate ARRAY_LENGTH template in favor of C++17's std::size AJR2021-02-141-1/+1
| | | | | | | | | | * osdcomm.h: Move definition of EQUIVALENT_ARRAY to coretmpl.h * sharc.cpp, gt64xxx.cpp, ym2413.cpp, gb_lcd.cpp, snes_ppu.cpp: Use STRUCT_MEMBER for save state registration * gio/newport.cpp, megadrive/svp.cpp, nes_ctrl/bcbattle.cpp, arm7.cpp, tms9995.cpp, pckeybrd.cpp, sa1110.cpp, sa1111.cpp, jangou_blitter.cpp, vic4567.cpp: Use std::fill(_n) instead of memset * emucore.h: Remove obsolete typedef
* fixed some modernize-use-auto clang-tidy warnings (nw) (#6238) Oliver Stöneberg2020-01-301-3/+3
|
* Creating an -attach_window command line parameter on Windows to attach to an ↵ npwoods2019-08-041-4/+4
| | | | | | | | | | | | | | existing window (#5381) * Creating an -attach_window command line parameter on Windows to attach to an existing window * Moved -attach_window option to Windows-specific code * Created an osd_set_aggressive_input_focus() function and exposed to LUA * Created a dummy implementation of osd_set_aggressive_input_focus() for SDL
* Move special windows.h include directives to build defines (nw) Brad Hughes2016-12-281-3/+0
|
* NOTICE (TYPE NAME CONSOLIDATION) Miodrag Milanovic2016-10-221-7/+7
| | | | | 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
* use standard types uintptr_t, char16_t and char32_t instead of FPTR, ↵ Miodrag Milanovic2016-10-221-8/+8
| | | | utf16_char, unicode_char (nw)
* Bulk renaming of Windows string conversion functions Nathan Woods2016-10-031-2/+2
| | | | | utf8_from_[a|w|t]string ==> osd::text::from_[a|w|t]string [a|w|t]string_from_utf8 ==> osd::text::to_[a|w|t]string
* Adding id() property to input_device Tomer Verona2016-09-201-8/+8
| | | | | | | | | | | | 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.
* osd input code cleanup (nw) Brad Hughes2016-08-221-5/+3
|
* algorithm-> utility where appropriate, fix imgtool (nw) Miodrag Milanovic2016-07-311-1/+1
|
* std::min and std:max instead of MIN and MAX, also some more macros converted ↵ Miodrag Milanovic2016-07-311-5/+8
| | | | to inline functions (nw)
* Changed strconv.[cpp|h] functions to return their results as std::string and ↵ Nathan Woods2016-07-241-15/+4
| | | | std::wstring
* Fix input issues on big endian systems (fixes #963) Brad Hughes2016-06-291-5/+17
|
* Introduce dynamic_module Giuseppe Gorgoglione2016-06-111-7/+11
| | | | | This is a central cross-platform facility to dynamically bind functions from shared libraries. Updated all OSD modules to use it.
* Move window_list to osd_common_t Brad Hughes2016-06-111-1/+1
|
* Unify window_list in Windows and SDL OSD Brad Hughes2016-06-101-1/+1
|
* Improve support for more Joysticks with DirectInput8. Also repair ↵ Quench02016-05-201-3/+13
| | | | DirectInput7 compile.
* Cleanups and version bumpmame0173 Miodrag Milanovic2016-04-271-3/+3
|
* Revert "Temp revert of Brad changes (nw)" Miodrag Milanovic2016-04-251-1/+1
| | | | This reverts commit 5e831f6506ee06f8c30cb113551ee0fec53804db.
* Temp revert of Brad changes (nw) Miodrag Milanovic2016-04-251-1/+1
|
* Various cleanups suggested by static analyzer (nw) Miodrag Milanovic2016-04-241-1/+1
|
* Refactor OSD window. Brad Hughes2016-04-211-1/+1
| | | | | | | | | | Unified renderer in osd_window as std::unique_ptr Made windows all std::shared_ptr<window_type> Made window lists std::list<std::shared_ptr<window_type>> Updated OSD SDL worker_param to not use malloc (not compatible with smart pointers) Made renderer pointer to window a weak reference. May not be available during destruction of the window.
* Hybrid DirectInput/XInput module Brad Hughes2016-04-041-321/+251
|
* Cleanups and version bump Miodrag Milanovic2016-03-301-4/+4
|
* Fix cross compile (nw) Jeffrey Clark2016-03-231-1/+1
|
* Fix VS Build issue for WRL ComPtr Brad Hughes2016-03-191-1/+1
|
* temporary fix for VS build. (nw) dankan18902016-03-201-1/+1
|
* Fix DirectInput stuck joystick directional input when window loses focus. ↵ Brad Hughes2016-03-181-4/+4
| | | | The reset function for the device was overwriting the axis information previously obtained. Changed it to correctly only reset the state member.
* General code cleanup in input modules. Using ComPtr to manage DirectInput ↵ Brad Hughes2016-03-181-64/+80
| | | | resources.