Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
with
110 additions
and 4 deletions.
- +2 −0 README.md
- +1 −0 premake5.lua
- +16 −3 src/device/controller/peripherals/analog_controller.cpp
- +12 −0 src/device/controller/peripherals/analog_controller.h
- +1 −1 src/platform/windows/gui/file.cpp
- +48 −0 src/platform/windows/input/sdl_input_manager.cpp
- +22 −0 src/platform/windows/input/sdl_input_manager.h
- +8 −0 src/utils/event.h
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -1,24 +1,46 @@ | ||
#pragma once | ||
#include <atomic> | ||
#include <condition_variable> | ||
#include <mutex> | ||
#include <thread> | ||
#include <unordered_map> | ||
#include "config.h" | ||
#include "input/input_manager.h" | ||
#include "key.h" | ||
|
||
class SdlInputManager : public InputManager { | ||
int busToken; | ||
std::unordered_map<int, SDL_GameController*> controllers; | ||
int32_t mouseX = 0; // Track mouse movement in frame | ||
int32_t mouseY = 0; | ||
|
||
bool handleKey(Key key, AnalogValue value); | ||
void fixControllerId(SDL_Event& event); | ||
|
||
// Vibration stuff | ||
struct VibrationData { | ||
SDL_GameController* controller; | ||
Event::Controller::Vibration e; | ||
}; | ||
|
||
std::atomic<bool> vibrationThreadExit = false; | ||
std::mutex vibrationMutex; | ||
std::condition_variable vibrationHasNewData; | ||
VibrationData vibrationData; | ||
std::thread vibrationThread; | ||
|
||
void vibrationThreadFunc(); | ||
void onVibrationEvent(Event::Controller::Vibration e); | ||
|
||
public: | ||
bool mouseCaptured = false; | ||
bool keyboardCaptured = false; | ||
bool mouseLocked = false; | ||
bool waitingForKeyPress = false; | ||
Key lastPressedKey; | ||
|
||
SdlInputManager(); | ||
~SdlInputManager(); | ||
void newFrame(); | ||
bool handleEvent(SDL_Event& event); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters