gonzui


Format: Advanced Search

tkernel_2/include/device/lowkbpd.hbare sourcepermlink (0.05 seconds)

Search this content:

    1: /*
    2:  *----------------------------------------------------------------------
    3:  *    T-Kernel 2.0 Software Package
    4:  *
    5:  *    Copyright 2011 by Ken Sakamura.
    6:  *    This software is distributed under the latest version of T-License 2.x.
    7:  *----------------------------------------------------------------------
    8:  *
    9:  *    Released by T-Engine Forum(http://www.t-engine.org/) at 2011/05/17.
   10:  *    Modified by TRON Forum(http://www.tron.org/) at 2015/06/01.
   11:  *
   12:  *----------------------------------------------------------------------
   13:  */
   14: 
   15: /*
   16:  *      lowkbpd.h
   17:  *
   18:  *       low-level KB/PD driver
   19:  */
   20: 
   21: #ifndef __DEVICE_LOWKBPD_H__
   22: #define __DEVICE_LOWKBPD_H__
   23: 
   24: #include <basic.h>
   25: #include <tk/syscall.h>
   26: 
   27: #ifdef __cplusplus
   28: extern "C" {
   29: #endif
   30: 
   31: /* transmission from real I/O driver */
   32: 
   33: typedef enum {
   34:         INP_PD = 0,            /* PD data                       */
   35:         INP_KEY = 1,           /* key data                        */
   36:         INP_FLG = 2,           /* event flag registration */
   37:         INP_PD2        = 3,           /* pd data 2            */
   38:         SpecialReserve = -1    /* negative numbers are reserved for special purpose */
   39: } InputCmd;
   40: 
   41: /* device error */
   42: typedef enum {
   43:         DEV_OK         = 0,   /* normal                            */
   44:         DEV_OVRRUN     = 1,        /* data overrun during receiving             */
   45:         DEV_FAIL       = 2,  /* hardware malfunction              */
   46:         DEV_SYSERR     = 3,        /* problem of real I/O driver         */
   47:         DEV_RESET      = 15 /* reset                  */
   48: } DevError;
   49: 
   50: /* INP_PD : sending PD input    */
   51: typedef struct {
   52:         UW     read:1;             /* already read flag            */
   53:         InputCmd cmd:7;                /* = INP_PD                      */
   54:         UW     rsv1:4;             /* reserved(0)                        */
   55:         DevError err:4;                /* device error              */
   56: 
   57:         UW     nodsp:1;    /* hide pointer      */
   58:         UW     absalt:1;   /* adjusting absolute coordinate (ordinary 0)      */
   59:         UW     onebut:1;   /* one button operation */
   60:         UW     abs:1;              /* coordinate is absolute or relative         */
   61:         UW     norel:1;    /* relative mode not supported  */
   62:         UW     tmout:1;    /* PD timeout is in effect  */
   63:         UW     butrev:1;   /* enable button left-right swap            */
   64:         UW     xyrev:1;    /* enable XY coordinate values swap            */
   65: 
   66: #if BIGENDIAN
   67:         UW     rsv3:3;             /* reserved (0)                        */
   68:         UW     qpress:1;   /* quick press modifiver             */
   69:         UW     inv:1;              /* out of valid area (coordinates are invalid)        */
   70:         UW     vst:1;              /* enter the valid area from outside        */
   71:         UW     sub:1;              /* subbutton status              */
   72:         UW     main:1;             /* main button status              */
   73: #else
   74:         UW     main:1;             /* main button status              */
   75:         UW     sub:1;              /* subbutton status              */
   76:         UW     vst:1;              /* enter the valid area from outside        */
   77:         UW     inv:1;              /* out of valid area (coordinates are invalid)        */
   78:         UW     qpress:1;   /* quick press modifiver             */
   79:         UW     rsv3:3;             /* reserved (0)                        */
   80: #endif
   81: } PdInStat;
   82: 
   83: typedef struct {
   84:         T_MSG  head;
   85:         PdInStat stat;
   86:         H      xpos;                /* X coordinate (relative / absolute) */
   87:         H      ypos;                /* Y coordinate (relative / absolute)         */
   88: } PdInput;
   89: 
   90: /*
   91:  * normalized coordinate
   92:  *       if the ratio of height and width of the real screen and the ratio of the normalized coordinate is different by a large factor,
   93:  *       pointer movement looks very strange. Be warned.
   94:  */
   95: #define PDIN_XMAX       4096
   96: #define PDIN_YMAX       3072
   97: 
   98: /* INP_PD2: transmission 2 of PD input    */
   99: typedef struct {
  100:         UW     read:1;             /* already read flag            */
  101:         InputCmd cmd:7;                /* = INP_PD2                      */
  102:         UW     rsv1:4;             /* reserved(0)                        */
  103:         DevError err:4;                /* device error              */
  104:         UW     rsv2:16;    /* reserved (0)                        */
  105: } PdIn2Stat;
  106: 
  107: typedef struct {
  108:         T_MSG  head;
  109:         PdIn2Stat stat;
  110:         H      wheel;               /* wheel rotation amount      */
  111:         H      rsv;         /* reserved(0)                        */
  112: } PdInput2;
  113: 
  114: /* INP_KEY: transmission of key input      */
  115: typedef struct {
  116:         UW     read:1;             /* already read flag            */
  117:         InputCmd cmd:7;                /* = INP_KEY                      */
  118:         UW     rsv1:4;             /* reserved(0)                        */
  119:         DevError err:4;                /* device error              */
  120:         UW     rsv2:7;             /* reserved(0)                        */
  121:         UW     tenkey:1;   /* 1 in the case of ten key pad */
  122:         UW     kbid:7;             /* keyboard ID              */
  123:         UW     press:1;    /* ON : 1, OFF : 0         */
  124: } KeyInStat;
  125: 
  126: typedef struct {
  127:         T_MSG  head;
  128:         KeyInStat stat;
  129:         W      keytop;              /* key top code              */
  130: } KeyInput;
  131: 
  132: /* INP_FLG: registration and de-registration of event flag for command */
  133: 
  134: typedef struct {
  135:         UW     read:1;             /* already read flag            */
  136:         InputCmd cmd:7;                /* = INP_FLG                      */
  137:         UW     rsv1:4;             /* reserved(0)                        */
  138:         DevError err:4;                /* always DEV_OK                    */
  139:         UW     rsv2:7;             /* reserved(0)                        */
  140:         UW     kb:1;               /* 1 when kbid is valid                 */
  141:         UW     kbid:7;             /* keyboard ID              */
  142:         UW     reg:1;              /* registration : 1, de-registration : 0      */
  143: } FlgInStat;
  144: 
  145: typedef struct {
  146:         T_MSG  head;
  147:         FlgInStat stat;
  148:         ID     flgid;              /* event flag ID            */
  149: } FlgInput;
  150: 
  151: 
  152: /* send command to real I/O driver */
  153: 
  154: /* PD scan speed command rate = 0 - 15 */
  155: #define ScanRateCmd(rate)       (0x01000000 | (rate))
  156: 
  157: /* PD sensivitity command :   sense = 0 - 15     sensivitity
  158:  *                               | PD_ABS        request absolude mode
  159:  *                               | PD_ACMSK      accelleration (0 - 7)
  160:  *      PD_ABS
  161:  *      if absolute mode request is sent, a PD that can operate in absolute mode must use absolute mode
  162:  *      before sending back the data for INP_PD .
  163:  *       if there is no absolute mode request, then if PD can operate in relative mode, use relative modes
  164:  *      before sending back the data for INP_PD .
  165:  *               specified: event with absolute position (PdInStat.abs = 1)
  166:  *               not specified : event with relative postion (PdInStat.abs = 0)
  167:  *
  168:  *      PD_ACMSK
  169:  *       setting up acceleration to update pointer location (effective only in relative mode)
  170:  *       0       no acceleration
  171:  *       1 - 7 acceleration (small to large)
  172:  */
  173: #define SenseCmd(sense)         (0x02000000 | (sense))
  174: 
  175: /* input mode command  :  mode  :  value for InputMode
  176:                                 (HiraMode, AlphaMode, KataMode, CapsMode) */
  177: #define InputModeCmd(mode)      (0x03000000 | (mode))
  178: 
  179: /* suspend / resume command */
  180: #define SuspendKBPD             (0x10000000)
  181: #define ResumeKBPD              (0x10000001)
  182: 
  183: /* flag to show that command to real I/O driver can be sent */
  184: #define DeviceCommandReady      (0x80000000)
  185: 
  186: #ifdef __cplusplus
  187: }
  188: #endif
  189: #endif /* __DEVICE_LOWKBPD_H__ */