-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
executable file
·50 lines (39 loc) · 1.07 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "main.hpp"
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include "gamepad.hpp"
int button_name;
bool button_value;
int axis_name;
float axis_value;
void ButtonHandler(const GamePad*,ButtonNames,bool);
void AxisHandler(const GamePad*,AxisNames,float);
void finish(int){
puts("finish");
exit(0);
}
int main(){
GamePad pad("/dev/input/js0");
signal(SIGINT,finish);
MotorManager::MotorManager(const char* filename,speed_t rate);
std::string word();
pad.Status();
pad.SetButtonChangedEvent(ButtonHandler);
pad.SetAxisChangedEvent(AxisHandler);
//pad.SetButtonChangedEvent(const GamePad* obj,ButtonNames button,bool value);
while (1){
}
}
}
void AxisHandler(const GamePad*obj,AxisNames axis,float value){
//puts("bbbb");
//printf("%s(%d),%f\n",GetAxisName(axis),(int)axis,value);
axis_name = (int)axis;
axis_value = value;
}
void ButtonHandler(const GamePad* obj,ButtonNames button,bool value){
//printf("%s,%s\n",GetButtonName(button),value?"true":"false");
button_name = (int)button;
button_value = value;
}