Files
RetroArch/input/drivers/ps4_input.c
LibretroAdmin 87cfa110a1 input: an input driver's state call is not told the keyboard is held
Every input driver's state call took a flag, keyboard_mapping_blocked:
whether the keys are kept from the binds. It mattered when drivers
answered the binds themselves. The frontend answers them now, from the
keys it asks a driver for once a poll, and applies the flag itself; a
driver's state call answers the keyboard, the mouse and the pointer,
and none of the twenty-three read the flag. (udev passed it to its
touch code, which did not read it either.)

The parameter goes: from the interface, the twenty-three drivers, the
frontend's own stand-in driver and its nine calls. The frontend's own
functions keep theirs - that is where it is used.

Measured against this same master built without it, the frame's input
work over 300 frames (X11): 3,690,770 instructions to 3,690,476 with
no controller, 4,354,940 to 4,354,646 with one. An argument a call.

Checked: the frontend harness passes every lane; the X11 keyboard
session logs the same as before, and the hotkey and quit-combination
sessions what master's binary logged; the raw input keyboards test
and the plain Win32 input test, which call a driver's state function
themselves, pass under Wine. Built: Linux in full; DirectInput, raw
input and the plain Win32 driver with a mingw compiler; the Android
unity build with the NDK; Wayland; the Visual C++ 6 project and the
QNX driver on their stand-ins; a build with the optional features
off. Not compiled, there being no compiler for them here: Cocoa, UWP,
the web driver, SDL 1 and the console drivers (DOS, Wii, PS3, PS4,
PSP and Vita, Switch, Wii U); theirs is the same one line, taken out
by script.

The second of three pieces before steps 3 and 4 of the mapping
compiler (plan, section 21). The joypad, its info and the binds are
handed to the same call, and two drivers use any of it: the Wii's
reads one field of the info, the Wii U's asks the joypad for its
touch screen. With those two reworked the call would take the port
and what is asked, and nothing else.
2026-10-08 03:29:08 +02:00

104 lines
2.8 KiB
C

/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stdlib.h>
#ifdef HAVE_CONFIG_H
#include "../../config.h"
#endif
#include <orbis/libScePad.h>
#include <defines/ps4_defines.h>
#include <boolean.h>
#include <libretro.h>
#include <retro_miscellaneous.h>
#include "../input_driver.h"
typedef struct ps4_input
{
const input_device_driver_t *joypad;
} ps4_input_t;
/* Nothing of its own to answer. The pad's buttons, and the hotkeys and
* other controls bound to them, are read by the frontend from the
* joypad driver; this read them a second time from the binds it was
* handed, and the two answers were or'ed together. */
int16_t ps4_input_state(void *data,
const input_device_driver_t *joypad_data,
rarch_joypad_info_t *joypad_info,
const retro_keybind_set *retro_keybinds,
unsigned port, unsigned device, unsigned index, unsigned id)
{
(void)data;
(void)joypad_data;
(void)joypad_info;
(void)retro_keybinds;
(void)port;
(void)device;
(void)index;
(void)id;
return 0;
}
static void ps4_input_free_input(void *data)
{
ps4_input_t *ps4 = (ps4_input_t*)data;
if (ps4 && ps4->joypad)
ps4->joypad->destroy();
free(data);
}
static void* ps4_input_initialize(const char *joypad_driver)
{
ps4_input_t *ps4 = (ps4_input_t*)calloc(1, sizeof(*ps4));
if (!ps4)
return NULL;
ps4->joypad = input_joypad_init_driver(joypad_driver, ps4);
return ps4;
}
static void ps4_input_poll(void *data)
{
ps4_input_t *ps4 = (ps4_input_t*)data;
if (ps4 && ps4->joypad)
ps4->joypad->poll();
}
static uint64_t ps4_input_get_capabilities(void *data)
{
return (1 << RETRO_DEVICE_JOYPAD)
| (1 << RETRO_DEVICE_ANALOG);
}
input_driver_t input_ps4 = {
ps4_input_initialize,
ps4_input_poll, /* poll */
ps4_input_state, /* input_state */
ps4_input_free_input,
NULL,
NULL,
ps4_input_get_capabilities,
"ps4",
NULL, /* grab_mouse */
NULL,
NULL
};