Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43355755
engine
提交
abc7473c
E
engine
项目概览
weixin_43355755
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
abc7473c
编写于
11月 10, 2015
作者:
C
Collin Jackson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a service for receiving hardware keys
上级
cc81c2fb
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
210 addition
and
0 deletion
+210
-0
sky/services/engine/input_event.mojom
sky/services/engine/input_event.mojom
+10
-0
sky/services/raw_keyboard/BUILD.gn
sky/services/raw_keyboard/BUILD.gn
+36
-0
sky/services/raw_keyboard/raw_keyboard.mojom
sky/services/raw_keyboard/raw_keyboard.mojom
+17
-0
sky/services/raw_keyboard/src/org/domokit/raw_keyboard/RawKeyboardServiceImpl.java
.../src/org/domokit/raw_keyboard/RawKeyboardServiceImpl.java
+45
-0
sky/services/raw_keyboard/src/org/domokit/raw_keyboard/RawKeyboardServiceState.java
...src/org/domokit/raw_keyboard/RawKeyboardServiceState.java
+69
-0
sky/shell/BUILD.gn
sky/shell/BUILD.gn
+2
-0
sky/shell/android/org/domokit/sky/shell/PlatformViewAndroid.java
...ll/android/org/domokit/sky/shell/PlatformViewAndroid.java
+22
-0
sky/shell/android/org/domokit/sky/shell/SkyApplication.java
sky/shell/android/org/domokit/sky/shell/SkyApplication.java
+9
-0
未找到文件。
sky/services/engine/input_event.mojom
浏览文件 @
abc7473c
...
...
@@ -8,6 +8,15 @@ module sky;
enum EventType {
UNKNOWN,
BACK,
KEY_PRESSED,
KEY_RELEASED,
};
struct KeyData {
int32 key_code;
int32 flags;
int32 scan_code;
int32 meta_state;
};
// TODO(abarth): Should we have a malloc-free way of creating an input event
...
...
@@ -15,4 +24,5 @@ enum EventType {
struct InputEvent {
EventType type;
int64 time_stamp;
KeyData? key_data;
};
sky/services/raw_keyboard/BUILD.gn
0 → 100644
浏览文件 @
abc7473c
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//mojo/public/tools/bindings/mojom.gni")
mojom("interfaces") {
sources = [
"raw_keyboard.mojom",
]
deps = [
"//sky/services/engine:interfaces"
]
}
if (is_android) {
import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
android_library("raw_keyboard_lib") {
java_files = [
"src/org/domokit/raw_keyboard/RawKeyboardServiceImpl.java",
"src/org/domokit/raw_keyboard/RawKeyboardServiceState.java",
]
deps = [
"//base:base_java",
"//mojo/public/java:bindings",
"//mojo/public/java:system",
"//sky/services/engine:interfaces_java",
":interfaces_java",
]
}
}
sky/services/raw_keyboard/raw_keyboard.mojom
0 → 100644
浏览文件 @
abc7473c
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
[DartPackage="sky_services"]
module raw_keyboard;
import "sky/services/engine/input_event.mojom";
interface RawKeyboardListener {
OnKey(sky.InputEvent event);
};
interface RawKeyboardService {
AddListener(RawKeyboardListener listener);
RemoveListener(RawKeyboardListener listener);
};
sky/services/raw_keyboard/src/org/domokit/raw_keyboard/RawKeyboardServiceImpl.java
0 → 100644
浏览文件 @
abc7473c
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package
org.domokit.raw_keyboard
;
import
org.chromium.mojo.system.MojoException
;
import
org.chromium.mojom.raw_keyboard.RawKeyboardListener
;
import
org.chromium.mojom.raw_keyboard.RawKeyboardService
;
/**
* Android implementation of Keyboard.
*/
public
class
RawKeyboardServiceImpl
implements
RawKeyboardService
{
// We have a unique ServiceImpl per connection. However multiple views
// can be sending us key events simultaneously.
private
static
RawKeyboardServiceState
sViewState
;
public
RawKeyboardServiceImpl
()
{
}
public
static
void
setViewState
(
RawKeyboardServiceState
state
)
{
if
(
sViewState
!=
null
)
sViewState
.
close
();
sViewState
=
state
;
}
@Override
public
void
addListener
(
RawKeyboardListener
listener
)
{
sViewState
.
addListener
(
listener
);
}
@Override
public
void
removeListener
(
RawKeyboardListener
listener
)
{
sViewState
.
removeListener
(
listener
);
}
@Override
public
void
onConnectionError
(
MojoException
e
)
{}
@Override
public
void
close
()
{
if
(
sViewState
==
null
)
return
;
sViewState
.
close
();
}
}
sky/services/raw_keyboard/src/org/domokit/raw_keyboard/RawKeyboardServiceState.java
0 → 100644
浏览文件 @
abc7473c
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package
org.domokit.raw_keyboard
;
import
android.util.Log
;
import
android.view.KeyEvent
;
import
android.view.View
;
import
java.util.ArrayList
;
import
org.chromium.mojo.system.MojoException
;
import
org.chromium.mojom.raw_keyboard.RawKeyboardListener
;
import
org.chromium.mojom.raw_keyboard.RawKeyboardService
;
import
org.chromium.mojom.sky.InputEvent
;
import
org.chromium.mojom.sky.EventType
;
import
org.chromium.mojom.sky.KeyData
;
/**
* Per-View raw keyboard state.
*/
public
class
RawKeyboardServiceState
implements
View
.
OnKeyListener
{
private
static
final
String
TAG
=
"RawKeyboardServiceState"
;
private
ArrayList
<
RawKeyboardListener
>
mListeners
=
new
ArrayList
<
RawKeyboardListener
>();
public
RawKeyboardServiceState
()
{
}
public
void
addListener
(
RawKeyboardListener
listener
)
{
mListeners
.
add
(
listener
);
}
public
void
removeListener
(
RawKeyboardListener
listener
)
{
mListeners
.
remove
(
listener
);
listener
.
close
();
}
public
void
close
()
{
}
@Override
public
boolean
onKey
(
View
v
,
int
keyCode
,
KeyEvent
nativeEvent
)
{
if
(
mListeners
.
isEmpty
())
return
false
;
InputEvent
event
=
new
InputEvent
();
switch
(
nativeEvent
.
getAction
())
{
case
KeyEvent
.
ACTION_DOWN
:
event
.
type
=
EventType
.
KEY_PRESSED
;
break
;
case
KeyEvent
.
ACTION_UP
:
event
.
type
=
EventType
.
KEY_RELEASED
;
break
;
default
:
Log
.
w
(
TAG
,
"Unknown key event received"
);
return
false
;
}
KeyData
keyData
=
new
KeyData
();
keyData
.
flags
=
nativeEvent
.
getFlags
();
keyData
.
scanCode
=
nativeEvent
.
getScanCode
();
keyData
.
metaState
=
nativeEvent
.
getMetaState
();
keyData
.
keyCode
=
keyCode
;
event
.
keyData
=
keyData
;
for
(
RawKeyboardListener
listener
:
mListeners
)
listener
.
onKey
(
event
);
return
true
;
}
}
sky/shell/BUILD.gn
浏览文件 @
abc7473c
...
...
@@ -151,6 +151,8 @@ if (is_android) {
"//sky/services/media:media_lib",
"//sky/services/oknet",
"//sky/services/pointer:interfaces_java",
"//sky/services/raw_keyboard:raw_keyboard_lib",
"//sky/services/raw_keyboard:interfaces_java",
"//sky/services/updater:interfaces_java",
"//sky/services/vsync:interfaces_java",
"//sky/services/vsync:vsync_lib",
...
...
sky/shell/android/org/domokit/sky/shell/PlatformViewAndroid.java
浏览文件 @
abc7473c
...
...
@@ -6,6 +6,7 @@ package org.domokit.sky.shell;
import
android.content.Context
;
import
android.os.Build
;
import
android.view.KeyEvent
;
import
android.view.MotionEvent
;
import
android.view.Surface
;
import
android.view.SurfaceHolder
;
...
...
@@ -31,6 +32,9 @@ import org.chromium.mojom.sky.ViewportMetrics;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.domokit.raw_keyboard.RawKeyboardServiceImpl
;
import
org.domokit.raw_keyboard.RawKeyboardServiceState
;
/**
* A view containing Sky
*/
...
...
@@ -43,6 +47,7 @@ public class PlatformViewAndroid extends SurfaceView {
private
final
SurfaceHolder
.
Callback
mSurfaceCallback
;
private
final
EdgeDims
mPadding
;
private
final
KeyboardServiceState
mKeyboardState
;
private
final
RawKeyboardServiceState
mRawKeyboardState
;
/**
* Dimensions in each of the four cardinal directions.
...
...
@@ -100,6 +105,23 @@ public class PlatformViewAndroid extends SurfaceView {
// TODO(eseidel): We need per-view services!
mKeyboardState
=
new
KeyboardServiceState
(
this
);
KeyboardServiceImpl
.
setViewState
(
mKeyboardState
);
mRawKeyboardState
=
new
RawKeyboardServiceState
();
RawKeyboardServiceImpl
.
setViewState
(
mRawKeyboardState
);
}
@Override
public
boolean
onKeyUp
(
int
keyCode
,
KeyEvent
event
)
{
if
(
mRawKeyboardState
.
onKey
(
this
,
keyCode
,
event
))
return
true
;
return
super
.
onKeyUp
(
keyCode
,
event
);
}
@Override
public
boolean
onKeyDown
(
int
keyCode
,
KeyEvent
event
)
{
if
(
mRawKeyboardState
.
onKey
(
this
,
keyCode
,
event
))
return
true
;
return
super
.
onKeyDown
(
keyCode
,
event
);
}
SkyEngine
getEngine
()
{
...
...
sky/shell/android/org/domokit/sky/shell/SkyApplication.java
浏览文件 @
abc7473c
...
...
@@ -21,12 +21,14 @@ import org.chromium.mojom.activity.PathService;
import
org.chromium.mojom.keyboard.KeyboardService
;
import
org.chromium.mojom.media.MediaService
;
import
org.chromium.mojom.mojo.NetworkService
;
import
org.chromium.mojom.raw_keyboard.RawKeyboardService
;
import
org.chromium.mojom.sensors.SensorService
;
import
org.chromium.mojom.vsync.VSyncProvider
;
import
org.domokit.activity.ActivityImpl
;
import
org.domokit.activity.PathServiceImpl
;
import
org.domokit.media.MediaServiceImpl
;
import
org.domokit.oknet.NetworkServiceImpl
;
import
org.domokit.raw_keyboard.RawKeyboardServiceImpl
;
import
org.domokit.vsync.VSyncProviderImpl
;
/**
...
...
@@ -99,6 +101,13 @@ public class SkyApplication extends BaseChromiumApplication {
}
});
registry
.
register
(
RawKeyboardService
.
MANAGER
.
getName
(),
new
ServiceFactory
()
{
@Override
public
void
connectToService
(
Context
context
,
Core
core
,
MessagePipeHandle
pipe
)
{
RawKeyboardService
.
MANAGER
.
bind
(
new
RawKeyboardServiceImpl
(),
pipe
);
}
});
registry
.
register
(
MediaService
.
MANAGER
.
getName
(),
new
ServiceFactory
()
{
@Override
public
void
connectToService
(
Context
context
,
Core
core
,
MessagePipeHandle
pipe
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录