~ubuntu-branches/ubuntu/saucy/nut/saucy

« back to all changes in this revision

Viewing changes to drivers/hidparser.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2005-07-20 19:48:50 UTC
  • mto: (16.1.1 squeeze)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20050720194850-oo61wjr33rrx2mre
Tags: upstream-2.0.2
ImportĀ upstreamĀ versionĀ 2.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
 * Return pointer on current offset value for Report designed by 
58
58
 * ReportID/ReportType
59
59
 * -------------------------------------------------------------------------- */
60
 
uchar* GetReportOffset(HIDParser* pParser, 
61
 
                       const uchar ReportID, 
62
 
                       const uchar ReportType)
 
60
static u_char* GetReportOffset(HIDParser* pParser, 
 
61
                       const u_char ReportID, 
 
62
                       const u_char ReportType)
63
63
{
64
 
  ushort Pos=0;
 
64
  u_short Pos=0;
65
65
  while(Pos<MAX_REPORT && pParser->OffsetTab[Pos][0]!=0)
66
66
  {
67
67
    if(pParser->OffsetTab[Pos][0]==ReportID 
82
82
}
83
83
 
84
84
/*
85
 
 * FormatValue(long Value, uchar Size)
 
85
 * FormatValue(long Value, u_char Size)
86
86
 * Format Value to fit with long format with respect of negative values
87
87
 * -------------------------------------------------------------------------- */
88
 
long FormatValue(long Value, uchar Size)
 
88
static long FormatValue(long Value, u_char Size)
89
89
{
90
90
  if(Size==1) 
91
91
    Value=(long)(char)Value;
137
137
      case ITEM_UPAGE :
138
138
      {
139
139
        /* Copy UPage in Usage stack */
140
 
        pParser->UPage=(ushort)pParser->Value;
 
140
        pParser->UPage=(u_short)pParser->Value;
141
141
        break;
142
142
      }
143
143
      case ITEM_USAGE :
144
144
      {
145
145
        /* Copy global or local UPage if any, in Usage stack */
146
146
         if((pParser->Item & SIZE_MASK)>2)
147
 
          pParser->UsageTab[pParser->UsageSize].UPage=(ushort)(pParser->Value>>16);
 
147
          pParser->UsageTab[pParser->UsageSize].UPage=(u_short)(pParser->Value>>16);
148
148
        else
149
149
          pParser->UsageTab[pParser->UsageSize].UPage=pParser->UPage;
150
150
 
151
151
        /* Copy Usage in Usage stack */
152
 
        pParser->UsageTab[pParser->UsageSize].Usage=(ushort)(pParser->Value & 0xFFFF);
 
152
        pParser->UsageTab[pParser->UsageSize].Usage=(u_short)(pParser->Value & 0xFFFF);
153
153
 
154
154
        /* Increment Usage stack size */
155
155
        pParser->UsageSize++;
166
166
        /* Unstack UPage/Usage from UsageTab (never remove the last) */
167
167
        if(pParser->UsageSize>0)
168
168
        {
169
 
          uchar ii=0;
 
169
          u_char ii=0;
170
170
          while(ii<pParser->UsageSize)
171
171
          {
172
172
            pParser->UsageTab[ii].Usage=pParser->UsageTab[ii+1].Usage;
219
219
        /* Unstack UPage/Usage from UsageTab (never remove the last) */
220
220
        if(pParser->UsageSize>0)
221
221
        {
222
 
          uchar ii=0;
 
222
          u_char ii=0;
223
223
          while(ii<pParser->UsageSize)
224
224
          {
225
225
            pParser->UsageTab[ii].UPage=pParser->UsageTab[ii+1].UPage;
231
231
        }
232
232
 
233
233
        /* Copy data type */
234
 
        pParser->Data.Type=(uchar)(pParser->Item & ITEM_MASK);
 
234
        pParser->Data.Type=(u_char)(pParser->Item & ITEM_MASK);
235
235
 
236
236
        /* Copy data attribute */
237
 
        pParser->Data.Attribute=(uchar)pParser->Value;
 
237
        pParser->Data.Attribute=(u_char)pParser->Value;
238
238
 
239
239
        /* Store offset */
240
 
        pParser->Data.Offset=*GetReportOffset(pParser, pParser->Data.ReportID, (uchar)(pParser->Item & ITEM_MASK));
 
240
        pParser->Data.Offset=*GetReportOffset(pParser, pParser->Data.ReportID, (u_char)(pParser->Item & ITEM_MASK));
241
241
    
242
242
        /* Get Object in pData */
243
243
        /* -------------------------------------------------------------------------- */
245
245
        /* -------------------------------------------------------------------------- */
246
246
 
247
247
        /* Increment Report Offset */
248
 
        *GetReportOffset(pParser, pParser->Data.ReportID, (uchar)(pParser->Item & ITEM_MASK)) += pParser->Data.Size;
 
248
        *GetReportOffset(pParser, pParser->Data.ReportID, (u_char)(pParser->Item & ITEM_MASK)) += pParser->Data.Size;
249
249
 
250
250
        /* Remove path last node */
251
251
        pParser->Data.Path.Size--;
256
256
      }
257
257
      case ITEM_REP_ID :
258
258
      {
259
 
        pParser->Data.ReportID=(uchar)pParser->Value;
 
259
        pParser->Data.ReportID=(u_char)pParser->Value;
260
260
        break;
261
261
      }
262
262
      case ITEM_REP_SIZE :
263
263
      {
264
 
        pParser->Data.Size=(uchar)pParser->Value;
 
264
        pParser->Data.Size=(u_char)pParser->Value;
265
265
        break;
266
266
      }
267
267
      case ITEM_REP_COUNT :
268
268
      {
269
 
        pParser->ReportCount=(uchar)pParser->Value;
 
269
        pParser->ReportCount=(u_char)pParser->Value;
270
270
        break;
271
271
      }
272
272
      case ITEM_UNIT_EXP :
348
348
 * Use Value, Offset, Size and LogMax of pData.
349
349
 * Return response in Value.
350
350
 * -------------------------------------------------------------------------- */
351
 
void GetValue(const uchar* Buf, HIDData* pData)
 
351
void GetValue(const u_char* Buf, HIDData* pData)
352
352
{
353
353
  int Bit=pData->Offset+8; /* First byte of report indicate report ID */
354
354
  int Weight=0;
365
365
    Bit++;
366
366
  }
367
367
/*  if(pData->Value > pData->LogMax)
368
 
    pData->Value=FormatValue(pData->Value, (uchar)((pData->Size-1)/8+1));
 
368
    pData->Value=FormatValue(pData->Value, (u_char)((pData->Size-1)/8+1));
369
369
*/
370
370
  if (pData->Value > pData->LogMax)
371
371
    pData->Value |= ~pData->LogMax;
376
376
 * Set a data in a report stored in Buf. Use Value, Offset and Size of pData.
377
377
 * Return response in Buf.
378
378
 * -------------------------------------------------------------------------- */
379
 
void SetValue(const HIDData* pData, uchar* Buf)
 
379
void SetValue(const HIDData* pData, u_char* Buf)
380
380
{
381
381
  int Bit=pData->Offset+8; /* First byte of report indicate report ID */
382
382
  int Weight=0;