提交 af2b9b99 编写于 作者: B Bernard Xiong

[DeviceDrivers][USB Stack] code cleanup

上级 8cb012a0
......@@ -15,11 +15,13 @@
#include <rtthread.h>
#include <drivers/usb_host.h>
#include "hid.h"
#ifdef RT_USING_RTGUI
#include <rtgui/event.h>
#include <rtgui/rtgui_server.h>
#include "drv_lcd.h"
#endif
#if defined(RT_USBH_HID) && defined(RT_USBH_HID_MOUSE)
static struct uprotocal mouse_protocal;
......@@ -28,6 +30,7 @@ static struct uprotocal mouse_protocal;
#define RKEY_PRESS 0x02
#define MKEY_PRESS 0x04
#define MOUSE_SCALING 0x02
static rt_bool_t lkey_down=RT_FALSE;
//static rt_bool_t rkey_down=RT_FALSE;
//static rt_bool_t mkey_down=RT_FALSE;
......@@ -55,17 +58,20 @@ static rt_err_t rt_usbh_hid_mouse_callback(void* arg)
if(emouse.x>xoffset)
{
emouse.x-=xoffset;
}else
}
else
{
emouse.x=0;
}
}else
}
else
{
xoffset=(hid->buffer[1])*MOUSE_SCALING;
if((emouse.x+xoffset)<480)
{
emouse.x+=xoffset;
}else
}
else
{
emouse.x=480;
}
......@@ -80,17 +86,20 @@ static rt_err_t rt_usbh_hid_mouse_callback(void* arg)
if(emouse.y>yoffset)
{
emouse.y-=yoffset;
}else
}
else
{
emouse.y=0;
}
}else
}
else
{
yoffset=hid->buffer[2]*MOUSE_SCALING;
if(emouse.y+yoffset<272)
{
emouse.y+=yoffset;
}else
}
else
{
emouse.y=272;
}
......@@ -102,13 +111,15 @@ static rt_err_t rt_usbh_hid_mouse_callback(void* arg)
}
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);
rtgui_server_post_event(&emouse.parent, sizeof(struct rtgui_event_mouse));
lkey_down=RT_TRUE;
}
}else if(lkey_down==RT_TRUE)
}
else if(lkey_down==RT_TRUE)
{
// rt_kprintf("mouse left key press up\n");
emouse.button = (RTGUI_MOUSE_BUTTON_LEFT | RTGUI_MOUSE_BUTTON_UP);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册