2018-06-28 08:44:43 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-09-09 20:21:11 +00:00
|
|
|
#include "settings/streamingpreferences.h"
|
2018-09-15 01:35:28 +00:00
|
|
|
#include "backend/computermanager.h"
|
2018-09-09 20:21:11 +00:00
|
|
|
|
2018-06-28 08:44:43 +00:00
|
|
|
#include <SDL.h>
|
|
|
|
|
|
|
|
struct GamepadState {
|
|
|
|
SDL_GameController* controller;
|
|
|
|
SDL_JoystickID jsId;
|
|
|
|
short index;
|
|
|
|
|
|
|
|
short buttons;
|
|
|
|
short lsX, lsY;
|
|
|
|
short rsX, rsY;
|
|
|
|
unsigned char lt, rt;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MAX_GAMEPADS 4
|
|
|
|
|
|
|
|
class SdlInputHandler
|
|
|
|
{
|
|
|
|
public:
|
2018-09-15 01:35:28 +00:00
|
|
|
explicit SdlInputHandler(StreamingPreferences& prefs, NvComputer* computer);
|
2018-06-28 08:44:43 +00:00
|
|
|
|
2018-06-28 09:04:51 +00:00
|
|
|
~SdlInputHandler();
|
|
|
|
|
2018-06-28 08:44:43 +00:00
|
|
|
void handleKeyEvent(SDL_KeyboardEvent* event);
|
|
|
|
|
|
|
|
void handleMouseButtonEvent(SDL_MouseButtonEvent* event);
|
|
|
|
|
|
|
|
void handleMouseMotionEvent(SDL_MouseMotionEvent* event);
|
|
|
|
|
|
|
|
void handleMouseWheelEvent(SDL_MouseWheelEvent* event);
|
|
|
|
|
|
|
|
void handleControllerAxisEvent(SDL_ControllerAxisEvent* event);
|
|
|
|
|
|
|
|
void handleControllerButtonEvent(SDL_ControllerButtonEvent* event);
|
|
|
|
|
|
|
|
void handleControllerDeviceEvent(SDL_ControllerDeviceEvent* event);
|
|
|
|
|
|
|
|
int getAttachedGamepadMask();
|
|
|
|
|
|
|
|
private:
|
|
|
|
GamepadState*
|
|
|
|
findStateForGamepad(SDL_JoystickID id);
|
|
|
|
|
|
|
|
void sendGamepadState(GamepadState* state);
|
|
|
|
|
2018-09-04 07:09:35 +00:00
|
|
|
Uint32 m_LastMouseMotionTime;
|
2018-06-28 08:44:43 +00:00
|
|
|
bool m_MultiController;
|
2018-09-15 01:35:28 +00:00
|
|
|
bool m_NeedsInputDelay;
|
2018-06-28 08:44:43 +00:00
|
|
|
int m_GamepadMask;
|
|
|
|
GamepadState m_GamepadState[MAX_GAMEPADS];
|
|
|
|
|
|
|
|
static const int k_ButtonMap[];
|
|
|
|
};
|