1/*
2 * @APPLE_LICENSE_HEADER_START@
3 *
4 * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23/*
24	File:		HIDPostProcessRIValue.c
25
26	Contains:	xxx put contents here xxx
27
28	Version:	xxx put version here xxx
29
30	Copyright:	� 1999 by Apple Computer, Inc., all rights reserved.
31
32	File Ownership:
33
34		DRI:				xxx put dri here xxx
35
36		Other Contact:		xxx put other contact here xxx
37
38		Technology:			xxx put technology here xxx
39
40	Writers:
41
42		(BWS)	Brent Schorsch
43
44	Change History (most recent first):
45
46	  <USB1>	  4/7/99	BWS		first checked in
47*/
48
49#include "HIDLib.h"
50
51/*
52 *------------------------------------------------------------------------------
53 *
54 * HIDPostProcessRIValue - 	performs any post-processing necessary for data
55 *							retrieved _from_ a report for the specified report
56 *							item. Currently, the only post-processing done
57 *							is reversing when appropriate
58 *
59 *	 Input:
60 *			  reportItem			- The report item
61 *			  value					- the value, from HIDGetData
62 *	 Output:
63 *			  value					- The processed value
64 *	 Returns:
65 *			  kHIDSuccess			- Success
66 *
67 *------------------------------------------------------------------------------
68*/
69
70OSStatus HIDPostProcessRIValue (HIDReportItem *	 	reportItem,
71								SInt32 *			value)
72{
73
74	// if isReversed, returnValue = ((min - returnValue) + max)
75	if (reportItem->flags & kHIDReportItemFlag_Reversed)
76		*value = ((reportItem->globals.logicalMinimum - (*value)) +
77							reportItem->globals.logicalMaximum);
78
79	return kHIDSuccess;
80}
81
82/*
83 *------------------------------------------------------------------------------
84 *
85 * HIDPreProcessRIValue - 	performs any pre-processing necessary for data
86 *							ouput _to_ a report for the specified report
87 *							item. Currently, the only pre-processing done
88 *							is reversing when appropriate
89 *
90 *	 Input:
91 *			  reportItem			- The report item
92 *			  value					- the value, destined for HIDPutData
93 *	 Output:
94 *			  value					- The processed value
95 *	 Returns:
96 *			  kHIDSuccess			- Success
97 *
98 *------------------------------------------------------------------------------
99*/
100
101OSStatus HIDPreProcessRIValue  (HIDReportItem *	 	reportItem,
102								SInt32 *			value)
103{
104
105	// if isReversed, returnValue = ((min - returnValue) + max)
106	if (reportItem->flags & kHIDReportItemFlag_Reversed)
107		*value = ((reportItem->globals.logicalMinimum - (*value)) +
108							reportItem->globals.logicalMaximum);
109
110	return kHIDSuccess;
111}
112
113
114