hidparser.c File Reference

HID Parser. More...

#include "config.h"
#include <string.h>
#include "hidparser.h"

Go to the source code of this file.


#define ERROR(x)


void ResetParser (HIDParser *pParser)
static void ResetLocalState (HIDParser *pParser)
ucharGetReportOffset (HIDParser *pParser, const uchar ReportID, const uchar ReportType)
long FormatValue (long Value, uchar Size)
int HIDParse (HIDParser *pParser, HIDData *pData)
int FindObject (HIDParser *pParser, HIDData *pData)
void GetValue (const uchar *Buf, HIDData *pData)
void SetValue (const HIDData *pData, uchar *Buf)


const char ItemSize [4] = {0,1,2,4}

Detailed Description

HID Parser.

This file is part of the MGE UPS SYSTEMS HID Parser.

Copyright (C) 1998-2003 MGE UPS SYSTEMS, Written by Luc Descotils.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Definition in file hidparser.c.

Define Documentation

#define ERROR (  ) 

Make this use the ASSERT() macro as found in the rest of libhid

Definition at line 32 of file hidparser.c.

Function Documentation

int FindObject ( HIDParser pParser,
HIDData pData 

Get pData characteristics from pData->Path or from pData->ReportID/Offset.

TRUE if object was found

Definition at line 342 of file hidparser.c.

References HIDParse(), HIDPath::Node, HIDData::Offset, HIDData::Path, HIDData::ReportID, ResetParser(), HIDPath::Size, and HIDData::Type.

Referenced by hid_find_object().

long FormatValue ( long  Value,
uchar  Size 

Format Value to fit with long format with respect to negative values

Definition at line 102 of file hidparser.c.

Referenced by HIDParse().

uchar* GetReportOffset ( HIDParser pParser,
const uchar  ReportID,
const uchar  ReportType 

pointer to current offset value for the Report designated by ReportID and ReportType, or NULL if not found.

Definition at line 75 of file hidparser.c.

References MAX_REPORT, HIDParser::nReport, and HIDParser::OffsetTab.

Referenced by hid_get_report_size(), and HIDParse().

void GetValue ( const uchar Buf,
HIDData pData 

Extract data from a report stored in Buf. Use Value, Offset, Size and LogMax of pData.

Response in pData->Value.
Fix this "+8" business if there is only one report ID

Definition at line 374 of file hidparser.c.

References HIDData::LogMax, HIDData::Offset, and HIDData::Value.

Referenced by hid_extract_value().

int HIDParse ( HIDParser pParser,
HIDData pData 

Analyze report descriptor stored in HIDParser struct and store local and global context. Return in pData the last object found.

Initialize HIDParser structure with ResetParser() before beginning
TRUE when there is another item to parse.

Definition at line 119 of file hidparser.c.

References HIDData::Attribute, HIDParser::Count, HIDParser::Data, ERROR, FormatValue(), GetReportOffset(), HIDParser::Item, ITEM_COLLECTION, ITEM_END_COLLECTION, ITEM_FEATURE, ITEM_INPUT, ITEM_LOG_MAX, ITEM_LOG_MIN, ITEM_LONG, ITEM_MASK, ITEM_OUTPUT, ITEM_PHY_MAX, ITEM_PHY_MIN, ITEM_REP_COUNT, ITEM_REP_ID, ITEM_REP_SIZE, ITEM_UNIT, ITEM_UNIT_EXP, ITEM_UPAGE, ITEM_USAGE, ItemSize, HIDData::LogMax, HIDData::LogMin, MAX_REPORT, HIDParser::nObject, HIDPath::Node, HIDData::Offset, HIDData::Path, PATH_SIZE, HIDData::PhyMax, HIDData::PhyMin, HIDParser::Pos, REPORT_DSC_SIZE, HIDParser::ReportCount, HIDParser::ReportDesc, HIDParser::ReportDescSize, HIDData::ReportID, ResetLocalState(), HIDPath::Size, HIDData::Size, SIZE_MASK, HIDData::Type, HIDData::Unit, HIDData::UnitExp, HIDParser::UPage, HIDNode::UPage, HIDNode::Usage, USAGE_TAB_SIZE, HIDParser::UsageSize, HIDParser::UsageTab, and HIDParser::Value.

Referenced by FindObject(), hid_dump_tree(), and hid_prepare_parser().

static void ResetLocalState ( HIDParser pParser  )  [static]

Note: The USB HID specification states that Local items do not carry over to the next Main item (version 1.11, section Therefore the local state must be reset after each main item. In particular, any unused usages on the Usage tabs must be discarded and must not carry over to the next Main item. Some APC equipment actually sends multiple redundant "usage" commands for a single control, so resetting the local state is important.

Also note: UsageTab[0] is used as the usage of the next control, even if UsageSize=0. Therefore, this must be initialized

Definition at line 65 of file hidparser.c.

References HIDParser::UsageSize, and HIDParser::UsageTab.

Referenced by HIDParse().

void ResetParser ( HIDParser pParser  ) 

Reset HIDParser structure for new parsing. Keep Report descriptor data

Definition at line 40 of file hidparser.c.

References HIDParser::Count, HIDParser::Data, HIDParser::nObject, HIDParser::nReport, HIDParser::OffsetTab, HIDParser::Pos, HIDParser::UsageSize, and HIDParser::UsageTab.

Referenced by FindObject(), and hid_reset_parser().

void SetValue ( const HIDData pData,
uchar Buf 

Set a data in a report stored in Buf. Use Value, Offset and Size of pData.

Response in Buf.

Definition at line 401 of file hidparser.c.

References HIDData::Offset, and HIDData::Value.

Variable Documentation

const char ItemSize[4] = {0,1,2,4}

Definition at line 34 of file hidparser.c.

Referenced by HIDParse().

Generated on Sun Mar 30 15:28:25 2008 for libhid by  doxygen 1.5.1