-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
22a451f
commit bd640f2
Showing
8 changed files
with
110 additions
and
4 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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