SDL poll event inverting w with z and viceversa












2















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?










share|improve this question

























  • 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
















2















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?










share|improve this question

























  • 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














2












2








2








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?










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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



















  • 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

















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












2 Answers
2






active

oldest

votes


















0














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.






share|improve this answer































    0














    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.






    share|improve this answer























      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
      });


      }
      });














      draft saved

      draft discarded


















      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









      0














      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.






      share|improve this answer




























        0














        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.






        share|improve this answer


























          0












          0








          0







          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.






          share|improve this answer













          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 27 '13 at 20:01









          justForFunjustForFun

          1




          1

























              0














              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.






              share|improve this answer




























                0














                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.






                share|improve this answer


























                  0












                  0








                  0







                  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.






                  share|improve this answer













                  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.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 23 '18 at 19:38









                  Michel RouzicMichel Rouzic

                  396218




                  396218






























                      draft saved

                      draft discarded




















































                      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.




                      draft saved


                      draft discarded














                      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





















































                      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







                      Popular posts from this blog

                      Create new schema in PostgreSQL using DBeaver

                      Deepest pit of an array with Javascript: test on Codility

                      Costa Masnaga