home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / tek / peg.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-03-04  |  11.1 KB  |  365 lines

  1. /***********************************************************
  2. Copyright 1987 by Tektronix, Beaverton, Oregon,
  3. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  4.  
  5.                         All Rights Reserved
  6.  
  7. Permission to use, copy, modify, and distribute this software and its
  8. documentation for any purpose and without fee is hereby granted,
  9. provided that the above copyright notice appear in all copies and that
  10. both that copyright notice and this permission notice appear in
  11. supporting documentation, and that the names of Tektronix or MIT not be
  12. used in advertising or publicity pertaining to distribution of the
  13. software without specific, written prior permission.
  14.  
  15. TEKTRONIX DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  16. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  17. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  18. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  19. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  20. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21. SOFTWARE.
  22.  
  23. ******************************************************************/
  24. /* $Header: peg.h,v 1.4 90/03/05 11:41:40 keith Exp $ */
  25.  
  26. #ifndef PEG_H
  27. #define PEG_H
  28.  
  29. #include <sys/types.h>
  30.  
  31. #ifdef    UTEK
  32. #include <box/display.h>
  33. #include <machine/hdwr_config.h>
  34. #include "svc.h"
  35. #endif    /* UTEK */
  36.  
  37. #ifdef    UTEKV
  38. #include "redwing/keyboard.h"
  39. #include "redwing/display.h"
  40. #endif    /* UTEK */
  41.  
  42. #include "colormapst.h"
  43. #include <assert.h>
  44. #include <stdio.h>
  45.  
  46. #ifdef NOTDEF
  47. #include "color.h"
  48. #include "pfb.h"
  49. #endif
  50. #include "debug.h"
  51.  
  52. #define MOTION_BUFFER_OFF
  53.  
  54. /*
  55.  * Pathname for the 8 bells used in pegInitBells().
  56.  */
  57. #define    BELLNAME    "/usr/lib/X11/bells/bell%d.dev"
  58.  
  59. /*
  60.  * Pathnames for configuration variables.
  61.  */
  62. #define XSYSCONTROLS    "/usr/lib/X/Xcontrols"
  63. #define XUSRCONTROLS    "/.Xcontrols"
  64.  
  65. /*
  66.  * Constants used for configuring the memory for X11.
  67.  */
  68. #define    ONE_MB        0x100000
  69. #define    FOUR_MB        0x400000
  70. #define    STACK_SIZE    (2*ONE_MB)
  71.  
  72.  
  73. /*
  74.  * Minimum value for a keycode according to the spec (1-7 are reserved
  75.  * for other things).
  76.  */
  77. #define MINKEYCODE    8
  78.  
  79. /*
  80.  * A buffer size for internal buffers.
  81.  */
  82. #define    BUFFERSIZE    1024
  83.  
  84. #ifdef    UTEK
  85. /*
  86.  * short defines for accessing fields within the UTEK soft_config struct
  87.  */
  88. #define CPU_BOARD(softp)    (softp)->sc_hdwr.cpu_u.hc_cpu.cpu_board
  89. #define DISPLAY_TYPE(softp)    (softp)->sc_hdwr.screen_u.hc_screen.dtype
  90. #define SCREEN_X(softp)        (softp)->sc_hdwr.screen_u.hc_screen.screen_x
  91. #define SCREEN_Y(softp)        (softp)->sc_hdwr.screen_u.hc_screen.screen_y
  92. #define MM_SCREEN_X(softp)    (softp)->sc_hdwr.screen_u.hc_screen.mm_screen_x
  93. #define MM_SCREEN_Y(softp)    (softp)->sc_hdwr.screen_u.hc_screen.mm_screen_y
  94. #define BITMAP_X(softp)        (softp)->sc_hdwr.screen_u.hc_screen.bitmap_x
  95. #define BITMAP_Y(softp)        (softp)->sc_hdwr.screen_u.hc_screen.bitmap_y
  96. #define N_PLANE(softp)        (softp)->sc_hdwr.screen_u.hc_screen.fb_nplane
  97. #define KEYIDLANG(softp) \
  98.     ((softp)->sc_info.sc_regs.keyboardlangidstyle & 0xff00)
  99. #define KEYIDSTYLE(softp) \
  100.     ((softp)->sc_info.sc_regs.keyboardlangidstyle & 0xff)
  101.  
  102. #endif    /* UTEK */
  103.  
  104. #ifdef    UTEKV
  105. /*
  106.  * short defines for accessing fields within the Redwing - Xdriver shared memory
  107.  */
  108. #define DISPLAY_TYPE(dsp)    (dsp)->ds_displayModel
  109. #define SCREEN_X(dsp)        (dsp)->ds_fbScreen_x
  110. #define SCREEN_Y(dsp)        (dsp)->ds_fbScreen_y
  111. #define BITMAP_X(dsp)        (dsp)->ds_fbBitmap_x
  112. #define BITMAP_Y(dsp)        (dsp)->ds_fbBitmap_y
  113. #define N_PLANE(dsp)        (dsp)->ds_fbDepth
  114. #define KEYIDLANG(dsp)        ((dsp)->keyboardlangidstyle & 0xff00)
  115. #define KEYIDSTYLE(dsp)        ((dsp)->keyboardlangidstyle & 0xff)
  116. #endif    /* UTEKV */
  117.  
  118. #define    N_BELLS        8    /* XXX - this should accomodate X11 better */
  119. #define    N_TIMERS    4
  120. #define    KEYREPEAT    0
  121. #define    JOYNSREPEAT    1    /* north-south repeat */
  122. #define    JOYEWREPEAT    2    /* east-west repeat */
  123. #define    PANREPEAT    3
  124.  
  125. #define    True        1
  126. #define    False        0
  127.  
  128. #define    JoyKeyToMask(key)    (1<<((key)-KBJoyRight))
  129. #define    JOYRIGHT_BIT    JoyKeyToMask(KBJoyRight)    /* 0x1 */
  130. #define    JOYUP_BIT    JoyKeyToMask(KBJoyUp)        /* 0x2 */
  131. #define    JOYLEFT_BIT    JoyKeyToMask(KBJoyLeft)        /* 0x4 */
  132. #define    JOYDOWN_BIT    JoyKeyToMask(KBJoyDown)        /* 0x8 */
  133. #define    JOYEWMASK    (JOYRIGHT_BIT|JOYLEFT_BIT)
  134. #define    JOYNSMASK    (JOYUP_BIT|JOYDOWN_BIT)
  135. #define    JoyEWDepressed    (pegInfo.kv.joyState & JOYEWMASK)
  136. #define    JoyNSDepressed    (pegInfo.kv.joyState & JOYNSMASK)
  137. #define    JoyDepressed    (pegInfo.kv.joyState & (JOYEWMASK | JOYNSMASK))
  138.  
  139. #ifdef XTESTEXT1
  140. /*
  141.  * The Input synthesis extension uses these to disallow AutoRepeating while
  142.  * ProcessInputEvents is processing synthetic keypress events
  143.  */
  144. extern int AllowAutoRepeat;
  145. #define    DISALLOW_AUTOREPEAT    (AllowAutoRepeat = 0)
  146. #define    ALLOW_AUTOREPEAT    (AllowAutoRepeat = 1)
  147. #define    AUTOREPEAT_ALLOWED    (AllowAutoRepeat)
  148. #else
  149. #define AUTOREPEAT_ALLOWED    (TRUE)
  150. #endif
  151.  
  152. /*
  153.  * KeyDepressed() determines if a mapped keycode is depressed;
  154.  * rawKeyDepressed() determines if a keycode directly out of box/keyboard.h
  155.  * is depressed.
  156.  */
  157. #define    _checkmask(array, code)    ((array)[ (code) >> 3 ] & (1 << ((code) & 7)))
  158. #define    _setmask(array, code)    ((array)[ (code) >> 3 ] |= (1 << ((code) & 7)))
  159.  
  160. #define    RawKeyDepressed(k)                        \
  161.         _checkmask(((DeviceIntPtr)pegInfo.pKeyboard)->key->down, k+MINKEYCODE)
  162. #define    KeyDepressed(k)                        \
  163.         _checkmask(((DeviceIntPtr)pegInfo.pKeyboard)->key->down, k)
  164. #define    KeyRepeatable(k)                        \
  165.         _checkmask(                            \
  166.         ((DeviceIntPtr)pegInfo.pKeyboard)->kbdfeed->ctrl.autoRepeats, \
  167.         k)
  168. #define    MakeRawKeyRepeatable(k)                    \
  169.         _setmask(                            \
  170.         ((DeviceIntPtr)pegInfo.pKeyboard)->kbdfeed->ctrl.autoRepeats, \
  171.              k+MINKEYCODE)
  172. #define    KeyIsModifier(k)                        \
  173.         ((DeviceIntPtr)pegInfo.pKeyboard)->key->modifierMap[k]
  174. #define    AutoRepeatOn()                            \
  175.         ((((DeviceIntPtr)pegInfo.pKeyboard)->kbdfeed->ctrl.autoRepeat != 0) \
  176.         && AUTOREPEAT_ALLOWED)
  177.  
  178. /*
  179.  * At most, there are three things we want timers for: panning, joy disk
  180.  * key repeats, and normal key repeats.  So, we have a list of three timers.
  181.  * For setting the timer, we simply look for the next timer to happen and
  182.  * put that in the display state.  When we get the timeout event, we simply
  183.  * service any timer that appears to have expired.
  184.  */ 
  185. typedef struct _timer {
  186.     u_long    when;
  187.     short    key;
  188.     short    delay;
  189. } Timer;
  190.  
  191. typedef struct _bells {
  192.     int    fd;
  193.         char    *str[ N_BELLS ];
  194.         int     len[ N_BELLS ];
  195. } Bells;
  196.  
  197. typedef struct _keyvars {
  198.     Timer        timer[ N_TIMERS ];
  199.     Bool        panEnabled;        /* true if panning is on */
  200.     Bool        panStop;        /* true if panning continues */
  201.                         /* after release of the key */
  202.     Bool        readyToUnlock;        /* used to implement toggle */
  203.     long        panInertia;        /* behaviour after panning */
  204.                         /* key is released */
  205.     long        nPanDelays;
  206.     long        nPanDeltaX;        /* used only during init */
  207.     long        nPanDeltaY;        /* used only during init */
  208.     long        *panDelays;
  209.     long        *panDeltaX;
  210.     long        *panDeltaY;
  211.     long        nKeyDelays;
  212.     long        *keyDelays;
  213.     long        joyState;        /* state of the joy disk */
  214.     short        keyStack[ MAP_LENGTH ];    /* stack of repeating keys */
  215.     unsigned short    keyTOS;            /* Top of stack for keyStack */
  216. } KeyVars;
  217.  
  218. /* this is a guess at the register layout.  No documentation could
  219.  * be found...
  220.  */
  221.  
  222. typedef struct _cdp_regs {
  223.     unsigned long   write0Reg,
  224.             write1Reg,
  225.             planeEnableReg,
  226.             filterReg,
  227.             maskRegSet;
  228.     unsigned long   pad[5]; /* defined length is 10 */
  229. } COLOR_CNTL;
  230.  
  231. /* hack... */
  232. typedef long    MotionQueue;
  233.  
  234. typedef struct _init {
  235.         ScreenPtr    pScr;        /* ...if not otherwise available */
  236.     caddr_t        pixelFb;    /* packed-pixel frame buffer address */
  237.     caddr_t        oneColorFb;    /* one-color frame buffer address */
  238.     caddr_t        twoColorFb;    /* two-color frame buffer address */
  239.     caddr_t        videoCtl;    /* address of video control register */
  240.     COLOR_CNTL    *cdpCtl;    /* address of cdp control register */
  241.     SvcColorDefPtr    colorDefDefault;
  242.     DevicePtr    pKeyboard;
  243.     DevicePtr    pPointer;
  244.     Bool        screenIsSaved;    /* true if screen saver is active */
  245.     Bool        softwareCursor;    /* true if cursor is not in hardware */
  246.     int        width;        /* width of frame buffer in pixels */
  247.     int        height;        /* height of frame buffer in pixels */
  248.     int        depth;        /* screen depth (an array in future?) */
  249.     int        entries;    /* # of colormap entries (2**depth) */
  250.     int        scrWidth;    /* width of visible screen */
  251.     int        scrHeight;    /* height of visible screen */
  252.     int        mmScreenX;    /* Screen width in mm */
  253.     int        mmScreenY;    /* Screen height in mm */
  254.     int        consolePid;    /* process id to send console output */
  255.     int        eventFd;    /* file desc. for select on events */
  256.     int        lastEventTime;
  257.     int        qLimit;        /* maximum queable events */
  258.     int        nSupportedDepths;/* count of supportedDepths */
  259.     int        nVisuals;    /* count of visuals */
  260.     VisualPtr    visuals;    /* supported visuals */
  261.     DepthPtr    supportedDepths;/* supported depths */
  262.     EventQueue    *queue;        /* pointer to shared mem queue */
  263.     MotionQueue     *motionQueue;   /* pointer to motion history queue */
  264.     BoxRec        constraintBox;    /* box where cursor is constrained */
  265. #ifdef    UTEK
  266.     struct soft_config *softp;    /* pointer to software config block */
  267. #endif    /* UTEK */
  268.     XDisplayState    *dsp;        /* shared memory w/ X kernel driver */
  269.     KeyVars        kv;
  270.     Bells        bells;
  271.         int             fAvailableCDP;    /* True iff CDP can be used */
  272. #ifdef    UTEK
  273.     unsigned short    *videostate;    /* pointer to kernel - videostate
  274.                      * shadow var. in soft_config (UTek).
  275.                      */
  276. #endif    /* UTEK */
  277. #ifdef    UTEKV
  278.     unsigned char    *videostate;    /* pointer to kernel - videostate
  279.                      * shadow var. in xdisplaystate (UTEKV).
  280.                      */
  281. #endif    /* UTEKV */
  282.  
  283. } InitInfo;
  284.  
  285. extern InitInfo    pegInfo;
  286.  
  287. /*
  288.  * Test Consortium Input Extension variables
  289.  */
  290. #ifdef XTESTEXT1
  291. extern SvcCursorXY LastMousePosition;    /* Previous Cursor position */
  292. /*
  293.  * defined in xtestext1di.c
  294.  */
  295. extern KeyCode xtest_command_key;
  296. extern int      on_steal_input;
  297. extern Bool     XTestStealKeyData();
  298. #endif /* XTESTEXT1 */
  299.  
  300. /*
  301.  * Library declarations.
  302.  */
  303. extern char    *index();
  304. extern char    *strpbrk();
  305. extern char    *strtok();
  306. extern char    *getenv();
  307.  
  308. /*
  309.  * global pegasus routines.
  310.  */
  311. extern Bool peg1ScreenInit();
  312. extern Bool pegSaveScreen();
  313. extern Bool pegRealizeCursor();
  314. extern Bool pegUnrealizeCursor();
  315. extern void pegRecolorCursor();
  316. extern Bool pegDisplayCursor();
  317. extern Bool peg1DisplayCursor();
  318. extern Bool pegSetCursorPosition();
  319. extern void pegCursorLimits();
  320. extern void pegPointerNonInterestBox();
  321. extern void pegConstrainCursor();
  322. extern void pegQueryBestSize();
  323. extern void pegInitKeys();
  324. extern void InitKeybdState();
  325. extern int pegMouseProc();
  326. extern int pegKeybdProc();
  327.  
  328. /*
  329.  * Routines for software cursor protection.
  330.  */
  331. extern Bool pegSoftCreateWindow();
  332. extern Bool pegSoftCreateGC();
  333. extern Bool pegSoftChangeWindowAttr();
  334. extern void pegSoftGetImage();
  335. extern unsigned int *pegSoftGetSpans();
  336.  
  337. /*
  338.  * pfb routines needed here.
  339.  */
  340. extern Bool pfbScreenInit();
  341. extern Bool pfbCloseScreen();
  342. extern void pfb1ResolveColor();
  343. extern void pfb1CreateColormap();
  344. extern void pfbInstallColormap();
  345. extern void pfbUninstallColormap();
  346. extern void pfbListInstalledColormaps();
  347. extern void pfbStoreColors();
  348.  
  349. /*
  350.  * gfb routines needed here.
  351.  */
  352. extern void gfbXTLKBMappings();
  353. extern int gfbInitMotionQueue();
  354. extern int gfbGetMotionEvents();
  355. extern int gfbSaveMotionEvent();
  356. extern int gfbSendMotionEvent();
  357.  
  358.  
  359. /*
  360.  * external mi routines needed here... not many.
  361.  */
  362. void miRecolorCursor();
  363.  
  364. #endif /* PEG_H */
  365.