My Project
Loading...
Searching...
No Matches
CXTouchController.h
Go to the documentation of this file.
1
2//
3// Software License Agreement (BSD License)
4// Copyright (c) 2003-2024, CHAI3D
5// (www.chai3d.org)
6//
7// All rights reserved.
8//
9// Redistribution and use in source and binary forms, with or without
10// modification, are permitted provided that the following conditions
11// are met:
12//
13// * Redistributions of source code must retain the above copyright
14// notice, this list of conditions and the following disclaimer.
15//
16// * Redistributions in binary form must reproduce the above
17// copyright notice, this list of conditions and the following
18// disclaimer in the documentation and/or other materials provided
19// with the distribution.
20//
21// * Neither the name of CHAI3D nor the names of its contributors may
22// be used to endorse or promote products derived from this software
23// without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36// POSSIBILITY OF SUCH DAMAGE.
37//
39
40
41#ifndef __CXTOUCHCONTROLLER_H_
42#define __CXTOUCHCONTROLLER_H_
43
44// related header files
46
47// chai3d namespace
48namespace chai3d {
49
50
59
60
72
73const int C_XTOUCH_MAX_BUTTONS = 200;
74const int C_XTOUCH_MAX_SLIDERS = 200;
75const int C_XTOUCH_MAX_DIALS = 200;
76
77
78
91
93{
95 // CONSTRUCTOR & DESTRUCTOR:
97
98public:
99
101 cXTouchController(unsigned int a_deviceNumber = 0);
102
104 virtual ~cXTouchController();
105
106
108 // PUBLIC STATIC METHODS:
110
111public:
112
114 static unsigned int getNumDevices();
115
116
118 // PUBLIC METHODS - GENERAL
120
121public:
122
124 virtual bool open();
125
127 virtual bool close();
128
131
133 void setLayerA() { setLayer(0); }
134
136 void setLayerB() { setLayer(1); }
137
139 void setLayer(int a_layer);
140
142 void initialize();
143
144
146 // PUBLIC METHODS - SLIDERS
148
149public:
150
152 int getNumSliders();
153
155 double getSliderValue(int a_index);
156
158 void setSliderValue(int a_index, double a_value);
159
161 void setAllSlidersValue(double a_value);
162
163
165 // PUBLIC METHODS - DIALS
167
168public:
169
171 int getNumDials();
172
174 double getDialValue(int a_index);
175
177 double getDialRangeMin(int a_index);
178
180 double getDialRangeMax(int a_index);
181
183 void setDialRange(int a_index, double a_min, double a_max);
184
186 void setDialValue(int a_index, double a_value);
187
189 void setDialMode(int a_index, int a_mode);
190
192 void setDialModeSingle(int a_index);
193
195 void setDialModePan(int a_index);
196
198 void setDialModeFan(int a_index);
199
201 void setDialModeSpread(int a_index);
202
204 void setDialModeTrim(int a_index);
205
207 void setDialLightOn(int a_index);
208
210 void setDialLightOff(int a_index);
211
213 void setDialLightBlinking(int a_index);
214
216 void setAllDialsValue(double a_value);
217
219 void setAllDialsRange(double a_min, double a_max);
220
222 void setAllDialsMode(int a_mode);
223
226
228 void setAllDialsModePan();
229
231 void setAllDialsModeFan();
232
235
237 void setAllDialsModeTrim();
238
240 void setAllDialsLightOn();
241
243 void setAllDialsLightOff();
244
247
248
250 // PUBLIC METHODS - BUTTONS
252
253public:
254
256 int getNumButtons();
257
259 int getButtonMode(int a_index);
260
262 bool getButtonState(int a_index);
263
265 int getButtonLightBehavior(int a_index);
266
268 void setButtonState(int a_index, bool a_state);
269
271 void setButtonToggleMode(int a_index);
272
274 void setButtonMomentaryMode(int a_index);
275
277 void setButtonMode(int a_index, int a_mode);
278
280 void setButtonToggleOn(int a_index);
281
283 void setButtonToggleOff(int a_index);
284
286 void setButtonLightBehavior(int a_index, int a_mode);
287
289 void setButtonLightOn(int a_index);
290
292 void setButtonLightOff(int a_index);
293
295 void setButtonLightBlinking(int a_index);
296
298 void setAllButtonsState(bool a_state);
299
302
305
307 void setAllButtonsMode(int a_mode);
308
311
314
316 void setAllButtonsLightBehavior(int a_mode);
317
320
323
326
327
329 // PUBLIC METHODS:
331
332public:
333
335 void callbackMidiIn(double a_deltatime, std::vector< unsigned char > *a_message);
336
337
339 // PROTECTED METHODS:
341
342public:
343
345 void sendMidi3(unsigned char a_data0, unsigned char a_data1, unsigned char a_data2);
346
348 void sendMidi2(unsigned char a_data0, unsigned char a_data1);
349
351 double convertFrom(unsigned char a_value, double a_rangeMin, double a_rangeMax);
352
354 unsigned char convertTo(double a_value, double a_rangeMin, double a_rangeMax);
355
356
358 // PROTECTED MEMBERS:
360
361protected:
362
365
367 void *midiin;
368
370 void *midiout;
371
373 unsigned int m_portNumberIn;
374
376 unsigned int m_portNumberOut;
377
380
383
386
389
392
395
398
401};
402
403
404} // chai3d namespace
405
406
407#endif // __CXTOUCHCONTROLLER_H_
408
Implements a device base class.
This class implements an abstract class for hardware devices.
Definition CGenericDevice.h:84
This class implements support for the X-Touch midi controller.
Definition CXTouchController.h:93
void setAllDialsModeFan()
This method sets the display mode of all dials to fan.
Definition CXTouchController.cpp:949
void setDialModePan(int a_index)
This method sets the display mode of the dial to pan.
Definition CXTouchController.cpp:740
void setButtonMode(int a_index, int a_mode)
This method set a button to a given mode.
Definition CXTouchController.cpp:1203
virtual bool open()
This method opens a connection to this device.
Definition CXTouchController.cpp:252
void setAllButtonsToggleOn()
This method toggles all buttons ON.
Definition CXTouchController.cpp:1477
cXTouchModel getModel()
This method returns the model of X-Touch interface.
Definition CXTouchController.h:130
int m_buttonBehavior[C_XTOUCH_MAX_BUTTONS]
Button light behavior.
Definition CXTouchController.h:400
void setDialLightOff(int a_index)
This method turns the lights of the dial OFF.
Definition CXTouchController.cpp:819
void initialize()
This method iniaitalizes the table to its default state.
Definition CXTouchController.cpp:304
double m_sliderValue[C_XTOUCH_MAX_SLIDERS]
Slider values.
Definition CXTouchController.h:382
void setDialMode(int a_index, int a_mode)
This method sets the mode of a dial.
Definition CXTouchController.cpp:680
void setButtonLightOn(int a_index)
This method sets the light of a button ON.
Definition CXTouchController.cpp:1290
virtual ~cXTouchController()
Destructor of cXTouchController.
Definition CXTouchController.cpp:195
void sendMidi2(unsigned char a_data0, unsigned char a_data1)
This method sends a message through the midi port composed of two bytes.
Definition CXTouchController.cpp:1812
void setDialModeFan(int a_index)
This method sets the display mode of the dial to fan.
Definition CXTouchController.cpp:753
void setDialModeSpread(int a_index)
This method sets the display mode of the dial to spread.
Definition CXTouchController.cpp:766
int getNumDials()
This method returns the number of dials.
Definition CXTouchController.cpp:521
double convertFrom(unsigned char a_value, double a_rangeMin, double a_rangeMax)
This method converts a midi value (0-127) into a ranged value.
Definition CXTouchController.cpp:1864
void setAllDialsModeSingle()
This method sets the display mode of all dials to single.
Definition CXTouchController.cpp:921
void setAllButtonsLightOff()
This method sets the light of all buttons OFF.
Definition CXTouchController.cpp:1535
void setAllDialsValue(double a_value)
This method sets a value to all dials.
Definition CXTouchController.cpp:873
void setButtonLightOff(int a_index)
This method sets the light of a button OFF.
Definition CXTouchController.cpp:1333
unsigned char convertTo(double a_value, double a_rangeMin, double a_rangeMax)
This method converts a ranged value into a midi value (0-127).
Definition CXTouchController.cpp:1899
double m_dialRange[C_XTOUCH_MAX_DIALS][2]
Dial Ranges.
Definition CXTouchController.h:391
unsigned int m_portNumberIn
Port number MIDI in.
Definition CXTouchController.h:373
static unsigned int getNumDevices()
This method returns the number of haptic devices available for this class of devices.
Definition CXTouchController.cpp:210
void setLayerB()
This method enables layer B.
Definition CXTouchController.h:136
void setAllButtonsMode(int a_mode)
This method sets all buttons to a given mode.
Definition CXTouchController.cpp:1463
void setButtonLightBehavior(int a_index, int a_mode)
This method sets the light mode of a button.
Definition CXTouchController.cpp:1267
void setDialLightBlinking(int a_index)
This method turns the lights of the dial to blinking.
Definition CXTouchController.cpp:846
void setButtonState(int a_index, bool a_state)
This method sets the state of a button.
Definition CXTouchController.cpp:1173
void setAllButtonsLightBehavior(int a_mode)
This method sets the light behavior of all buttons.
Definition CXTouchController.cpp:1507
void * midiout
Midi interface output data.
Definition CXTouchController.h:370
void setSliderValue(int a_index, double a_value)
This method sets the value of a slider.
Definition CXTouchController.cpp:465
int m_buttonMode[C_XTOUCH_MAX_BUTTONS]
Button modes.
Definition CXTouchController.h:397
void setAllDialsModePan()
This method sets the display mode of all dials to pan.
Definition CXTouchController.cpp:935
void setLayerA()
This method enables layer A.
Definition CXTouchController.h:133
unsigned int m_portNumberOut
Port number MIDI out.
Definition CXTouchController.h:376
void setButtonMomentaryMode(int a_index)
This method sets a button to momentary mode.
Definition CXTouchController.cpp:1155
void setAllButtonsState(bool a_state)
This method sets the state of all buttons.
Definition CXTouchController.cpp:1419
void setAllDialsModeTrim()
This method sets the display mode of all dials to trim.
Definition CXTouchController.cpp:977
void setDialModeSingle(int a_index)
This method sets the display mode of the dial to single.
Definition CXTouchController.cpp:727
double getDialRangeMin(int a_index)
This method returns the minium range value of a dial.
Definition CXTouchController.cpp:571
void setDialRange(int a_index, double a_min, double a_max)
This method assigns a range of values to the dial.
Definition CXTouchController.cpp:608
void setDialLightOn(int a_index)
This method turns the lights of the dial ON.
Definition CXTouchController.cpp:792
void setDialModeTrim(int a_index)
This method sets the display mode of the dial to trim.
Definition CXTouchController.cpp:779
int getButtonMode(int a_index)
This method return the current mode of a button.
Definition CXTouchController.cpp:1072
double m_sliderRange[C_XTOUCH_MAX_DIALS][2]
Slider Ranges.
Definition CXTouchController.h:385
void setAllButtonsToggleOff()
This method toggles all buttons OFF.
Definition CXTouchController.cpp:1491
double getDialRangeMax(int a_index)
This method returns the maximum range value of a dial.
Definition CXTouchController.cpp:589
void setAllDialsLightOff()
This method turns the lights of all dials OFF.
Definition CXTouchController.cpp:1005
void setDialValue(int a_index, double a_value)
This method sets a value to a dial.
Definition CXTouchController.cpp:631
int getNumButtons()
This method returns the number of buttons.
Definition CXTouchController.cpp:1036
double m_dialValue[C_XTOUCH_MAX_DIALS]
Dial values.
Definition CXTouchController.h:388
void sendMidi3(unsigned char a_data0, unsigned char a_data1, unsigned char a_data2)
This method sends a message through the midi port composed of three bytes.
Definition CXTouchController.cpp:1836
void setAllDialsLightOn()
This method turns the lights of all dials ON.
Definition CXTouchController.cpp:991
bool getButtonState(int a_index)
This method returns the state of a button.
Definition CXTouchController.cpp:1092
void * midiin
Midi interface input data.
Definition CXTouchController.h:367
void setButtonToggleOn(int a_index)
This method toggles the buttons ON.
Definition CXTouchController.cpp:1220
void setAllButtonsLightBlinking()
This method sets the light of all buttona to blinking.
Definition CXTouchController.cpp:1549
void setAllButtonsMomentaryMode()
This method sets all buttons to momentary mode.
Definition CXTouchController.cpp:1447
virtual bool close()
This method closes the connection to this device.
Definition CXTouchController.cpp:281
void setLayer(int a_layer)
This method selects the desired layer (A or B)
Definition CXTouchController.cpp:385
int getButtonLightBehavior(int a_index)
This method returns the light behavior of a button.
Definition CXTouchController.cpp:1121
void setAllButtonsToggleMode()
This method sets all buttons to toggle mode.
Definition CXTouchController.cpp:1433
void setAllDialsRange(double a_min, double a_max)
This method assigns a range of values to the dial.
Definition CXTouchController.cpp:890
void setButtonToggleMode(int a_index)
This method sets a button to toggle mode.
Definition CXTouchController.cpp:1138
void setAllDialsLightBlinking()
This method turns the lights of all dials to blinking.
Definition CXTouchController.cpp:1019
void setButtonLightBlinking(int a_index)
This method sets the light of a button to blinking.
Definition CXTouchController.cpp:1376
bool m_buttonState[C_XTOUCH_MAX_BUTTONS]
Button states.
Definition CXTouchController.h:394
int m_layer
Current layer.
Definition CXTouchController.h:379
void callbackMidiIn(double a_deltatime, std::vector< unsigned char > *a_message)
This method is a callback for all midi data coming from the interface.
Definition CXTouchController.cpp:1566
cXTouchModel m_model
Device model.
Definition CXTouchController.h:364
double getDialValue(int a_index)
This method returns the value of a dial.
Definition CXTouchController.cpp:553
void setAllDialsMode(int a_mode)
This method sets the mode of all dials.
Definition CXTouchController.cpp:906
void setAllButtonsLightOn()
This method sets the light of all buttons ON.
Definition CXTouchController.cpp:1521
void setAllSlidersValue(double a_value)
This method sets the value of a all sliders.
Definition CXTouchController.cpp:504
void setAllDialsModeSpread()
This method sets the display mode of all dials to spread.
Definition CXTouchController.cpp:963
double getSliderValue(int a_index)
This method returns the value of a slider.
Definition CXTouchController.cpp:447
void setButtonToggleOff(int a_index)
This method toggles the button OFF.
Definition CXTouchController.cpp:1243
int getNumSliders()
This method returns the number of active sliders.
Definition CXTouchController.cpp:415
Definition CAudioBuffer.cpp:57
cXTouchModel
Definition CXTouchController.h:67
@ C_XTOUCH_COMPACT
Definition CXTouchController.h:69
@ C_XTOUCH_MINI
Definition CXTouchController.h:70
@ C_XTOUCH_NOT_DETECTED
Definition CXTouchController.h:68
const int C_XTOUCH_MAX_DIALS
Definition CXTouchController.h:75
const int C_XTOUCH_MAX_SLIDERS
Definition CXTouchController.h:74
const int C_XTOUCH_MAX_BUTTONS
Definition CXTouchController.h:73