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

Last change on this file since 110 was 16, checked in by Bayard Gildas, 9 years ago

Reformatting

File size: 2.7 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 { Usb, Bluetooth } ConnectionType_t;
53
54 DualShock3(const core::FrameworkManager *parent, 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 int mystr2ba(const char *s, bdaddr_t *ba);
82 char *myba2str(const bdaddr_t *ba);
83 int8_t compute_dead_zone(int axis, unsigned char value);
84 struct motion_dev *dev;
85 int usb_fd;
86 int isk;
87 core::Time last_voltage_time;
88
89 int8_t *datas;
90 uint8_t dataSize;
91
92 void usb_scan();
93 void usb_pair_device(struct usb_device *dev, int itfnum);
94
95 void rumble(uint8_t left_force, uint8_t left_timeout, uint8_t right_force,
96 uint8_t right_timeout);
97 void set_led(uint8_t led, uint8_t on_timeout, uint8_t off_timeout);
98 char ledmask;
99 uint8_t led1_on, led1_off, led2_on, led2_off, led3_on, led3_off, led4_on,
100 led4_off;
101};
102}
103}
104
105#endif // DUALSHOCK3_H
Note: See TracBrowser for help on using the repository browser.