kodi
WiiUse_WiiRemote.h
1  /* Copyright (C) 2009 by Cory Fields
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program. If not, see <http://www.gnu.org/licenses/>.
14  *
15  *
16  */
17 
18 #pragma once
19 
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <sys/socket.h>
23 #include <sys/time.h>
24 //#include <math.h>
25 #include <unistd.h>
26 #ifdef DEB_PACK
27 #include <xbmc/xbmcclient.h>
28 #else
29 #include "../../lib/c++/xbmcclient.h"
30 #endif
31 //#ifndef WIN32
32 // #include <unistd.h>
33 //#endif
34 #include "wiiuse.h"
35 //#define ICON_PATH "../../"
36 #define PORT 9777
37 #define MAX_WIIMOTES 1
38 #define OVER_180_DEG 1
39 #define UNDER_NEG_180_DEG 2
40 #define WIIMOTE_BUTTON_TWO 0x0001
41 #define WIIMOTE_BUTTON_ONE 0x0002
42 #define WIIMOTE_BUTTON_B 0x0004
43 #define WIIMOTE_BUTTON_A 0x0008
44 #define WIIMOTE_BUTTON_MINUS 0x0010
45 #define WIIMOTE_BUTTON_HOME 0x0080
46 #define WIIMOTE_BUTTON_LEFT 0x0100
47 #define WIIMOTE_BUTTON_RIGHT 0x0200
48 #define WIIMOTE_BUTTON_DOWN 0x0400
49 #define WIIMOTE_BUTTON_UP 0x0800
50 #define WIIMOTE_BUTTON_PLUS 0x1000
51 
52 #define WIIMOTE_NUM_BUTTONS 11
53 #define KEYCODE_BUTTON_UP 1
54 #define KEYCODE_BUTTON_DOWN 2
55 #define KEYCODE_BUTTON_LEFT 3
56 #define KEYCODE_BUTTON_RIGHT 4
57 #define KEYCODE_BUTTON_A 5
58 #define KEYCODE_BUTTON_B 6
59 #define KEYCODE_BUTTON_MINUS 7
60 #define KEYCODE_BUTTON_HOME 8
61 #define KEYCODE_BUTTON_PLUS 9
62 #define KEYCODE_BUTTON_ONE 10
63 #define KEYCODE_BUTTON_TWO 11
64 #define KEYCODE_ROLL_NEG 33
65 #define KEYCODE_ROLL_POS 34
66 #define KEYCODE_PITCH_NEG 35
67 #define KEYCODE_PITCH_POS 36
68 
69 
70 #define ACTION_NONE 0
71 #define ACTION_ROLL 1
72 #define ACTION_PITCH 2
73 
75  public:
76 
77  bool m_holdableHeld;
78  bool m_holdableReleased;
79  bool m_repeatableHeld;
80  bool m_repeatableReleased;
81 
82  unsigned short m_buttonPressed;
83  unsigned short m_buttonReleased;
84  unsigned short m_buttonHeld;
85  unsigned short m_repeatFlags;
86  unsigned short m_holdFlags;
87  unsigned short m_currentAction;
88 
89  int32_t m_buttonDownTime;
90 
91  float m_abs_roll;
92  float m_abs_pitch;
93  float m_rel_roll;
94  float m_rel_pitch;
95  float m_start_roll;
96  float m_start_pitch;
97  char* m_joyString;
98 
99 
100  void get_keys(wiimote* wm);
101  void handleKeyPress();
102  void handleRepeat();
103  void handleACC(float, float);
104  void handleIR();
105 
107  {
108  m_joyString = "JS0:WiiRemote";
109  m_repeatFlags = WIIMOTE_BUTTON_UP | WIIMOTE_BUTTON_DOWN | WIIMOTE_BUTTON_LEFT | WIIMOTE_BUTTON_RIGHT;
110  m_holdFlags = WIIMOTE_BUTTON_B;
111  }
112 };
113 
114 unsigned short g_deadzone = 30;
115 unsigned short g_hold_button_timeout = 200;
116 unsigned short g_repeat_rate = 400;
117 
119 int connectWiimote(wiimote** );
120 int32_t getTicks(void);
121 void EnableMotionSensing(wiimote* wm) {if (!WIIUSE_USING_ACC(wm)) wiiuse_motion_sensing(wm, 1);}
122 void DisableMotionSensing(wiimote* wm) {if (WIIUSE_USING_ACC(wm)) wiiuse_motion_sensing(wm, 0);}
123 unsigned short convert_code(unsigned short);
124 float smoothDeg(float, float);
125 
126 CXBMCClient EventClient;
127 
Wiimote structure.
Definition: wiiuse.h:531
API header file.
Definition: xbmcclient.h:730
void wiiuse_motion_sensing(struct wiimote_t *wm, int status)
Set if the wiimote should report motion sensing.
Definition: wiiuse.c:273
void handle_disconnect(wiimote *wm)
Callback that handles a disconnection event.
Definition: example.c:256
Definition: WiiUse_WiiRemote.h:74