rpcs3/rpcs3/mm_joystick_handler.h
Megamouse 662fe8cc95 [Qt/Input] Improve pad_settings_dialog a bit (#3611)
* Input: further work on remapping Xinput and begin work on remapping DS4

* Input: Improve pad_settings_dialog a bit and begin Remapping for XInput

* Input: begin evdev remapping and change all handlers to use cfg::string

* Input: finish work on remapping evdev

and some more crap

* Input: finish work on remapping Xinput and DS4

* Input: add DS4 Colors to DS4 config

* Input: Improve DS4 deadzone scaling

Jarves made some mistakes, so I'll fix them in the follow up commit

* Input: fix Jarves fixes on DS4 deadzone

and remove unnecessary usage of toUtf8

* Input: add primitive batterychecks to XInput and DS4

* Input: add mmjoystick remapping

* Input: Fix evdev and some Vibration issues

* Input: adjust capabilities to fix stick input for games like LoS 2

also fix threshold slider minimum
also add ps button to all the handlers

* Input: Further evdev work

based on danilaml code review and own debugging:
Fixed path issue, <= 0 issue, some captures, const, axis with same codes.
Adds a map to each device that differentiates negative and positive axis mappings.
adjusted rest of the file to tabs (ListDevices and beginning of threadProc)

* Input: use 20ms vibration update time for xbox one elite controllers.

* Input: Fix return type of Clamp()

* Input: Evdev Fix

* Input: Evdev Optional GetNextButtonPress

presumably better than the other

* Input: review changes

* Input: evdev: fix wrong index in axis handling

move bindpadtodevice down to keep consistency between handlers and not get crazy

* Input: evdev: fix expensive add_device in GetNextButtonPress

* cleanup

* Input: mmjoy: fix type

* Input: evdev: final fixes

* Input: evdev: exclude unnecessary buttons while mapping Xbox 360 or DS4

* Input: add deadzone preview by passing necessary values in callback

use 0.5 of max value for threshold in pad dialog

* Input: get rid of all-uppercase variables
2017-11-28 01:31:15 +04:00

111 lines
2.9 KiB
C++

#pragma once
#include "Emu/Io/PadHandler.h"
#include <Windows.h>
#include <mmsystem.h>
#include "Utilities/Config.h"
class mm_joystick_handler final : public PadHandlerBase
{
// Unique names for the config files and our pad settings dialog
const std::unordered_map<u64, std::string> button_list =
{
{ JOY_BUTTON1 , "Button 1" },
{ JOY_BUTTON2 , "Button 2" },
{ JOY_BUTTON3 , "Button 3" },
{ JOY_BUTTON4 , "Button 4" },
{ JOY_BUTTON5 , "Button 5" },
{ JOY_BUTTON6 , "Button 6" },
{ JOY_BUTTON7 , "Button 7" },
{ JOY_BUTTON8 , "Button 8" },
{ JOY_BUTTON9 , "Button 9" },
{ JOY_BUTTON10, "Button 10" },
{ JOY_BUTTON11, "Button 11" },
{ JOY_BUTTON12, "Button 12" },
{ JOY_BUTTON13, "Button 13" },
{ JOY_BUTTON14, "Button 14" },
{ JOY_BUTTON15, "Button 15" },
{ JOY_BUTTON16, "Button 16" },
{ JOY_BUTTON17, "Button 17" },
{ JOY_BUTTON18, "Button 18" },
{ JOY_BUTTON19, "Button 19" },
{ JOY_BUTTON20, "Button 20" },
{ JOY_BUTTON21, "Button 21" },
{ JOY_BUTTON22, "Button 22" },
{ JOY_BUTTON23, "Button 23" },
{ JOY_BUTTON24, "Button 24" },
{ JOY_BUTTON25, "Button 25" },
{ JOY_BUTTON26, "Button 26" },
{ JOY_BUTTON27, "Button 27" },
{ JOY_BUTTON28, "Button 28" },
{ JOY_BUTTON29, "Button 29" },
{ JOY_BUTTON30, "Button 30" },
{ JOY_BUTTON31, "Button 31" },
{ JOY_BUTTON32, "Button 32" },
};
// Unique names for the config files and our pad settings dialog
const std::unordered_map<u64, std::string> pov_list =
{
{ JOY_POVFORWARD, "POV Up" },
{ JOY_POVRIGHT, "POV Right" },
{ JOY_POVBACKWARD, "POV Down" },
{ JOY_POVLEFT, "POV Left" },
};
enum mmjoy_axis
{
joy_x_pos = 9700,
joy_x_neg,
joy_y_pos,
joy_y_neg,
joy_z_pos,
joy_z_neg,
joy_r_pos,
joy_r_neg,
joy_u_pos,
joy_u_neg,
joy_v_pos,
joy_v_neg,
};
// Unique names for the config files and our pad settings dialog
const std::unordered_map<u64, std::string> axis_list =
{
{ joy_x_pos, "X+" },
{ joy_x_neg, "X-" },
{ joy_y_pos, "Y+" },
{ joy_y_neg, "Y-" },
{ joy_z_pos, "Z+" },
{ joy_z_neg, "Z-" },
{ joy_r_pos, "R+" },
{ joy_r_neg, "R-" },
{ joy_u_pos, "U+" },
{ joy_u_neg, "U-" },
{ joy_v_pos, "V+" },
{ joy_v_neg, "V-" },
};
public:
mm_joystick_handler();
~mm_joystick_handler();
bool Init() override;
std::vector<std::string> ListDevices() override;
bool bindPadToDevice(std::shared_ptr<Pad> pad, const std::string& device) override;
void ThreadProc() override;
void GetNextButtonPress(const std::string& padId, const std::function<void(u16, std::string, int[])>& callback) override;
private:
void TranslateButtonPress(u64 keyCode, bool& pressed, u16& val, bool ignore_threshold = false) override;
std::unordered_map<u64, u16> GetButtonValues();
bool is_init;
u32 supportedJoysticks;
JOYINFOEX js_info;
JOYCAPS js_caps;
std::vector<std::shared_ptr<Pad>> bindings;
std::array<bool, 7> last_connection_status = {};
};