Skip to content

Commit

Permalink
Apply Guichan's changes from 84ff8621369de297eadbc80761a6da9764435e58…
Browse files Browse the repository at this point in the history
… (Mar 9th 2008)

* Issue 37 has been fixed. http://code.google.com/p/guichan/issues/detail?id=37
  • Loading branch information
Jarod42 committed Aug 21, 2024
1 parent 0cc4217 commit 06aa6fc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
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

0 comments on commit 06aa6fc

Please sign in to comment.