SFML community forums

General => General discussions => Topic started by: OMGOuned on June 03, 2013, 03:22:33 am

Title: [Mac OS X][Keyboard] Keypad redundant keys disabled
Post by: OMGOuned 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?
Title: Re: [Mac OS X][Keyboard] Keypad redundant keys disabled
Post by: Hiura 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.  :)
Title: Re: [Mac OS X][Keyboard] Keypad redundant keys disabled
Post by: OMGOuned 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.
Title: Re: [Mac OS X][Keyboard] Keypad redundant keys disabled
Post by: OMGOuned on June 03, 2013, 11:40:41 pm
I made a pull request at https://github.com/SFML/SFML/pull/401 (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.