mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 15:21:56 -05:00
Merge commit godotengine/godot@4ebf67c
This commit is contained in:
@@ -60,6 +60,19 @@ JoypadSDL::JoypadSDL() {
|
||||
singleton = this;
|
||||
}
|
||||
|
||||
#ifdef WINDOWS_ENABLED
|
||||
extern "C" {
|
||||
HWND SDL_HelperWindow;
|
||||
}
|
||||
|
||||
// Required for DInput joypads to work
|
||||
// TODO: remove this workaround when we update to newer version of SDL
|
||||
JoypadSDL::JoypadSDL(HWND p_helper_window) :
|
||||
JoypadSDL() {
|
||||
SDL_HelperWindow = p_helper_window;
|
||||
}
|
||||
#endif
|
||||
|
||||
JoypadSDL::~JoypadSDL() {
|
||||
// Process any remaining input events
|
||||
process_events();
|
||||
@@ -90,6 +103,9 @@ Error JoypadSDL::initialize() {
|
||||
SDL_AddGamepadMappingsFromIO(rw, 1);
|
||||
}
|
||||
|
||||
// Make sure that we handle already connected joypads when the driver is initialized.
|
||||
process_events();
|
||||
|
||||
print_verbose("SDL: Init OK!");
|
||||
return OK;
|
||||
}
|
||||
@@ -246,17 +262,6 @@ void JoypadSDL::process_events() {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WINDOWS_ENABLED
|
||||
extern "C" {
|
||||
HWND SDL_HelperWindow;
|
||||
}
|
||||
|
||||
// Required for DInput joypads to work
|
||||
void JoypadSDL::setup_sdl_helper_window(HWND p_hwnd) {
|
||||
SDL_HelperWindow = p_hwnd;
|
||||
}
|
||||
#endif
|
||||
|
||||
void JoypadSDL::close_joypad(int p_pad_idx) {
|
||||
int sdl_instance_idx = joypads[p_pad_idx].sdl_instance_idx;
|
||||
|
||||
|
||||
@@ -41,15 +41,15 @@ typedef struct HWND__ *HWND;
|
||||
class JoypadSDL {
|
||||
public:
|
||||
JoypadSDL();
|
||||
#ifdef WINDOWS_ENABLED
|
||||
JoypadSDL(HWND p_helper_window);
|
||||
#endif
|
||||
~JoypadSDL();
|
||||
|
||||
static JoypadSDL *get_singleton();
|
||||
|
||||
Error initialize();
|
||||
void process_events();
|
||||
#ifdef WINDOWS_ENABLED
|
||||
void setup_sdl_helper_window(HWND p_hwnd);
|
||||
#endif
|
||||
|
||||
private:
|
||||
struct Joypad {
|
||||
|
||||
Reference in New Issue
Block a user