Fawkes API
Fawkes Development Version
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
acquisition_thread.h
1
2
/***************************************************************************
3
* acquisition_thread.h - Thread that retrieves the joystick data
4
*
5
* Created: Sat Nov 22 18:10:35 2008
6
* Copyright 2006-2008 Tim Niemueller [www.niemueller.de]
7
*
8
****************************************************************************/
9
10
/* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU Library General Public License for more details.
19
*
20
* Read the full text in the LICENSE.GPL file in the doc directory.
21
*/
22
23
#ifndef __PLUGINS_JOYSTICK_ACQUISITION_THREAD_H_
24
#define __PLUGINS_JOYSTICK_ACQUISITION_THREAD_H_
25
26
#include "bb_handler.h"
27
28
#include <core/threading/thread.h>
29
#include <aspect/logging.h>
30
#include <aspect/configurable.h>
31
32
#include <utils/math/types.h>
33
34
#include <string>
35
#include <vector>
36
37
namespace
fawkes {
38
class
Mutex;
39
}
40
41
class
JoystickForceFeedback
;
42
43
class
JoystickAcquisitionThread
44
:
public
fawkes::Thread
,
45
public
fawkes::LoggingAspect
,
46
public
fawkes::ConfigurableAspect
47
{
48
public
:
49
JoystickAcquisitionThread
();
50
JoystickAcquisitionThread
(
const
char
*device_file,
51
JoystickBlackBoardHandler
*handler,
52
fawkes::Logger
*
logger
);
53
54
virtual
void
init
();
55
virtual
void
finalize
();
56
virtual
void
loop
();
57
58
bool
lock_if_new_data
();
59
void
unlock
();
60
61
char
num_axes
()
const
;
62
char
num_buttons
()
const
;
63
const
char
*
joystick_name
()
const
;
64
unsigned
int
pressed_buttons
()
const
;
65
float
*
axis_values
();
66
67
/** Access force feedback of joystick.
68
* @return instance of JoystickForceFeedback class for current joystick. */
69
JoystickForceFeedback
*
ff
()
const
{
return
__ff; }
70
71
/** Stub to see name in backtrace for easier debugging. @see Thread::run() */
72
protected
:
virtual
void
run
() {
Thread::run
(); }
73
74
private
:
75
void
init
(std::string device_file);
76
void
open_joystick();
77
void
open_forcefeedback();
78
79
private
:
80
std::string __cfg_device_file;
81
82
int
__fd;
83
bool
__connected;
84
unsigned
int
__axis_array_size;
85
char
__num_axes;
86
char
__num_buttons;
87
char
__joystick_name[128];
88
89
bool
__new_data;
90
fawkes::Mutex
*__data_mutex;
91
92
unsigned
int
__pressed_buttons;
93
float
*__axis_values;
94
95
JoystickBlackBoardHandler
*__bbhandler;
96
JoystickForceFeedback
*__ff;
97
};
98
99
100
#endif
src
plugins
joystick
acquisition_thread.h
Generated by
1.8.1.1