optimize: auto file size generated by touch record
docs: selector
This commit is contained in:
@@ -129,7 +129,7 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".external.open.EditIntentActivity"
|
android:name=".external.open.EditIntentActivity"
|
||||||
android:icon="@drawable/ic_edit_green_48dp"
|
android:icon="@drawable/ic_edit_green_48dp"
|
||||||
android:label="编辑脚本">
|
android:label="@string/text_edit_script">
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW"/>
|
<action android:name="android.intent.action.VIEW"/>
|
||||||
@@ -168,7 +168,7 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".external.open.RunIntentActivity"
|
android:name=".external.open.RunIntentActivity"
|
||||||
android:icon="@drawable/ic_ali_run"
|
android:icon="@drawable/ic_ali_run"
|
||||||
android:label="运行脚本"
|
android:label="@string/text_run_script"
|
||||||
android:taskAffinity="com.stardust.scriptdroid.external.open.RunIntentActivity"
|
android:taskAffinity="com.stardust.scriptdroid.external.open.RunIntentActivity"
|
||||||
android:theme="@android:style/Theme.NoDisplay">
|
android:theme="@android:style/Theme.NoDisplay">
|
||||||
|
|
||||||
@@ -186,6 +186,7 @@
|
|||||||
<data android:mimeType="application/plain"/>
|
<data android:mimeType="application/plain"/>
|
||||||
<data android:mimeType="application/x-javascript"/>
|
<data android:mimeType="application/x-javascript"/>
|
||||||
<data android:mimeType="text/*"/>
|
<data android:mimeType="text/*"/>
|
||||||
|
<data android:mimeType="*/*" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.SEND"/>
|
<action android:name="android.intent.action.SEND"/>
|
||||||
@@ -209,8 +210,9 @@
|
|||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".external.open.ImportIntentActivity"
|
android:name=".external.open.ImportIntentActivity"
|
||||||
|
android:theme="@style/AppTheme.Transparent"
|
||||||
android:icon="@drawable/ic_import"
|
android:icon="@drawable/ic_import"
|
||||||
android:label="导入脚本文件">
|
android:label="@string/text_import_script">
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW"/>
|
<action android:name="android.intent.action.VIEW"/>
|
||||||
@@ -226,6 +228,8 @@
|
|||||||
<data android:mimeType="application/plain"/>
|
<data android:mimeType="application/plain"/>
|
||||||
<data android:mimeType="application/x-javascript"/>
|
<data android:mimeType="application/x-javascript"/>
|
||||||
<data android:mimeType="text/*"/>
|
<data android:mimeType="text/*"/>
|
||||||
|
<data android:mimeType="*/*" />
|
||||||
|
<data android:mimeType="application/*" android:host="*" android:pathPattern=".*.auto" android:scheme="content" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.SEND"/>
|
<action android:name="android.intent.action.SEND"/>
|
||||||
|
|||||||
@@ -1,12 +1,24 @@
|
|||||||
**自动操作的函数都需要开启"自动操作服务"才能执行,否则执行到相应函数时脚本会停止运行。**
|
**自动操作的函数都需要开启"无障碍服务"才能执行,否则执行到相应函数时脚本会停止运行。**
|
||||||
### auto模式
|
### auto模式
|
||||||
如果代码的第一行是
|
如果代码的第一行是
|
||||||
```
|
```
|
||||||
"auto";
|
"auto";
|
||||||
```
|
```
|
||||||
那么脚本运行前会先确保自动操作服务已开启。
|
那么脚本运行前会先确保无障碍操作服务已开启。如果服务没有开启,则尝试用root权限开启服务并继续运行脚本,或没有root权限时停止运行脚本并跳转到服务开启界面。
|
||||||
|
|
||||||
|
注意,由于这个语句在必须在第一行(包括注释),因此使用起来比较不方便,已经被auto()函数代替。
|
||||||
|
|
||||||
|
您可以在设置中开启"使用Root权限自动开启自动无障碍服务",从而在运行到相应语句时可以自动开启。
|
||||||
|
|
||||||
|
### auto(\[mode = "normal"\])
|
||||||
|
* mode \<String\> 获取屏幕上控件时所使用的模式,包括:
|
||||||
|
* normal 正常模式
|
||||||
|
* fast 快速模式
|
||||||
|
|
||||||
|
确保无障碍服务开启,这个函数的行为与在代码第一行加上`"auto";`是一样的。同时可以指定参数mode。
|
||||||
|
|
||||||
|
fast模式对自动操作的脚本执行速度有一定提高,但可能造成脚本运行不稳定。
|
||||||
|
|
||||||
您也可以在设置中开启"使用Root权限自动开启自动操作服务",从而在运行到相应语句时可以自动开启。
|
|
||||||
### click(text[, i])
|
### click(text[, i])
|
||||||
* text \<String\> 要点击的区域的文本
|
* text \<String\> 要点击的区域的文本
|
||||||
* i \<Number\> 如果相同的文本在屏幕中出现多次,则i表示要点击第几个文本
|
* i \<Number\> 如果相同的文本在屏幕中出现多次,则i表示要点击第几个文本
|
||||||
@@ -62,22 +74,22 @@ while(!click("扫一扫"));
|
|||||||
|
|
||||||
|
|
||||||
### back()
|
### back()
|
||||||
模拟按下返回键
|
模拟按下返回键。返回是否执行成功。
|
||||||
|
|
||||||
### home()
|
### home()
|
||||||
模拟按下Home键
|
模拟按下Home键。返回是否执行成功。
|
||||||
|
|
||||||
### powerDialog()
|
### powerDialog()
|
||||||
弹出电源键菜单
|
弹出电源键菜单。返回是否执行成功。
|
||||||
|
|
||||||
### notifications()
|
### notifications()
|
||||||
弹出通知栏
|
弹出通知栏。返回是否执行成功。
|
||||||
|
|
||||||
### quickSettings()
|
### quickSettings()
|
||||||
显示快速设置(下拉通知栏到底)
|
显示快速设置(下拉通知栏到底)。返回是否执行成功。
|
||||||
|
|
||||||
### recents()
|
### recents()
|
||||||
显示最近任务
|
显示最近任务。返回是否执行成功。
|
||||||
|
|
||||||
### splitScreen()
|
### splitScreen()
|
||||||
分屏
|
分屏。返回是否执行成功。
|
||||||
|
|||||||
@@ -9,6 +9,12 @@
|
|||||||
|
|
||||||
## 简介
|
## 简介
|
||||||
|
|
||||||
|
选择器是书写稍微复杂的自动操作脚本所必须。使用选择器的一般步骤是:
|
||||||
|
1. 用各种筛选条件找出想要的控件,如某个文本控件、列表控件、图片控件
|
||||||
|
2. 对找出的控件执行想要的操作,如点击、滑动、设置文字、长按
|
||||||
|
|
||||||
|
问题的关键在于如何找出想要的控件。对于文本控件一般通过他的文字来定位他,图片控件则通过id或者图片描述(desc)。选择器所做的就是提供这些筛选条件并给出筛选结果。
|
||||||
|
|
||||||
选择器提供了更强大的定位界面控件与对其进行操作的功能,可以用他们完成更多的自动操作和提取界面信息。
|
选择器提供了更强大的定位界面控件与对其进行操作的功能,可以用他们完成更多的自动操作和提取界面信息。
|
||||||
选择器通过附加筛选条件,筛选出符合条件的控件或控件集合,之后可以对这些控件这些操作。
|
选择器通过附加筛选条件,筛选出符合条件的控件或控件集合,之后可以对这些控件这些操作。
|
||||||
可供选择的筛选条件包括:
|
可供选择的筛选条件包括:
|
||||||
@@ -42,10 +48,13 @@ emoj.click();
|
|||||||
id("name").packageName("com.tencent.mobileqq").clickable()
|
id("name").packageName("com.tencent.mobileqq").clickable()
|
||||||
.className("ImageView").click();
|
.className("ImageView").click();
|
||||||
```
|
```
|
||||||
|
|
||||||
|
这段代码意思是,找出id为"name", 包名为"com.tentcent.mobileqq",类名为ImageView的所有可点击控件,对他们执行点击动作。
|
||||||
|
|
||||||
最后的click()函数相当于untilFind().click()。也就是如果只需要在找到控件以后立即进行操作,只需要调用相应的操作函数,而不需要先调用find等函数等到控件再操作。
|
最后的click()函数相当于untilFind().click()。也就是如果只需要在找到控件以后立即进行操作,只需要调用相应的操作函数,而不需要先调用find等函数等到控件再操作。
|
||||||
要获取屏幕上的控件的信息(例如id, text, desc, bounds等),可以开启悬浮窗,使用界面层次查看和界面范围查看。
|
要获取屏幕上的控件的信息(例如id, text, desc, bounds等),可以开启悬浮窗,使用界面层次查看和界面范围查看。
|
||||||
|
|
||||||
因为选择器部分内容如果有安卓开发经验会更容易掌握,因而更适合UI测试。
|
选择器部分内容如果有安卓开发经验会更容易掌握。
|
||||||
|
|
||||||
# 选择器
|
# 选择器
|
||||||
|
|
||||||
@@ -56,13 +65,15 @@ id("name").packageName("com.tencent.mobileqq").clickable()
|
|||||||
|
|
||||||
附加id严格匹配筛选条件。
|
附加id严格匹配筛选条件。
|
||||||
|
|
||||||
|
控件的id属性通常是可以用来确定控件的唯一标识,如果一个控件有id,那么使用id来找到他是最好的方法。要查看屏幕上的控件的id,可以开启悬浮窗并使用界面工具,点击相应控件即可查看。若查看到的控件id为null, 表示该控件没有id。另外,在列表中会出现多个控件的id相同的情况。例如微信的联系人列表,每个头像的id都是一样的。此时不能用id来唯一确定控件。
|
||||||
|
|
||||||
|
在QQ界面经常会出现多个id为"name"的控件,在微信上则每个版本的id都会变化。对于这些软件而言比较难用id定位控件。
|
||||||
|
|
||||||
### idContains(str)
|
### idContains(str)
|
||||||
* str \<Regex\> id要包含的字符串
|
* str \<String\> id要包含的字符串
|
||||||
|
|
||||||
附加控件id包含字符串str的筛选条件。
|
附加控件id包含字符串str的筛选条件。
|
||||||
|
|
||||||
> 控件的id属性通常是可以用来确定控件的唯一标识,如果一个控件有id,那么使用id来找到他是最好的方法。要查看屏幕上的控件的id,可以开启悬浮窗并使用界面工具,点击相应控件即可查看。若查看到的控件id为null, 表示该控件没有id。另外,在列表中会出现多个控件的id相同的情况。例如微信的联系人列表,每个头像的id都是一样的。此时不能用id来唯一确定控件。
|
|
||||||
|
|
||||||
### idStartsWith(prefix)
|
### idStartsWith(prefix)
|
||||||
* prefix \<String\> id前缀
|
* prefix \<String\> id前缀
|
||||||
|
|
||||||
@@ -73,17 +84,22 @@ id("name").packageName("com.tencent.mobileqq").clickable()
|
|||||||
|
|
||||||
附加id需要以suffix结束的筛选条件。
|
附加id需要以suffix结束的筛选条件。
|
||||||
|
|
||||||
### idMatches(regex)
|
### idMatches(String)
|
||||||
* regex \<Regex\> id要满足的正则表达式
|
* String \<String\> id要满足的正则表达式
|
||||||
|
|
||||||
附加id需要满足正则表达式。有关正则表达式,可以查看[菜鸟教程](http://www.runoob.com/regexp/regexp-example.html)。
|
附加id需要满足正则表达式。有关正则表达式,可以查看[菜鸟教程](http://www.runoob.com/Stringp/Stringp-example.html)。
|
||||||
|
|
||||||
|
这里的正则表达式是Java的正则表达式,不能直接使用JavaScript的正则表达式。
|
||||||
|
```
|
||||||
|
idMatches("[a-zA-Z]+")
|
||||||
|
```
|
||||||
|
|
||||||
### text(str)
|
### text(str)
|
||||||
* str \<String\> 控件文本
|
* str \<String\> 控件文本
|
||||||
|
|
||||||
附加控件文本等于字符串str的筛选条件。
|
附加控件文本等于字符串str的筛选条件。
|
||||||
|
|
||||||
> 控件的text(文本)属性是控件上的显示的文字,例如微信左上角的"微信"文本。对于图片或者其他控件通常text属性为null。
|
控件的text(文本)属性是控件上的显示的文字,例如微信左上角的"微信"文本。对于图片或者其他控件通常text属性为null。
|
||||||
|
|
||||||
### textContains(str)
|
### textContains(str)
|
||||||
|
|
||||||
@@ -103,7 +119,7 @@ id("name").packageName("com.tencent.mobileqq").clickable()
|
|||||||
附加控件文本需要以suffix结束的筛选条件。
|
附加控件文本需要以suffix结束的筛选条件。
|
||||||
|
|
||||||
### textMatches(str)
|
### textMatches(str)
|
||||||
* regex \<Regex\> 要满足的正则表达式
|
* String \<String\> 要满足的正则表达式
|
||||||
|
|
||||||
附加控件文本需要满足正则表达式的条件。
|
附加控件文本需要满足正则表达式的条件。
|
||||||
|
|
||||||
@@ -112,7 +128,9 @@ id("name").packageName("com.tencent.mobileqq").clickable()
|
|||||||
|
|
||||||
附加控件描述等于字符串str的筛选条件。
|
附加控件描述等于字符串str的筛选条件。
|
||||||
|
|
||||||
> 控件的desc(描述,全称为Content-Description)属性是对一个控件的描述,例如网易云音乐右上角的放大镜图标的描述为搜索。要查看一个控件的描述,同样地可以借助悬浮窗查看。
|
控件的desc(描述,全称为Content-Description)属性是对一个控件的描述,例如网易云音乐右上角的放大镜图标的描述为搜索。要查看一个控件的描述,同样地可以借助悬浮窗查看。
|
||||||
|
|
||||||
|
desc属性同样是定位控件的利器。
|
||||||
|
|
||||||
### descContains(str)
|
### descContains(str)
|
||||||
|
|
||||||
@@ -132,7 +150,7 @@ id("name").packageName("com.tencent.mobileqq").clickable()
|
|||||||
附加控件描述需要以suffix结束的筛选条件。
|
附加控件描述需要以suffix结束的筛选条件。
|
||||||
|
|
||||||
### descMatches(str)
|
### descMatches(str)
|
||||||
* regex \<Regex\> 要满足的正则表达式
|
* String \<String\> 要满足的正则表达式
|
||||||
|
|
||||||
附加控件描述需要满足正则表达式的条件。
|
附加控件描述需要满足正则表达式的条件。
|
||||||
|
|
||||||
@@ -141,7 +159,7 @@ id("name").packageName("com.tencent.mobileqq").clickable()
|
|||||||
|
|
||||||
附加控件类名等于字符串str的筛选条件。
|
附加控件类名等于字符串str的筛选条件。
|
||||||
|
|
||||||
> 控件的className属性是一个控件的具体类型,例如图片控件通常为ImageView,文本控件通常为TextView, 输入框通常为EditText。(若一个控件是在android.widget包里的,那么android.widget可以省略。但除此之外的其他控件必须是类的全名,例如"com.stardust.theme.ThemeColorImageView")。
|
控件的className属性是一个控件的具体类型,例如图片控件通常为ImageView,文本控件通常为TextView, 输入框通常为EditText。(若一个控件是在android.widget包里的,那么android.widget可以省略。但除此之外的其他控件必须是类的全名,例如"com.stardust.theme.ThemeColorImageView")。
|
||||||
|
|
||||||
### classNameContains(str)
|
### classNameContains(str)
|
||||||
|
|
||||||
@@ -161,7 +179,7 @@ id("name").packageName("com.tencent.mobileqq").clickable()
|
|||||||
附加控件类名需要以suffix结束的筛选条件。
|
附加控件类名需要以suffix结束的筛选条件。
|
||||||
|
|
||||||
### classNameMatches(str)
|
### classNameMatches(str)
|
||||||
* regex \<Regex\> 要满足的正则表达式
|
* String \<String\> 要满足的正则表达式
|
||||||
|
|
||||||
附加控件类名需要满足正则表达式的条件。
|
附加控件类名需要满足正则表达式的条件。
|
||||||
|
|
||||||
@@ -170,7 +188,7 @@ id("name").packageName("com.tencent.mobileqq").clickable()
|
|||||||
|
|
||||||
附加包名等于字符串str的筛选条件。
|
附加包名等于字符串str的筛选条件。
|
||||||
|
|
||||||
> packageName属性也即控件所属的应用的包名(参见《shell命令:应用包名》),通常用来保证当前运行的应用是想要的应用。
|
packageName属性也即控件所属的应用的包名(参见《shell命令:应用包名》),通常用来保证当前运行的应用是想要的应用。
|
||||||
|
|
||||||
### packageNameContains(str)
|
### packageNameContains(str)
|
||||||
|
|
||||||
@@ -190,7 +208,7 @@ id("name").packageName("com.tencent.mobileqq").clickable()
|
|||||||
附加包名需要以suffix结束的筛选条件。
|
附加包名需要以suffix结束的筛选条件。
|
||||||
|
|
||||||
### packageNameMatches(str)
|
### packageNameMatches(str)
|
||||||
* regex \<Regex\> 要满足的正则表达式
|
* String \<String\> 要满足的正则表达式
|
||||||
|
|
||||||
附加包名需要满足正则表达式的条件。
|
附加包名需要满足正则表达式的条件。
|
||||||
|
|
||||||
@@ -205,52 +223,52 @@ id("name").packageName("com.tencent.mobileqq").clickable()
|
|||||||
### drawingOrder(order)
|
### drawingOrder(order)
|
||||||
* order \<Number\> 控件在父视图中的绘制顺序,在一些
|
* order \<Number\> 控件在父视图中的绘制顺序,在一些
|
||||||
|
|
||||||
### checkable(b = true)
|
### checkable(\[b = true\])
|
||||||
* b \<Boolean\> 表示控件是否可勾选, 默认为true
|
* b \<Boolean\> 表示控件是否可勾选, 默认为true
|
||||||
|
|
||||||
附加控件是否可勾选的条件。可勾选指的是,例如QQ和微信发送图片时图片的勾选。
|
附加控件是否可勾选的条件。可勾选指的是,例如QQ和微信发送图片时图片的勾选。
|
||||||
|
|
||||||
### selected(b = true)
|
### selected(\[b = true\])
|
||||||
* b \<Boolean\> 表示控件是否被选中,默认为true
|
* b \<Boolean\> 表示控件是否被选中,默认为true
|
||||||
|
|
||||||
附加控件是否被选中的条件。被选中指的是,例如QQ聊天界面点击下方的表情按钮时,会出现自己收藏的表情,这时表情按钮便处于选中状态。
|
附加控件是否被选中的条件。被选中指的是,例如QQ聊天界面点击下方的表情按钮时,会出现自己收藏的表情,这时表情按钮便处于选中状态。
|
||||||
|
|
||||||
### clickable(b = true)
|
### clickable(\[b = true\])
|
||||||
* b \<Boolean\> 表示控件是否可点击, 默认为true
|
* b \<Boolean\> 表示控件是否可点击, 默认为true
|
||||||
|
|
||||||
附加控件是否可点击的条件。但并非所有clickable为false的控件都真的不能点击,这取决于控件的实现。因而要确定一个控件的clickable属性,可以开启悬浮窗工具。
|
附加控件是否可点击的条件。但并非所有clickable为false的控件都真的不能点击,这取决于控件的实现。因而要确定一个控件的clickable属性,可以开启悬浮窗工具。
|
||||||
|
|
||||||
### longClickable(b = true)
|
### longClickable(\[b = true\])
|
||||||
* b \<Boolean\> 表示控件是否可长按, 默认为true
|
* b \<Boolean\> 表示控件是否可长按, 默认为true
|
||||||
|
|
||||||
附加控件是否可长按的条件。
|
附加控件是否可长按的条件。
|
||||||
|
|
||||||
### enabled(b = true)
|
### enabled(\[b = true\])
|
||||||
* b \<Boolean\> 表示控件是否已启用, 默认为true
|
* b \<Boolean\> 表示控件是否已启用, 默认为true
|
||||||
|
|
||||||
附加控件是否已启用的条件。大多数控件都是启用的状态,处于“禁用”状态通常是灰色并且不可点击。
|
附加控件是否已启用的条件。大多数控件都是启用的状态,处于“禁用”状态通常是灰色并且不可点击。
|
||||||
|
|
||||||
### scrollable(b = true)
|
### scrollable(\[b = true\])
|
||||||
* b \<Boolean\> 表示控件是否可滑动, 默认为true
|
* b \<Boolean\> 表示控件是否可滑动, 默认为true
|
||||||
|
|
||||||
附加控件是否可滑动的条件。
|
附加控件是否可滑动的条件。
|
||||||
|
|
||||||
### editable(b = true)
|
### editable(\[b = true\])
|
||||||
* b \<Boolean\> 表示控件是否可编辑, 默认为true
|
* b \<Boolean\> 表示控件是否可编辑, 默认为true
|
||||||
|
|
||||||
附加控件是否可编辑的条件。一般来说可编辑的控件为输入框(EditText)。
|
附加控件是否可编辑的条件。一般来说可编辑的控件为输入框(EditText)。
|
||||||
|
|
||||||
### contentInvalid(b = true)
|
### contentInvalid(\[b = true\])
|
||||||
* b \<Boolean\> 表示控件是否是contentInvalid, 默认为true
|
* b \<Boolean\> 表示控件是否是contentInvalid, 默认为true
|
||||||
|
|
||||||
我也不知道是什么,下次再补充吧。
|
我也不知道是什么,下次再补充吧。
|
||||||
|
|
||||||
### contextClickable(b = true)
|
### contextClickable(\[b = true\])
|
||||||
* b \<Boolean\> 表示控件是否是contextClickable, 默认为true
|
* b \<Boolean\> 表示控件是否是contextClickable, 默认为true
|
||||||
|
|
||||||
我也不知道是什么,下次再补充吧。
|
我也不知道是什么,下次再补充吧。
|
||||||
|
|
||||||
### multiLine(b = true)
|
### multiLine(\[b = true\])
|
||||||
* b \<Boolean\> 表示文本或输入框控件是否是多行显示的, 默认为true
|
* b \<Boolean\> 表示文本或输入框控件是否是多行显示的, 默认为true
|
||||||
|
|
||||||
附加控件是否文本或输入框控件是否是多行显示的条件。
|
附加控件是否文本或输入框控件是否是多行显示的条件。
|
||||||
@@ -263,59 +281,85 @@ id("name").packageName("com.tencent.mobileqq").clickable()
|
|||||||
### find()
|
### find()
|
||||||
根据当前的选择器所确定的筛选条件,对屏幕上的控件进行搜索,找到所有满足条件的控件集合并返回。这个搜索只进行一次,并不保证一直会找到,因而会出现返回的控件集合为空的情况。参见[控件集合](#控件集合)。
|
根据当前的选择器所确定的筛选条件,对屏幕上的控件进行搜索,找到所有满足条件的控件集合并返回。这个搜索只进行一次,并不保证一直会找到,因而会出现返回的控件集合为空的情况。参见[控件集合](#控件集合)。
|
||||||
|
|
||||||
|
可以通过empty()或nonEmpty()函数判断找到的是否为空。例如:
|
||||||
|
```
|
||||||
|
var c = className("AbsListView").find();
|
||||||
|
if(c.empty()){
|
||||||
|
toast("找到啦");
|
||||||
|
}else{
|
||||||
|
toast("没找到╭(╯^╰)╮");
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### untilFind()
|
### untilFind()
|
||||||
根据当前的选择器所确定的筛选条件,对屏幕上的控件进行搜索,直到找到至少一个满足条件的控件为止,并返回所有满足条件的控件集合。参见[控件集合](#控件集合)。
|
根据当前的选择器所确定的筛选条件,对屏幕上的控件进行搜索,直到找到至少一个满足条件的控件为止,并返回所有满足条件的控件集合。参见[控件集合](#控件集合)。
|
||||||
|
|
||||||
|
### exists()
|
||||||
|
判断屏幕上是否存在控件符合选择器所确定的条件。例如要判断某个文本出现就执行某个动作,可以用:
|
||||||
|
```
|
||||||
|
if(text("嘿嘿嘿").exists()){
|
||||||
|
//嘿嘿嘿
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### waitFor()
|
||||||
|
等待屏幕上出现符合条件的控件。
|
||||||
|
```
|
||||||
|
text("嘿嘿嘿").waitFor();
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## 操作
|
## 操作
|
||||||
|
|
||||||
### click()
|
### click()
|
||||||
找到所有符合条件的控件并点击。相当于untilFind().click()。参见[click](#UiCollection.click)。
|
找到所有符合条件的控件并点击。相当于untilFind().click()。参见[click](#UiCollection.click())。
|
||||||
|
|
||||||
### longClick()
|
### longClick()
|
||||||
找到所有符合条件的控件并长按。相当于untilFind().longClick()。参见[longClick](#UiCollection.longClick)。
|
找到所有符合条件的控件并长按。相当于untilFind().longClick()。参见[longClick](#UiCollection.longClick())。
|
||||||
|
|
||||||
### copy()
|
### copy()
|
||||||
找到所有符合条件的控件并复制其内容,只对文本框或输入框控件有文字选中时有效。相当于untilFind().copy()。参见[copy](#UiCollection.copy)。
|
找到所有符合条件的控件并复制其内容,只对文本框或输入框控件有文字选中时有效。相当于untilFind().copy()。参见[copy](#UiCollection.copy())。
|
||||||
|
|
||||||
### paste()
|
### paste()
|
||||||
找到所有符合条件的控件并粘贴,只对输入框控件有效。相当于untilFind().paste()。参见[paste](#UiCollection.paste)。
|
找到所有符合条件的控件并粘贴,只对输入框控件有效。相当于untilFind().paste()。参见[paste](#UiCollection.paste())。
|
||||||
|
|
||||||
### select()
|
### select()
|
||||||
找到所有符合条件的控件并选中。相当于untilFind().select()。参见[select](#UiCollection.select)。
|
找到所有符合条件的控件并选中。相当于untilFind().select()。参见[select](#UiCollection.select())。
|
||||||
|
|
||||||
### cut()
|
### cut()
|
||||||
找到所有符合条件的控件并剪切其内容,只对文本框或输入框控件有文字选中时有效。相当于untilFind().cut()。参见[cut](#UiCollection.cut)。
|
找到所有符合条件的控件并剪切其内容,只对文本框或输入框控件有文字选中时有效。相当于untilFind().cut()。参见[cut](#UiCollection.cut())。
|
||||||
|
|
||||||
### collapse()
|
### collapse()
|
||||||
找到所有符合条件的控件并折叠。相当于untilFind().collapse()。参见[collapse](#UiCollection.collapse)。
|
找到所有符合条件的控件并折叠。相当于untilFind().collapse()。参见[collapse](#UiCollection.collapse())。
|
||||||
|
|
||||||
### expand()
|
### expand()
|
||||||
找到所有符合条件的控件并展开。相当于untilFind().expand()。参见[expand](#UiCollection.expand)。
|
找到所有符合条件的控件并展开。相当于untilFind().expand()。参见[expand](#UiCollection.expand())。
|
||||||
|
|
||||||
### show()
|
### show()
|
||||||
找到所有符合条件的控件并使其出现在屏幕上。相当于untilFind().show()。参见[show](#UiCollection.show)。
|
找到所有符合条件的控件并使其出现在屏幕上。相当于untilFind().show()。参见[show](#UiCollection.show())。
|
||||||
|
|
||||||
### scrollForward()
|
### scrollForward()
|
||||||
找到所有符合条件的控件并向前滑。相当于untilFind().scrollForward()。参见[scrollForward](#UiCollection.scrollForward)。
|
找到所有符合条件的控件并向前滑。相当于untilFind().scrollForward()。参见[scrollForward](#UiCollection.scrollForward())。
|
||||||
向前滑指的是,对于左右滑动的控件向右滑,上下滑动的控件向下滑。
|
向前滑指的是,对于左右滑动的控件向右滑,上下滑动的控件向下滑。
|
||||||
|
|
||||||
### scrollBackward()
|
### scrollBackward()
|
||||||
找到所有符合条件的控件并向后滑。相当于untilFind().scrollBackward()。参见[scrollBackward](#UiCollection.scrollBackward)。
|
找到所有符合条件的控件并向后滑。相当于untilFind().scrollBackward()。参见[scrollBackward](#UiCollection.scrollBackward())。
|
||||||
向后滑指的是,对于左右滑动的控件向左滑,上下滑动的控件向上滑。
|
向后滑指的是,对于左右滑动的控件向左滑,上下滑动的控件向上滑。
|
||||||
|
|
||||||
### scrollUp()
|
### scrollUp()
|
||||||
找到所有符合条件的控件并向上滑。相当于untilFind().scrollUp()。参见[scrollUp](#UiCollection.scrollUp)。
|
找到所有符合条件的控件并向上滑。相当于untilFind().scrollUp()。参见[scrollUp](#UiCollection.scrollUp())。
|
||||||
|
|
||||||
### scrollDown()
|
### scrollDown()
|
||||||
找到所有符合条件的控件并向下滑。相当于untilFind().scrollDown()。参见[scrollDown](#UiCollection.scrollDown)。
|
找到所有符合条件的控件并向下滑。相当于untilFind().scrollDown()。参见[scrollDown](#UiCollection.scrollDown())。
|
||||||
|
|
||||||
### scrollLeft()
|
### scrollLeft()
|
||||||
找到所有符合条件的控件并向左滑。相当于untilFind().scrollLeft()。参见[scrollLeft](#UiCollection.scrollLeft)。
|
找到所有符合条件的控件并向左滑。相当于untilFind().scrollLeft()。参见[scrollLeft](#UiCollection.scrollLeft())。
|
||||||
|
|
||||||
### scrollRight()
|
### scrollRight()
|
||||||
找到所有符合条件的控件并向右滑。相当于untilFind().scrollRight()。参见[scrollRight](#UiCollection.scrollRight)。
|
找到所有符合条件的控件并向右滑。相当于untilFind().scrollRight()。参见[scrollRight](#UiCollection.scrollRight())。
|
||||||
|
|
||||||
### contextClick()
|
### contextClick()
|
||||||
|
\\\\文档缺失
|
||||||
|
|
||||||
### setSelection(start, end)
|
### setSelection(start, end)
|
||||||
* start \<Number\> 文字选中开始位置
|
* start \<Number\> 文字选中开始位置
|
||||||
@@ -349,10 +393,30 @@ c.each(function(o){
|
|||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### empty()
|
||||||
|
返回控件集合是否为空。
|
||||||
|
|
||||||
|
### nonEmpty()
|
||||||
|
返回控件集合是否非空。
|
||||||
|
|
||||||
|
### filter(filter)
|
||||||
|
* filter \<Function\> 过滤函数。参数为UiObject,返回值为Boolean。
|
||||||
|
|
||||||
|
过滤出控件集合中符合条件的子控件。例如要过滤出所有子控件数目为1的控件为:
|
||||||
|
```
|
||||||
|
var newCollection = collection.filter(function(obj){
|
||||||
|
return obj.childCount() == 1;
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
### find(selector)
|
### find(selector)
|
||||||
* selector \<UiSelector\> 选择器
|
* selector \<UiSelector\> 选择器
|
||||||
|
|
||||||
根据selector所确定的条件在该控件集合中找到所有符合条件的控件并返回控件集合。例如:
|
根据selector所确定的条件在该控件集合的控件和**子控件**找到所有符合条件的控件并返回控件集合。
|
||||||
|
|
||||||
|
注意这会递归地遍历控件集合里所有的控件以及他们的子控件。和filter函数不同。
|
||||||
|
|
||||||
|
例如:
|
||||||
```
|
```
|
||||||
var names = id("name");
|
var names = id("name");
|
||||||
var clickableNames = names.find(clickable());
|
var clickableNames = names.find(clickable());
|
||||||
@@ -433,4 +497,77 @@ UiObject, 选择器的findOne方法返回的对象。和UiCollection有相似的
|
|||||||
返回父控件(UiObject)。
|
返回父控件(UiObject)。
|
||||||
|
|
||||||
### children()
|
### children()
|
||||||
返回该控件的所有子控件组成的控件集合。
|
返回该控件的所有子控件组成的控件集合。
|
||||||
|
|
||||||
|
### childCount()
|
||||||
|
返回子控件数目。
|
||||||
|
|
||||||
|
### bounds()
|
||||||
|
返回控件在屏幕上的范围,其值是一个\[Rect\]对象。
|
||||||
|
|
||||||
|
### boundsInParent()
|
||||||
|
返回控件在父控件中的范围,其值是一个\[Rect\]对象。
|
||||||
|
|
||||||
|
### drawingOrder()
|
||||||
|
返回控件的绘制次序。
|
||||||
|
|
||||||
|
### id()
|
||||||
|
返回控件的id,可能为null。
|
||||||
|
|
||||||
|
### text()
|
||||||
|
返回控件的文本,如果控件没有文本,返回""。
|
||||||
|
|
||||||
|
### findByText(text)
|
||||||
|
* text \<String\> 文本
|
||||||
|
|
||||||
|
根据文本text在子控件中递归地寻找并返回文本或描述(desc)**包含**这段文本text的控件,返回它们组成的集合。。
|
||||||
|
|
||||||
|
### find(selector)
|
||||||
|
* selector \<UiSelector\> 选择器
|
||||||
|
|
||||||
|
根据选择器selector在子控件中递归地寻找符合条件的控件,返回它们组成的集合。
|
||||||
|
|
||||||
|
### findOne
|
||||||
|
|
||||||
|
### find(selector)
|
||||||
|
* selector \<UiSelector\> 选择器
|
||||||
|
|
||||||
|
根据选择器selector在子控件中递归地寻找一个符合条件的控件。找不到则返回null。
|
||||||
|
|
||||||
|
# Rect
|
||||||
|
|
||||||
|
UiObject.bounds(), UiObject.boundsInParent()返回的对象。表示一个长方形。
|
||||||
|
|
||||||
|
### Rect.left
|
||||||
|
长方形左边界的x坐标、
|
||||||
|
|
||||||
|
### Rect.right
|
||||||
|
长方形左边界的x坐标、
|
||||||
|
|
||||||
|
### Rect.top
|
||||||
|
长方形上边界的y坐标、
|
||||||
|
|
||||||
|
### Rect.bottom
|
||||||
|
长方形下边界的y坐标、
|
||||||
|
|
||||||
|
### Rect.centerX()
|
||||||
|
长方形中点x坐标。
|
||||||
|
|
||||||
|
### Rect.centerY()
|
||||||
|
长方形中点y坐标。
|
||||||
|
|
||||||
|
### Rect.width()
|
||||||
|
长方形宽度。通常可以作为控件宽度。
|
||||||
|
|
||||||
|
### Rect.height()
|
||||||
|
长方形高度。通常可以作为控件高度。
|
||||||
|
|
||||||
|
### Rect.contains(r)
|
||||||
|
* r \<Rect\>
|
||||||
|
|
||||||
|
返回是否包含另一个长方形r。
|
||||||
|
|
||||||
|
### Rect.intersect(r)
|
||||||
|
* r \<Rect\>
|
||||||
|
|
||||||
|
返回是否和另一个长方形相交。
|
||||||
|
|||||||
@@ -1,12 +1,41 @@
|
|||||||
以下函数均需要root权限,可以实现任意位置的点击、滑动、长按、模拟物理按键等。
|
以下函数均需要root权限,可以实现任意位置的点击、滑动、长按、模拟物理按键等。
|
||||||
|
|
||||||
这些函数通常首字母大写以表示其特殊的权限。
|
这些函数通常首字母大写以表示其特殊的权限。
|
||||||
函数是返回值均是一个布尔值。true表示成功,false表示失败。一般而言,只有没有root权限时才会运行失败。
|
这些函数均不返回任何值。
|
||||||
|
并且,这些函数的执行是异步的、非实时的,在不同机型上所用的时间不同。脚本不会等待动作执行完成才继续执行。因此最好在每个函数之后加上适当的sleep来达到期望的效果。
|
||||||
|
|
||||||
|
例如:
|
||||||
|
```
|
||||||
|
Tap(100, 100);
|
||||||
|
sleep(500);
|
||||||
|
```
|
||||||
|
|
||||||
|
注意,动作的执行可能无法被停止,例如:
|
||||||
|
```
|
||||||
|
for(var i = 0; i < 100; i++){
|
||||||
|
Tap(100, 100);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
这段代码执行后可能会出现在任务管理中停止脚本后点击仍然继续的情况。
|
||||||
|
因此,强烈建议在每个动作后加上延时:
|
||||||
|
```
|
||||||
|
for(var i = 0; i < 100; i++){
|
||||||
|
Tap(100, 100);
|
||||||
|
sleep(500);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### Tap(x, y)
|
### Tap(x, y)
|
||||||
|
* x, y \<Number\> 要点击的坐标。
|
||||||
|
|
||||||
点击位置(x, y), 您可以通过"开发者选项"开启指针位置来确定点击坐标。
|
点击位置(x, y), 您可以通过"开发者选项"开启指针位置来确定点击坐标。
|
||||||
|
|
||||||
### Swipe(x1, y1, x2, y2, \[delay\])
|
### Swipe(x1, y1, x2, y2, \[duration\])
|
||||||
|
* x1, y1 \<Number\> 滑动起点的坐标
|
||||||
|
* x2, y2 \<Number\> 滑动终点的坐标
|
||||||
|
* duration \<Number\> 滑动动作所用的时间
|
||||||
|
|
||||||
滑动。从(x1, y1)位置滑动到(x2, y2)位置。
|
滑动。从(x1, y1)位置滑动到(x2, y2)位置。
|
||||||
|
|
||||||
### Home()
|
### Home()
|
||||||
|
|||||||
14
app/src/main/assets/sample/图片与图色处理/实时显示触摸点颜色.js
Normal file
14
app/src/main/assets/sample/图片与图色处理/实时显示触摸点颜色.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
requestScreenCapture();
|
||||||
|
console.show();
|
||||||
|
events.observeTouch();
|
||||||
|
events.setTouchEventTimeout(30);
|
||||||
|
events.on("touch", function(point){
|
||||||
|
var img = captureScreen();
|
||||||
|
if(img == null){
|
||||||
|
var c = null;
|
||||||
|
}else{
|
||||||
|
var c = colors.toString(images.pixel(captureScreen(), point.x, point.y);
|
||||||
|
}
|
||||||
|
log("(" + point.x + ", " + point.y + "): " + c);
|
||||||
|
log("");
|
||||||
|
});
|
||||||
@@ -5,13 +5,19 @@ import android.net.Uri;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.webkit.MimeTypeMap;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.stardust.scriptdroid.ui.BaseActivity;
|
import com.stardust.scriptdroid.ui.BaseActivity;
|
||||||
|
import com.stardust.scriptdroid.ui.common.ScriptOperations;
|
||||||
import com.stardust.scriptdroid.ui.main.MainActivity;
|
import com.stardust.scriptdroid.ui.main.MainActivity;
|
||||||
import com.stardust.scriptdroid.R;
|
import com.stardust.scriptdroid.R;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import io.reactivex.annotations.NonNull;
|
||||||
|
import io.reactivex.functions.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Stardust on 2017/2/2.
|
* Created by Stardust on 2017/2/2.
|
||||||
@@ -22,20 +28,14 @@ public class ImportIntentActivity extends BaseActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
try {
|
onNewIntent(getIntent());
|
||||||
handleIntent(getIntent());
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
Toast.makeText(this, R.string.edit_and_run_handle_intent_error, Toast.LENGTH_LONG).show();
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNewIntent(Intent intent) {
|
protected void onNewIntent(Intent intent) {
|
||||||
try {
|
try {
|
||||||
handleIntent(intent);
|
handleIntent(intent);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Toast.makeText(this, R.string.edit_and_run_handle_intent_error, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, R.string.edit_and_run_handle_intent_error, Toast.LENGTH_LONG).show();
|
||||||
finish();
|
finish();
|
||||||
@@ -45,14 +45,28 @@ public class ImportIntentActivity extends BaseActivity {
|
|||||||
private void handleIntent(Intent intent) throws FileNotFoundException {
|
private void handleIntent(Intent intent) throws FileNotFoundException {
|
||||||
Uri uri = intent.getData();
|
Uri uri = intent.getData();
|
||||||
if (uri != null && "content".equals(uri.getScheme())) {
|
if (uri != null && "content".equals(uri.getScheme())) {
|
||||||
MainActivity.importScriptFileByInputStream(this, getContentResolver().openInputStream(uri));
|
InputStream stream = getContentResolver().openInputStream(uri);
|
||||||
|
new ScriptOperations(this, null)
|
||||||
|
.importFile("", stream)
|
||||||
|
.subscribe(new Consumer<String>() {
|
||||||
|
@Override
|
||||||
|
public void accept(@NonNull String s) throws Exception {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
final String path = intent.getData().getPath();
|
final String path = intent.getData().getPath();
|
||||||
if (!TextUtils.isEmpty(path)) {
|
if (!TextUtils.isEmpty(path)) {
|
||||||
MainActivity.importScriptFile(this, path);
|
new ScriptOperations(this, null)
|
||||||
|
.importFile(path)
|
||||||
|
.subscribe(new Consumer<String>() {
|
||||||
|
@Override
|
||||||
|
public void accept(@NonNull String s) throws Exception {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finish();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -110,6 +110,7 @@ public class HelpCatalogueActivity extends BaseActivity {
|
|||||||
mLoadingIndicatorView.hide();
|
mLoadingIndicatorView.hide();
|
||||||
handleIntent();
|
handleIntent();
|
||||||
}
|
}
|
||||||
|
setToolbarAsBack(mTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readCatalogues() {
|
private void readCatalogues() {
|
||||||
@@ -141,7 +142,6 @@ public class HelpCatalogueActivity extends BaseActivity {
|
|||||||
|
|
||||||
private void setUpUI() {
|
private void setUpUI() {
|
||||||
setContentView(R.layout.activity_help);
|
setContentView(R.layout.activity_help);
|
||||||
setToolbarAsBack(mTitle);
|
|
||||||
setUpRecyclerView();
|
setUpRecyclerView();
|
||||||
setUpLoadingView();
|
setUpLoadingView();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,13 +94,12 @@ public class MainActivity extends BaseActivity implements OnActivityResultDelega
|
|||||||
private OnActivityResultDelegate.Mediator mActivityResultMediator = new OnActivityResultDelegate.Mediator();
|
private OnActivityResultDelegate.Mediator mActivityResultMediator = new OnActivityResultDelegate.Mediator();
|
||||||
private DrawableSaver mDrawerHeaderBackgroundSaver, mAppbarBackgroundSaver;
|
private DrawableSaver mDrawerHeaderBackgroundSaver, mAppbarBackgroundSaver;
|
||||||
private VersionGuard mVersionGuard;
|
private VersionGuard mVersionGuard;
|
||||||
private Intent mIntentToHandle;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
checkPermissions();
|
checkPermissions();
|
||||||
mIntentToHandle = getIntent();
|
|
||||||
EventBus.getDefault().register(this);
|
EventBus.getDefault().register(this);
|
||||||
mVersionGuard = new VersionGuard(this);
|
mVersionGuard = new VersionGuard(this);
|
||||||
showAnnunciationIfNeeded();
|
showAnnunciationIfNeeded();
|
||||||
@@ -200,15 +199,6 @@ public class MainActivity extends BaseActivity implements OnActivityResultDelega
|
|||||||
.build();
|
.build();
|
||||||
mViewPager.setAdapter(mPagerAdapter);
|
mViewPager.setAdapter(mPagerAdapter);
|
||||||
tabLayout.setupWithViewPager(mViewPager);
|
tabLayout.setupWithViewPager(mViewPager);
|
||||||
mPagerAdapter.setOnFragmentInstantiateListener(new FragmentPagerAdapterBuilder.OnFragmentInstantiateListener() {
|
|
||||||
@Override
|
|
||||||
public void OnInstantiate(Fragment fragment) {
|
|
||||||
if (fragment instanceof MyScriptListFragment && mIntentToHandle != null) {
|
|
||||||
handleIntent(mIntentToHandle);
|
|
||||||
mIntentToHandle = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Click(R.id.add)
|
@Click(R.id.add)
|
||||||
@@ -239,7 +229,8 @@ public class MainActivity extends BaseActivity implements OnActivityResultDelega
|
|||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
provider.clearCacheExceptInitialDirectory();
|
provider.clearCacheExceptInitialDirectory();
|
||||||
new ScriptOperations(MainActivity.this, mDrawerLayout)
|
new ScriptOperations(MainActivity.this, mDrawerLayout)
|
||||||
.importFile(file.getPath());
|
.importFile(file.getPath())
|
||||||
|
.subscribe();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.title(R.string.text_please_choose_file_to_import)
|
.title(R.string.text_please_choose_file_to_import)
|
||||||
@@ -289,59 +280,6 @@ public class MainActivity extends BaseActivity implements OnActivityResultDelega
|
|||||||
mVersionGuard.checkDeprecateAndUpdate();
|
mVersionGuard.checkDeprecateAndUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onNewIntent(Intent intent) {
|
|
||||||
super.onNewIntent(intent);
|
|
||||||
handleIntent(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleIntent(Intent intent) {
|
|
||||||
String action = intent.getStringExtra(EXTRA_ACTION);
|
|
||||||
if (action == null)
|
|
||||||
return;
|
|
||||||
switch (action) {
|
|
||||||
|
|
||||||
case ACTION_IMPORT_SCRIPT:
|
|
||||||
handleImportScriptFile(intent);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleImportScriptFile(Intent intent) {
|
|
||||||
String path = intent.getStringExtra(ARGUMENT_PATH);
|
|
||||||
if (path != null) {
|
|
||||||
new ScriptOperations(MainActivity.this, mDrawerLayout)
|
|
||||||
.importFile(intent.getStringExtra(ARGUMENT_PATH))
|
|
||||||
.subscribe();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
InputStream inputStream = IntentExtras.fromIntent(intent).getAndClear(ARGUMENT_INPUT_STREAM);
|
|
||||||
new ScriptOperations(MainActivity.this, mDrawerLayout)
|
|
||||||
.importFile("", inputStream)
|
|
||||||
.subscribe();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void importScriptFile(Context context, String path) {
|
|
||||||
context.startActivity(new Intent(context, MainActivity_.class)
|
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
|
||||||
.putExtra(EXTRA_ACTION, ACTION_IMPORT_SCRIPT)
|
|
||||||
.putExtra(ARGUMENT_PATH, path));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void importScriptFileByInputStream(Context context, InputStream inputStream) {
|
|
||||||
Intent intent = new Intent(context, MainActivity_.class)
|
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
|
||||||
.putExtra(EXTRA_ACTION, ACTION_IMPORT_SCRIPT);
|
|
||||||
IntentExtras.newExtras()
|
|
||||||
.put(ARGUMENT_INPUT_STREAM, inputStream)
|
|
||||||
.putInIntent(intent);
|
|
||||||
context.startActivity(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Click(R.id.toolbar)
|
@Click(R.id.toolbar)
|
||||||
public void OnToolbarClick() {
|
public void OnToolbarClick() {
|
||||||
mAppbarBackgroundSaver.select(this, mActivityResultMediator);
|
mAppbarBackgroundSaver.select(this, mActivityResultMediator);
|
||||||
|
|||||||
@@ -213,6 +213,9 @@
|
|||||||
<string name="text_on_progress">处理中</string>
|
<string name="text_on_progress">处理中</string>
|
||||||
<string name="text_delete_failed">删除失败</string>
|
<string name="text_delete_failed">删除失败</string>
|
||||||
<string name="text_enable_accessibility_service_by_root_ing">正在使用root权限启用无障碍服务</string>
|
<string name="text_enable_accessibility_service_by_root_ing">正在使用root权限启用无障碍服务</string>
|
||||||
|
<string name="text_edit_script">编辑脚本</string>
|
||||||
|
<string name="text_run_script">运行脚本</string>
|
||||||
|
<string name="text_import_script">导入脚本文件</string>
|
||||||
|
|
||||||
|
|
||||||
<string-array name="record_control_keys">
|
<string-array name="record_control_keys">
|
||||||
|
|||||||
@@ -20,6 +20,16 @@
|
|||||||
<item name="windowActionBar">false</item>
|
<item name="windowActionBar">false</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="AppTheme.Transparent" parent="AppTheme">
|
||||||
|
<item name="android:windowIsTranslucent">true</item>
|
||||||
|
<item name="android:windowBackground">@android:color/transparent</item>
|
||||||
|
<item name="android:windowContentOverlay">@null</item>
|
||||||
|
<item name="android:windowNoTitle">true</item>
|
||||||
|
<item name="android:windowIsFloating">true</item>
|
||||||
|
<item name="android:backgroundDimEnabled">false</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
||||||
<style name="MainToolbarTheme" parent="AppTheme">
|
<style name="MainToolbarTheme" parent="AppTheme">
|
||||||
<item name="android:textColorSecondary">#c4c4c4</item>
|
<item name="android:textColorSecondary">#c4c4c4</item>
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,14 @@
|
|||||||
|
package com.stardust.autojs.codegeneration;
|
||||||
|
|
||||||
|
import com.stardust.autojs.runtime.api.UiSelector;
|
||||||
|
import com.stardust.automator.UiGlobalSelector;
|
||||||
|
import com.stardust.automator.UiObject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Stardust on 2017/8/4.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class AutoScriptGenerator {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ package com.stardust.autojs.runtime.api;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import com.stardust.autojs.engine.RootAutomatorEngine;
|
import com.stardust.autojs.engine.RootAutomatorEngine;
|
||||||
|
import com.stardust.autojs.runtime.record.inputevent.InputEventCodes;
|
||||||
import com.stardust.pio.UncheckedIOException;
|
import com.stardust.pio.UncheckedIOException;
|
||||||
import com.stardust.util.ScreenMetrics;
|
import com.stardust.util.ScreenMetrics;
|
||||||
|
|
||||||
@@ -11,6 +12,8 @@ import java.io.File;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static com.stardust.autojs.runtime.record.inputevent.InputEventCodes.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Stardust on 2017/7/16.
|
* Created by Stardust on 2017/7/16.
|
||||||
*/
|
*/
|
||||||
@@ -20,6 +23,9 @@ public class RootAutomator {
|
|||||||
|
|
||||||
public static final byte DATA_TYPE_SLEEP = 0;
|
public static final byte DATA_TYPE_SLEEP = 0;
|
||||||
public static final byte DATA_TYPE_EVENT = 1;
|
public static final byte DATA_TYPE_EVENT = 1;
|
||||||
|
public static final byte DATA_TYPE_EVENT_SYNC_REPORT = 2;
|
||||||
|
public static final byte DATA_TYPE_EVENT_TOUCH_X = 3;
|
||||||
|
public static final byte DATA_TYPE_EVENT_TOUCH_Y = 4;
|
||||||
|
|
||||||
private DataOutputStream mTmpFileOutputStream;
|
private DataOutputStream mTmpFileOutputStream;
|
||||||
private File mEventTmpFile;
|
private File mEventTmpFile;
|
||||||
@@ -86,6 +92,23 @@ public class RootAutomator {
|
|||||||
mTmpFileOutputStream.writeInt(n);
|
mTmpFileOutputStream.writeInt(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void tap(int x, int y) throws IOException {
|
||||||
|
//sendEvent(EV_ABS, ABS_MT_TRACKING_ID, 0x0000398c);
|
||||||
|
sendEvent(EV_KEY, BTN_TOUCH, 0x00000001);
|
||||||
|
sendEvent(EV_KEY, BTN_TOOL_FINGER, 0x00000001);
|
||||||
|
sendEvent(EV_ABS, ABS_MT_POSITION_X, x);
|
||||||
|
sendEvent(EV_ABS, ABS_MT_POSITION_Y, y);
|
||||||
|
sendEvent(EV_SYN, SYN_REPORT, 0x00000000);
|
||||||
|
//sendEvent(EV_ABS, ABS_MT_TRACKING_ID, 0xffffffff);
|
||||||
|
sendEvent(EV_KEY, BTN_TOUCH, 0x00000000);
|
||||||
|
sendEvent(EV_KEY, BTN_TOOL_FINGER, 0x00000000);
|
||||||
|
sendEvent(EV_SYN, SYN_REPORT, 0x00000000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void swipe(int x, int y, int duration){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public AbstractShell.Result writeToDevice(Context context) {
|
public AbstractShell.Result writeToDevice(Context context) {
|
||||||
if (mDevicePath == null) {
|
if (mDevicePath == null) {
|
||||||
return new RootAutomatorEngine(context).execute(mEventTmpFile.getAbsolutePath());
|
return new RootAutomatorEngine(context).execute(mEventTmpFile.getAbsolutePath());
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.
|
|||||||
public class UiSelector extends UiGlobalSelector {
|
public class UiSelector extends UiGlobalSelector {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static final String TAG = "UiSelector";
|
private static final String TAG = "UiSelector";
|
||||||
|
|
||||||
private AccessibilityBridge mAccessibilityBridge;
|
private AccessibilityBridge mAccessibilityBridge;
|
||||||
@@ -135,6 +134,11 @@ public class UiSelector extends UiGlobalSelector {
|
|||||||
return new UiObject(collection.get(0).getInfo());
|
return new UiObject(collection.get(0).getInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ScriptInterface
|
||||||
|
public void waitFor() {
|
||||||
|
untilFind();
|
||||||
|
}
|
||||||
|
|
||||||
@ScriptInterface
|
@ScriptInterface
|
||||||
public UiSelector id(final String id) {
|
public UiSelector id(final String id) {
|
||||||
if (!id.contains(":")) {
|
if (!id.contains(":")) {
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package com.stardust.autojs.runtime.api.image;
|
package com.stardust.autojs.runtime.api.image;
|
||||||
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.media.Image;
|
import android.media.Image;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.support.annotation.RequiresApi;
|
import android.support.annotation.RequiresApi;
|
||||||
|
import android.view.Display;
|
||||||
|
|
||||||
import com.stardust.autojs.runtime.ScriptInterruptedException;
|
import com.stardust.autojs.runtime.ScriptInterruptedException;
|
||||||
import com.stardust.concurrent.VolatileBox;
|
import com.stardust.concurrent.VolatileBox;
|
||||||
@@ -31,9 +31,11 @@ public class ColorFinder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ThreadPoolExecutor mThreadPoolExecutor;
|
private ThreadPoolExecutor mThreadPoolExecutor;
|
||||||
|
private ScreenMetrics mScreenMetrics;
|
||||||
|
|
||||||
public ColorFinder(ThreadPoolExecutor threadPoolExecutor) {
|
public ColorFinder(ThreadPoolExecutor threadPoolExecutor) {
|
||||||
mThreadPoolExecutor = threadPoolExecutor;
|
mThreadPoolExecutor = threadPoolExecutor;
|
||||||
|
mScreenMetrics = new ScreenMetrics();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ColorFinder() {
|
public ColorFinder() {
|
||||||
@@ -75,10 +77,9 @@ public class ColorFinder {
|
|||||||
private Point scalePoint(Point point, int width, int height) {
|
private Point scalePoint(Point point, int width, int height) {
|
||||||
if (point == null)
|
if (point == null)
|
||||||
return null;
|
return null;
|
||||||
if (ScreenMetrics.getDeviceScreenHeight() == height && ScreenMetrics.getDeviceScreenWidth() == height) {
|
mScreenMetrics.setDesignHeight(height);
|
||||||
return point;
|
mScreenMetrics.setDesignWidth(width);
|
||||||
}
|
point.set(mScreenMetrics.scaleX(point.x), mScreenMetrics.scaleY(point.y));
|
||||||
point.set(ScreenMetrics.scaleX(point.x, width), ScreenMetrics.scaleY(point.y, height));
|
|
||||||
return point;
|
return point;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ import android.os.Build;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.support.annotation.RequiresApi;
|
import android.support.annotation.RequiresApi;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.Display;
|
||||||
|
import android.view.Surface;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
|
||||||
import com.stardust.autojs.runtime.ScriptRuntime;
|
import com.stardust.autojs.runtime.ScriptRuntime;
|
||||||
import com.stardust.autojs.runtime.ScriptInterruptedException;
|
import com.stardust.autojs.runtime.ScriptInterruptedException;
|
||||||
@@ -37,14 +40,17 @@ public class Images {
|
|||||||
private ScreenCaptureRequester mScreenCaptureRequester;
|
private ScreenCaptureRequester mScreenCaptureRequester;
|
||||||
private ScreenCapturer mScreenCapturer;
|
private ScreenCapturer mScreenCapturer;
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
private Display mDisplay;
|
||||||
|
|
||||||
@ScriptVariable
|
@ScriptVariable
|
||||||
public ColorFinder colorFinder = new ColorFinder();
|
public final ColorFinder colorFinder;
|
||||||
|
|
||||||
public Images(Context context, ScriptRuntime scriptRuntime, ScreenCaptureRequester screenCaptureRequester) {
|
public Images(Context context, ScriptRuntime scriptRuntime, ScreenCaptureRequester screenCaptureRequester) {
|
||||||
mScriptRuntime = scriptRuntime;
|
mScriptRuntime = scriptRuntime;
|
||||||
mScreenCaptureRequester = screenCaptureRequester;
|
mScreenCaptureRequester = screenCaptureRequester;
|
||||||
mContext = context;
|
mContext = context;
|
||||||
|
mDisplay = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
|
||||||
|
colorFinder = new ColorFinder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||||
@@ -71,7 +77,10 @@ public class Images {
|
|||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||||
public boolean requestScreenCapture() {
|
public boolean requestScreenCapture() {
|
||||||
return requestScreenCapture(ScreenMetrics.getDeviceScreenWidth(), ScreenMetrics.getDeviceScreenHeight());
|
if (mDisplay.getRotation() == Surface.ROTATION_0 || mDisplay.getRotation() == Surface.ROTATION_180)
|
||||||
|
return requestScreenCapture(ScreenMetrics.getDeviceScreenWidth(), ScreenMetrics.getDeviceScreenHeight());
|
||||||
|
else
|
||||||
|
return requestScreenCapture(ScreenMetrics.getDeviceScreenHeight(), ScreenMetrics.getDeviceScreenWidth());
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||||
@@ -116,8 +125,9 @@ public class Images {
|
|||||||
public static int pixel(Image image, int x, int y) {
|
public static int pixel(Image image, int x, int y) {
|
||||||
int originX = x;
|
int originX = x;
|
||||||
int originY = y;
|
int originY = y;
|
||||||
x = ScreenMetrics.rescaleX(x, image.getWidth());
|
ScreenMetrics metrics = new ScreenMetrics(image.getWidth(), image.getHeight());
|
||||||
y = ScreenMetrics.rescaleY(y, image.getHeight());
|
x = metrics.rescaleX(x);
|
||||||
|
y = metrics.rescaleY(y);
|
||||||
Image.Plane plane = image.getPlanes()[0];
|
Image.Plane plane = image.getPlanes()[0];
|
||||||
int offset = y * plane.getRowStride() + x * plane.getPixelStride();
|
int offset = y * plane.getRowStride() + x * plane.getPixelStride();
|
||||||
int c = plane.getBuffer().getInt(offset);
|
int c = plane.getBuffer().getInt(offset);
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public class ScreenCapturer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initVirtualDisplay(MediaProjectionManager manager, Intent data, int screenWidth, int screenHeight, int screenDensity) {
|
private void initVirtualDisplay(MediaProjectionManager manager, Intent data, int screenWidth, int screenHeight, int screenDensity) {
|
||||||
mImageReader = ImageReader.newInstance(screenWidth, screenHeight, PixelFormat.RGBA_8888, 2);
|
mImageReader = ImageReader.newInstance(screenWidth, screenHeight, PixelFormat.RGBA_8888, 1);
|
||||||
mMediaProjection = manager.getMediaProjection(Activity.RESULT_OK, data);
|
mMediaProjection = manager.getMediaProjection(Activity.RESULT_OK, data);
|
||||||
mVirtualDisplay = mMediaProjection.createVirtualDisplay("screen-mirror",
|
mVirtualDisplay = mMediaProjection.createVirtualDisplay("screen-mirror",
|
||||||
screenWidth, screenHeight, screenDensity, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
|
screenWidth, screenHeight, screenDensity, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
|
||||||
@@ -158,7 +158,7 @@ public class ScreenCapturer {
|
|||||||
mImageReader.close();
|
mImageReader.close();
|
||||||
}
|
}
|
||||||
if (mImageAcquireLooper != null) {
|
if (mImageAcquireLooper != null) {
|
||||||
mImageAcquireLooper.quitSafely();
|
mImageAcquireLooper.quit();
|
||||||
}
|
}
|
||||||
if (mImage != null) {
|
if (mImage != null) {
|
||||||
mImage.close();
|
mImage.close();
|
||||||
|
|||||||
@@ -0,0 +1,833 @@
|
|||||||
|
package com.stardust.autojs.runtime.record.inputevent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Stardust on 2017/8/5.
|
||||||
|
* <p>
|
||||||
|
* from linux/input-event-codes.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public class InputEventCodes {
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Device properties and quirks
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static final int INPUT_PROP_POINTER = 0x00; /* needs a pointer */
|
||||||
|
public static final int INPUT_PROP_DIRECT = 0x01; /* direct input devices */
|
||||||
|
public static final int INPUT_PROP_BUTTONPAD = 0x02; /* has button(s) under pad */
|
||||||
|
public static final int INPUT_PROP_SEMI_MT = 0x03; /* touch rectangle only */
|
||||||
|
public static final int INPUT_PROP_TOPBUTTONPAD = 0x04; /* softbuttons at top of pad */
|
||||||
|
public static final int INPUT_PROP_POINTING_STICK = 0x05; /* is a pointing stick */
|
||||||
|
public static final int INPUT_PROP_ACCELEROMETER = 0x06; /* has accelerometer */
|
||||||
|
|
||||||
|
public static final int INPUT_PROP_MAX = 0x1f;
|
||||||
|
public static final int INPUT_PROP_CNT = (INPUT_PROP_MAX + 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Event types
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static final int EV_SYN = 0x00;
|
||||||
|
public static final int EV_KEY = 0x01;
|
||||||
|
public static final int EV_REL = 0x02;
|
||||||
|
public static final int EV_ABS = 0x03;
|
||||||
|
public static final int EV_MSC = 0x04;
|
||||||
|
public static final int EV_SW = 0x05;
|
||||||
|
public static final int EV_LED = 0x11;
|
||||||
|
public static final int EV_SND = 0x12;
|
||||||
|
public static final int EV_REP = 0x14;
|
||||||
|
public static final int EV_FF = 0x15;
|
||||||
|
public static final int EV_PWR = 0x16;
|
||||||
|
public static final int EV_FF_STATUS = 0x17;
|
||||||
|
public static final int EV_MAX = 0x1f;
|
||||||
|
public static final int EV_CNT = (EV_MAX + 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Synchronization events.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static final int SYN_REPORT = 0;
|
||||||
|
public static final int SYN_CONFIG = 1;
|
||||||
|
public static final int SYN_MT_REPORT = 2;
|
||||||
|
public static final int SYN_DROPPED = 3;
|
||||||
|
public static final int SYN_MAX = 0xf;
|
||||||
|
public static final int SYN_CNT = (SYN_MAX + 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Keys and buttons
|
||||||
|
*
|
||||||
|
* Most of the keys/buttons are modeled after USB HUT 1.12
|
||||||
|
* (see http://www.usb.org/developers/hidpage).
|
||||||
|
* Abbreviations in the comments:
|
||||||
|
* AC - Application Control
|
||||||
|
* AL - Application Launch Button
|
||||||
|
* SC - System Control
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static final int KEY_RESERVED = 0;
|
||||||
|
public static final int KEY_ESC = 1;
|
||||||
|
public static final int KEY_1 = 2;
|
||||||
|
public static final int KEY_2 = 3;
|
||||||
|
public static final int KEY_3 = 4;
|
||||||
|
public static final int KEY_4 = 5;
|
||||||
|
public static final int KEY_5 = 6;
|
||||||
|
public static final int KEY_6 = 7;
|
||||||
|
public static final int KEY_7 = 8;
|
||||||
|
public static final int KEY_8 = 9;
|
||||||
|
public static final int KEY_9 = 10;
|
||||||
|
public static final int KEY_0 = 11;
|
||||||
|
public static final int KEY_MINUS = 12;
|
||||||
|
public static final int KEY_EQUAL = 13;
|
||||||
|
public static final int KEY_BACKSPACE = 14;
|
||||||
|
public static final int KEY_TAB = 15;
|
||||||
|
public static final int KEY_Q = 16;
|
||||||
|
public static final int KEY_W = 17;
|
||||||
|
public static final int KEY_E = 18;
|
||||||
|
public static final int KEY_R = 19;
|
||||||
|
public static final int KEY_T = 20;
|
||||||
|
public static final int KEY_Y = 21;
|
||||||
|
public static final int KEY_U = 22;
|
||||||
|
public static final int KEY_I = 23;
|
||||||
|
public static final int KEY_O = 24;
|
||||||
|
public static final int KEY_P = 25;
|
||||||
|
public static final int KEY_LEFTBRACE = 26;
|
||||||
|
public static final int KEY_RIGHTBRACE = 27;
|
||||||
|
public static final int KEY_ENTER = 28;
|
||||||
|
public static final int KEY_LEFTCTRL = 29;
|
||||||
|
public static final int KEY_A = 30;
|
||||||
|
public static final int KEY_S = 31;
|
||||||
|
public static final int KEY_D = 32;
|
||||||
|
public static final int KEY_F = 33;
|
||||||
|
public static final int KEY_G = 34;
|
||||||
|
public static final int KEY_H = 35;
|
||||||
|
public static final int KEY_J = 36;
|
||||||
|
public static final int KEY_K = 37;
|
||||||
|
public static final int KEY_L = 38;
|
||||||
|
public static final int KEY_SEMICOLON = 39;
|
||||||
|
public static final int KEY_APOSTROPHE = 40;
|
||||||
|
public static final int KEY_GRAVE = 41;
|
||||||
|
public static final int KEY_LEFTSHIFT = 42;
|
||||||
|
public static final int KEY_BACKSLASH = 43;
|
||||||
|
public static final int KEY_Z = 44;
|
||||||
|
public static final int KEY_X = 45;
|
||||||
|
public static final int KEY_C = 46;
|
||||||
|
public static final int KEY_V = 47;
|
||||||
|
public static final int KEY_B = 48;
|
||||||
|
public static final int KEY_N = 49;
|
||||||
|
public static final int KEY_M = 50;
|
||||||
|
public static final int KEY_COMMA = 51;
|
||||||
|
public static final int KEY_DOT = 52;
|
||||||
|
public static final int KEY_SLASH = 53;
|
||||||
|
public static final int KEY_RIGHTSHIFT = 54;
|
||||||
|
public static final int KEY_KPASTERISK = 55;
|
||||||
|
public static final int KEY_LEFTALT = 56;
|
||||||
|
public static final int KEY_SPACE = 57;
|
||||||
|
public static final int KEY_CAPSLOCK = 58;
|
||||||
|
public static final int KEY_F1 = 59;
|
||||||
|
public static final int KEY_F2 = 60;
|
||||||
|
public static final int KEY_F3 = 61;
|
||||||
|
public static final int KEY_F4 = 62;
|
||||||
|
public static final int KEY_F5 = 63;
|
||||||
|
public static final int KEY_F6 = 64;
|
||||||
|
public static final int KEY_F7 = 65;
|
||||||
|
public static final int KEY_F8 = 66;
|
||||||
|
public static final int KEY_F9 = 67;
|
||||||
|
public static final int KEY_F10 = 68;
|
||||||
|
public static final int KEY_NUMLOCK = 69;
|
||||||
|
public static final int KEY_SCROLLLOCK = 70;
|
||||||
|
public static final int KEY_KP7 = 71;
|
||||||
|
public static final int KEY_KP8 = 72;
|
||||||
|
public static final int KEY_KP9 = 73;
|
||||||
|
public static final int KEY_KPMINUS = 74;
|
||||||
|
public static final int KEY_KP4 = 75;
|
||||||
|
public static final int KEY_KP5 = 76;
|
||||||
|
public static final int KEY_KP6 = 77;
|
||||||
|
public static final int KEY_KPPLUS = 78;
|
||||||
|
public static final int KEY_KP1 = 79;
|
||||||
|
public static final int KEY_KP2 = 80;
|
||||||
|
public static final int KEY_KP3 = 81;
|
||||||
|
public static final int KEY_KP0 = 82;
|
||||||
|
public static final int KEY_KPDOT = 83;
|
||||||
|
|
||||||
|
public static final int KEY_ZENKAKUHANKAKU = 85;
|
||||||
|
public static final int KEY_102ND = 86;
|
||||||
|
public static final int KEY_F11 = 87;
|
||||||
|
public static final int KEY_F12 = 88;
|
||||||
|
public static final int KEY_RO = 89;
|
||||||
|
public static final int KEY_KATAKANA = 90;
|
||||||
|
public static final int KEY_HIRAGANA = 91;
|
||||||
|
public static final int KEY_HENKAN = 92;
|
||||||
|
public static final int KEY_KATAKANAHIRAGANA = 93;
|
||||||
|
public static final int KEY_MUHENKAN = 94;
|
||||||
|
public static final int KEY_KPJPCOMMA = 95;
|
||||||
|
public static final int KEY_KPENTER = 96;
|
||||||
|
public static final int KEY_RIGHTCTRL = 97;
|
||||||
|
public static final int KEY_KPSLASH = 98;
|
||||||
|
public static final int KEY_SYSRQ = 99;
|
||||||
|
public static final int KEY_RIGHTALT = 100;
|
||||||
|
public static final int KEY_LINEFEED = 101;
|
||||||
|
public static final int KEY_HOME = 102;
|
||||||
|
public static final int KEY_UP = 103;
|
||||||
|
public static final int KEY_PAGEUP = 104;
|
||||||
|
public static final int KEY_LEFT = 105;
|
||||||
|
public static final int KEY_RIGHT = 106;
|
||||||
|
public static final int KEY_END = 107;
|
||||||
|
public static final int KEY_DOWN = 108;
|
||||||
|
public static final int KEY_PAGEDOWN = 109;
|
||||||
|
public static final int KEY_INSERT = 110;
|
||||||
|
public static final int KEY_DELETE = 111;
|
||||||
|
public static final int KEY_MACRO = 112;
|
||||||
|
public static final int KEY_MUTE = 113;
|
||||||
|
public static final int KEY_VOLUMEDOWN = 114;
|
||||||
|
public static final int KEY_VOLUMEUP = 115;
|
||||||
|
public static final int KEY_POWER = 116; /* SC System Power Down */
|
||||||
|
public static final int KEY_KPEQUAL = 117;
|
||||||
|
public static final int KEY_KPPLUSMINUS = 118;
|
||||||
|
public static final int KEY_PAUSE = 119;
|
||||||
|
public static final int KEY_SCALE = 120; /* AL Compiz Scale (Expose) */
|
||||||
|
|
||||||
|
public static final int KEY_KPCOMMA = 121;
|
||||||
|
public static final int KEY_HANGEUL = 122;
|
||||||
|
public static final int KEY_HANGUEL = KEY_HANGEUL;
|
||||||
|
public static final int KEY_HANJA = 123;
|
||||||
|
public static final int KEY_YEN = 124;
|
||||||
|
public static final int KEY_LEFTMETA = 125;
|
||||||
|
public static final int KEY_RIGHTMETA = 126;
|
||||||
|
public static final int KEY_COMPOSE = 127;
|
||||||
|
|
||||||
|
public static final int KEY_STOP = 128; /* AC Stop */
|
||||||
|
public static final int KEY_AGAIN = 129;
|
||||||
|
public static final int KEY_PROPS = 130; /* AC Properties */
|
||||||
|
public static final int KEY_UNDO = 131; /* AC Undo */
|
||||||
|
public static final int KEY_FRONT = 132;
|
||||||
|
public static final int KEY_COPY = 133; /* AC Copy */
|
||||||
|
public static final int KEY_OPEN = 134; /* AC Open */
|
||||||
|
public static final int KEY_PASTE = 135; /* AC Paste */
|
||||||
|
public static final int KEY_FIND = 136; /* AC Search */
|
||||||
|
public static final int KEY_CUT = 137; /* AC Cut */
|
||||||
|
public static final int KEY_HELP = 138; /* AL Integrated Help Center */
|
||||||
|
public static final int KEY_MENU = 139; /* Menu (show menu) */
|
||||||
|
public static final int KEY_CALC = 140; /* AL Calculator */
|
||||||
|
public static final int KEY_SETUP = 141;
|
||||||
|
public static final int KEY_SLEEP = 142; /* SC System Sleep */
|
||||||
|
public static final int KEY_WAKEUP = 143; /* System Wake Up */
|
||||||
|
public static final int KEY_FILE = 144; /* AL Local Machine Browser */
|
||||||
|
public static final int KEY_SENDFILE = 145;
|
||||||
|
public static final int KEY_DELETEFILE = 146;
|
||||||
|
public static final int KEY_XFER = 147;
|
||||||
|
public static final int KEY_PROG1 = 148;
|
||||||
|
public static final int KEY_PROG2 = 149;
|
||||||
|
public static final int KEY_WWW = 150; /* AL Internet Browser */
|
||||||
|
public static final int KEY_MSDOS = 151;
|
||||||
|
public static final int KEY_COFFEE = 152; /* AL Terminal Lock/Screensaver */
|
||||||
|
public static final int KEY_SCREENLOCK = KEY_COFFEE;
|
||||||
|
public static final int KEY_ROTATE_DISPLAY = 153; /* Display orientation for e.g. tablets */
|
||||||
|
public static final int KEY_DIRECTION = KEY_ROTATE_DISPLAY;
|
||||||
|
public static final int KEY_CYCLEWINDOWS = 154;
|
||||||
|
public static final int KEY_MAIL = 155;
|
||||||
|
public static final int KEY_BOOKMARKS = 156; /* AC Bookmarks */
|
||||||
|
public static final int KEY_COMPUTER = 157;
|
||||||
|
public static final int KEY_BACK = 158; /* AC Back */
|
||||||
|
public static final int KEY_FORWARD = 159; /* AC Forward */
|
||||||
|
public static final int KEY_CLOSECD = 160;
|
||||||
|
public static final int KEY_EJECTCD = 161;
|
||||||
|
public static final int KEY_EJECTCLOSECD = 162;
|
||||||
|
public static final int KEY_NEXTSONG = 163;
|
||||||
|
public static final int KEY_PLAYPAUSE = 164;
|
||||||
|
public static final int KEY_PREVIOUSSONG = 165;
|
||||||
|
public static final int KEY_STOPCD = 166;
|
||||||
|
public static final int KEY_RECORD = 167;
|
||||||
|
public static final int KEY_REWIND = 168;
|
||||||
|
public static final int KEY_PHONE = 169; /* Media Select Telephone */
|
||||||
|
public static final int KEY_ISO = 170;
|
||||||
|
public static final int KEY_CONFIG = 171; /* AL Consumer Control Configuration */
|
||||||
|
public static final int KEY_HOMEPAGE = 172; /* AC Home */
|
||||||
|
public static final int KEY_REFRESH = 173; /* AC Refresh */
|
||||||
|
public static final int KEY_EXIT = 174; /* AC Exit */
|
||||||
|
public static final int KEY_MOVE = 175;
|
||||||
|
public static final int KEY_EDIT = 176;
|
||||||
|
public static final int KEY_SCROLLUP = 177;
|
||||||
|
public static final int KEY_SCROLLDOWN = 178;
|
||||||
|
public static final int KEY_KPLEFTPAREN = 179;
|
||||||
|
public static final int KEY_KPRIGHTPAREN = 180;
|
||||||
|
public static final int KEY_NEW = 181; /* AC New */
|
||||||
|
public static final int KEY_REDO = 182; /* AC Redo/Repeat */
|
||||||
|
|
||||||
|
public static final int KEY_F13 = 183;
|
||||||
|
public static final int KEY_F14 = 184;
|
||||||
|
public static final int KEY_F15 = 185;
|
||||||
|
public static final int KEY_F16 = 186;
|
||||||
|
public static final int KEY_F17 = 187;
|
||||||
|
public static final int KEY_F18 = 188;
|
||||||
|
public static final int KEY_F19 = 189;
|
||||||
|
public static final int KEY_F20 = 190;
|
||||||
|
public static final int KEY_F21 = 191;
|
||||||
|
public static final int KEY_F22 = 192;
|
||||||
|
public static final int KEY_F23 = 193;
|
||||||
|
public static final int KEY_F24 = 194;
|
||||||
|
|
||||||
|
public static final int KEY_PLAYCD = 200;
|
||||||
|
public static final int KEY_PAUSECD = 201;
|
||||||
|
public static final int KEY_PROG3 = 202;
|
||||||
|
public static final int KEY_PROG4 = 203;
|
||||||
|
public static final int KEY_DASHBOARD = 204; /* AL Dashboard */
|
||||||
|
public static final int KEY_SUSPEND = 205;
|
||||||
|
public static final int KEY_CLOSE = 206; /* AC Close */
|
||||||
|
public static final int KEY_PLAY = 207;
|
||||||
|
public static final int KEY_FASTFORWARD = 208;
|
||||||
|
public static final int KEY_BASSBOOST = 209;
|
||||||
|
public static final int KEY_PRINT = 210; /* AC Print */
|
||||||
|
public static final int KEY_HP = 211;
|
||||||
|
public static final int KEY_CAMERA = 212;
|
||||||
|
public static final int KEY_SOUND = 213;
|
||||||
|
public static final int KEY_QUESTION = 214;
|
||||||
|
public static final int KEY_EMAIL = 215;
|
||||||
|
public static final int KEY_CHAT = 216;
|
||||||
|
public static final int KEY_SEARCH = 217;
|
||||||
|
public static final int KEY_CONNECT = 218;
|
||||||
|
public static final int KEY_FINANCE = 219; /* AL Checkbook/Finance */
|
||||||
|
public static final int KEY_SPORT = 220;
|
||||||
|
public static final int KEY_SHOP = 221;
|
||||||
|
public static final int KEY_ALTERASE = 222;
|
||||||
|
public static final int KEY_CANCEL = 223; /* AC Cancel */
|
||||||
|
public static final int KEY_BRIGHTNESSDOWN = 224;
|
||||||
|
public static final int KEY_BRIGHTNESSUP = 225;
|
||||||
|
public static final int KEY_MEDIA = 226;
|
||||||
|
|
||||||
|
public static final int KEY_SWITCHVIDEOMODE = 227; /* Cycle between available video
|
||||||
|
outputs (Monitor/LCD/TV-out/etc) */
|
||||||
|
public static final int KEY_KBDILLUMTOGGLE = 228;
|
||||||
|
public static final int KEY_KBDILLUMDOWN = 229;
|
||||||
|
public static final int KEY_KBDILLUMUP = 230;
|
||||||
|
|
||||||
|
public static final int KEY_SEND = 231; /* AC Send */
|
||||||
|
public static final int KEY_REPLY = 232; /* AC Reply */
|
||||||
|
public static final int KEY_FORWARDMAIL = 233; /* AC Forward Msg */
|
||||||
|
public static final int KEY_SAVE = 234; /* AC Save */
|
||||||
|
public static final int KEY_DOCUMENTS = 235;
|
||||||
|
|
||||||
|
public static final int KEY_BATTERY = 236;
|
||||||
|
|
||||||
|
public static final int KEY_BLUETOOTH = 237;
|
||||||
|
public static final int KEY_WLAN = 238;
|
||||||
|
public static final int KEY_UWB = 239;
|
||||||
|
|
||||||
|
public static final int KEY_UNKNOWN = 240;
|
||||||
|
|
||||||
|
public static final int KEY_VIDEO_NEXT = 241; /* drive next video source */
|
||||||
|
public static final int KEY_VIDEO_PREV = 242; /* drive previous video source */
|
||||||
|
public static final int KEY_BRIGHTNESS_CYCLE = 243; /* brightness up, after max is min */
|
||||||
|
public static final int KEY_BRIGHTNESS_AUTO = 244; /* Set Auto Brightness: manual
|
||||||
|
brightness control is off,
|
||||||
|
rely on ambient */
|
||||||
|
public static final int KEY_BRIGHTNESS_ZERO = KEY_BRIGHTNESS_AUTO;
|
||||||
|
public static final int KEY_DISPLAY_OFF = 245; /* display device to off state */
|
||||||
|
|
||||||
|
public static final int KEY_WWAN = 246; /* Wireless WAN (LTE, UMTS, GSM, etc.) */
|
||||||
|
public static final int KEY_WIMAX = KEY_WWAN;
|
||||||
|
public static final int KEY_RFKILL = 247; /* Key that controls all radios */
|
||||||
|
|
||||||
|
public static final int KEY_MICMUTE = 248; /* Mute / unmute the microphone */
|
||||||
|
|
||||||
|
/* Code 255 is reserved for special needs of AT keyboard driver */
|
||||||
|
|
||||||
|
public static final int BTN_MISC = 0x100;
|
||||||
|
public static final int BTN_0 = 0x100;
|
||||||
|
public static final int BTN_1 = 0x101;
|
||||||
|
public static final int BTN_2 = 0x102;
|
||||||
|
public static final int BTN_3 = 0x103;
|
||||||
|
public static final int BTN_4 = 0x104;
|
||||||
|
public static final int BTN_5 = 0x105;
|
||||||
|
public static final int BTN_6 = 0x106;
|
||||||
|
public static final int BTN_7 = 0x107;
|
||||||
|
public static final int BTN_8 = 0x108;
|
||||||
|
public static final int BTN_9 = 0x109;
|
||||||
|
|
||||||
|
public static final int BTN_MOUSE = 0x110;
|
||||||
|
public static final int BTN_LEFT = 0x110;
|
||||||
|
public static final int BTN_RIGHT = 0x111;
|
||||||
|
public static final int BTN_MIDDLE = 0x112;
|
||||||
|
public static final int BTN_SIDE = 0x113;
|
||||||
|
public static final int BTN_EXTRA = 0x114;
|
||||||
|
public static final int BTN_FORWARD = 0x115;
|
||||||
|
public static final int BTN_BACK = 0x116;
|
||||||
|
public static final int BTN_TASK = 0x117;
|
||||||
|
|
||||||
|
public static final int BTN_JOYSTICK = 0x120;
|
||||||
|
public static final int BTN_TRIGGER = 0x120;
|
||||||
|
public static final int BTN_THUMB = 0x121;
|
||||||
|
public static final int BTN_THUMB2 = 0x122;
|
||||||
|
public static final int BTN_TOP = 0x123;
|
||||||
|
public static final int BTN_TOP2 = 0x124;
|
||||||
|
public static final int BTN_PINKIE = 0x125;
|
||||||
|
public static final int BTN_BASE = 0x126;
|
||||||
|
public static final int BTN_BASE2 = 0x127;
|
||||||
|
public static final int BTN_BASE3 = 0x128;
|
||||||
|
public static final int BTN_BASE4 = 0x129;
|
||||||
|
public static final int BTN_BASE5 = 0x12a;
|
||||||
|
public static final int BTN_BASE6 = 0x12b;
|
||||||
|
public static final int BTN_DEAD = 0x12f;
|
||||||
|
|
||||||
|
public static final int BTN_GAMEPAD = 0x130;
|
||||||
|
public static final int BTN_SOUTH = 0x130;
|
||||||
|
public static final int BTN_A = BTN_SOUTH;
|
||||||
|
public static final int BTN_EAST = 0x131;
|
||||||
|
public static final int BTN_B = BTN_EAST;
|
||||||
|
public static final int BTN_C = 0x132;
|
||||||
|
public static final int BTN_NORTH = 0x133;
|
||||||
|
public static final int BTN_X = BTN_NORTH;
|
||||||
|
public static final int BTN_WEST = 0x134;
|
||||||
|
public static final int BTN_Y = BTN_WEST;
|
||||||
|
public static final int BTN_Z = 0x135;
|
||||||
|
public static final int BTN_TL = 0x136;
|
||||||
|
public static final int BTN_TR = 0x137;
|
||||||
|
public static final int BTN_TL2 = 0x138;
|
||||||
|
public static final int BTN_TR2 = 0x139;
|
||||||
|
public static final int BTN_SELECT = 0x13a;
|
||||||
|
public static final int BTN_START = 0x13b;
|
||||||
|
public static final int BTN_MODE = 0x13c;
|
||||||
|
public static final int BTN_THUMBL = 0x13d;
|
||||||
|
public static final int BTN_THUMBR = 0x13e;
|
||||||
|
|
||||||
|
public static final int BTN_DIGI = 0x140;
|
||||||
|
public static final int BTN_TOOL_PEN = 0x140;
|
||||||
|
public static final int BTN_TOOL_RUBBER = 0x141;
|
||||||
|
public static final int BTN_TOOL_BRUSH = 0x142;
|
||||||
|
public static final int BTN_TOOL_PENCIL = 0x143;
|
||||||
|
public static final int BTN_TOOL_AIRBRUSH = 0x144;
|
||||||
|
public static final int BTN_TOOL_FINGER = 0x145;
|
||||||
|
public static final int BTN_TOOL_MOUSE = 0x146;
|
||||||
|
public static final int BTN_TOOL_LENS = 0x147;
|
||||||
|
public static final int BTN_TOOL_QUINTTAP = 0x148; /* Five fingers on trackpad */
|
||||||
|
public static final int BTN_TOUCH = 0x14a;
|
||||||
|
public static final int BTN_STYLUS = 0x14b;
|
||||||
|
public static final int BTN_STYLUS2 = 0x14c;
|
||||||
|
public static final int BTN_TOOL_DOUBLETAP = 0x14d;
|
||||||
|
public static final int BTN_TOOL_TRIPLETAP = 0x14e;
|
||||||
|
public static final int BTN_TOOL_QUADTAP = 0x14f; /* Four fingers on trackpad */
|
||||||
|
|
||||||
|
public static final int BTN_WHEEL = 0x150;
|
||||||
|
public static final int BTN_GEAR_DOWN = 0x150;
|
||||||
|
public static final int BTN_GEAR_UP = 0x151;
|
||||||
|
|
||||||
|
public static final int KEY_OK = 0x160;
|
||||||
|
public static final int KEY_SELECT = 0x161;
|
||||||
|
public static final int KEY_GOTO = 0x162;
|
||||||
|
public static final int KEY_CLEAR = 0x163;
|
||||||
|
public static final int KEY_POWER2 = 0x164;
|
||||||
|
public static final int KEY_OPTION = 0x165;
|
||||||
|
public static final int KEY_INFO = 0x166; /* AL OEM Features/Tips/Tutorial */
|
||||||
|
public static final int KEY_TIME = 0x167;
|
||||||
|
public static final int KEY_VENDOR = 0x168;
|
||||||
|
public static final int KEY_ARCHIVE = 0x169;
|
||||||
|
public static final int KEY_PROGRAM = 0x16a; /* Media Select Program Guide */
|
||||||
|
public static final int KEY_CHANNEL = 0x16b;
|
||||||
|
public static final int KEY_FAVORITES = 0x16c;
|
||||||
|
public static final int KEY_EPG = 0x16d;
|
||||||
|
public static final int KEY_PVR = 0x16e; /* Media Select Home */
|
||||||
|
public static final int KEY_MHP = 0x16f;
|
||||||
|
public static final int KEY_LANGUAGE = 0x170;
|
||||||
|
public static final int KEY_TITLE = 0x171;
|
||||||
|
public static final int KEY_SUBTITLE = 0x172;
|
||||||
|
public static final int KEY_ANGLE = 0x173;
|
||||||
|
public static final int KEY_ZOOM = 0x174;
|
||||||
|
public static final int KEY_MODE = 0x175;
|
||||||
|
public static final int KEY_KEYBOARD = 0x176;
|
||||||
|
public static final int KEY_SCREEN = 0x177;
|
||||||
|
public static final int KEY_PC = 0x178; /* Media Select Computer */
|
||||||
|
public static final int KEY_TV = 0x179; /* Media Select TV */
|
||||||
|
public static final int KEY_TV2 = 0x17a; /* Media Select Cable */
|
||||||
|
public static final int KEY_VCR = 0x17b; /* Media Select VCR */
|
||||||
|
public static final int KEY_VCR2 = 0x17c; /* VCR Plus */
|
||||||
|
public static final int KEY_SAT = 0x17d; /* Media Select Satellite */
|
||||||
|
public static final int KEY_SAT2 = 0x17e;
|
||||||
|
public static final int KEY_CD = 0x17f; /* Media Select CD */
|
||||||
|
public static final int KEY_TAPE = 0x180; /* Media Select Tape */
|
||||||
|
public static final int KEY_RADIO = 0x181;
|
||||||
|
public static final int KEY_TUNER = 0x182; /* Media Select Tuner */
|
||||||
|
public static final int KEY_PLAYER = 0x183;
|
||||||
|
public static final int KEY_TEXT = 0x184;
|
||||||
|
public static final int KEY_DVD = 0x185; /* Media Select DVD */
|
||||||
|
public static final int KEY_AUX = 0x186;
|
||||||
|
public static final int KEY_MP3 = 0x187;
|
||||||
|
public static final int KEY_AUDIO = 0x188; /* AL Audio Browser */
|
||||||
|
public static final int KEY_VIDEO = 0x189; /* AL Movie Browser */
|
||||||
|
public static final int KEY_DIRECTORY = 0x18a;
|
||||||
|
public static final int KEY_LIST = 0x18b;
|
||||||
|
public static final int KEY_MEMO = 0x18c; /* Media Select Messages */
|
||||||
|
public static final int KEY_CALENDAR = 0x18d;
|
||||||
|
public static final int KEY_RED = 0x18e;
|
||||||
|
public static final int KEY_GREEN = 0x18f;
|
||||||
|
public static final int KEY_YELLOW = 0x190;
|
||||||
|
public static final int KEY_BLUE = 0x191;
|
||||||
|
public static final int KEY_CHANNELUP = 0x192; /* Channel Increment */
|
||||||
|
public static final int KEY_CHANNELDOWN = 0x193; /* Channel Decrement */
|
||||||
|
public static final int KEY_FIRST = 0x194;
|
||||||
|
public static final int KEY_LAST = 0x195; /* Recall Last */
|
||||||
|
public static final int KEY_AB = 0x196;
|
||||||
|
public static final int KEY_NEXT = 0x197;
|
||||||
|
public static final int KEY_RESTART = 0x198;
|
||||||
|
public static final int KEY_SLOW = 0x199;
|
||||||
|
public static final int KEY_SHUFFLE = 0x19a;
|
||||||
|
public static final int KEY_BREAK = 0x19b;
|
||||||
|
public static final int KEY_PREVIOUS = 0x19c;
|
||||||
|
public static final int KEY_DIGITS = 0x19d;
|
||||||
|
public static final int KEY_TEEN = 0x19e;
|
||||||
|
public static final int KEY_TWEN = 0x19f;
|
||||||
|
public static final int KEY_VIDEOPHONE = 0x1a0; /* Media Select Video Phone */
|
||||||
|
public static final int KEY_GAMES = 0x1a1; /* Media Select Games */
|
||||||
|
public static final int KEY_ZOOMIN = 0x1a2; /* AC Zoom In */
|
||||||
|
public static final int KEY_ZOOMOUT = 0x1a3; /* AC Zoom Out */
|
||||||
|
public static final int KEY_ZOOMRESET = 0x1a4; /* AC Zoom */
|
||||||
|
public static final int KEY_WORDPROCESSOR = 0x1a5; /* AL Word Processor */
|
||||||
|
public static final int KEY_EDITOR = 0x1a6; /* AL Text Editor */
|
||||||
|
public static final int KEY_SPREADSHEET = 0x1a7; /* AL Spreadsheet */
|
||||||
|
public static final int KEY_GRAPHICSEDITOR = 0x1a8; /* AL Graphics Editor */
|
||||||
|
public static final int KEY_PRESENTATION = 0x1a9; /* AL Presentation App */
|
||||||
|
public static final int KEY_DATABASE = 0x1aa; /* AL Database App */
|
||||||
|
public static final int KEY_NEWS = 0x1ab; /* AL Newsreader */
|
||||||
|
public static final int KEY_VOICEMAIL = 0x1ac; /* AL Voicemail */
|
||||||
|
public static final int KEY_ADDRESSBOOK = 0x1ad; /* AL Contacts/Address Book */
|
||||||
|
public static final int KEY_MESSENGER = 0x1ae; /* AL Instant Messaging */
|
||||||
|
public static final int KEY_DISPLAYTOGGLE = 0x1af; /* Turn display (LCD) on and off */
|
||||||
|
public static final int KEY_BRIGHTNESS_TOGGLE = KEY_DISPLAYTOGGLE;
|
||||||
|
public static final int KEY_SPELLCHECK = 0x1b0; /* AL Spell Check */
|
||||||
|
public static final int KEY_LOGOFF = 0x1b1; /* AL Logoff */
|
||||||
|
|
||||||
|
public static final int KEY_DOLLAR = 0x1b2;
|
||||||
|
public static final int KEY_EURO = 0x1b3;
|
||||||
|
|
||||||
|
public static final int KEY_FRAMEBACK = 0x1b4; /* Consumer - transport controls */
|
||||||
|
public static final int KEY_FRAMEFORWARD = 0x1b5;
|
||||||
|
public static final int KEY_CONTEXT_MENU = 0x1b6; /* GenDesc - system context menu */
|
||||||
|
public static final int KEY_MEDIA_REPEAT = 0x1b7; /* Consumer - transport control */
|
||||||
|
public static final int KEY_10CHANNELSUP = 0x1b8; /* 10 channels up (10+) */
|
||||||
|
public static final int KEY_10CHANNELSDOWN = 0x1b9; /* 10 channels down (10-) */
|
||||||
|
public static final int KEY_IMAGES = 0x1ba; /* AL Image Browser */
|
||||||
|
|
||||||
|
public static final int KEY_DEL_EOL = 0x1c0;
|
||||||
|
public static final int KEY_DEL_EOS = 0x1c1;
|
||||||
|
public static final int KEY_INS_LINE = 0x1c2;
|
||||||
|
public static final int KEY_DEL_LINE = 0x1c3;
|
||||||
|
|
||||||
|
public static final int KEY_FN = 0x1d0;
|
||||||
|
public static final int KEY_FN_ESC = 0x1d1;
|
||||||
|
public static final int KEY_FN_F1 = 0x1d2;
|
||||||
|
public static final int KEY_FN_F2 = 0x1d3;
|
||||||
|
public static final int KEY_FN_F3 = 0x1d4;
|
||||||
|
public static final int KEY_FN_F4 = 0x1d5;
|
||||||
|
public static final int KEY_FN_F5 = 0x1d6;
|
||||||
|
public static final int KEY_FN_F6 = 0x1d7;
|
||||||
|
public static final int KEY_FN_F7 = 0x1d8;
|
||||||
|
public static final int KEY_FN_F8 = 0x1d9;
|
||||||
|
public static final int KEY_FN_F9 = 0x1da;
|
||||||
|
public static final int KEY_FN_F10 = 0x1db;
|
||||||
|
public static final int KEY_FN_F11 = 0x1dc;
|
||||||
|
public static final int KEY_FN_F12 = 0x1dd;
|
||||||
|
public static final int KEY_FN_1 = 0x1de;
|
||||||
|
public static final int KEY_FN_2 = 0x1df;
|
||||||
|
public static final int KEY_FN_D = 0x1e0;
|
||||||
|
public static final int KEY_FN_E = 0x1e1;
|
||||||
|
public static final int KEY_FN_F = 0x1e2;
|
||||||
|
public static final int KEY_FN_S = 0x1e3;
|
||||||
|
public static final int KEY_FN_B = 0x1e4;
|
||||||
|
|
||||||
|
public static final int KEY_BRL_DOT1 = 0x1f1;
|
||||||
|
public static final int KEY_BRL_DOT2 = 0x1f2;
|
||||||
|
public static final int KEY_BRL_DOT3 = 0x1f3;
|
||||||
|
public static final int KEY_BRL_DOT4 = 0x1f4;
|
||||||
|
public static final int KEY_BRL_DOT5 = 0x1f5;
|
||||||
|
public static final int KEY_BRL_DOT6 = 0x1f6;
|
||||||
|
public static final int KEY_BRL_DOT7 = 0x1f7;
|
||||||
|
public static final int KEY_BRL_DOT8 = 0x1f8;
|
||||||
|
public static final int KEY_BRL_DOT9 = 0x1f9;
|
||||||
|
public static final int KEY_BRL_DOT10 = 0x1fa;
|
||||||
|
|
||||||
|
public static final int KEY_NUMERIC_0 = 0x200; /* used by phones, remote controls, */
|
||||||
|
public static final int KEY_NUMERIC_1 = 0x201; /* and other keypads */
|
||||||
|
public static final int KEY_NUMERIC_2 = 0x202;
|
||||||
|
public static final int KEY_NUMERIC_3 = 0x203;
|
||||||
|
public static final int KEY_NUMERIC_4 = 0x204;
|
||||||
|
public static final int KEY_NUMERIC_5 = 0x205;
|
||||||
|
public static final int KEY_NUMERIC_6 = 0x206;
|
||||||
|
public static final int KEY_NUMERIC_7 = 0x207;
|
||||||
|
public static final int KEY_NUMERIC_8 = 0x208;
|
||||||
|
public static final int KEY_NUMERIC_9 = 0x209;
|
||||||
|
public static final int KEY_NUMERIC_STAR = 0x20a;
|
||||||
|
public static final int KEY_NUMERIC_POUND = 0x20b;
|
||||||
|
public static final int KEY_NUMERIC_A = 0x20c; /* Phone key A - HUT Telephony 0xb9 */
|
||||||
|
public static final int KEY_NUMERIC_B = 0x20d;
|
||||||
|
public static final int KEY_NUMERIC_C = 0x20e;
|
||||||
|
public static final int KEY_NUMERIC_D = 0x20f;
|
||||||
|
|
||||||
|
public static final int KEY_CAMERA_FOCUS = 0x210;
|
||||||
|
public static final int KEY_WPS_BUTTON = 0x211; /* WiFi Protected Setup key */
|
||||||
|
|
||||||
|
public static final int KEY_TOUCHPAD_TOGGLE = 0x212; /* Request switch touchpad on or off */
|
||||||
|
public static final int KEY_TOUCHPAD_ON = 0x213;
|
||||||
|
public static final int KEY_TOUCHPAD_OFF = 0x214;
|
||||||
|
|
||||||
|
public static final int KEY_CAMERA_ZOOMIN = 0x215;
|
||||||
|
public static final int KEY_CAMERA_ZOOMOUT = 0x216;
|
||||||
|
public static final int KEY_CAMERA_UP = 0x217;
|
||||||
|
public static final int KEY_CAMERA_DOWN = 0x218;
|
||||||
|
public static final int KEY_CAMERA_LEFT = 0x219;
|
||||||
|
public static final int KEY_CAMERA_RIGHT = 0x21a;
|
||||||
|
|
||||||
|
public static final int KEY_ATTENDANT_ON = 0x21b;
|
||||||
|
public static final int KEY_ATTENDANT_OFF = 0x21c;
|
||||||
|
public static final int KEY_ATTENDANT_TOGGLE = 0x21d; /* Attendant call on or off */
|
||||||
|
public static final int KEY_LIGHTS_TOGGLE = 0x21e; /* Reading light on or off */
|
||||||
|
|
||||||
|
public static final int BTN_DPAD_UP = 0x220;
|
||||||
|
public static final int BTN_DPAD_DOWN = 0x221;
|
||||||
|
public static final int BTN_DPAD_LEFT = 0x222;
|
||||||
|
public static final int BTN_DPAD_RIGHT = 0x223;
|
||||||
|
|
||||||
|
public static final int KEY_ALS_TOGGLE = 0x230; /* Ambient light sensor */
|
||||||
|
|
||||||
|
public static final int KEY_BUTTONCONFIG = 0x240; /* AL Button Configuration */
|
||||||
|
public static final int KEY_TASKMANAGER = 0x241; /* AL Task/Project Manager */
|
||||||
|
public static final int KEY_JOURNAL = 0x242; /* AL Log/Journal/Timecard */
|
||||||
|
public static final int KEY_CONTROLPANEL = 0x243; /* AL Control Panel */
|
||||||
|
public static final int KEY_APPSELECT = 0x244; /* AL Select Task/Application */
|
||||||
|
public static final int KEY_SCREENSAVER = 0x245; /* AL Screen Saver */
|
||||||
|
public static final int KEY_VOICECOMMAND = 0x246; /* Listening Voice Command */
|
||||||
|
public static final int KEY_ASSISTANT = 0x247; /* AL Context-aware desktop assistant */
|
||||||
|
|
||||||
|
public static final int KEY_BRIGHTNESS_MIN = 0x250; /* Set Brightness to Minimum */
|
||||||
|
public static final int KEY_BRIGHTNESS_MAX = 0x251; /* Set Brightness to Maximum */
|
||||||
|
|
||||||
|
public static final int KEY_KBDINPUTASSIST_PREV = 0x260;
|
||||||
|
public static final int KEY_KBDINPUTASSIST_NEXT = 0x261;
|
||||||
|
public static final int KEY_KBDINPUTASSIST_PREVGROUP = 0x262;
|
||||||
|
public static final int KEY_KBDINPUTASSIST_NEXTGROUP = 0x263;
|
||||||
|
public static final int KEY_KBDINPUTASSIST_ACCEPT = 0x264;
|
||||||
|
public static final int KEY_KBDINPUTASSIST_CANCEL = 0x265;
|
||||||
|
|
||||||
|
/* Diagonal movement keys */
|
||||||
|
public static final int KEY_RIGHT_UP = 0x266;
|
||||||
|
public static final int KEY_RIGHT_DOWN = 0x267;
|
||||||
|
public static final int KEY_LEFT_UP = 0x268;
|
||||||
|
public static final int KEY_LEFT_DOWN = 0x269;
|
||||||
|
|
||||||
|
public static final int KEY_ROOT_MENU = 0x26a; /* Show Device's Root Menu */
|
||||||
|
/* Show Top Menu of the Media (e.g. DVD) */
|
||||||
|
public static final int KEY_MEDIA_TOP_MENU = 0x26b;
|
||||||
|
public static final int KEY_NUMERIC_11 = 0x26c;
|
||||||
|
public static final int KEY_NUMERIC_12 = 0x26d;
|
||||||
|
/*
|
||||||
|
* Toggle Audio Description: refers to an audio service that helps blind and
|
||||||
|
* visually impaired consumers understand the action in a program. Note: in
|
||||||
|
* some countries this is referred to as "Video Description".
|
||||||
|
*/
|
||||||
|
public static final int KEY_AUDIO_DESC = 0x26e;
|
||||||
|
public static final int KEY_3D_MODE = 0x26f;
|
||||||
|
public static final int KEY_NEXT_FAVORITE = 0x270;
|
||||||
|
public static final int KEY_STOP_RECORD = 0x271;
|
||||||
|
public static final int KEY_PAUSE_RECORD = 0x272;
|
||||||
|
public static final int KEY_VOD = 0x273; /* Video on Demand */
|
||||||
|
public static final int KEY_UNMUTE = 0x274;
|
||||||
|
public static final int KEY_FASTREVERSE = 0x275;
|
||||||
|
public static final int KEY_SLOWREVERSE = 0x276;
|
||||||
|
/*
|
||||||
|
* Control a data application associated with the currently viewed channel,
|
||||||
|
* e.g. teletext or data broadcast application (MHEG, MHP, HbbTV, etc.)
|
||||||
|
*/
|
||||||
|
public static final int KEY_DATA = 0x277;
|
||||||
|
public static final int KEY_ONSCREEN_KEYBOARD = 0x278;
|
||||||
|
|
||||||
|
public static final int BTN_TRIGGER_HAPPY = 0x2c0;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY1 = 0x2c0;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY2 = 0x2c1;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY3 = 0x2c2;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY4 = 0x2c3;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY5 = 0x2c4;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY6 = 0x2c5;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY7 = 0x2c6;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY8 = 0x2c7;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY9 = 0x2c8;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY10 = 0x2c9;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY11 = 0x2ca;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY12 = 0x2cb;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY13 = 0x2cc;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY14 = 0x2cd;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY15 = 0x2ce;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY16 = 0x2cf;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY17 = 0x2d0;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY18 = 0x2d1;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY19 = 0x2d2;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY20 = 0x2d3;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY21 = 0x2d4;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY22 = 0x2d5;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY23 = 0x2d6;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY24 = 0x2d7;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY25 = 0x2d8;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY26 = 0x2d9;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY27 = 0x2da;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY28 = 0x2db;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY29 = 0x2dc;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY30 = 0x2dd;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY31 = 0x2de;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY32 = 0x2df;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY33 = 0x2e0;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY34 = 0x2e1;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY35 = 0x2e2;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY36 = 0x2e3;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY37 = 0x2e4;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY38 = 0x2e5;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY39 = 0x2e6;
|
||||||
|
public static final int BTN_TRIGGER_HAPPY40 = 0x2e7;
|
||||||
|
|
||||||
|
/* We avoid low common keys in module aliases so they don't get huge. */
|
||||||
|
public static final int KEY_MIN_INTERESTING = KEY_MUTE;
|
||||||
|
public static final int KEY_MAX = 0x2ff;
|
||||||
|
public static final int KEY_CNT = (KEY_MAX + 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Relative axes
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static final int REL_X = 0x00;
|
||||||
|
public static final int REL_Y = 0x01;
|
||||||
|
public static final int REL_Z = 0x02;
|
||||||
|
public static final int REL_RX = 0x03;
|
||||||
|
public static final int REL_RY = 0x04;
|
||||||
|
public static final int REL_RZ = 0x05;
|
||||||
|
public static final int REL_HWHEEL = 0x06;
|
||||||
|
public static final int REL_DIAL = 0x07;
|
||||||
|
public static final int REL_WHEEL = 0x08;
|
||||||
|
public static final int REL_MISC = 0x09;
|
||||||
|
public static final int REL_MAX = 0x0f;
|
||||||
|
public static final int REL_CNT = (REL_MAX + 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Absolute axes
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static final int ABS_X = 0x00;
|
||||||
|
public static final int ABS_Y = 0x01;
|
||||||
|
public static final int ABS_Z = 0x02;
|
||||||
|
public static final int ABS_RX = 0x03;
|
||||||
|
public static final int ABS_RY = 0x04;
|
||||||
|
public static final int ABS_RZ = 0x05;
|
||||||
|
public static final int ABS_THROTTLE = 0x06;
|
||||||
|
public static final int ABS_RUDDER = 0x07;
|
||||||
|
public static final int ABS_WHEEL = 0x08;
|
||||||
|
public static final int ABS_GAS = 0x09;
|
||||||
|
public static final int ABS_BRAKE = 0x0a;
|
||||||
|
public static final int ABS_HAT0X = 0x10;
|
||||||
|
public static final int ABS_HAT0Y = 0x11;
|
||||||
|
public static final int ABS_HAT1X = 0x12;
|
||||||
|
public static final int ABS_HAT1Y = 0x13;
|
||||||
|
public static final int ABS_HAT2X = 0x14;
|
||||||
|
public static final int ABS_HAT2Y = 0x15;
|
||||||
|
public static final int ABS_HAT3X = 0x16;
|
||||||
|
public static final int ABS_HAT3Y = 0x17;
|
||||||
|
public static final int ABS_PRESSURE = 0x18;
|
||||||
|
public static final int ABS_DISTANCE = 0x19;
|
||||||
|
public static final int ABS_TILT_X = 0x1a;
|
||||||
|
public static final int ABS_TILT_Y = 0x1b;
|
||||||
|
public static final int ABS_TOOL_WIDTH = 0x1c;
|
||||||
|
|
||||||
|
public static final int ABS_VOLUME = 0x20;
|
||||||
|
|
||||||
|
public static final int ABS_MISC = 0x28;
|
||||||
|
|
||||||
|
public static final int ABS_MT_SLOT = 0x2f; /* MT slot being modified */
|
||||||
|
public static final int ABS_MT_TOUCH_MAJOR = 0x30; /* Major axis of touching ellipse */
|
||||||
|
public static final int ABS_MT_TOUCH_MINOR = 0x31; /* Minor axis (omit if circular) */
|
||||||
|
public static final int ABS_MT_WIDTH_MAJOR = 0x32; /* Major axis of approaching ellipse */
|
||||||
|
public static final int ABS_MT_WIDTH_MINOR = 0x33; /* Minor axis (omit if circular) */
|
||||||
|
public static final int ABS_MT_ORIENTATION = 0x34; /* Ellipse orientation */
|
||||||
|
public static final int ABS_MT_POSITION_X = 0x35; /* Center X touch position */
|
||||||
|
public static final int ABS_MT_POSITION_Y = 0x36; /* Center Y touch position */
|
||||||
|
public static final int ABS_MT_TOOL_TYPE = 0x37; /* Type of touching device */
|
||||||
|
public static final int ABS_MT_BLOB_ID = 0x38; /* Group a set of packets as a blob */
|
||||||
|
public static final int ABS_MT_TRACKING_ID = 0x39; /* Unique ID of initiated contact */
|
||||||
|
public static final int ABS_MT_PRESSURE = 0x3a; /* Pressure on contact area */
|
||||||
|
public static final int ABS_MT_DISTANCE = 0x3b; /* Contact hover distance */
|
||||||
|
public static final int ABS_MT_TOOL_X = 0x3c; /* Center X tool position */
|
||||||
|
public static final int ABS_MT_TOOL_Y = 0x3d; /* Center Y tool position */
|
||||||
|
|
||||||
|
|
||||||
|
public static final int ABS_MAX = 0x3f;
|
||||||
|
public static final int ABS_CNT = (ABS_MAX + 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Switch events
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static final int SW_LID = 0x00; /* set = lid shut */
|
||||||
|
public static final int SW_TABLET_MODE = 0x01; /* set = tablet mode */
|
||||||
|
public static final int SW_HEADPHONE_INSERT = 0x02; /* set = inserted */
|
||||||
|
public static final int SW_RFKILL_ALL = 0x03; /* rfkill master switch, type "any"
|
||||||
|
set = radio enabled */
|
||||||
|
public static final int SW_RADIO = SW_RFKILL_ALL; /* deprecated */
|
||||||
|
public static final int SW_MICROPHONE_INSERT = 0x04; /* set = inserted */
|
||||||
|
public static final int SW_DOCK = 0x05; /* set = plugged into dock */
|
||||||
|
public static final int SW_LINEOUT_INSERT = 0x06; /* set = inserted */
|
||||||
|
public static final int SW_JACK_PHYSICAL_INSERT = 0x07; /* set = mechanical switch set */
|
||||||
|
public static final int SW_VIDEOOUT_INSERT = 0x08; /* set = inserted */
|
||||||
|
public static final int SW_CAMERA_LENS_COVER = 0x09; /* set = lens covered */
|
||||||
|
public static final int SW_KEYPAD_SLIDE = 0x0a; /* set = keypad slide out */
|
||||||
|
public static final int SW_FRONT_PROXIMITY = 0x0b; /* set = front proximity sensor active */
|
||||||
|
public static final int SW_ROTATE_LOCK = 0x0c; /* set = rotate locked/disabled */
|
||||||
|
public static final int SW_LINEIN_INSERT = 0x0d; /* set = inserted */
|
||||||
|
public static final int SW_MUTE_DEVICE = 0x0e; /* set = device disabled */
|
||||||
|
public static final int SW_PEN_INSERTED = 0x0f; /* set = pen inserted */
|
||||||
|
public static final int SW_MAX = 0x0f;
|
||||||
|
public static final int SW_CNT = (SW_MAX + 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Misc events
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static final int MSC_SERIAL = 0x00;
|
||||||
|
public static final int MSC_PULSELED = 0x01;
|
||||||
|
public static final int MSC_GESTURE = 0x02;
|
||||||
|
public static final int MSC_RAW = 0x03;
|
||||||
|
public static final int MSC_SCAN = 0x04;
|
||||||
|
public static final int MSC_TIMESTAMP = 0x05;
|
||||||
|
public static final int MSC_MAX = 0x07;
|
||||||
|
public static final int MSC_CNT = (MSC_MAX + 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* LEDs
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static final int LED_NUML = 0x00;
|
||||||
|
public static final int LED_CAPSL = 0x01;
|
||||||
|
public static final int LED_SCROLLL = 0x02;
|
||||||
|
public static final int LED_COMPOSE = 0x03;
|
||||||
|
public static final int LED_KANA = 0x04;
|
||||||
|
public static final int LED_SLEEP = 0x05;
|
||||||
|
public static final int LED_SUSPEND = 0x06;
|
||||||
|
public static final int LED_MUTE = 0x07;
|
||||||
|
public static final int LED_MISC = 0x08;
|
||||||
|
public static final int LED_MAIL = 0x09;
|
||||||
|
public static final int LED_CHARGING = 0x0a;
|
||||||
|
public static final int LED_MAX = 0x0f;
|
||||||
|
public static final int LED_CNT = (LED_MAX + 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Autorepeat values
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static final int REP_DELAY = 0x00;
|
||||||
|
public static final int REP_PERIOD = 0x01;
|
||||||
|
public static final int REP_MAX = 0x01;
|
||||||
|
public static final int REP_CNT = (REP_MAX + 1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sounds
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static final int SND_CLICK = 0x00;
|
||||||
|
public static final int SND_BELL = 0x01;
|
||||||
|
public static final int SND_TONE = 0x02;
|
||||||
|
public static final int SND_MAX = 0x07;
|
||||||
|
public static final int SND_CNT = (SND_MAX + 1);
|
||||||
|
}
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.stardust.autojs.runtime.record.inputevent;
|
package com.stardust.autojs.runtime.record.inputevent;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.hardware.input.InputManager;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.InputDevice;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
|
||||||
import com.stardust.autojs.engine.RootAutomatorEngine;
|
import com.stardust.autojs.engine.RootAutomatorEngine;
|
||||||
import com.stardust.autojs.runtime.api.RootAutomator;
|
import com.stardust.autojs.runtime.api.RootAutomator;
|
||||||
@@ -54,7 +57,7 @@ public class InputEventToAutoFileRecorder extends InputEventRecorder {
|
|||||||
public void recordInputEvent(@NonNull InputEventObserver.InputEvent event) {
|
public void recordInputEvent(@NonNull InputEventObserver.InputEvent event) {
|
||||||
try {
|
try {
|
||||||
convertEventOrThrow(event);
|
convertEventOrThrow(event);
|
||||||
Log.d(LOG_TAG, "recordInputEvent: " + event);
|
//Log.d(LOG_TAG, "recordInputEvent: " + event);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -65,21 +68,25 @@ public class InputEventToAutoFileRecorder extends InputEventRecorder {
|
|||||||
if (mLastEventTime == 0) {
|
if (mLastEventTime == 0) {
|
||||||
mLastEventTime = event.time;
|
mLastEventTime = event.time;
|
||||||
} else if (event.time - mLastEventTime > 0.001) {
|
} else if (event.time - mLastEventTime > 0.001) {
|
||||||
mDataOutputStream.writeByte(RootAutomator.DATA_TYPE_SLEEP);
|
writeSleep((int) (1000L * (event.time - mLastEventTime)));
|
||||||
int n = (int) (1000L * (event.time - mLastEventTime));
|
|
||||||
mDataOutputStream.writeInt(n);
|
|
||||||
mLastEventTime = event.time;
|
mLastEventTime = event.time;
|
||||||
}
|
}
|
||||||
int device = parseDeviceNumber(event.device);
|
int device = parseDeviceNumber(event.device);
|
||||||
short type = (short) Long.parseLong(event.type, 16);
|
short type = (short) Long.parseLong(event.type, 16);
|
||||||
short code = (short) Long.parseLong(event.code, 16);
|
short code = (short) Long.parseLong(event.code, 16);
|
||||||
int value = (int) Long.parseLong(event.value, 16);
|
int value = (int) Long.parseLong(event.value, 16);
|
||||||
if (type == 3) {
|
if (type == InputEventCodes.EV_ABS) {
|
||||||
if (code == 53 || code == 54) {
|
if (code == InputEventCodes.ABS_MT_POSITION_X || code == InputEventCodes.ABS_MT_POSITION_Y) {
|
||||||
mTouchDevice = device;
|
mTouchDevice = device;
|
||||||
RootAutomatorEngine.setTouchDevice(device);
|
RootAutomatorEngine.setTouchDevice(device);
|
||||||
|
writeTouch(code, value);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (type == InputEventCodes.EV_SYN && code == InputEventCodes.SYN_REPORT && value == 0) {
|
||||||
|
writeSyncReport();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (device != mTouchDevice) {
|
if (device != mTouchDevice) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -87,6 +94,29 @@ public class InputEventToAutoFileRecorder extends InputEventRecorder {
|
|||||||
mDataOutputStream.writeShort(type);
|
mDataOutputStream.writeShort(type);
|
||||||
mDataOutputStream.writeShort(code);
|
mDataOutputStream.writeShort(code);
|
||||||
mDataOutputStream.writeInt(value);
|
mDataOutputStream.writeInt(value);
|
||||||
|
Log.d(LOG_TAG, "write event: " + event);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeSleep(int millis) throws IOException {
|
||||||
|
mDataOutputStream.writeByte(RootAutomator.DATA_TYPE_SLEEP);
|
||||||
|
mDataOutputStream.writeInt(millis);
|
||||||
|
Log.d(LOG_TAG, "write sleep: " + millis);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeSyncReport() throws IOException {
|
||||||
|
mDataOutputStream.writeByte(RootAutomator.DATA_TYPE_EVENT_SYNC_REPORT);
|
||||||
|
Log.d(LOG_TAG, "write sync report");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeTouch(short code, int value) throws IOException {
|
||||||
|
if (code == InputEventCodes.ABS_MT_POSITION_X) {
|
||||||
|
mDataOutputStream.writeByte(RootAutomator.DATA_TYPE_EVENT_TOUCH_X);
|
||||||
|
Log.d(LOG_TAG, "write touch x: " + value);
|
||||||
|
} else {
|
||||||
|
mDataOutputStream.writeByte(RootAutomator.DATA_TYPE_EVENT_TOUCH_Y);
|
||||||
|
Log.d(LOG_TAG, "write touch y: " + value);
|
||||||
|
}
|
||||||
|
mDataOutputStream.writeInt(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCode() {
|
public String getCode() {
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package com.stardust.util;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
|
import android.view.Display;
|
||||||
|
import android.view.Surface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Stardust on 2017/4/26.
|
* Created by Stardust on 2017/4/26.
|
||||||
@@ -13,6 +15,7 @@ public class ScreenMetrics {
|
|||||||
private static int deviceScreenWidth;
|
private static int deviceScreenWidth;
|
||||||
private static boolean initialized = false;
|
private static boolean initialized = false;
|
||||||
private static int deviceScreenDensity;
|
private static int deviceScreenDensity;
|
||||||
|
private static Display display;
|
||||||
|
|
||||||
public static void initIfNeeded(Activity activity) {
|
public static void initIfNeeded(Activity activity) {
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
@@ -21,6 +24,7 @@ public class ScreenMetrics {
|
|||||||
deviceScreenHeight = metrics.heightPixels;
|
deviceScreenHeight = metrics.heightPixels;
|
||||||
deviceScreenWidth = metrics.widthPixels;
|
deviceScreenWidth = metrics.widthPixels;
|
||||||
deviceScreenDensity = metrics.densityDpi;
|
deviceScreenDensity = metrics.densityDpi;
|
||||||
|
display = activity.getWindowManager().getDefaultDisplay();
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,29 +66,57 @@ public class ScreenMetrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private int mScreenWidth;
|
private int mDesignWidth;
|
||||||
private int mScreenHeight;
|
private int mDesignHeight;
|
||||||
|
|
||||||
|
public ScreenMetrics(int designWidth, int designHeight) {
|
||||||
public void setScreenWidth(int screenWidth) {
|
mDesignWidth = designWidth;
|
||||||
mScreenWidth = screenWidth;
|
mDesignHeight = designHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScreenHeight(int screenHeight) {
|
public ScreenMetrics() {
|
||||||
mScreenHeight = screenHeight;
|
}
|
||||||
|
|
||||||
|
public void setDesignWidth(int designWidth) {
|
||||||
|
mDesignWidth = designWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDesignHeight(int designHeight) {
|
||||||
|
mDesignHeight = designHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int scaleX(int x) {
|
public int scaleX(int x) {
|
||||||
return scaleX(x, mScreenWidth);
|
if (display.getRotation() == Surface.ROTATION_0 || display.getRotation() == Surface.ROTATION_180)
|
||||||
|
return scaleX(x, mDesignWidth);
|
||||||
|
else
|
||||||
|
return scaleY(x, mDesignWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int scaleY(int y) {
|
public int scaleY(int y) {
|
||||||
return scaleY(y, mScreenHeight);
|
if (display.getRotation() == Surface.ROTATION_0 || display.getRotation() == Surface.ROTATION_180)
|
||||||
|
return scaleY(y, mDesignHeight);
|
||||||
|
else
|
||||||
|
return scaleX(y, mDesignHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setScreenMetrics(int width, int height) {
|
public void setScreenMetrics(int width, int height) {
|
||||||
mScreenWidth = width;
|
mDesignWidth = width;
|
||||||
mScreenHeight = height;
|
mDesignHeight = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int rescaleX(int x) {
|
||||||
|
if (display.getRotation() == Surface.ROTATION_0 || display.getRotation() == Surface.ROTATION_180)
|
||||||
|
return rescaleX(x, mDesignWidth);
|
||||||
|
else
|
||||||
|
return rescaleY(x, mDesignWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int rescaleY(int y) {
|
||||||
|
if (display.getRotation() == Surface.ROTATION_0 || display.getRotation() == Surface.ROTATION_180)
|
||||||
|
return rescaleY(y, mDesignHeight);
|
||||||
|
else
|
||||||
|
return rescaleX(y, mDesignHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user