Merge pull request #4594 from FernetMenta/paplayer
[xbmc.git] / xbmc / android / activity / AndroidJoyStick.h
blob722c977a9c51abbaa3d438c43846e9b38ababa92
1 #pragma once
2 /*
3 * Copyright (C) 2012-2013 Team XBMC
4 * http://xbmc.org
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
22 #include <string>
23 #include <vector>
25 struct AInputEvent;
27 typedef struct {
28 float flat;
29 float fuzz;
30 float min;
31 float max;
32 float range;
33 float value;
34 // internal helper values
35 bool enabled;
36 float deadzone;
37 float buttonclamp;
38 } APP_InputDeviceAxis;
40 typedef struct {
41 int32_t id;
42 APP_InputDeviceAxis x_hat;
43 APP_InputDeviceAxis y_hat;
44 APP_InputDeviceAxis x_axis;
45 APP_InputDeviceAxis y_axis;
46 APP_InputDeviceAxis z_axis;
47 APP_InputDeviceAxis rz_axis;
48 } APP_InputDeviceAxes;
50 class CAndroidJoyStick
52 public:
53 CAndroidJoyStick();
54 ~CAndroidJoyStick();
56 bool onJoyStickKeyEvent(AInputEvent* event);
57 bool onJoyStickMotionEvent(AInputEvent* event);
59 private:
60 void ProcessMotionEvents(AInputEvent *event, size_t pointer_index,
61 int32_t device, APP_InputDeviceAxes *axes);
62 bool ProcessHat( AInputEvent *event, size_t pointer_index,
63 APP_InputDeviceAxis &hat, int device, int android_axis);
64 bool ProcessAxis(AInputEvent *event, size_t pointer_index,
65 APP_InputDeviceAxis &axis, int device, int keymap_axis, int android_axis);
67 void XBMC_JoyAxis(uint8_t device, uint8_t axis, float value);
68 void XBMC_JoyHat(uint8_t device, uint8_t value);
69 void XBMC_JoyButton(uint8_t device, uint8_t button, uint32_t holdtime, bool up);
71 uint8_t m_prev_device;
72 uint8_t m_prev_button;
73 uint32_t m_prev_holdtime;
74 std::vector<APP_InputDeviceAxes*> m_input_devices;