📄 gui_mouse_driverps2.lst
字号:
C51 COMPILER V8.05a GUI_MOUSE_DRIVERPS2 04/11/2008 14:18:45 PAGE 1
C51 COMPILER V8.05a, COMPILATION OF MODULE GUI_MOUSE_DRIVERPS2
OBJECT MODULE PLACED IN GUI_MOUSE_DriverPS2.obj
COMPILER INVOKED BY: D:\Program Files\keil\C51\BIN\C51.EXE gui\Core\GUI_MOUSE_DriverPS2.c LARGE BROWSE MDU_F120 DEBUG OB
-JECTEXTEND PRINT(.\GUI_MOUSE_DriverPS2.lst) OBJECT(GUI_MOUSE_DriverPS2.obj)
line level source
1 /*
2 *********************************************************************************************************
3 * uC/GUI
4 * Universal graphic software for embedded applications
5 *
6 * (c) Copyright 2002, Micrium Inc., Weston, FL
7 * (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
8 *
9 * 礐/GUI is protected by international copyright laws. Knowledge of the
10 * source code may not be used to write a similar product. This file may
11 * only be used in accordance with a license and should not be redistributed
12 * in any way. We appreciate your understanding and fairness.
13 *
14 ----------------------------------------------------------------------
15 File : GUITOUCH.C
16 Purpose : Touch screen manager
17 ----------------------------------------------------------------------
18 This module handles the touch screen. It is configured in the file
19 GUITouch.conf.h (Should be located in the Config\ directory).
20 ----------------------------------------------------------------------
21 */
22
23
24 #include "gui\Core\LCD_Private.h" /* private modul definitions & config */
25 #include "gui\Core\GUI_Protected.h"
26
27 /*********************************************************************
28 *
29 * Local Variables & Defines
30 *
31 **********************************************************************
32 */
33
34 static int _ScreenX = 0; /* x-pos */
35 static int _ScreenY = 0; /* y-pos */
36 static int _NumBytesInBuffer = 0; /* bytes in rx buffer */
37 static U8 _Buttons = 0; /* button status */
38 static U8 _abInBuffer[3]; /* mouse rx buffer */
39
40
41
42 /*********************************************************************
43 *
44 * _EvaPacket
45 *
46 **********************************************************************
47
48 Process data packet from mouse:
49
50 D7 D6 D5 D4 D3 D2 D1 D0
51 -----------------------------------------------
52 1st byte | -- -- Y- X- 1 -- LB RB
53 2nd byte | X7 X6 X5 X4 X3 X2 X1 X0
54 3rd byte | Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0
C51 COMPILER V8.05a GUI_MOUSE_DRIVERPS2 04/11/2008 14:18:45 PAGE 2
55
56 */
57
58 static void _EvaPacket(void) {
59 1 char a;
60 1 GUI_PID_STATE State;
61 1 _Buttons = _abInBuffer[0] & 0x03;
62 1 a = _abInBuffer[1];
63 1 // test x move sign.
64 1 if(_abInBuffer[0] & 0x10) {
65 2 a=-a;
66 2 _ScreenX -= a;
67 2 } /* direction is negative, move left */
68 1 else {
69 2 _ScreenX += a;
70 2 }
71 1 a = _abInBuffer[2];
72 1 // test y move sign.
73 1 if(_abInBuffer[0] & 0x20) {
74 2 a=-a;
75 2 _ScreenY += a;
76 2 } /* direction is negative, move down */ else {
77 2 _ScreenY -= a;
78 2 }
79 1 /* check min/max positions */
80 1 if (_ScreenX < 0) {
81 2 _ScreenX = 0;
82 2 } else if (_ScreenX > LCD_XSIZE-1) {
83 2 _ScreenX = LCD_XSIZE-1;
84 2 } if (_ScreenY < 0) {
85 2 _ScreenY = 0;
86 2 } else if (_ScreenY > LCD_YSIZE-1) {
87 2 _ScreenY = LCD_YSIZE-1;
88 2 }
89 1 /* signal new mouse data */
90 1 State.x = _ScreenX;
91 1 State.y = _ScreenY;
92 1 State.Pressed = _Buttons;
93 1 GUI_MOUSE_StoreState(&State);
94 1 }
95
96
97 /*********************************************************************
98 *
99 * GUI_MOUSE_DRIVER_PS2_OnRx : Mouse receive interrupt handler
100 *
101 **********************************************************************
102
103 The PS2 mouse interrupt gets in three bytes from the mouse, then wakes
104 up the mouse LSR.
105 */
106
107 void GUI_MOUSE_DRIVER_PS2_OnRx(unsigned char Data) {
108 1 if (!_NumBytesInBuffer) {
109 2 /* check for start frame */
110 2 if ((Data & 0x0c) == 0x08) {
111 3 _abInBuffer[0] = Data;
112 3 _NumBytesInBuffer++;
113 3 }
114 2 } else {
115 2 _abInBuffer[_NumBytesInBuffer] = Data;
116 2 _NumBytesInBuffer++;
C51 COMPILER V8.05a GUI_MOUSE_DRIVERPS2 04/11/2008 14:18:45 PAGE 3
117 2 if (_NumBytesInBuffer >= 3) {
118 3 _EvaPacket();
119 3 _NumBytesInBuffer = 0;
120 3 }
121 2 }
122 1 }
123
124 /*********************************************************************
125 *
126 * GUI_MOUSE_DRIVER_PS2_Init
127 *
128 **********************************************************************
129 */
130
131 void GUI_MOUSE_DRIVER_PS2_Init(void) {
132 1 _NumBytesInBuffer = 0;
133 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 349 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = 10 5
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -