2 * Copyright (C) 2014-2016 Team Kodi
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this Program; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
22 #include "JoystickTypes.h"
27 * \brief Interface defining methods to handle joystick events for raw driver
28 * elements (buttons, hats, axes)
33 virtual ~IDriverHandler(void) { }
36 * \brief Handle button motion
38 * \param buttonIndex The index of the button as reported by the driver
39 * \param bPressed true for press motion, false for release motion
41 * \return True if a press was handled, false otherwise
43 virtual bool OnButtonMotion(unsigned int buttonIndex
, bool bPressed
) = 0;
46 * \brief Handle hat motion
48 * \param hatIndex The index of the hat as reported by the driver
49 * \param state The direction the hat is now being pressed
51 * \return True if the new direction was handled, false otherwise
53 virtual bool OnHatMotion(unsigned int hatIndex
, HAT_STATE state
) = 0;
56 * \brief Handle axis motion
58 * If a joystick feature requires multiple axes (analog sticks, accelerometers),
59 * they can be buffered for later processing.
61 * \param axisIndex The index of the axis as reported by the driver
62 * \param position The position of the axis in the closed interval [-1.0, 1.0]
64 * \return True if the motion was handled, false otherwise
66 virtual bool OnAxisMotion(unsigned int axisIndex
, float position
) = 0;
69 * \brief Handle buffered axis positions for features that require multiple axes
71 * ProcessAxisMotions() is called at the end of the frame when all axis motions
72 * have been reported. This has several uses, including:
74 * - Combining multiple axes into a single analog stick or accelerometer event
75 * - Imitating an analog feature with a digital button so that events can be
76 * dispatched every frame.
78 virtual void ProcessAxisMotions(void) = 0;