Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply Guichan's changes from 84ff8621369de297eadbc80761a6da9764435e58… #44

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
* Continue rebasing from 33d1e46684936a304ae82587a0c35c68d6b0b93c
* Continue rebasing from df337fb783bc0f8ce1bab1bc672e301f88b9d364
* Add a focus listener interface.
* Make focus apply synchronously.
* Graphics and input objects for DirectX.
Expand Down
8 changes: 4 additions & 4 deletions include/guisan/sdl/sdlinput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ namespace gcn
int convertMouseButton(int button);

/**
* Converts an SDL event key to a key value.
* Converts an SDL event to a Guisan key value.
*
* @param event an SDL event with a key to convert.
* @return a key value.
* @param event The SDL event to convert.
* @return A Guisan key value.
* @see Key
*/
int convertKeyCharacter(SDL_Event event);
Key convertSDLEventToGuichanKeyValue(SDL_Event event);

std::queue<KeyInput> mKeyInputQueue;
std::queue<MouseInput> mMouseInputQueue;
Expand Down
21 changes: 10 additions & 11 deletions src/sdl/sdlinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ namespace gcn
mKeyInputQueue.push(keyInput);
break;
case SDL_KEYDOWN:
keyInput.setKey(Key(convertKeyCharacter(event)));
keyInput.setKey(convertSDLEventToGuichanKeyValue(event));
keyInput.setType(KeyInput::PRESSED);
keyInput.setShiftPressed(event.key.keysym.mod & KMOD_SHIFT);
keyInput.setControlPressed(event.key.keysym.mod & KMOD_CTRL);
Expand All @@ -183,7 +183,7 @@ namespace gcn
break;

case SDL_KEYUP:
keyInput.setKey(Key(convertKeyCharacter(event)));
keyInput.setKey(convertSDLEventToGuichanKeyValue(event));
keyInput.setType(KeyInput::RELEASED);
keyInput.setShiftPressed(event.key.keysym.mod & KMOD_SHIFT);
keyInput.setControlPressed(event.key.keysym.mod & KMOD_CTRL);
Expand Down Expand Up @@ -278,12 +278,11 @@ namespace gcn
}
}

int SDLInput::convertKeyCharacter(SDL_Event event)
Key SDLInput::convertSDLEventToGuichanKeyValue(SDL_Event event)
{
SDL_Keysym keysym = event.key.keysym;

int value = 0;
switch (keysym.sym)
int value = -1;

switch (event.key.keysym.sym)
{
case SDLK_TAB:
value = Key::TAB;
Expand Down Expand Up @@ -422,13 +421,13 @@ namespace gcn
break;

default:
value = keysym.sym;
value = event.key.keysym.sym;
break;
}

if (!(keysym.mod & KMOD_NUM))
if (!(event.key.keysym.mod & KMOD_NUM))
{
switch (keysym.sym)
switch (event.key.keysym.sym)
{
case SDLK_KP_0:
value = Key::INSERT;
Expand Down Expand Up @@ -466,7 +465,7 @@ namespace gcn
}
else
{
switch (keysym.sym)
switch (event.key.keysym.sym)
{
case SDLK_KP_0:
value = SDLK_0;
Expand Down