Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [Mac OS X][Keyboard] Keypad redundant keys disabled  (Read 2356 times)

0 Members and 1 Guest are viewing this topic.

OMGOuned

  • Newbie
  • *
  • Posts: 3
    • View Profile
[Mac OS X][Keyboard] Keypad redundant keys disabled
« on: June 03, 2013, 03:22:33 am »
Hello,
As I was using sf::Event to handle keyboard input, I realized that the keypad period key was not generating event, like the "normal" period key did.

I looked into the SFML source code and I found the SFML/Window/OSX/HIDInputManager.mm file with:
//        case 0x41: /* keypad         */ return sf::Keyboard::Period;
        case 0x2f: /* keyboard       */ return sf::Keyboard::Period;
        case 0x27:                      return sf::Keyboard::Quote;
        case 0x2c:                      return sf::Keyboard::Slash;
        case 0x2a:                      return sf::Keyboard::BackSlash;
           
#warning sf::Keyboard::Tilde might be in conflict with some other key.
            // 0x0a is for "Non-US Backslash" according to HID Calibrator,
            // a sample provided by Apple.
        case 0x0a:                      return sf::Keyboard::Tilde;
           
//        case 0x51: /* keypad         */ return sf::Keyboard::Equal;
        case 0x18: /* keyboard       */ return sf::Keyboard::Equal;
        case 0x32:                      return sf::Keyboard::Dash;
        case 0x31:                      return sf::Keyboard::Space;
//        case 0x4c: /* keypad         */ return sf::Keyboard::Return;
        case 0x24: /* keyboard       */ return sf::Keyboard::Return;
We can see that the keypad keys are commented. I can't figure out why as I successfully recompiled the library after uncommenting these values and had it work.

Here is my question: why are these values commented and is it possible to change the default behavior so that keypad keys are treated like "normal" keys?

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: [Mac OS X][Keyboard] Keypad redundant keys disabled
« Reply #1 on: June 03, 2013, 04:12:52 pm »
Hi !

The reason is that I never was able to test those keys (I have no keypad) and didn't want to introduce any bug – a dead key is better I think.

Anyway, since you can test that, I guess we can modify this behaviour for 2.1. Could you also update HIDInputManager::usageToVirtualCode and create a Pull Request, or send me a diff file ?

Thanks.  :)
SFML / OS X developer

OMGOuned

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: [Mac OS X][Keyboard] Keypad redundant keys disabled
« Reply #2 on: June 03, 2013, 08:53:27 pm »
I'll create a pull request so :). I'm going to update the virtual codes according to the "Events.h" from the HIToolbox Carbon framework and "NSEvent.h" from AppKit.

OMGOuned

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: [Mac OS X][Keyboard] Keypad redundant keys disabled
« Reply #3 on: June 03, 2013, 11:40:41 pm »
I made a pull request at https://github.com/SFML/SFML/pull/401.
I thought it would be good to handle caps lock events so I modified few more files than expected.
I hope my modifications to "Keyboard.hpp" will fit with other platforms.