SDL poll event inverting w with z and viceversa
I'm doing a simple camera movement with the WASD keys:
switch (k) {
case SDLK_w:
this->up = true;
break;
case SDLK_s:
this->down = true;
break;
case SDLK_a:
this->left = true;
break;
case SDLK_d:
this->right = true;
break;
default:
break;
}
It's pretty self explanatory. But when I press w
it simply doesn't detect that button pressing. If I press a
or d
or s
it works. The cool thing about it is that if I just change SDLK_w
to any other button (let's say SDLK_q
) keeping the same exact code, it just works. It's not an issue of how I handle this->up
because even if I print something on the screen inside the case SDLK_w:
and I press w it doesn't print anything.
PS: obviously my w key is not broken otherwise I would have had trouble writing this post doWn.
What's wrong with w?
c++ sdl
|
show 12 more comments
I'm doing a simple camera movement with the WASD keys:
switch (k) {
case SDLK_w:
this->up = true;
break;
case SDLK_s:
this->down = true;
break;
case SDLK_a:
this->left = true;
break;
case SDLK_d:
this->right = true;
break;
default:
break;
}
It's pretty self explanatory. But when I press w
it simply doesn't detect that button pressing. If I press a
or d
or s
it works. The cool thing about it is that if I just change SDLK_w
to any other button (let's say SDLK_q
) keeping the same exact code, it just works. It's not an issue of how I handle this->up
because even if I print something on the screen inside the case SDLK_w:
and I press w it doesn't print anything.
PS: obviously my w key is not broken otherwise I would have had trouble writing this post doWn.
What's wrong with w?
c++ sdl
What value does SDLK_w represent?
– ctor
Dec 1 '12 at 20:52
@Loggie, it represent 119 and it's the exact key code value for the Mac keyboard. I've just checked with a specific application.
– Shoe
Dec 1 '12 at 20:53
What happens if you cout the value of k in the default case and press the w key?
– ctor
Dec 1 '12 at 20:56
@Loggie, It prints122
, it's quite strange.
– Shoe
Dec 1 '12 at 20:57
1
I don't know if this would affect it but out of curiosity, what is your keyboard region set to?
– ctor
Dec 1 '12 at 21:12
|
show 12 more comments
I'm doing a simple camera movement with the WASD keys:
switch (k) {
case SDLK_w:
this->up = true;
break;
case SDLK_s:
this->down = true;
break;
case SDLK_a:
this->left = true;
break;
case SDLK_d:
this->right = true;
break;
default:
break;
}
It's pretty self explanatory. But when I press w
it simply doesn't detect that button pressing. If I press a
or d
or s
it works. The cool thing about it is that if I just change SDLK_w
to any other button (let's say SDLK_q
) keeping the same exact code, it just works. It's not an issue of how I handle this->up
because even if I print something on the screen inside the case SDLK_w:
and I press w it doesn't print anything.
PS: obviously my w key is not broken otherwise I would have had trouble writing this post doWn.
What's wrong with w?
c++ sdl
I'm doing a simple camera movement with the WASD keys:
switch (k) {
case SDLK_w:
this->up = true;
break;
case SDLK_s:
this->down = true;
break;
case SDLK_a:
this->left = true;
break;
case SDLK_d:
this->right = true;
break;
default:
break;
}
It's pretty self explanatory. But when I press w
it simply doesn't detect that button pressing. If I press a
or d
or s
it works. The cool thing about it is that if I just change SDLK_w
to any other button (let's say SDLK_q
) keeping the same exact code, it just works. It's not an issue of how I handle this->up
because even if I print something on the screen inside the case SDLK_w:
and I press w it doesn't print anything.
PS: obviously my w key is not broken otherwise I would have had trouble writing this post doWn.
What's wrong with w?
c++ sdl
c++ sdl
edited Dec 1 '12 at 21:21
Nicol Bolas
288k33479651
288k33479651
asked Dec 1 '12 at 20:50
ShoeShoe
59.3k26123217
59.3k26123217
What value does SDLK_w represent?
– ctor
Dec 1 '12 at 20:52
@Loggie, it represent 119 and it's the exact key code value for the Mac keyboard. I've just checked with a specific application.
– Shoe
Dec 1 '12 at 20:53
What happens if you cout the value of k in the default case and press the w key?
– ctor
Dec 1 '12 at 20:56
@Loggie, It prints122
, it's quite strange.
– Shoe
Dec 1 '12 at 20:57
1
I don't know if this would affect it but out of curiosity, what is your keyboard region set to?
– ctor
Dec 1 '12 at 21:12
|
show 12 more comments
What value does SDLK_w represent?
– ctor
Dec 1 '12 at 20:52
@Loggie, it represent 119 and it's the exact key code value for the Mac keyboard. I've just checked with a specific application.
– Shoe
Dec 1 '12 at 20:53
What happens if you cout the value of k in the default case and press the w key?
– ctor
Dec 1 '12 at 20:56
@Loggie, It prints122
, it's quite strange.
– Shoe
Dec 1 '12 at 20:57
1
I don't know if this would affect it but out of curiosity, what is your keyboard region set to?
– ctor
Dec 1 '12 at 21:12
What value does SDLK_w represent?
– ctor
Dec 1 '12 at 20:52
What value does SDLK_w represent?
– ctor
Dec 1 '12 at 20:52
@Loggie, it represent 119 and it's the exact key code value for the Mac keyboard. I've just checked with a specific application.
– Shoe
Dec 1 '12 at 20:53
@Loggie, it represent 119 and it's the exact key code value for the Mac keyboard. I've just checked with a specific application.
– Shoe
Dec 1 '12 at 20:53
What happens if you cout the value of k in the default case and press the w key?
– ctor
Dec 1 '12 at 20:56
What happens if you cout the value of k in the default case and press the w key?
– ctor
Dec 1 '12 at 20:56
@Loggie, It prints
122
, it's quite strange.– Shoe
Dec 1 '12 at 20:57
@Loggie, It prints
122
, it's quite strange.– Shoe
Dec 1 '12 at 20:57
1
1
I don't know if this would affect it but out of curiosity, what is your keyboard region set to?
– ctor
Dec 1 '12 at 21:12
I don't know if this would affect it but out of curiosity, what is your keyboard region set to?
– ctor
Dec 1 '12 at 21:12
|
show 12 more comments
2 Answers
2
active
oldest
votes
It could depend on the type of keyboard you are using, actually your W and Z key could be inversed depending on your keyboard layout. I recommand you try ALT+SHIFT.
add a comment |
Do not use SDLK_w for this as it gives you whatever key actually gives you a W letter, whereas what you want is the key that you'd expect at the W position regardless of the layout, you do this by using scancodes, in this case SDL_SCANCODE_W.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f13663625%2fsdl-poll-event-inverting-w-with-z-and-viceversa%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
It could depend on the type of keyboard you are using, actually your W and Z key could be inversed depending on your keyboard layout. I recommand you try ALT+SHIFT.
add a comment |
It could depend on the type of keyboard you are using, actually your W and Z key could be inversed depending on your keyboard layout. I recommand you try ALT+SHIFT.
add a comment |
It could depend on the type of keyboard you are using, actually your W and Z key could be inversed depending on your keyboard layout. I recommand you try ALT+SHIFT.
It could depend on the type of keyboard you are using, actually your W and Z key could be inversed depending on your keyboard layout. I recommand you try ALT+SHIFT.
answered Mar 27 '13 at 20:01
justForFunjustForFun
1
1
add a comment |
add a comment |
Do not use SDLK_w for this as it gives you whatever key actually gives you a W letter, whereas what you want is the key that you'd expect at the W position regardless of the layout, you do this by using scancodes, in this case SDL_SCANCODE_W.
add a comment |
Do not use SDLK_w for this as it gives you whatever key actually gives you a W letter, whereas what you want is the key that you'd expect at the W position regardless of the layout, you do this by using scancodes, in this case SDL_SCANCODE_W.
add a comment |
Do not use SDLK_w for this as it gives you whatever key actually gives you a W letter, whereas what you want is the key that you'd expect at the W position regardless of the layout, you do this by using scancodes, in this case SDL_SCANCODE_W.
Do not use SDLK_w for this as it gives you whatever key actually gives you a W letter, whereas what you want is the key that you'd expect at the W position regardless of the layout, you do this by using scancodes, in this case SDL_SCANCODE_W.
answered Nov 23 '18 at 19:38
Michel RouzicMichel Rouzic
396218
396218
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f13663625%2fsdl-poll-event-inverting-w-with-z-and-viceversa%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What value does SDLK_w represent?
– ctor
Dec 1 '12 at 20:52
@Loggie, it represent 119 and it's the exact key code value for the Mac keyboard. I've just checked with a specific application.
– Shoe
Dec 1 '12 at 20:53
What happens if you cout the value of k in the default case and press the w key?
– ctor
Dec 1 '12 at 20:56
@Loggie, It prints
122
, it's quite strange.– Shoe
Dec 1 '12 at 20:57
1
I don't know if this would affect it but out of curiosity, what is your keyboard region set to?
– ctor
Dec 1 '12 at 21:12