Welcome to the EyeBot  Version 7 - RPi1
A Controller For Various Hardware IO
Macros | Functions | Variables
key.h File Reference

Header file for the key functions. More...

#include "types.h"
#include <stdio.h>

Go to the source code of this file.

Macros

#define KEY1   0x00000001
 
#define KEY2   0x00000002
 
#define KEY3   0x00000004
 
#define KEY4   0x00000008
 
#define ANYKEY   0xFFFFFFFF
 
#define KEY_ESCAPE   0x80000000
 
#define KEY_LISTTL   0x40000000
 
#define KEY_LISTUP   0x20000000
 
#define KEY_LISTDN   0x10000000
 
#define KEY_LIST1   0x00000010
 
#define KEY_LIST2   0x00000020
 
#define KEY_LIST3   0x00000040
 
#define KEY_LIST4   0x00000080
 
#define KEY_LIST5   0x00000100
 
#define KEY_LIST6   0x00000200
 
#define KEY_LIST7   0x00000400
 
#define KEY_LIST8   0x00000800
 
#define KEY_GOIDLE   1
 
#define KEY_NOIDLE   0
 
#define KEY_STATE   -1
 
#define KEY_GOIDLE   1
 
#define KEY_NOIDLE   0
 
#define KEY_STATE   -1
 
#define KEYTM_UNKNOWN   0x00
 
#define KEYTM_CLASSIC   0x01
 
#define KEYTM_STANDARD   0x02
 
#define KEYTM_REGIONS   0x03
 
#define KEYTM_LISTMENU   0x04
 
#define KEY_TIMEOUT   0x00000000
 
#define KEY_INVALID   0xFFFFFFFF
 

Functions

int inside (int x, int y, BOX rect)
 Check if a point is inside a rectangle. More...
 
int KEYInit (void)
 Open the evdev device file for reading touch events. Load the key configuration file (if found), else use the hardcoded default value. More...
 
int KEYRelease (void)
 Close the evdev device file and stop checking any key touch event. More...
 
int KEYIdle (int idle)
 Enable/disable event checking procedure. More...
 
KEYMODE KEYSetTM (KEYMODE mode)
 Set mode for key touch map. More...
 
KEYMODE KEYGetTM (TOUCH_MAP **ptouch_map)
 Get current mode and touch map (region map). More...
 
int KEYSetRegion (int index, BOX *region)
 Manually set region data into current touch map. Only used in KEYTM_REGIONS mode. If region is 0x0, resets the touch map (mode becomes KEYTM_UNKNOWN). More...
 
int KEYGetRegion (int index, BOX *region)
 Copy specific region data out from the current touch map. Only used in KEYTM_REGIONS mode. More...
 
int KEYNoTouch (TOUCH_EVENT *rawtouch)
 Validate there's no touch on screen surface. More...
 
int KEYGetRAW (TOUCH_EVENT *rawtouch)
 Gets raw touch info - a non-blocking function. Mainly used for calibration and testing. More...
 
KEYCODE KEYDecode (TOUCH_EVENT *rawtouch)
 Decode raw touch info into a keycode based on the current touch map. Mainly used for testing. More...
 
KEYCODE KEYWait (KEYCODE excode)
 Wait for specific keys only. More...
 
KEYCODE KEYRead (void)
 Read a keycode and returns. Function does not wait, thus includes KEY_TIMEOUT. More...
 
KEYCODE KEYGet (void)
 Wait for a touch event and return keycode (including KEY_INVALID - undefined keycode). More...
 
COORD_PAIR KEYGetXY (void)
 Wait for a touch event and return the XY-coordinate. More...
 
int KEYXY (int *x, int *y)
 Wait for a touch event and return the XY-coordinate. More...
 
int activate_escape (int escape)
 

Variables

int KEY_INITIAL
 

Detailed Description

Header file for the key functions.

Author
Marcus Pham & Remi KEAT

Function Documentation

