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