mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-25 08:14:45 +02:00
Additionally, break out the analog stick mapping to the same file. This will make more sense soon when I change where the analog mapping is called from, but want this refactor in separately for testing.
46 lines
1.2 KiB
C++
46 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include "Common/Input/InputState.h"
|
|
#include "Core/KeyMap.h"
|
|
|
|
#include <functional>
|
|
|
|
// Utilities for mapping input events to PSP inputs and virtual keys.
|
|
// Main use is of course from EmuScreen.cpp, but also useful from control settings etc.
|
|
|
|
|
|
// Maps analog stick input to a distorted space according to
|
|
// the deadzone and shape settings.
|
|
void ConvertAnalogStick(float &x, float &y);
|
|
|
|
|
|
class ControlMapper {
|
|
public:
|
|
bool Key(const KeyInput &key, bool *pauseTrigger);
|
|
bool Axis(const AxisInput &axis);
|
|
|
|
void SetCallbacks(
|
|
std::function<void(int)> onVKeyDown,
|
|
std::function<void(int)> onVKeyUp,
|
|
std::function<void(char, float, int)> setPSPAxis);
|
|
|
|
private:
|
|
void processAxis(const AxisInput &axis, int direction);
|
|
void pspKey(int pspKeyCode, int flags);
|
|
void setVKeyAnalog(char axis, int stick, int virtualKeyMin, int virtualKeyMax, bool setZero = true);
|
|
|
|
void onVKeyDown(int vkey);
|
|
void onVKeyUp(int vkey);
|
|
|
|
// To track mappable virtual keys. We can have as many as we want.
|
|
bool virtKeys[VIRTKEY_COUNT]{};
|
|
|
|
// De-noise mapped axis updates
|
|
int axisState_[JOYSTICK_AXIS_MAX]{};
|
|
|
|
// Callbacks
|
|
std::function<void(int)> onVKeyDown_;
|
|
std::function<void(int)> onVKeyUp_;
|
|
std::function<void(char, float, int)> setPSPAxis_;
|
|
};
|