mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-05 15:56:49 +00:00
Input: replace a bunch of static_pointer_cast
This commit is contained in:
parent
f6d465667a
commit
870d26f9d8
@ -136,7 +136,7 @@ std::string evdev_joystick_handler::get_device_name(const libevdev* dev)
|
||||
|
||||
bool evdev_joystick_handler::update_device(const std::shared_ptr<PadDevice>& device)
|
||||
{
|
||||
auto evdev_device = std::static_pointer_cast<EvdevDevice>(device);
|
||||
EvdevDevice* evdev_device = static_cast<EvdevDevice*>(device.get());
|
||||
if (!evdev_device)
|
||||
return false;
|
||||
|
||||
@ -193,7 +193,7 @@ void evdev_joystick_handler::Close()
|
||||
{
|
||||
for (auto& binding : bindings)
|
||||
{
|
||||
auto evdev_device = std::static_pointer_cast<EvdevDevice>(binding.first);
|
||||
EvdevDevice* evdev_device = static_cast<EvdevDevice*>(binding.first.get());
|
||||
if (evdev_device)
|
||||
{
|
||||
auto& dev = evdev_device->device;
|
||||
@ -424,7 +424,7 @@ void evdev_joystick_handler::get_next_button_press(const std::string& padId, con
|
||||
// https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/InputCommon/ControllerInterface/evdev/evdev.cpp
|
||||
// https://github.com/reicast/reicast-emulator/blob/master/core/linux-dist/evdev.cpp
|
||||
// http://www.infradead.org/~mchehab/kernel_docs_pdf/linux-input.pdf
|
||||
void evdev_joystick_handler::SetRumble(std::shared_ptr<EvdevDevice> device, u16 large, u16 small)
|
||||
void evdev_joystick_handler::SetRumble(EvdevDevice* device, u16 large, u16 small)
|
||||
{
|
||||
if (!device || !device->has_rumble || device->effect_id == -2)
|
||||
return;
|
||||
@ -658,7 +658,7 @@ int evdev_joystick_handler::add_device(const std::string& device, const std::sha
|
||||
// It's a joystick. Now let's make sure we don't already have this one.
|
||||
if (std::any_of(bindings.begin(), bindings.end(), [&path](std::pair<std::shared_ptr<PadDevice>, std::shared_ptr<Pad>> binding)
|
||||
{
|
||||
const auto device = std::static_pointer_cast<EvdevDevice>(binding.first);
|
||||
EvdevDevice* device = static_cast<EvdevDevice*>(binding.first.get());
|
||||
return device && path == device->path;
|
||||
}))
|
||||
{
|
||||
@ -703,7 +703,7 @@ PadHandlerBase::connection evdev_joystick_handler::update_connection(const std::
|
||||
if (!update_device(device))
|
||||
return connection::disconnected;
|
||||
|
||||
auto evdev_device = std::static_pointer_cast<EvdevDevice>(device);
|
||||
EvdevDevice* evdev_device = static_cast<EvdevDevice*>(device.get());
|
||||
if (!evdev_device || !evdev_device->device)
|
||||
return connection::disconnected;
|
||||
|
||||
@ -859,7 +859,7 @@ void evdev_joystick_handler::get_mapping(const std::shared_ptr<PadDevice>& devic
|
||||
|
||||
void evdev_joystick_handler::apply_pad_data(const std::shared_ptr<PadDevice>& device, const std::shared_ptr<Pad>& pad)
|
||||
{
|
||||
auto evdev_device = std::static_pointer_cast<EvdevDevice>(device);
|
||||
EvdevDevice* evdev_device = static_cast<EvdevDevice*>(device.get());
|
||||
if (!evdev_device)
|
||||
return;
|
||||
|
||||
|
@ -374,7 +374,7 @@ private:
|
||||
int add_device(const std::string& device, const std::shared_ptr<Pad>& pad, bool in_settings = false);
|
||||
int GetButtonInfo(const input_event& evt, const std::shared_ptr<EvdevDevice>& device, int& button_code);
|
||||
std::unordered_map<u64, std::pair<u16, bool>> GetButtonValues(const std::shared_ptr<EvdevDevice>& device);
|
||||
void SetRumble(std::shared_ptr<EvdevDevice> device, u16 large, u16 small);
|
||||
void SetRumble(EvdevDevice* device, u16 large, u16 small);
|
||||
|
||||
// Search axis_orientations map for the direction by index, returns -1 if not found, 0 for positive and 1 for negative
|
||||
int FindAxisDirection(const std::unordered_map<int, bool>& map, int index);
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
#include "hidapi.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
struct CalibData
|
||||
{
|
||||
s16 bias;
|
||||
@ -84,12 +86,7 @@ protected:
|
||||
const s32 rem = calibData.sens_numer % calibData.sens_denom;
|
||||
const s32 output = (quot * biased) + ((rem * biased) / calibData.sens_denom);
|
||||
|
||||
if (output > INT16_MAX)
|
||||
return INT16_MAX;
|
||||
else if (output < INT16_MIN)
|
||||
return INT16_MIN;
|
||||
else
|
||||
return static_cast<s16>(output);
|
||||
return static_cast<s16>(std::clamp<s32>(output, INT16_MIN, INT16_MAX));
|
||||
}
|
||||
|
||||
inline s16 read_s16(const void* buf)
|
||||
|
@ -125,7 +125,7 @@ std::array<u32, PadHandlerBase::button::button_count> mm_joystick_handler::get_m
|
||||
{
|
||||
std::array<u32, button::button_count> mapping{ 0 };
|
||||
|
||||
auto joy_device = std::static_pointer_cast<MMJOYDevice>(device);
|
||||
MMJOYDevice* joy_device = static_cast<MMJOYDevice*>(device.get());
|
||||
if (!joy_device)
|
||||
return mapping;
|
||||
|
||||
@ -429,7 +429,7 @@ std::unordered_map<u64, u16> mm_joystick_handler::GetButtonValues(const JOYINFOE
|
||||
|
||||
std::unordered_map<u64, u16> mm_joystick_handler::get_button_values(const std::shared_ptr<PadDevice>& device)
|
||||
{
|
||||
auto dev = std::static_pointer_cast<MMJOYDevice>(device);
|
||||
MMJOYDevice* dev = static_cast<MMJOYDevice*>(device.get());
|
||||
if (!dev)
|
||||
return std::unordered_map<u64, u16>();
|
||||
return GetButtonValues(dev->device_info, dev->device_caps);
|
||||
@ -508,14 +508,14 @@ bool mm_joystick_handler::get_is_right_stick(u64 keyCode)
|
||||
|
||||
PadHandlerBase::connection mm_joystick_handler::update_connection(const std::shared_ptr<PadDevice>& device)
|
||||
{
|
||||
auto dev = std::static_pointer_cast<MMJOYDevice>(device);
|
||||
MMJOYDevice* dev = static_cast<MMJOYDevice*>(device.get());
|
||||
if (!dev)
|
||||
return connection::disconnected;
|
||||
|
||||
const auto old_status = dev->device_status;
|
||||
dev->device_status = joyGetPosEx(dev->device_id, &dev->device_info);
|
||||
|
||||
if (dev->device_status == JOYERR_NOERROR && (old_status == JOYERR_NOERROR || GetMMJOYDevice(dev->device_id, dev.get())))
|
||||
if (dev->device_status == JOYERR_NOERROR && (old_status == JOYERR_NOERROR || GetMMJOYDevice(dev->device_id, dev)))
|
||||
{
|
||||
return connection::connected;
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ int xinput_pad_handler::GetDeviceNumber(const std::string& padId)
|
||||
std::unordered_map<u64, u16> xinput_pad_handler::get_button_values(const std::shared_ptr<PadDevice>& device)
|
||||
{
|
||||
PadButtonValues values;
|
||||
auto dev = std::static_pointer_cast<XInputDevice>(device);
|
||||
XInputDevice* dev = static_cast<XInputDevice*>(device.get());
|
||||
if (!dev || dev->state != ERROR_SUCCESS) // the state has to be aquired with update_connection before calling this function
|
||||
return values;
|
||||
|
||||
@ -426,7 +426,7 @@ bool xinput_pad_handler::get_is_right_stick(u64 keyCode)
|
||||
|
||||
PadHandlerBase::connection xinput_pad_handler::update_connection(const std::shared_ptr<PadDevice>& device)
|
||||
{
|
||||
auto dev = std::static_pointer_cast<XInputDevice>(device);
|
||||
XInputDevice* dev = static_cast<XInputDevice*>(device.get());
|
||||
if (!dev)
|
||||
return connection::disconnected;
|
||||
|
||||
@ -451,7 +451,7 @@ PadHandlerBase::connection xinput_pad_handler::update_connection(const std::shar
|
||||
|
||||
void xinput_pad_handler::get_extended_info(const std::shared_ptr<PadDevice>& device, const std::shared_ptr<Pad>& pad)
|
||||
{
|
||||
auto dev = std::static_pointer_cast<XInputDevice>(device);
|
||||
XInputDevice* dev = static_cast<XInputDevice*>(device.get());
|
||||
if (!dev || !pad)
|
||||
return;
|
||||
|
||||
@ -478,7 +478,7 @@ void xinput_pad_handler::get_extended_info(const std::shared_ptr<PadDevice>& dev
|
||||
|
||||
void xinput_pad_handler::apply_pad_data(const std::shared_ptr<PadDevice>& device, const std::shared_ptr<Pad>& pad)
|
||||
{
|
||||
auto dev = std::static_pointer_cast<XInputDevice>(device);
|
||||
XInputDevice* dev = static_cast<XInputDevice*>(device.get());
|
||||
if (!dev || !pad)
|
||||
return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user