Added the sf::Event::KeyEvent::System member (implements feature #8)

This commit is contained in:
Laurent Gomila 2011-04-26 21:58:03 +02:00
parent eac841ec71
commit ede01df778
13 changed files with 17 additions and 1 deletions

View File

@ -203,6 +203,7 @@ struct sfKeyEvent
sfBool Alt; sfBool Alt;
sfBool Control; sfBool Control;
sfBool Shift; sfBool Shift;
sfBool System;
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -58,6 +58,7 @@ inline void ConvertEvent(const sf::Event& SFMLEvent, sfEvent* event)
event->Key.Alt = SFMLEvent.Key.Alt ? sfTrue : sfFalse; event->Key.Alt = SFMLEvent.Key.Alt ? sfTrue : sfFalse;
event->Key.Control = SFMLEvent.Key.Control ? sfTrue : sfFalse; event->Key.Control = SFMLEvent.Key.Control ? sfTrue : sfFalse;
event->Key.Shift = SFMLEvent.Key.Shift ? sfTrue : sfFalse; event->Key.Shift = SFMLEvent.Key.Shift ? sfTrue : sfFalse;
event->Key.System = SFMLEvent.Key.System ? sfTrue : sfFalse;
break; break;
case sfEvtMouseWheelMoved : case sfEvtMouseWheelMoved :

View File

@ -242,6 +242,9 @@ namespace SFML
/// <summary>Is the Shift modifier pressed?</summary> /// <summary>Is the Shift modifier pressed?</summary>
public int Shift; public int Shift;
/// <summary>Is the System modifier pressed?</summary>
public int System;
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -23,6 +23,7 @@ namespace SFML
Alt = e.Alt != 0; Alt = e.Alt != 0;
Control = e.Control != 0; Control = e.Control != 0;
Shift = e.Shift != 0; Shift = e.Shift != 0;
System = e.System != 0;
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -37,7 +38,8 @@ namespace SFML
" Code(" + Code + ")" + " Code(" + Code + ")" +
" Alt(" + Alt + ")" + " Alt(" + Alt + ")" +
" Control(" + Control + ")" + " Control(" + Control + ")" +
" Shift(" + Shift + ")"; " Shift(" + Shift + ")" +
" System(" + System + ")";
} }
/// <summary>Code of the key (see KeyCode enum)</summary> /// <summary>Code of the key (see KeyCode enum)</summary>
@ -51,6 +53,9 @@ namespace SFML
/// <summary>Is the Shift modifier pressed?</summary> /// <summary>Is the Shift modifier pressed?</summary>
public bool Shift; public bool Shift;
/// <summary>Is the System modifier pressed?</summary>
public bool System;
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -215,6 +215,7 @@ public :
bool Alt; ///< Is the Alt key pressed? bool Alt; ///< Is the Alt key pressed?
bool Control; ///< Is the Control key pressed? bool Control; ///< Is the Control key pressed?
bool Shift; ///< Is the Shift key pressed? bool Shift; ///< Is the Shift key pressed?
bool System; ///< Is the System key pressed?
}; };
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////

View File

@ -686,12 +686,14 @@ bool WindowImplX11::ProcessEvent(XEvent windowEvent)
XLookupString(&windowEvent.xkey, buffer, sizeof(buffer), &symbol, &keyboard); XLookupString(&windowEvent.xkey, buffer, sizeof(buffer), &symbol, &keyboard);
// Fill the event parameters // Fill the event parameters
// TODO: if modifiers are wrong, use XGetModifierMapping to retrieve the actual modifiers mapping
Event event; Event event;
event.Type = Event::KeyPressed; event.Type = Event::KeyPressed;
event.Key.Code = KeysymToSF(symbol); event.Key.Code = KeysymToSF(symbol);
event.Key.Alt = windowEvent.xkey.state & Mod1Mask; event.Key.Alt = windowEvent.xkey.state & Mod1Mask;
event.Key.Control = windowEvent.xkey.state & ControlMask; event.Key.Control = windowEvent.xkey.state & ControlMask;
event.Key.Shift = windowEvent.xkey.state & ShiftMask; event.Key.Shift = windowEvent.xkey.state & ShiftMask;
event.Key.System = windowEvent.xkey.state & Mod4Mask;
PushEvent(event); PushEvent(event);
// Generate a TextEntered event // Generate a TextEntered event
@ -749,6 +751,7 @@ bool WindowImplX11::ProcessEvent(XEvent windowEvent)
event.Key.Alt = windowEvent.xkey.state & Mod1Mask; event.Key.Alt = windowEvent.xkey.state & Mod1Mask;
event.Key.Control = windowEvent.xkey.state & ControlMask; event.Key.Control = windowEvent.xkey.state & ControlMask;
event.Key.Shift = windowEvent.xkey.state & ShiftMask; event.Key.Shift = windowEvent.xkey.state & ShiftMask;
event.Key.System = windowEvent.xkey.state & Mod4Mask;
PushEvent(event); PushEvent(event);
break; break;

View File

@ -498,6 +498,7 @@ void WindowImplWin32::ProcessEvent(UINT message, WPARAM wParam, LPARAM lParam)
event.Key.Alt = HIWORD(GetAsyncKeyState(VK_MENU)) != 0; event.Key.Alt = HIWORD(GetAsyncKeyState(VK_MENU)) != 0;
event.Key.Control = HIWORD(GetAsyncKeyState(VK_CONTROL)) != 0; event.Key.Control = HIWORD(GetAsyncKeyState(VK_CONTROL)) != 0;
event.Key.Shift = HIWORD(GetAsyncKeyState(VK_SHIFT)) != 0; event.Key.Shift = HIWORD(GetAsyncKeyState(VK_SHIFT)) != 0;
event.Key.System = HIWORD(GetAsyncKeyState(VK_LWIN)) || HIWORD(GetAsyncKeyState(VK_RWIN));
event.Key.Code = VirtualKeyCodeToSF(wParam, lParam); event.Key.Code = VirtualKeyCodeToSF(wParam, lParam);
PushEvent(event); PushEvent(event);
} }
@ -514,6 +515,7 @@ void WindowImplWin32::ProcessEvent(UINT message, WPARAM wParam, LPARAM lParam)
event.Key.Control = HIWORD(GetAsyncKeyState(VK_CONTROL)) != 0; event.Key.Control = HIWORD(GetAsyncKeyState(VK_CONTROL)) != 0;
event.Key.Shift = HIWORD(GetAsyncKeyState(VK_SHIFT)) != 0; event.Key.Shift = HIWORD(GetAsyncKeyState(VK_SHIFT)) != 0;
event.Key.Code = VirtualKeyCodeToSF(wParam, lParam); event.Key.Code = VirtualKeyCodeToSF(wParam, lParam);
event.Key.System = HIWORD(GetAsyncKeyState(VK_LWIN)) || HIWORD(GetAsyncKeyState(VK_RWIN));
PushEvent(event); PushEvent(event);
break; break;
} }