home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 (Developer) / NS_dev_3.2.iso / NextDeveloper / Headers / bsd / dev / ev_types.h < prev    next >
Text File  |  1993-10-19  |  5KB  |  171 lines

  1. /******************************************************************************
  2.     ev_types.h
  3.     Data types for the events status driver.
  4.     This file contains public API.
  5.     mpaque 11Oct91
  6.     
  7.     Copyright 1991 NeXT Computer, Inc.
  8.     
  9.     Modified:
  10.     
  11. ******************************************************************************/
  12.  
  13. #ifndef _DEV_EV_TYPES_
  14. #define _DEV_EV_TYPES_
  15.  
  16. #import <mach/boolean.h>
  17.  
  18. /* Maximum length of SetMouseScaling arrays */
  19. #define NX_MAXMOUSESCALINGS 20
  20.  
  21. typedef struct evsioKeymapping        /* Match old struct names in kernel */
  22. {
  23.     int size;
  24.     char *mapping;
  25. } NXKeyMapping;
  26.  
  27. typedef struct evsioMouseScaling    /* Match old struct names in kernel */
  28. {
  29.     int numScaleLevels;
  30.     short scaleThresholds[NX_MAXMOUSESCALINGS];
  31.     short scaleFactors[NX_MAXMOUSESCALINGS];
  32. } NXMouseScaling;
  33.  
  34. typedef enum {
  35.     NX_OneButton,
  36.     NX_LeftButton,
  37.     NX_RightButton
  38. } NXMouseButton;
  39.  
  40.  
  41. /*
  42.  * NXEventSystemInfo() information structures.  These are designed to
  43.  * allow for expansion.
  44.  *
  45.  * The current implementation of NXEventSystemInfo() uses an ioctl call.
  46.  * THIS WILL CHANGE.
  47.  */
  48.  
  49. /*
  50.  * Generic query max size and typedefs.
  51.  *
  52.  *    The maximum size is selected to support anticipated future extensions
  53.  *    of request flavors.  Certain flavors planned for future releases may 
  54.  *    require roughtly 800 ints to represent.  We allow a little extra, in
  55.  *    case further growth is needed.
  56.  */
  57. typedef int *NXEventSystemInfoType;
  58. #define NX_EVS_INFO_MAX        (1024)    /* Max array size */
  59. typedef int NXEventSystemInfoData[NX_EVS_INFO_MAX];
  60.  
  61. /* Event System Devices query */
  62. #define NX_EVS_DEVICE_MAX    16
  63.  
  64.     /* Interface types */
  65. #define NX_EVS_DEVICE_INTERFACE_OTHER        0
  66. #define NX_EVS_DEVICE_INTERFACE_NeXT        1 // NeXT custom, in older sys
  67. #define NX_EVS_DEVICE_INTERFACE_ADB        2 // NeXT/fruit keybds/mice
  68. #define NX_EVS_DEVICE_INTERFACE_ACE        3 // For x86 PC keyboards
  69. #define NX_EVS_DEVICE_INTERFACE_SERIAL_ACE    4 // For PC serial mice 
  70. #define NX_EVS_DEVICE_INTERFACE_BUS_ACE        5 // For PC bus mice 
  71.  
  72.     /* Device types */
  73. #define NX_EVS_DEVICE_TYPE_OTHER    0
  74. #define NX_EVS_DEVICE_TYPE_KEYBOARD    1
  75. #define NX_EVS_DEVICE_TYPE_MOUSE    2    // Relative position devices
  76. #define NX_EVS_DEVICE_TYPE_TABLET    3    // Absolute position devices
  77.  
  78. typedef struct {
  79.     int    interface;    /* NeXT, ADB, other */
  80.     int    interface_addr;    /* Device address on the interface */
  81.     int    dev_type;    /* Keyboard, mouse, tablet, other */
  82.     int    id;        /* manufacturer's device handler ID */
  83. } NXEventSystemDevice;
  84.  
  85. typedef struct {
  86.     NXEventSystemDevice    dev[NX_EVS_DEVICE_MAX];
  87. } NXEventSystemDeviceList;
  88.  
  89. #define __OLD_NX_EVS_DEVICE_INFO        1
  90. #define NX_EVS_DEVICE_INFO            "Evs_EventDeviceInfo"
  91. #define NX_EVS_DEVICE_INFO_COUNT \
  92.     (sizeof (NXEventSystemDeviceList) / sizeof (int))
  93.  
  94. /*
  95.  * Multiprocessor locks used within the shared memory area between the
  96.  * kernel and event system.  These must work in both user and kernel mode.
  97.  * 
  98.  * These routines are public, for the purpose of writing frame buffer device
  99.  * drivers which handle their own cursors.  Certain architectures define a
  100.  * generic display class which handles cursor drawing and is subclassed by
  101.  * driver writers.  These drivers need not be concerned with the following
  102.  * types and definitions.
  103.  *
  104.  * The ev_lock(), ev_unlock(), and ev_try_lock() functions are available only
  105.  * to drivers built in or dynamically loaded into the kernel, and to DPS
  106.  * drivers built in or dynamically loaded into the Window Server.  They do not
  107.  * exist in any shared library.
  108.  */
  109.  
  110. typedef volatile int    ev_lock_data_t;
  111. typedef ev_lock_data_t    *ev_lock_t;
  112.  
  113. extern void ev_lock(ev_lock_t l);        // Spin lock!
  114. extern void ev_unlock(ev_lock_t l);
  115. extern boolean_t ev_try_lock(ev_lock_t l);
  116.  
  117. #define ev_init_lock(l)        (*(l) = (ev_lock_data_t)0)
  118. #define ev_is_locked(l)        (*(l) != (ev_lock_data_t)0)
  119.  
  120. /* The following typedefs are defined here for compatibility with PostScript */
  121.  
  122. #if !defined(__Point__) && !defined(BINTREE_H)
  123. #define __Point__
  124. typedef struct { short x, y; } Point;
  125. #endif
  126.  
  127. #if !defined(__Bounds__) && !defined(BINTREE_H)
  128. #define __Bounds__
  129. typedef struct { short minx, maxx, miny, maxy; } Bounds;
  130. #endif
  131.  
  132. /*
  133.  * Types used in evScreen protocol compliant operations.
  134.  */
  135.  
  136. typedef enum {EVNOP, EVHIDE, EVSHOW, EVMOVE, EVLEVEL} EvCmd; /* Cursor state */
  137.  
  138. #define EV_SCREEN_MIN_BRIGHTNESS    0
  139. #define EV_SCREEN_MAX_BRIGHTNESS    64
  140. /* Scale should lie between MIN_BRIGHTNESS and MAX_BRIGHTNESS */
  141. #define EV_SCALE_BRIGHTNESS( scale, datum ) \
  142.     ((((unsigned long)(datum))*((unsigned long)scale)) >> 6)
  143.  
  144. /*
  145.  * Definition of a tick, as a time in milliseconds. This controls how
  146.  * often the event system periodic jobs are run.  All actual tick times
  147.  * are derived from the nanosecond timer.  These values are typically used
  148.  * as part of computing mouse velocity for acceleration purposes.
  149.  */
  150. #define EV_TICK_TIME        16            /* 16 milliseconds */
  151. #define EV_TICKS_PER_SEC    (1000/EV_TICK_TIME)    /* ~ 62 Hz */
  152. #define EV_NS_TO_TICK(ns)    ((ns)>>24)
  153. #define EV_TICK_TO_NS(tick)    (((ns_time_t)(tick))<<24)
  154.  
  155. /* Mouse Button bits, as passed from an EventSrc to the Event Driver */
  156. #define EV_RB        (0x01)
  157. #define EV_LB        (0x04)
  158. #define EV_MOUSEBUTTONMASK    (EV_LB | EV_RB)
  159.  
  160. /* Tablet Pressure Constants, as passed from an EventSrc to the Event Driver */
  161. #define EV_MINPRESSURE 0
  162. #define EV_MAXPRESSURE 255
  163.  
  164. /* Cursor size in pixels */
  165. #define EV_CURSOR_WIDTH        16
  166. #define EV_CURSOR_HEIGHT    16
  167.  
  168.  
  169. #endif /* _DEV_EV_TYPES_ */
  170.  
  171.