baseport/src/cedar/generic/base/syborg/pointer/syborg_pointer.h
changeset 0 ffa851df0825
equal deleted inserted replaced
-1:000000000000 0:ffa851df0825
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: Minimalistic pointer driver
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef _SYBORG_POINTER_H
       
    19 #define _SYBORG_POINTER_H
       
    20 
       
    21 #include <kernel.h>
       
    22 #include <system.h>
       
    23 #include <videodriver.h>
       
    24 #include <hal.h>
       
    25 
       
    26 #define FIFO_SIZE 16
       
    27 
       
    28 #ifdef DEBUG
       
    29 #define __DEBUG_PRINT(format...)    Kern::Printf(format)
       
    30 #else
       
    31 #define __DEBUG_PRINT(format...)    __KTRACE_OPT(KBOOT,Kern::Printf(format))
       
    32 #endif
       
    33 
       
    34 class TPointerRv
       
    35 {
       
    36 public:
       
    37   TPointerRv();
       
    38   virtual ~TPointerRv();
       
    39   static TInt DoPointerHalFunction(TAny* aThis, TInt aFunction, TAny* a1, TAny* a2);
       
    40   TInt PointerHalFunction(TInt aFunction, TAny* a1, TAny* a2);
       
    41   void Init3();
       
    42 
       
    43  private:
       
    44   struct PData {
       
    45 	TInt x;
       
    46 	TInt y;
       
    47 	TInt z;
       
    48 	TInt but;
       
    49   };
       
    50 
       
    51   struct PData* FifoPop(void);
       
    52   void FifoPush(struct PData*);
       
    53 
       
    54   struct PData iPDataFifo[FIFO_SIZE];
       
    55   TInt iFifoPos;
       
    56   TInt iFifoCount;
       
    57 
       
    58  private:
       
    59   static void Isr(TAny* aPtr);
       
    60   static void RxDfc(TAny* aPtr );
       
    61   static void Process(TPointerRv *i, struct PData *);
       
    62 
       
    63   TDfc iRxDfc;
       
    64 	
       
    65   TBool iPointerOn;       // cursor visiability
       
    66   TInt  iScreenWidth;
       
    67   TInt  iScreenHeight;
       
    68   TInt  iDisplayMode;
       
    69 
       
    70   TInt ix,iy;
       
    71   TInt iLastBut;
       
    72 
       
    73   
       
    74  public:
       
    75 
       
    76   enum {
       
    77     POINTER_ID          = 0,
       
    78     POINTER_LATCH       = 1,
       
    79     POINTER_FIFO_COUNT  = 2,
       
    80     POINTER_X           = 3,
       
    81     POINTER_Y           = 4,
       
    82     POINTER_Z           = 5,
       
    83     POINTER_BUTTONS     = 6,
       
    84     POINTER_INT_ENABLE  = 7
       
    85   };
       
    86 
       
    87  private:
       
    88   // Fixed point maths
       
    89   class Fixed {
       
    90 
       
    91   private:
       
    92 	int g;
       
    93 	const static int BP = 8;
       
    94 	const static int BP2 = BP*2;
       
    95 	enum FixedRaw { RAW };
       
    96     Fixed(FixedRaw, int guts) : g(guts) {}
       
    97 	
       
    98   public:
       
    99     Fixed() : g(0) {}
       
   100     Fixed(const Fixed& a) : g( a.g ) {}
       
   101     Fixed(int a) : g( a << BP ) {}
       
   102 	operator int() { return g>>BP; }
       
   103 	Fixed operator +() const { return Fixed(RAW,g); }
       
   104 	Fixed operator -() const { return Fixed(RAW,-g); }
       
   105 	Fixed operator +(const Fixed& a) const { return Fixed(RAW, g + a.g); }
       
   106 	Fixed operator -(const Fixed& a) const { return Fixed(RAW, g - a.g); }
       
   107 	Fixed operator *(const Fixed& a) const { return Fixed(RAW,  (int)( ((long long)g * (long long)a.g ) >> BP)); }
       
   108 	Fixed operator /(const Fixed& a) const { return Fixed(RAW, int( (((long long)g << BP2) / (long long)(a.g)) >> BP) ); }
       
   109   };
       
   110 
       
   111   Fixed iXFactor;
       
   112   Fixed iYFactor;
       
   113 };
       
   114 
       
   115 #endif