source: flair-src/trunk/tools/Controller/DualShock3/src/DualShock3.h@ 471

Last change on this file since 471 was 470, checked in by Sanahuja Guillaume, 3 years ago

add timeout for ds3 input event

File size: 2.8 KB
Line 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5// created: 2015/03/31
6// filename: DualShock3.h
7//
8// authors: pabr.org, Gildas Bayard
9// Copyright (c) 2010 pabr@pabr.org
10// Copyright Heudiasyc UMR UTC/CNRS 7253
11//
12// version: $Id: $
13//
14// purpose: Sony DualShock3 host side driver class. Talks to target side
15// through ethernet.
16//
17//
18/*********************************************************************/
19
20#ifndef DUALSHOCK3_H
21#define DUALSHOCK3_H
22
23#include <HostEthController.h>
24
25#include <stdint.h>
26#include <bluetooth/bluetooth.h>
27#include <bluetooth/l2cap.h>
28#include <usb.h>
29
30namespace flair {
31namespace core {
32class FrameworkManager;
33}
34namespace gui {
35class SpinBox;
36class Label;
37class CheckBox;
38}
39}
40
41struct motion_dev;
42
43namespace flair {
44namespace sensor {
45/*! \class DualShock3
46*
47* \brief Sony DualShock3 host side driver class. Talks to target side through
48*ethernet.
49*/
50class DualShock3 : public HostEthController {
51public:
52 typedef enum { UsbHidRaw, UsbEvent,Bluetooth } ConnectionType_t;
53
54 DualShock3(std::string name,
55 std::string receiverAddress, int receiverPort,
56 ConnectionType_t connectionType, uint32_t period = 10,
57 uint32_t bitsPerAxis = 7, uint8_t priority = 0);
58 ~DualShock3();
59
60private:
61 gui::SpinBox *deadZone;
62 gui::CheckBox *enabled;
63 gui::Label *batteryChargeLevel;
64 ConnectionType_t connectionType;
65 core::Time now;
66
67 std::string GetAxisDescription(unsigned int axis);
68 std::string GetButtonDescription(unsigned int button);
69 void GetAxisData();
70 void GetButtonData();
71 bool IsDataFrameReady();
72 void ProcessMessage(core::Message *controllerAction);
73
74 void UpdateFrom(const core::io_data *data){};
75 void fatal(const char *msg);
76 int l2cap_listen(const bdaddr_t *bdaddr, unsigned short psm);
77 struct motion_dev *accept_device(int csk, int isk);
78 void hidp_trans(int csk, char *buf, int len);
79 void setup_device(struct motion_dev *dev);
80 bool parse_report_sixaxis_ds3(unsigned char *r, int len);
81 bool parse_input_event(int timeout_ms);
82 int mystr2ba(const char *s, bdaddr_t *ba);
83 char *myba2str(const bdaddr_t *ba);
84 int8_t compute_dead_zone(int axis, unsigned char value);
85 uint8_t SetBitValue(int8_t &reg,uint8_t mask,uint8_t value);
86 struct motion_dev *dev;
87 int usb_fd;
88 int isk;
89 core::Time last_voltage_time;
90
91 int8_t *datas;
92 uint8_t dataSize;
93
94 void usb_scan();
95 void usb_pair_device(struct usb_device *dev, int itfnum);
96
97 void rumble(uint8_t left_force, uint8_t left_timeout, uint8_t right_force,
98 uint8_t right_timeout);
99 void set_led(uint8_t led, uint8_t on_timeout, uint8_t off_timeout);
100 char ledmask;
101 uint8_t led1_on, led1_off, led2_on, led2_off, led3_on, led3_off, led4_on,
102 led4_off;
103};
104}
105}
106
107#endif // DUALSHOCK3_H
Note: See TracBrowser for help on using the repository browser.