MiniGUI IAL engine implementation

xiaoxiao2021-03-06  67

2 How to add a new IAL engine in Minigui: (assuming the new IAL engine is _name_ial)

1. Add a new engine in the IAl.c file:

For example: (in the cent.c file)

A) #ifdef _name _ial #include "name.h" #ENDIF

B) Add in the input array

#ifdef _name _ial {"name", initnameInput, termitameInput}, #ENDIF

2. Add new .C to the makefile.am file.

3. Modify the Profile IAL engine item and use this new IAL engine _Name_ial.

2 How to write IAL engines:

1. The concept of input abstractrat layer, IAL is introduced in MiniGUI, which greatly enhances the portability of MiniGUI.

2. IAL is a set of definitions that do not depend on any special hardware abstract interface. And the IAL engine we mentioned here is the underlying code for the implementation of the abstract interface defined by IAL.

3. The IAL interface is the IAL engine, which uses some functions provided by the input device driver; the application or GDI is the application or GDI. The parseEvent () function in the upper minigui library will pass these IAL engines to the mouse The keyboard event is converted to messages in MiniGUI.

4. The MiniGUI IAl structure is as follows:

In the code implementation, the MiniGUI represents the input engine via the input data structure.

Typedef struct taginput

{

CHAR * ID;

// Initialization and Termination

Bool (* init_input) (Struct Taginput * Input, Const Char * MDEV, Const Char * mtype);

Void (* Term_INPUT) (Void);

// mouse Operations

INT (* update_mouse) (void);

Void (* get_mouse_xy) (int * x, int * y);

Void (* set_mouse_xy) (int X, int y);

INT (* get_mouse_button) (void);

Void (* set_mouse_range) (int Minx, Int miny, int Maxx, int MAXY);

Void (* suspend_mouse) (void);

INT (* resume_mouse) (void);

// Keyboard Operations

INT (* update_keyboard) (void);

Const char * (* get_keyboard_state) (void);

Void (* suspend_keyboard) (void);

INT (* resume_keyboard) (void);

Void (* set_leds) (UNSIGNED INT LEDS);

// Event

#ifdef _lite_version

INT (* Wait_Event) (int WHICH, INT MAXFD, FD_SET * IN, FD_SET * OUT, FD_SET * EXCEPT,

Struct TimeVal * Timeout;

#ELSE

INT (* Wait_Event) (int WHICH, FD_SET * IN, FD_SET * OUT, FD_SET * EXCEPT, STRUCT TIMEVAL * TIMEOUT);

#ENDIF

Char Mdev [MAX_PATH 1];

} Input;

EXTERN INPUT * CUR_INPUT;

After the system is activated, the specific input engine will be found as the current input engine, and the global variable CUR_INPUT is assigned to the global variable.

For writing, it is convenient to define the C language macron of the current engine.

#define IAL_INITINPUT (* Cur_Input-> Init_Input)

#define IAL_TERMINPUT (* CUR_INPUT-> Term_input)

#define IAL_UPDATEMOUSE (* CUR_INPUT-> UPDATE_MOUSE)

#define IAL_GETMOUSEXY (* Cur_INPUT-> GET_MOUSE_XY)

#define IAL_GETMOUSEBUTTON (* CUR_INPUT-> get_mouse_button)

#define IAL_SETMOUSEXY IF (CUR_INPUT-> SET_MOUSE_XY) (* Cur_Input-> set_mouse_xy)

#define IAL_SETMOUSERANGE IF (CUR_INPUT-> SET_MOUSE_RANGE) (* Cur_Input-> set_mouse_range)

#define IAL_SUSPENDMOUSE IF (CUR_INPUT-> SUSPEND_MOUSE) (* Cur_Input-> Suspend_Mouse)

#define IAL_UPDATEKEYBOARD (* Cur_Input-> Update_Keyboard)

#define IAL_GetKeyBoardState (* Cur_Input-> get_keyboard_state)

#define IAL_SUSPENDKEYBOARD IF (CUR_INPUT-> SUSPEND_KEYBOARD) (* Cur_Input-> Suspend_Keyboard)

#define IAL_SETLEDS (LEDS) IF (CUR_INPUT-> SET_LEDS) (* CUR_INPUT-> Set_LEDS) (LEDS)

5. We write IAL engines to do these functions defined in the input engine structure in _name_ial.c. Such as: _Name_Ial.c:

#include .........

…………..Variable definitions

/ ***************************************************************************************************************************************************TION * /

mouse_update ()

{

...............

}

mouse_getxy ()

{

..................

}

mouse_getbutton ()

{

..................

}

............ The other functionality of the mouse in the .ial engine structure generally does not need to be implemented.

Keyboard_Update ()

{

................

}

Keyboard_getState ()

{

.........

}

.................. Other functions defined in the same structure generally do not need to be implemented.

Wait_Event ()

{

..................

}

InitNameInput (Input * Input, Const Char * MDEV, Const Char * mtype) {

..........

Input-> Update_mouse = mouse_update;

Input-> GET_MOUSE_XY = mouse_getxy;

Input-> set_mouse_xy = NULL;

Input-> get_mouse_button = mouse_getbutton;

INPUT-> set_mouse_range = NULL;

Input-> Update_keyboard = keyboard_update;

Input-> get_keyboard_state = keyboard_getstate;

Input-> set_leds = NULL;

Input-> WAIT_EVENT = WAIT_EVENT;

..................

}

Void TermNameInput (Void)

{

..............

}

6. Each function function Description: Development of an input engine is generally the following functions.

Ø The initNameInput function is the initialization function of the NAME input engine defined in SRC / IAL / IAL.C, which opens the touch screen (mouse) and the keyboard device file. After successfully opening these two device files, this function sets other members of the INPUT structure. Some of these members are assigned NULL.

The Ø mouse_update function always returns 1, indicating that the update mouse is successful.

Ø Mouse_getxy function Returns the mouse position prepared by other functions, it is possible to make the appropriate boundary check and the support screen display to rotate the coordinate. The parameter of the function is two pointer variables.

Ø Mouse_getButton function returns the touch screen status, that is, whether the user touches the screen, which is equivalent to pressing the left button. (Or which button is pressed, the left button, right click or the one?)

The return value is a touch screen (mouse) state.

Ø Keyboard_UPDATE function is ready to fill the State array appropriately according to other functions. The return value is NR_KEYS.

Ø Keyboard_State function returns the address of the State array: "Return State".

Ø WAIT_EVENT function is the core function of the input engine. This function first combines the file descriptor of the previously opened two devices with the incoming IN file descriptor set together, and then calls the SELECT system call. When the SELECT system call returns a value greater than 0, the function checks if there is readable data on the two file descriptors waiting to be read, and if yes, the touch screen and button data are read from the two file descriptors, respectively.

Return Value INT RETVALUE variable, which contains information: mouse events, keyboard events, or mouse and keyboard events happen (RetValue | = IAL_KEYEVENT).

7. Develop IAL engines to achieve the above functions:

Ø Development IAL engine preparation: Some need to know the input device:

a) Is it a mouse, touch screen or touchpad? What are the keys?

