Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Windows scancode implementation #1294

Open
wants to merge 3 commits into
base: feature/scancode
from

Conversation

@JonnyPtn
Copy link
Contributor

JonnyPtn commented Sep 28, 2017

SFML Tasks

  • Adjust code, according to the review comments
  • Merge into the feature/scancode branch

Just the events side of things so far. I'm away for a few days now but feel free to pick it apart before I return.

Also made me dig up #304 as raw input might be worth considering for keyboard input too?

@eXpl0it3r

This comment has been minimized.

Copy link
Member

eXpl0it3r commented Sep 28, 2017

Also made me dig up #304 as raw input might be worth considering for keyboard input too?

Let's not mix topics unless it absolutely makes sense. Every OS specific feature, needs again to be implemented on the other OS. 😉

@eXpl0it3r eXpl0it3r added this to WIP in SFML 2.5.0 Sep 28, 2017
@JonnyPtn

This comment has been minimized.

Copy link
Contributor Author

JonnyPtn commented Sep 29, 2017

If you try helping with this you'll see why I thought it made sense to mention it - Scancodes are a bitch on windows, especially when using a legacy API

also it's windows specific so although other platforms may have options to implement raw input, I'm talking specifically about windows, where rawinput would help with implementing scancodes

@JonnyPtn

This comment has been minimized.

Copy link
Contributor Author

JonnyPtn commented Oct 4, 2017

This looks to be working well with test program mentioned in #1235, could do with some testing (Once I get hold of a keyboard with the extra buttons I'll try and fill in the blanks)

Copy link
Member

eXpl0it3r left a comment

I hope to test it later this week.

case Keyboard::F13: vkey = VK_F13; break;
case Keyboard::F14: vkey = VK_F14; break;
case Keyboard::F15: vkey = VK_F15; break;
case Keyboard::Pause: vkey = VK_PAUSE; break;

This comment has been minimized.

Copy link
@eXpl0it3r

eXpl0it3r Oct 11, 2017

Member

Looks like your IDE auto "corrected" the indention here, unfortunately it's not how we format switch-cases.

{
auto winCode = sfScanToWin(code);
auto vkey = MapVirtualKey(winCode, MAPVK_VSC_TO_VK_EX);
auto state = GetAsyncKeyState(vkey);

This comment has been minimized.

Copy link
@eXpl0it3r

eXpl0it3r Oct 11, 2017

Member

auto is a C++11 feature, SFML 2 is still on C++03.

case Keyboard::ScanRAlt: return 56;
//case Keyboard::ScanRSystem: return ? ? ? ;

default: return 0; // Not sure what to return here?

This comment has been minimized.

Copy link
@eXpl0it3r

eXpl0it3r Oct 11, 2017

Member

Wrong switch-case indentation.

@@ -31,6 +31,7 @@
#include <SFML/Window/Keyboard.hpp>
#include <SFML/Window/Mouse.hpp>

#include <windows.h>

This comment has been minimized.

Copy link
@eXpl0it3r

eXpl0it3r Oct 11, 2017

Member

Is this needed to get access to WORD?


private:

static WORD sfScanToWin(Keyboard::Scancode code);

This comment has been minimized.

Copy link
@eXpl0it3r

eXpl0it3r Oct 11, 2017

Member

The sf in sfScanToWin seems kind of odd, i.e. making the namespace a prefix. I'd prefer a different name.

case 93: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::ScanMenu : Keyboard::ScanUnknown;

default: return Keyboard::ScanUnknown;
}

This comment has been minimized.

Copy link
@eXpl0it3r

eXpl0it3r Oct 11, 2017

Member

Wrong switch-case indentation.

@mantognini mantognini mentioned this pull request Nov 29, 2017
1 of 8 tasks complete
@eXpl0it3r eXpl0it3r added this to Discussion in SFML 2.6.0 via automation Jan 25, 2018
@eXpl0it3r eXpl0it3r removed this from WIP in SFML 2.5.0 Jan 25, 2018
@mantognini mantognini self-assigned this Mar 30, 2018
@eliasdaler

This comment has been minimized.

Copy link
Contributor

eliasdaler commented Apr 20, 2018

Posted on a forum, but I'll post it here too:

Bugs found:

On QWERTY:

  • Tilde/Grave accent is identified as ScanBackslash
  • F11 and F12 don't have a string description
  • Backslash (the key left to Enter) is detected as ScanDash and getDescription returns "`"
  • Volume Up/Down, Find and Mute buttons are "Unknown"
  • Keyboard enter is "ScanReturn", though it should be "ScanEnter". Numpad enter should be "ScanReturn" (see comments in enum)

Other keyboard layouts work, but I wonder if "ScanReverseSolidus" will be identified correctly. Someone who has a keyboad with this key (it's the one right to the LShift, it usually has "<>|" on it should test it.

  • And getDescription returns translated descriptions for Ctrl, Shift, Alt, Home, PageUp, etc. in non-English layouts. E.g. if I turn on AZERTY, I get descriptions in French. Not sure if it's a behaviour we want... We'll discuss it in Scancode PR (#1235).
@eXpl0it3r eXpl0it3r moved this from Discussion to WIP in SFML 2.6.0 Aug 13, 2018
@eXpl0it3r eXpl0it3r moved this from WIP to Discussion in SFML 2.6.0 Dec 29, 2018
@eXpl0it3r eXpl0it3r moved this from Discussion to WIP in SFML 2.6.0 Dec 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
SFML 2.6.0
  
WIP
4 participants
You can’t perform that action at this time.