Skip to content

Commit

Permalink
Merge pull request #194 from kimkulling/kimkulling/fix_sdl2_input_han…
Browse files Browse the repository at this point in the history
…dling_issue-192

Add sdl2 handling for ctrl and shift.
  • Loading branch information
kimkulling authored Sep 20, 2023
2 parents dbcc290 + f87ee09 commit 9f2a084
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
4 changes: 2 additions & 2 deletions include/osre/Platform/KeyTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ enum Key {
KEY_3 = 51,
KEY_4 = 52,
KEY_5 = 53,
EY_6 = 54,
KEY_6 = 54,
KEY_7 = 55,
KEY_8 = 56,
KEY_9 = 57,
Expand Down Expand Up @@ -208,7 +208,7 @@ enum Key {
KEY_UNDO = 322, ///< Atari keyboard has Undo

/* Add any other keys here */
KEY_LAST = 323
KEY_LAST
};

} // Namespace Platform
Expand Down
4 changes: 1 addition & 3 deletions samples/01_ModelLoading/ModelLoading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ class ModelLoadingApp : public App::AppBase {
// empty
}

~ModelLoadingApp() override {
// empty
}
~ModelLoadingApp() override = default;

bool hasModel() const {
return m_modelNode.isValid();
Expand Down
1 change: 0 additions & 1 deletion src/Engine/App/AppBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ AppBase::AppBase(i32 argc, const c8 *argv[], const String &supportedArgs, const

AppBase::~AppBase() {
delete mSettings;
mSettings = nullptr;
}

bool AppBase::initWindow(ui32 x, ui32 y, ui32 width, ui32 height, const String &title, bool fullscreen, bool childWindow,
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/Platform/PlatformOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void PlatformOperations::getFileOpenDialog(const String &title, const c8 *extens
location.clear();
}
#else
osre_warn( Tag, "Not supported," );
osre_error( Tag, "Not supported," );
#endif // OSRE_WINDOWS
}

Expand Down
13 changes: 12 additions & 1 deletion src/Engine/Platform/sdl2/SDL2EventQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ struct SDL2PeekInputUpdate final : public AbstractSDL2InputUpdate {
if (0 == ret) {
return false;
}

return true;
}
};
Expand Down Expand Up @@ -154,7 +155,17 @@ bool SDL2EventHandler::update() {
case SDL_KEYDOWN:
case SDL_KEYUP: {
KeyboardButtonEventData *data = new KeyboardButtonEventData(SDL_KEYDOWN == ev.type, m_eventTriggerer);
data->m_key = (Key)ev.key.keysym.sym;
if (ev.key.keysym.sym == SDLK_RCTRL) {
data->m_key = KEY_RCTRL;
} else if (ev.key.keysym.sym == SDLK_LCTRL) {
data->m_key = KEY_LCTRL;
} else if (ev.key.keysym.sym == SDLK_LSHIFT){
data->m_key = KEY_LSHIFT;
} else if (ev.key.keysym.sym == SDLK_RSHIFT){
data->m_key = KEY_RSHIFT;
} else {
data->m_key = (Key)ev.key.keysym.sym;
}
activeEventQueue->addBack(data);
} break;

Expand Down
2 changes: 1 addition & 1 deletion src/Engine/Platform/sdl2/SDL2Initializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ bool SDL2Initializer::init() {
return false;
}

if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_TIMER ) < 0 ) {
if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_EVENTS) < 0 ) {
return false;
}
s_inited = true;
Expand Down

0 comments on commit 9f2a084

Please sign in to comment.