bluetoothengine/bthid/mouse/hidmousedriver/inc/mouse.h
changeset 0 f63038272f30
child 12 b23265fb36da
equal deleted inserted replaced
-1:000000000000 0:f63038272f30
       
     1 /*
       
     2 * Copyright (c) 2008 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 "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:  Declares main application class.
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __MOUSE_H
       
    20 #define __MOUSE_H
       
    21 
       
    22 #include <e32std.h>
       
    23 #include <w32std.h>
       
    24 
       
    25 #include <e32msgqueue.h>
       
    26 #include <e32cmn.h>
       
    27 #include "pointmsgqueue.h"
       
    28 
       
    29 #include "hidinterfaces.h"
       
    30 
       
    31 class CField;
       
    32 class CHidMouseDriver;
       
    33 
       
    34 /*!
       
    35  HID mouse driver class
       
    36  */
       
    37 class CHidMouseDriver : public CHidDriver //public CHidDriverPluginInterface
       
    38     {
       
    39 
       
    40 private:
       
    41     /*! Initialisation states */
       
    42     enum TMouseDriverState
       
    43         {
       
    44         EUninitialised, /*!< Driver has not been initialised */
       
    45         EInitialised, /*!< Driver is initialised */
       
    46         EDisabled
       
    47         /*!< The driver will not respond to interrupt data */
       
    48         };
       
    49 
       
    50 private:
       
    51     TMouseDriverState iDriverState;
       
    52     TInt iConnectionId;
       
    53     TInt iAppMenuId;
       
    54 
       
    55 public:
       
    56     /*!
       
    57      Creates an instantiated CHidMouseDriver object.
       
    58      @param aHid The generic HID layer that requested the driver
       
    59      @param aFactory aFactory The factory that created the driver
       
    60      @result A pointer to the instantiated keyboard driver
       
    61      */
       
    62     static CHidMouseDriver* NewL(MDriverAccess* aHid);
       
    63     /*!
       
    64      Creates an instantiated CHidMouseDriver object and leaves it on the
       
    65      cleanup stack.
       
    66      @param aHid The generic HID layer that requested the driver
       
    67      @param aFactory aFactory The factory that created the driver
       
    68      @result A pointer to the instantiated keyboard driver
       
    69      */
       
    70     static CHidMouseDriver* NewLC(MDriverAccess* aHid);
       
    71 
       
    72     /*!
       
    73      Stops driver activity, deletes the key repeat and decode objects and closes
       
    74      the window server session before the driver is deleted
       
    75      */
       
    76     virtual ~CHidMouseDriver();
       
    77 
       
    78     /*!
       
    79      Called by the Generic HID layer to see if the driver can is able to use
       
    80      reports from a newly-connected device
       
    81      @result ETrue The driver can handle the reports
       
    82      @result EFalse The driver cannot handle the reports
       
    83      */
       
    84     virtual TInt CanHandleReportL(CReportRoot* aReportRoot);
       
    85 
       
    86     /*!
       
    87      Called by the Generic HID layer when a device has been removed, prior to the
       
    88      driver being removed.  This allows the driver to notify any applications of
       
    89      disconnection, if required
       
    90      @param aReason The reason for device disconnection
       
    91      */
       
    92     virtual void Disconnected(TInt aReason);
       
    93 
       
    94     /*!
       
    95      Called by the Generic HID layer when data has been received from the device
       
    96      handled by this driver.
       
    97      @param aChannel The channel on which the data was received (as defined by the
       
    98      transport layer
       
    99      @param aPayload A pointer to the data buffer
       
   100      */
       
   101     virtual TInt DataIn(CHidTransport::THidChannelType aChannel,
       
   102             const TDesC8& aPayload);
       
   103 
       
   104     /*!
       
   105      Called by the transport layers to inform the generic HID of the success of
       
   106      the last Set... command.
       
   107      @param aConnectionId ID of the device
       
   108      @param aCmdAck Status of the last Set... command
       
   109      */
       
   110     virtual void CommandResult(TInt aCmdAck);
       
   111 
       
   112     /*!
       
   113      Called after a driver is sucessfully created by the Generic HID, when a
       
   114      device is connected
       
   115      */
       
   116     virtual void InitialiseL(TInt aConnectionId);
       
   117 
       
   118     /*!
       
   119      Resets the internal state of the driver (any pressed keys are released) and
       
   120      enables the driver
       
   121      */
       
   122     virtual void StartL(TInt aConnectionId);
       
   123     /*!
       
   124      Cancels all pressed keys and disables the driver (so it will not
       
   125      process interrupt data)
       
   126      */
       
   127     virtual void Stop();
       
   128 
       
   129     virtual TInt SupportedFieldCount();
       
   130 
       
   131     /**
       
   132      * Set input handling registy 
       
   133      *
       
   134      * @since S60 v5.0     
       
   135      * @param aHandlingReg  a Input handling registry
       
   136      */
       
   137     virtual void SetInputHandlingReg(CHidInputDataHandlingReg* aHandlingReg);
       
   138 
       
   139 private:
       
   140     // Constructor taking a pointer to the HID layer requesting the driver
       
   141     // instance
       
   142     CHidMouseDriver(MDriverAccess* aHid);
       
   143 
       
   144     void ConstructL();
       
   145 
       
   146 private:
       
   147     // The types of keyboard input report fields that we handle:
       
   148     enum TKeyFieldType
       
   149         {
       
   150         EButtons = 0,
       
   151         EXY = 1,
       
   152         EWheel = 2,
       
   153         EMediaKeys = 3,
       
   154         EPowerKeys = 4,
       
   155         KNumInputFieldTypes
       
   156         };
       
   157 
       
   158 private:
       
   159     // Called from within DataIn to handle interrupt and control channel data
       
   160     void InterruptData(const TDesC8& aPayload);
       
   161 
       
   162     // Handles the states of the XY (mouse up, down, left, right)
       
   163     void UpdateXY(TInt aFieldIndex, const TDesC8& aReport);
       
   164 
       
   165     // Handles the states of the Buttons (left & right button)
       
   166     void UpdateButtons(TInt aFieldIndex, const TDesC8& aReport);
       
   167 
       
   168     // Handles the states of the wheel
       
   169     void UpdateWheel(TInt aFieldIndex, const TDesC8& aReport);
       
   170 
       
   171     void MoveCursor(const TPoint& aPoint);
       
   172     TInt PostPointer(const TPoint& aPoint);
       
   173     TInt SendButtonEvent(TBool aButtonDown);
       
   174 
       
   175     void LaunchApplicationL(const TDesC& aName);
       
   176     //void LaunchApplicationL(TInt aAppUid);
       
   177 
       
   178 private:
       
   179     // The Generic HID layer
       
   180     MDriverAccess *iGenericHid;
       
   181 
       
   182     // Pointers to the fields in the report descriptor containing the
       
   183     // various types of key:
       
   184     const CField* iField[KNumInputFieldTypes];
       
   185 
       
   186     //Supported field types count
       
   187     TInt iSupportedFieldCount;
       
   188 
       
   189     CHidInputDataHandlingReg* iInputHandlingReg;
       
   190     RMsgQueue<TPointBuffer> iPointBufQueue;
       
   191     TPointBuffer iPointerBuffer;
       
   192     TBool iButtonDown;
       
   193     TBool iButton2Down;
       
   194 
       
   195     // A window server session, so keypresses can be sent to applications:
       
   196     RWsSession iWsSession;
       
   197     };
       
   198 
       
   199 // ----------------------------------------------------------------------
       
   200 
       
   201 #endif