Add scancode and virtual key and fix some sdl stuff on Windows

This commit is contained in:
Lynix
2019-05-19 16:34:29 +02:00
parent 848f05a420
commit ab5188c57d
33 changed files with 920 additions and 382 deletions

View File

@@ -209,7 +209,7 @@ namespace Ndk
overlay->keyPressedSlot.Connect(eventHandler.OnKeyPressed, [&consoleRef] (const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& event)
{
if (event.code == Nz::Keyboard::F9)
if (event.virtualKey == Nz::Keyboard::VKey::F9)
consoleRef.Show(!consoleRef.IsVisible());
});

View File

@@ -144,7 +144,7 @@ namespace Ndk
if (m_widgetEntries[m_keyboardOwner].widget->OnKeyPressed(event))
return;
if (event.code == Nz::Keyboard::Tab)
if (event.virtualKey == Nz::Keyboard::VKey::Tab)
{
if (!event.shift)
{

View File

@@ -178,12 +178,12 @@ namespace Ndk
case Nz::WindowEventType_KeyPressed:
{
switch (event.key.code)
switch (event.key.virtualKey)
{
case Nz::Keyboard::Down:
case Nz::Keyboard::Up:
case Nz::Keyboard::VKey::Down:
case Nz::Keyboard::VKey::Up:
{
if (event.key.code == Nz::Keyboard::Up)
if (event.key.virtualKey == Nz::Keyboard::VKey::Up)
m_historyPosition = std::min<std::size_t>(m_commandHistory.size(), m_historyPosition + 1);
else
{

View File

@@ -17,8 +17,8 @@ namespace Ndk
/*********************************** Nz::Keyboard **********************************/
keyboard.Reset("Keyboard");
{
keyboard.BindStaticMethod("GetKeyName", &Nz::Keyboard::GetKeyName);
keyboard.BindStaticMethod("IsKeyPressed", &Nz::Keyboard::IsKeyPressed);
//keyboard.BindStaticMethod("GetKeyName", &Nz::Keyboard::GetKeyName);
//keyboard.BindStaticMethod("IsKeyPressed", &Nz::Keyboard::IsKeyPressed);
}
}
@@ -31,9 +31,9 @@ namespace Ndk
{
keyboard.Register(state);
keyboard.PushGlobalTable(state);
/*keyboard.PushGlobalTable(state);
{
static_assert(Nz::Keyboard::Count == 124, "Nz::Keyboard::Key has been updated but change was not reflected to Lua binding");
static_assert(Nz::Keyboard::Max == 123, "Nz::Keyboard::Key has been updated but change was not reflected to Lua binding");
state.PushField("Undefined", Nz::Keyboard::Undefined);
@@ -119,7 +119,7 @@ namespace Ndk
state.PushField("NumLock", Nz::Keyboard::NumLock);
state.PushField("ScrollLock", Nz::Keyboard::ScrollLock);
}
state.Pop();
state.Pop();*/
static_assert(Nz::WindowStyle_Max + 1 == 6, "Nz::WindowStyle has been updated but change was not reflected to Lua binding");
state.PushTable(0, Nz::WindowStyle_Max + 1);

View File

@@ -207,9 +207,9 @@ namespace Ndk
bool TextAreaWidget::OnKeyPressed(const Nz::WindowEvent::KeyEvent& key)
{
switch (key.code)
switch (key.virtualKey)
{
case Nz::Keyboard::Delete:
case Nz::Keyboard::VKey::Delete:
{
if (HasSelection())
EraseSelection();
@@ -219,7 +219,7 @@ namespace Ndk
return true;
}
case Nz::Keyboard::Down:
case Nz::Keyboard::VKey::Down:
{
bool ignoreDefaultAction = false;
OnTextAreaKeyDown(this, &ignoreDefaultAction);
@@ -234,7 +234,7 @@ namespace Ndk
return true;
}
case Nz::Keyboard::End:
case Nz::Keyboard::VKey::End:
{
bool ignoreDefaultAction = false;
OnTextAreaKeyEnd(this, &ignoreDefaultAction);
@@ -251,7 +251,7 @@ namespace Ndk
return true;
}
case Nz::Keyboard::Home:
case Nz::Keyboard::VKey::Home:
{
bool ignoreDefaultAction = false;
OnTextAreaKeyHome(this, &ignoreDefaultAction);
@@ -263,7 +263,7 @@ namespace Ndk
return true;
}
case Nz::Keyboard::Left:
case Nz::Keyboard::VKey::Left:
{
bool ignoreDefaultAction = false;
OnTextAreaKeyLeft(this, &ignoreDefaultAction);
@@ -301,7 +301,7 @@ namespace Ndk
return true;
}
case Nz::Keyboard::Right:
case Nz::Keyboard::VKey::Right:
{
bool ignoreDefaultAction = false;
OnTextAreaKeyRight(this, &ignoreDefaultAction);
@@ -340,7 +340,7 @@ namespace Ndk
return true;
}
case Nz::Keyboard::Up:
case Nz::Keyboard::VKey::Up:
{
bool ignoreDefaultAction = false;
OnTextAreaKeyUp(this, &ignoreDefaultAction);
@@ -355,7 +355,7 @@ namespace Ndk
return true;
}
case Nz::Keyboard::Tab:
case Nz::Keyboard::VKey::Tab:
{
if (!m_tabEnabled)
return false;
@@ -425,7 +425,7 @@ namespace Ndk
Nz::Vector2ui hoveredGlyph = GetHoveredGlyph(float(x) - 5.f, float(y) - 5.f);
// Shift extends selection
if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::LShift) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::RShift))
if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::LShift) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::RShift))
SetSelection(hoveredGlyph, m_selectionCursor);
else
{