<commit_before>
#ifdef ATOMIC_PLATFORM_WINDOWS

#include <include/cef_client.h>

#include <ThirdParty/SDL/include/SDL.h>
#include <ThirdParty/SDL/include/SDL_syswm.h>

#include <ThirdParty/SDL/src/events/scancodes_windows.h>

#include <Atomic/Core/Variant.h>
#include <Atomic/Input/InputEvents.h>
#include <Atomic/Input/Input.h>
#include <Atomic/IO/Log.h>

#include "WebKeyboard.h"

namespace Atomic
{

static bool SDLScanCodeToWindowsScanCode(SDL_Scancode code, LPARAM& lParam, WPARAM& wParam )
{

    wParam = 0;
    lParam = 0;

    if (code >= SDL_SCANCODE_A && code <= SDL_SCANCODE_0)
        return false;

    /*
    int numCodes = sizeof(windows_scancode_table)/sizeof(SDL_Scancode);

    int windowsScanCode = -1;
    for (int i  = 0; i < numCodes; i++)
    {
        if (windows_scancode_table[i] == code)
        {
            windowsScanCode = i;
            break;
        }
    }

    if (windowsScanCode != -1)
    {
        lParam = windowsScanCode << 16;
    }
    */

    switch (code)
    {
    case SDL_SCANCODE_RIGHT:
        wParam = VK_RIGHT;
        break;
    case SDL_SCANCODE_LEFT:
        wParam = VK_LEFT;
        break;
    case SDL_SCANCODE_UP:
        wParam = VK_UP;
        break;
    case SDL_SCANCODE_DOWN:
        wParam = VK_DOWN;
        break;
    case SDL_SCANCODE_DELETE:
        wParam = VK_DELETE;
        break;
    case SDL_SCANCODE_BACKSPACE:
        wParam = VK_BACK;
        break;

    }

    return wParam != 0;

}

bool ConvertKeyEvent(Input* input, const StringHash eventType, VariantMap& eventData, CefKeyEvent& keyEvent)
{
    if (eventType != "KeyDown" && eventType != "KeyUp")
    {
        LOGERROR("ConvertKeyEvent - Unknown event type");
        return false;
    }

    WebKeyEvent wk(eventType, eventData);

    if (wk.scanCode == SDL_SCANCODE_RETURN)
    {
        if (!wk.keyDown)
            return false;

        keyEvent.windows_key_code = VK_RETURN;
        keyEvent.native_key_code = (int) 0;
        keyEvent.type = KEYEVENT_CHAR;
        return true;
    }

    LPARAM lParam;
    WPARAM wParam;<commit_msg>Updates for Windows WebView keyboard handling<commit_after>
#ifdef ATOMIC_PLATFORM_WINDOWS

#include <include/cef_client.h>

#include <ThirdParty/SDL/include/SDL.h>
#include <ThirdParty/SDL/include/SDL_syswm.h>

#include <ThirdParty/SDL/src/events/scancodes_windows.h>

#include <Atomic/Core/Variant.h>
#include <Atomic/Input/InputEvents.h>
#include <Atomic/Input/Input.h>
#include <Atomic/IO/Log.h>

#include "WebKeyboard.h"

namespace Atomic
{

static bool SDLScanCodeToWindowsScanCode(SDL_Scancode code, LPARAM& lParam, WPARAM& wParam )
{

    wParam = 0;
    lParam = 0;

    int numCodes = sizeof(windows_scancode_table)/sizeof(SDL_Scancode);

    int windowsScanCode = -1;
    for (int i  = 0; i < numCodes; i++)
    {
        if (windows_scancode_table[i] == code)
        {
            windowsScanCode = i;
            break;
        }
    }

    if (windowsScanCode != -1)
    {
        wParam = MapVirtualKey(windowsScanCode, MAPVK_VSC_TO_VK);
        lParam = windowsScanCode << 16;
    }

    switch (code)
    {
    case SDL_SCANCODE_RIGHT:
        wParam = VK_RIGHT;
        break;
    case SDL_SCANCODE_LEFT:
        wParam = VK_LEFT;
        break;
    case SDL_SCANCODE_UP:
        wParam = VK_UP;
        break;
    case SDL_SCANCODE_DOWN:
        wParam = VK_DOWN;
        break;
    case SDL_SCANCODE_DELETE:
        wParam = VK_DELETE;
        break;
    case SDL_SCANCODE_BACKSPACE:
        wParam = VK_BACK;
        break;

    }

    return wParam != 0 || lParam != 0;

}

bool ConvertKeyEvent(Input* input, const StringHash eventType, VariantMap& eventData, CefKeyEvent& keyEvent)
{
    if (eventType != "KeyDown" && eventType != "KeyUp")
    {
        LOGERROR("ConvertKeyEvent - Unknown event type");
        return false;
    }

    WebKeyEvent wk(eventType, eventData);

    if (wk.scanCode == SDL_SCANCODE_RETURN)
    {
        if (!wk.keyDown)
            return false;

        keyEvent.windows_key_code = VK_RETURN;
        keyEvent.native_key_code = (int) 0;
        keyEvent.type = KEYEVENT_CHAR;
        return true;
    }

    LPARAM lParam;
    WPARAM wParam;
{'fraction_non_alphanumeric': 0.10344827586206896, 'fraction_numerical': 0.004789272030651341, 'mean_word_length': 2.4606462303231154, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7139291', 'n_tokens_mistral': 1534, 'n_tokens_neox': 1463, 'n_words': 294}