Welcome to the EyeBot  Version 7 - RPi1
A Controller For Various Hardware IO
Functions
key.c File Reference

Defines functions for the key input. More...

#include "key.h"
#include "globals.h"
#include "lcd.h"

Functions

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...
 
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...
 
int KEYRelease (void)
 Close the evdev device file and stop checking any key touch event. More...
 
int inside (int x, int y, BOX rect)
 Check if a point is inside a rectangle. More...
 
int KEYIdle (int idle)
 Enable/disable event checking procedure. More...
 
KEYCODE KEYWait (KEYCODE excode)
 Wait for specific keys only. More...
 
KEYCODE KEYGet (void)
 Wait for a touch event and return keycode (including KEY_INVALID - undefined keycode). More...
 
COORD_PAIR KEYGetXY ()
 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...
 
KEYCODE KEYRead (void)
 Read a keycode and returns. Function does not wait, thus includes KEY_TIMEOUT. More...
 
int activate_escape (int escape)
 

Detailed Description

Defines functions for the key input.

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