1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright (c) 1985,1997-1998 by Sun Microsystems, Inc. 24*7c478bd9Sstevel@tonic-gate * All rights reserved. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate /* 28*7c478bd9Sstevel@tonic-gate * This file is used by the code of a virtual user input device 29*7c478bd9Sstevel@tonic-gate * (vuid) state maintainence package (see ../sundev/vuid_event.h for a 30*7c478bd9Sstevel@tonic-gate * description of what vuid is) and is private to that implementation. 31*7c478bd9Sstevel@tonic-gate * It implements the interface defined by ../sunwindowdev/vuid_state.h. 32*7c478bd9Sstevel@tonic-gate */ 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate #ifndef _SYS_VUID_STORE_H 35*7c478bd9Sstevel@tonic-gate #define _SYS_VUID_STORE_H 36*7c478bd9Sstevel@tonic-gate 37*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 38*7c478bd9Sstevel@tonic-gate 39*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 40*7c478bd9Sstevel@tonic-gate extern "C" { 41*7c478bd9Sstevel@tonic-gate #endif 42*7c478bd9Sstevel@tonic-gate 43*7c478bd9Sstevel@tonic-gate /* 44*7c478bd9Sstevel@tonic-gate * The typical struct vuid_seg state list contains 2 segments: 45*7c478bd9Sstevel@tonic-gate * 46*7c478bd9Sstevel@tonic-gate * First, the VKEY_FIRST segment with four values in its list, 47*7c478bd9Sstevel@tonic-gate * LOC_*_ABSOLUTE and LOC_*_DELTA. The rest of the values are 48*7c478bd9Sstevel@tonic-gate * booleans. The vuid storage package know to update the 49*7c478bd9Sstevel@tonic-gate * LOC_*_ABSOLUTE value when its gets a LOC_*_DELTA and visa 50*7c478bd9Sstevel@tonic-gate * versa. 51*7c478bd9Sstevel@tonic-gate * The ascii/meta segment has all booleans. 52*7c478bd9Sstevel@tonic-gate * 53*7c478bd9Sstevel@tonic-gate * The implementation is skewed to optimize the space usage but 54*7c478bd9Sstevel@tonic-gate * still be efficient in terms of accessing short vuid_value lists 55*7c478bd9Sstevel@tonic-gate * (e.g., during high volume mouse tracking) and gang requests 56*7c478bd9Sstevel@tonic-gate * about the state of shift buttons. 57*7c478bd9Sstevel@tonic-gate */ 58*7c478bd9Sstevel@tonic-gate 59*7c478bd9Sstevel@tonic-gate /* 60*7c478bd9Sstevel@tonic-gate * A component of virutal user input device (vuid) state storage. 61*7c478bd9Sstevel@tonic-gate * A struct vuid_value holds a single non-boolean value. 62*7c478bd9Sstevel@tonic-gate */ 63*7c478bd9Sstevel@tonic-gate typedef struct vuid_value { 64*7c478bd9Sstevel@tonic-gate struct vuid_value *next; /* Next node in list */ 65*7c478bd9Sstevel@tonic-gate ushort_t offset; /* Offset of value from seg addr */ 66*7c478bd9Sstevel@tonic-gate int value; /* Value */ 67*7c478bd9Sstevel@tonic-gate } Vuid_value; 68*7c478bd9Sstevel@tonic-gate #define VUID_VALUE_NULL ((Vuid_value *)0) 69*7c478bd9Sstevel@tonic-gate 70*7c478bd9Sstevel@tonic-gate #define BITSPERBYTE 8 71*7c478bd9Sstevel@tonic-gate #define VUID_BIT_ARRAY_SIZE (VUID_SEG_SIZE/((sizeof (char))*BITSPERBYTE)) 72*7c478bd9Sstevel@tonic-gate /* 73*7c478bd9Sstevel@tonic-gate * A component of virutal user input device (vuid) state storage. 74*7c478bd9Sstevel@tonic-gate * A struct vuid_seg contains all the values for a vuid segment. 75*7c478bd9Sstevel@tonic-gate * Neither the vuid_seg list or the vuid_value list will be sorted 76*7c478bd9Sstevel@tonic-gate * unless a performance problem is identified. As a new event is 77*7c478bd9Sstevel@tonic-gate * sent to vuid_set_value, so the lists grow. 78*7c478bd9Sstevel@tonic-gate */ 79*7c478bd9Sstevel@tonic-gate typedef struct vuid_seg { 80*7c478bd9Sstevel@tonic-gate struct vuid_seg *next; /* Next state segment in list */ 81*7c478bd9Sstevel@tonic-gate ushort_t addr; /* Starting address of segment */ 82*7c478bd9Sstevel@tonic-gate char booleans[VUID_BIT_ARRAY_SIZE]; 83*7c478bd9Sstevel@tonic-gate /* Up/down value of boolean codes */ 84*7c478bd9Sstevel@tonic-gate char ints[VUID_BIT_ARRAY_SIZE]; 85*7c478bd9Sstevel@tonic-gate /* In/not in list */ 86*7c478bd9Sstevel@tonic-gate struct vuid_value *list; /* Linked list of values of */ 87*7c478bd9Sstevel@tonic-gate /* non-boolean codes. If a code is */ 88*7c478bd9Sstevel@tonic-gate /* in this list, the boolean value is */ 89*7c478bd9Sstevel@tonic-gate /* ignored and the corresponding bit */ 90*7c478bd9Sstevel@tonic-gate /* in values is on. */ 91*7c478bd9Sstevel@tonic-gate } Vuid_seg; 92*7c478bd9Sstevel@tonic-gate #define VUID_SEG_NULL ((Vuid_seg *)0) 93*7c478bd9Sstevel@tonic-gate #define vuid_cstate_to_state(cstate) ((Vuid_seg *)cstate) 94*7c478bd9Sstevel@tonic-gate 95*7c478bd9Sstevel@tonic-gate #define vuid_set_boolean_bit(seg, offset) \ 96*7c478bd9Sstevel@tonic-gate (seg)->booleans[(offset)/BITSPERBYTE] |= \ 97*7c478bd9Sstevel@tonic-gate (1<<((BITSPERBYTE-1)-((offset)%BITSPERBYTE))) 98*7c478bd9Sstevel@tonic-gate #define vuid_clear_boolean_bit(seg, offset) \ 99*7c478bd9Sstevel@tonic-gate (seg)->booleans[(offset)/BITSPERBYTE] &= \ 100*7c478bd9Sstevel@tonic-gate (~(1<<((BITSPERBYTE-1)-((offset)%BITSPERBYTE)))) 101*7c478bd9Sstevel@tonic-gate #define vuid_get_boolean_bit(seg, offset) \ 102*7c478bd9Sstevel@tonic-gate ((seg)->booleans[(offset)/BITSPERBYTE] & \ 103*7c478bd9Sstevel@tonic-gate (1<<((BITSPERBYTE-1)-((offset)%BITSPERBYTE)))) 104*7c478bd9Sstevel@tonic-gate 105*7c478bd9Sstevel@tonic-gate #define vuid_set_int_bit(seg, offset) \ 106*7c478bd9Sstevel@tonic-gate (seg)->ints[(offset)/BITSPERBYTE] |= \ 107*7c478bd9Sstevel@tonic-gate (1<<((BITSPERBYTE-1)-((offset)%BITSPERBYTE))) 108*7c478bd9Sstevel@tonic-gate #define vuid_clear_int_bit(seg, offset) \ 109*7c478bd9Sstevel@tonic-gate (seg)->ints[(offset)/BITSPERBYTE] &= \ 110*7c478bd9Sstevel@tonic-gate (~(1<<((BITSPERBYTE-1)-((offset)%BITSPERBYTE)))) 111*7c478bd9Sstevel@tonic-gate #define vuid_get_int_bit(seg, offset) \ 112*7c478bd9Sstevel@tonic-gate ((seg)->ints[(offset)/BITSPERBYTE] & \ 113*7c478bd9Sstevel@tonic-gate (1<<((BITSPERBYTE-1)-((offset)%BITSPERBYTE)))) 114*7c478bd9Sstevel@tonic-gate 115*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 116*7c478bd9Sstevel@tonic-gate } 117*7c478bd9Sstevel@tonic-gate #endif 118*7c478bd9Sstevel@tonic-gate 119*7c478bd9Sstevel@tonic-gate #endif /* _SYS_VUID_STORE_H */ 120