b) What is the data package format? (Similarly to touch screen, different models have different data structures through the device file, if the A / D converted raw data processing is a bit trouble; the release of the keyboard and the pressing status is the character read by judging the character read How is the highest bit 0 and 1 to determine, or to the same key to press and release the code corresponding to two uninable characters) C) The code is the same as the miniGUI is defined in INCLUDE / COMMON.H?

d) Do you need to conversion between coordinates and screen display coordinates? The final returned coordinates in mouse_getxy are the screen display coordinates.

e) Enter the device driver Support SELECT system call?

f) Whether the touch screen (touchpad) driver solves the problem of jitter cancellation, do you need to resolve the touch screen in the IAL engine?

Ø Summary of the IAL engine developed for specific systems:

a) The work you have to do in the engine has been reacted in the above function function description, but it is specifically processed, not necessarily required to complete it in a function. For example, the information of the mouse coordinate is read from the device file and processes it. It is not necessarily completed in mouse_getxy, can be completed in Wait_Event or Update_Mouse, only the final display screen coordinate the mouse_getxy function in Mouse_Getxy function. parameter.

b) The role of the IAL engine is to correctly analyze the data read from the device file, obtain the mouse (touch screen, touchpad) coordinates and status and keyboard press (which key press? This button is released?). This is us Develop a guide to the IAL engine.

c) Use of the IAL engine in MiniGUI (location):

Ø In /src/sever/server.c196 function idlehandler4Server () uses IAL_Waitevent in the input engine to check if there is a bottom input event,

Ø Check these events when there is a mouse (touch screen, touchpad) event, or the keyboard event occurs, and use the Parseevent (MSG_QUE, EVENT) function (/SRC/sever/server.c), respectively.

Parseevent (msg_queue, IAL_MOUSEEVENT)

Parseevent (msg_queue, IAL_keyevent)

Parseevent (msg_queue, 0)

Ø Parseevent (MSG_QUE, Event) function first calls getLwEvent (LWE is defined in Parseevent), analyzes Event (Event, & LWE).

When Event is IAL_KEYEVENT:

Call the engine IAL_UPDATEKEYBOARD () and IAL_GetKeyboardState ()

When Event is IAL_MOUSEEVENT:

Call the engine IAL_UPDATEMOUSE () and functions Refreshcursor (& me-> x, & me-> y, & butt) (IAL_GETMOUSEXY (X, Y) and IAL_GETMOUSEBUTTON are called in this function)

GetLwevent (Event, & LWE) finally got specific information such as the coordinate state of the mouse keyboard, which is brought back by the LWE variable. Variable LWE data structure:

Typedef struct _lwevent

{

INT TYPE;

INT country;

DWORD status;

LWEVENTDATA DATA;

LWEVENT;

Typedef union _lweventdata {

MouseEvent ME;

KeyEvent KE;

} Lweventdata;

Ø Parseevent (MSG_QUE, EVENT) Using LWE is used to convert it into a message, put it in the message queue. Such as the keyboard:

Msg.Message = msg-keydown

Msg.wparam = ke-> scancode

Msg.iparam = KE-> status

Ø getLwevent (Event, & LWE) Collect the underlying input event LWE (using the IAL engine)

Parseevent (MSG_QUE, Event) converts these events that are collected into messages that can be understood.

d) The IAL engine with the keyboard is assigned to the State array.

MiniGUI lists the locations in the state array in Include / Common.h (such as #define scancode_z 44 can know the status of the 44 element in the State array representation of the Z key), we must analyze the read from the keyboard profile The information of the character byte is assigned to the respective elements in the state array based on this information, so that MiniGUI can correctly handle these events according to the state array (ie, MINIGUI is the element in the state array to correct which key is pressed. Must be strict State of the State array).

8. Write an input engine to refer to IPAQ.c, which is a more common touch screen.

9. Write the touch screen interface code. Note: The data acquired by the mouse is generally relative coordinates, and the typical touch screen is an absolute coordinate (different drive is directly returned to A / D conversion raw data).

转载请注明原文地址:https://www.9cbs.com/read-86797.html

New Post(0)