Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
在你之后
rt-thread
提交
af2b9b99
R
rt-thread
项目概览
在你之后
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
af2b9b99
编写于
11月 18, 2017
作者:
B
Bernard Xiong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[DeviceDrivers][USB Stack] code cleanup
上级
8cb012a0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
86 addition
and
75 deletion
+86
-75
components/drivers/usb/usbhost/class/umouse.c
components/drivers/usb/usbhost/class/umouse.c
+86
-75
未找到文件。
components/drivers/usb/usbhost/class/umouse.c
浏览文件 @
af2b9b99
...
@@ -15,19 +15,22 @@
...
@@ -15,19 +15,22 @@
#include <rtthread.h>
#include <rtthread.h>
#include <drivers/usb_host.h>
#include <drivers/usb_host.h>
#include "hid.h"
#include "hid.h"
#ifdef RT_USING_RTGUI
#ifdef RT_USING_RTGUI
#include <rtgui/event.h>
#include <rtgui/event.h>
#include <rtgui/rtgui_server.h>
#include <rtgui/rtgui_server.h>
#include "drv_lcd.h"
#include "drv_lcd.h"
#endif
#endif
#if defined(RT_USBH_HID) && defined(RT_USBH_HID_MOUSE)
#if defined(RT_USBH_HID) && defined(RT_USBH_HID_MOUSE)
static
struct
uprotocal
mouse_protocal
;
static
struct
uprotocal
mouse_protocal
;
#ifdef RT_USING_RTGUI
#ifdef RT_USING_RTGUI
#define LKEY_PRESS 0x01
#define LKEY_PRESS 0x01
#define RKEY_PRESS 0x02
#define RKEY_PRESS 0x02
#define MKEY_PRESS 0x04
#define MKEY_PRESS 0x04
#define MOUSE_SCALING 0x02
#define MOUSE_SCALING 0x02
static
rt_bool_t
lkey_down
=
RT_FALSE
;
static
rt_bool_t
lkey_down
=
RT_FALSE
;
//static rt_bool_t rkey_down=RT_FALSE;
//static rt_bool_t rkey_down=RT_FALSE;
//static rt_bool_t mkey_down=RT_FALSE;
//static rt_bool_t mkey_down=RT_FALSE;
...
@@ -36,86 +39,94 @@ static struct rtgui_event_mouse emouse;
...
@@ -36,86 +39,94 @@ static struct rtgui_event_mouse emouse;
static
rt_err_t
rt_usbh_hid_mouse_callback
(
void
*
arg
)
static
rt_err_t
rt_usbh_hid_mouse_callback
(
void
*
arg
)
{
{
struct
uhid
*
hid
;
struct
uhid
*
hid
;
#ifdef RT_USING_RTGUI
#ifdef RT_USING_RTGUI
rt_uint16_t
xoffset
=
0
;
rt_uint16_t
xoffset
=
0
;
rt_uint16_t
yoffset
=
0
;
rt_uint16_t
yoffset
=
0
;
#endif
#endif
hid
=
(
struct
uhid
*
)
arg
;
hid
=
(
struct
uhid
*
)
arg
;
RT_DEBUG_LOG
(
RT_DEBUG_USB
,
(
"hid 0x%x 0x%x
\n
"
,
RT_DEBUG_LOG
(
RT_DEBUG_USB
,
(
"hid 0x%x 0x%x
\n
"
,
*
(
rt_uint32_t
*
)
hid
->
buffer
,
*
(
rt_uint32_t
*
)
hid
->
buffer
,
*
(
rt_uint32_t
*
)(
&
hid
->
buffer
[
4
])));
*
(
rt_uint32_t
*
)(
&
hid
->
buffer
[
4
])));
#ifdef RT_USING_RTGUI
#ifdef RT_USING_RTGUI
if
(
hid
->
buffer
[
1
]
!=
0
)
if
(
hid
->
buffer
[
1
]
!=
0
)
{
{
if
(
hid
->
buffer
[
1
]
>
127
)
if
(
hid
->
buffer
[
1
]
>
127
)
{
{
xoffset
=
(
256
-
hid
->
buffer
[
1
])
*
MOUSE_SCALING
;
xoffset
=
(
256
-
hid
->
buffer
[
1
])
*
MOUSE_SCALING
;
if
(
emouse
.
x
>
xoffset
)
if
(
emouse
.
x
>
xoffset
)
{
{
emouse
.
x
-=
xoffset
;
emouse
.
x
-=
xoffset
;
}
else
}
{
else
{
emouse
.
x
=
0
;
emouse
.
x
=
0
;
}
}
}
else
}
{
else
xoffset
=
(
hid
->
buffer
[
1
])
*
MOUSE_SCALING
;
{
if
((
emouse
.
x
+
xoffset
)
<
480
)
xoffset
=
(
hid
->
buffer
[
1
])
*
MOUSE_SCALING
;
{
if
((
emouse
.
x
+
xoffset
)
<
480
)
{
emouse
.
x
+=
xoffset
;
emouse
.
x
+=
xoffset
;
}
else
}
{
else
{
emouse
.
x
=
480
;
emouse
.
x
=
480
;
}
}
}
}
}
}
if
(
hid
->
buffer
[
2
]
!=
0
)
if
(
hid
->
buffer
[
2
]
!=
0
)
{
{
if
(
hid
->
buffer
[
2
]
>
127
)
if
(
hid
->
buffer
[
2
]
>
127
)
{
{
yoffset
=
(
256
-
hid
->
buffer
[
2
])
*
MOUSE_SCALING
;
yoffset
=
(
256
-
hid
->
buffer
[
2
])
*
MOUSE_SCALING
;
if
(
emouse
.
y
>
yoffset
)
if
(
emouse
.
y
>
yoffset
)
{
{
emouse
.
y
-=
yoffset
;
emouse
.
y
-=
yoffset
;
}
else
}
{
else
{
emouse
.
y
=
0
;
emouse
.
y
=
0
;
}
}
}
else
}
{
else
yoffset
=
hid
->
buffer
[
2
]
*
MOUSE_SCALING
;
{
if
(
emouse
.
y
+
yoffset
<
272
)
yoffset
=
hid
->
buffer
[
2
]
*
MOUSE_SCALING
;
{
if
(
emouse
.
y
+
yoffset
<
272
)
{
emouse
.
y
+=
yoffset
;
emouse
.
y
+=
yoffset
;
}
else
}
{
else
{
emouse
.
y
=
272
;
emouse
.
y
=
272
;
}
}
}
}
}
}
if
(
xoffset
!=
0
||
yoffset
!=
0
)
if
(
xoffset
!=
0
||
yoffset
!=
0
)
{
{
cursor_set_position
(
emouse
.
x
,
emouse
.
y
);
cursor_set_position
(
emouse
.
x
,
emouse
.
y
);
}
}
if
(
hid
->
buffer
[
0
]
&
LKEY_PRESS
)
if
(
hid
->
buffer
[
0
]
&
LKEY_PRESS
)
{
{
if
(
lkey_down
==
RT_FALSE
){
if
(
lkey_down
==
RT_FALSE
)
// rt_kprintf("mouse left key press down\n");
{
emouse
.
button
=
(
RTGUI_MOUSE_BUTTON_LEFT
|
RTGUI_MOUSE_BUTTON_DOWN
);
// rt_kprintf("mouse left key press down\n");
rtgui_server_post_event
(
&
emouse
.
parent
,
sizeof
(
struct
rtgui_event_mouse
));
emouse
.
button
=
(
RTGUI_MOUSE_BUTTON_LEFT
|
RTGUI_MOUSE_BUTTON_DOWN
);
lkey_down
=
RT_TRUE
;
rtgui_server_post_event
(
&
emouse
.
parent
,
sizeof
(
struct
rtgui_event_mouse
));
}
lkey_down
=
RT_TRUE
;
}
else
if
(
lkey_down
==
RT_TRUE
)
}
{
}
// rt_kprintf("mouse left key press up\n");
else
if
(
lkey_down
==
RT_TRUE
)
emouse
.
button
=
(
RTGUI_MOUSE_BUTTON_LEFT
|
RTGUI_MOUSE_BUTTON_UP
);
{
rtgui_server_post_event
(
&
emouse
.
parent
,
sizeof
(
struct
rtgui_event_mouse
));
// rt_kprintf("mouse left key press up\n");
lkey_down
=
RT_FALSE
;
emouse
.
button
=
(
RTGUI_MOUSE_BUTTON_LEFT
|
RTGUI_MOUSE_BUTTON_UP
);
}
rtgui_server_post_event
(
&
emouse
.
parent
,
sizeof
(
struct
rtgui_event_mouse
));
#endif
lkey_down
=
RT_FALSE
;
}
#endif
return
RT_EOK
;
return
RT_EOK
;
}
}
...
@@ -123,24 +134,24 @@ static rt_err_t rt_usbh_hid_mouse_init(void* arg)
...
@@ -123,24 +134,24 @@ static rt_err_t rt_usbh_hid_mouse_init(void* arg)
{
{
struct
uintf
*
intf
=
(
struct
uintf
*
)
arg
;
struct
uintf
*
intf
=
(
struct
uintf
*
)
arg
;
RT_ASSERT
(
intf
!=
RT_NULL
);
RT_ASSERT
(
intf
!=
RT_NULL
);
rt_usbh_hid_set_protocal
(
intf
,
0
);
rt_usbh_hid_set_protocal
(
intf
,
0
);
rt_usbh_hid_set_idle
(
intf
,
10
,
0
);
rt_usbh_hid_set_idle
(
intf
,
10
,
0
);
RT_DEBUG_LOG
(
RT_DEBUG_USB
,
(
"start usb mouse
\n
"
));
RT_DEBUG_LOG
(
RT_DEBUG_USB
,
(
"start usb mouse
\n
"
));
#ifdef RT_USING_RTGUI
#ifdef RT_USING_RTGUI
RTGUI_EVENT_MOUSE_BUTTON_INIT
(
&
emouse
);
RTGUI_EVENT_MOUSE_BUTTON_INIT
(
&
emouse
);
emouse
.
wid
=
RT_NULL
;
emouse
.
wid
=
RT_NULL
;
cursor_display
(
RT_TRUE
);
cursor_display
(
RT_TRUE
);
#endif
#endif
return
RT_EOK
;
return
RT_EOK
;
}
}
/**
/**
* This function will define the hid mouse protocal, it will be register to the protocal list.
* This function will define the hid mouse protocal, it will be register to the protocal list.
*
*
* @return the keyboard protocal structure.
* @return the keyboard protocal structure.
*/
*/
uprotocal_t
rt_usbh_hid_protocal_mouse
(
void
)
uprotocal_t
rt_usbh_hid_protocal_mouse
(
void
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录