1/*
2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2008 Diego Hidalgo C. Gonzalez
4 * Copyright (C) 2009-2010 ProFUSION embedded systems
5 * Copyright (C) 2009-2010 Samsung Electronics
6 *
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 *    notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in the
16 *    documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include "config.h"
32#include "PlatformKeyboardEvent.h"
33
34#include "EflKeyboardUtilities.h"
35#include "NotImplemented.h"
36#include "TextEncoding.h"
37#include <Evas.h>
38#include <wtf/CurrentTime.h>
39
40namespace WebCore {
41
42PlatformKeyboardEvent::PlatformKeyboardEvent(const Evas_Event_Key_Down* event)
43    : PlatformEvent(PlatformEvent::KeyDown, evas_key_modifier_is_set(event->modifiers, "Shift"), evas_key_modifier_is_set(event->modifiers, "Control"), evas_key_modifier_is_set(event->modifiers, "Alt"), evas_key_modifier_is_set(event->modifiers, "Meta"), currentTime())
44    , m_text(String::fromUTF8(event->string))
45    , m_unmodifiedText(String::fromUTF8(event->string))
46    , m_keyIdentifier(keyIdentifierForEvasKeyName(String(event->key)))
47    , m_windowsVirtualKeyCode(windowsKeyCodeForEvasKeyName(String(event->key)))
48    , m_nativeVirtualKeyCode(0)
49    , m_macCharCode(0)
50    , m_autoRepeat(false)
51    , m_isKeypad(String(event->key).startsWith("KP_"))
52    , m_isSystemKey(false)
53{
54}
55
56PlatformKeyboardEvent::PlatformKeyboardEvent(const Evas_Event_Key_Up* event)
57    : PlatformEvent(PlatformEvent::KeyUp, evas_key_modifier_is_set(event->modifiers, "Shift"), evas_key_modifier_is_set(event->modifiers, "Control"), evas_key_modifier_is_set(event->modifiers, "Alt"), evas_key_modifier_is_set(event->modifiers, "Meta"), currentTime())
58    , m_text(String::fromUTF8(event->string))
59    , m_unmodifiedText(String::fromUTF8(event->string))
60    , m_keyIdentifier(keyIdentifierForEvasKeyName(String(event->key)))
61    , m_windowsVirtualKeyCode(windowsKeyCodeForEvasKeyName(String(event->key)))
62    , m_nativeVirtualKeyCode(0)
63    , m_macCharCode(0)
64    , m_autoRepeat(false)
65    , m_isKeypad(String(event->key).startsWith("KP_"))
66    , m_isSystemKey(false)
67{
68}
69
70void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool)
71{
72    ASSERT(m_type == KeyDown);
73    m_type = type;
74
75    if (type == PlatformEvent::RawKeyDown) {
76        m_text = String();
77        m_unmodifiedText = String();
78    } else {
79        m_keyIdentifier = String();
80        m_windowsVirtualKeyCode = 0;
81    }
82}
83
84bool PlatformKeyboardEvent::currentCapsLockState()
85{
86    notImplemented();
87    return false;
88}
89
90void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey)
91{
92    notImplemented();
93    shiftKey = false;
94    ctrlKey = false;
95    altKey = false;
96    metaKey = false;
97}
98
99}
100