int inside ( int  x,
int  y,
BOX  rect 
)

Check if a point is inside a rectangle.

Parameters
intx : X-coordinate of the point
inty : Y-coordinate of the point
BOXrect : rectangle structure
Returns
int retVal : non-null if inside
KEYCODE KEYDecode ( TOUCH_EVENT rawtouch)

Decode raw touch info into a keycode based on the current touch map. Mainly used for testing.

Parameters
TOUCH_EVENT*rawtouch : pointer to TOUCH_EVENT structure
Returns
KEYCODE keyCode : Status of touch data (variable in rawtouch)
KEYCODE KEYGet ( void  )

Wait for a touch event and return keycode (including KEY_INVALID - undefined keycode).

Returns
KEYCODE retKey : Keycode value
int KEYGetRAW ( TOUCH_EVENT rawtouch)

Gets raw touch info - a non-blocking function. Mainly used for calibration and testing.

Parameters
TOUCH_EVENT*rawtouch : pointer to TOUCH_EVENT structure
Returns
int retVal :
0 if sync signal received!
Negative value if otherwise
int KEYGetRegion ( int  index,
BOX region 
)

Copy specific region data out from the current touch map. Only used in KEYTM_REGIONS mode.

Parameters
intindex : Index for region
BOX*region : Pointer to a storage for region data
Returns
int retVal : 0 on success
Negative value on failure
KEYMODE KEYGetTM ( TOUCH_MAP **  ptouch_map)

Get current mode and touch map (region map).

Parameters
TOUCH_MAP**ptouch_map : Pointer to a TOUCH_MAP structure
Returns
KEYMODE retMod : Current touch map mode
COORD_PAIR KEYGetXY ( void  )

Wait for a touch event and return the XY-coordinate.

Returns
COORD_PAIR retCoord : Coordinate pair
int KEYIdle ( int  idle)

Enable/disable event checking procedure.

Parameters
intidle : user request

Valid values for idle:

  • KEY_GOIDLE - deactivate event checking
  • KEY_NOIDLE - activate event checking
  • KEY_STATE - request current status
Returns
int status : Idle status of event checking procedure
int KEYInit ( void  )

Open the evdev device file for reading touch events. Load the key configuration file (if found), else use the hardcoded default value.

Returns
int retVal : 0 on success
Negative value on failure
int KEYNoTouch ( TOUCH_EVENT rawtouch)

Validate there's no touch on screen surface.

Parameters
TOUCH_EVENT*rawtouch : pointer to TOUCH_EVENT structure this is optional! only if raw data needed! else, use 0x0!
Returns
int retVal :
0 - being touched
1 - not touched
KEYCODE KEYRead ( void  )

Read a keycode and returns. Function does not wait, thus includes KEY_TIMEOUT.

Returns
retKey the Keycode value
int KEYRelease ( void  )

Close the evdev device file and stop checking any key touch event.

Returns
int retVal : 0 on success
Negative value on failure
int KEYSetRegion ( int  index,
BOX region 
)

Manually set region data into current touch map. Only used in KEYTM_REGIONS mode. If region is 0x0, resets the touch map (mode becomes KEYTM_UNKNOWN).

Parameters
intindex : Index for region
BOX*region : Pointer to a region data
Returns
int retVal : 0 on success
Negative value on failure
KEYMODE KEYSetTM ( KEYMODE  mode)

Set mode for key touch map.

Parameters
KEYMODEmode : Requested touch map mode
Returns
KEYMODE retMod : Current touch map mode
KEYCODE KEYWait ( KEYCODE  excode)

Wait for specific keys only.

Parameters
KEYCODEexcode : Expected keycode values (bit XORed)
Returns
KEYCODE retKey : Keycode value
int KEYXY ( int *  x,
int *  y 
)

Wait for a touch event and return the XY-coordinate.

Parameters
xa pointer to the horizontal coord
ya pointer to the vertical coord
Returns
always 0