Panda3D
clientDialDevice.h
1 // Filename: clientDialDevice.h
2 // Created by: drose (26Jan01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef CLIENTDIALDEVICE_H
16 #define CLIENTDIALDEVICE_H
17 
18 #include "pandabase.h"
19 
20 #include "clientDevice.h"
21 
22 ////////////////////////////////////////////////////////////////////
23 // Class : ClientDialDevice
24 // Description : A device, attached to the ClientBase by a
25 // DialNode, that records the data from a single
26 // named dial device. The named device can contain
27 // any number of dials, numbered in sequence beginning
28 // at zero.
29 //
30 // A dial is a rotating device that does not have
31 // stops--it can keep rotating any number of times.
32 // Therefore it does not have a specific position at any
33 // given time, unlike an AnalogDevice.
34 ////////////////////////////////////////////////////////////////////
35 class EXPCL_PANDA_DEVICE ClientDialDevice : public ClientDevice {
36 protected:
37  INLINE ClientDialDevice(ClientBase *client, const string &device_name);
38 
39 public:
40  INLINE int get_num_dials() const;
41 
42  INLINE void push_dial(int index, double offset);
43  INLINE double read_dial(int index);
44  INLINE bool is_dial_known(int index) const;
45 
46 private:
47  void ensure_dial_index(int index);
48 
49 protected:
50  class DialState {
51  public:
52  INLINE DialState();
53 
54  double _offset;
55  bool _known;
56  };
57 
58  typedef pvector<DialState> Dials;
59  Dials _dials;
60 
61 
62 public:
63  static TypeHandle get_class_type() {
64  return _type_handle;
65  }
66  static void init_type() {
67  ClientDevice::init_type();
68  register_type(_type_handle, "ClientDialDevice",
69  ClientDevice::get_class_type());
70  }
71  virtual TypeHandle get_type() const {
72  return get_class_type();
73  }
74  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
75 
76 private:
77  static TypeHandle _type_handle;
78 };
79 
80 #include "clientDialDevice.I"
81 
82 #endif
A device, attached to the ClientBase by a DialNode, that records the data from a single named dial de...
An abstract base class for a family of client device interfaces–including trackers, buttons, dials, and other analog inputs.
Definition: clientBase.h:47
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
Any of a number of different devices that might be attached to a ClientBase, including trackers...
Definition: clientDevice.h:35