tangled
alpha
login
or
join now
buttplug.io
/
buttplug
20
fork
atom
Buttplug sex toy control library
20
fork
atom
overview
issues
pulls
pipelines
chore: Change heater to temperature
Fixes #792
qdot.tngl.sh
4 months ago
242fee59
5222904e
+51
-53
13 changed files
expand all
collapse all
unified
split
crates
buttplug_client
src
device
command.rs
feature.rs
buttplug_core
schema
buttplug-schema.json
src
message
device_feature.rs
v4
output_cmd.rs
buttplug_server
src
device
protocol.rs
server_device.rs
message
v3
client_device_message_attributes.rs
server_device_message_attributes.rs
buttplug_server_device_config
device-config-v4
buttplug-device-config-schema-v4.json
src
device_config_file
feature.rs
server_device_feature.rs
buttplug_tests
tests
util
device_test
client
client_v4
mod.rs
+5
-5
crates/buttplug_client/src/device/command.rs
···
31
31
Rotate(i32),
32
32
Oscillate(u32),
33
33
Constrict(u32),
34
34
-
Heater(u32),
34
34
+
Temperature(i32),
35
35
Led(u32),
36
36
Spray(u32),
37
37
Position(u32),
···
41
41
RotateFloat(f64),
42
42
OscillateFloat(f64),
43
43
ConstrictFloat(f64),
44
44
-
HeaterFloat(f64),
44
44
+
TemperatureFloat(f64),
45
45
LedFloat(f64),
46
46
SprayFloat(f64),
47
47
PositionFloat(f64),
···
58
58
OutputType::Oscillate => Ok(ClientDeviceOutputCommand::OscillateFloat(value)),
59
59
OutputType::Rotate => Ok(ClientDeviceOutputCommand::RotateFloat(value)),
60
60
OutputType::Constrict => Ok(ClientDeviceOutputCommand::ConstrictFloat(value)),
61
61
-
OutputType::Heater => Ok(ClientDeviceOutputCommand::HeaterFloat(value)),
61
61
+
OutputType::Temperature => Ok(ClientDeviceOutputCommand::TemperatureFloat(value)),
62
62
OutputType::Led => Ok(ClientDeviceOutputCommand::LedFloat(value)),
63
63
OutputType::Spray => Ok(ClientDeviceOutputCommand::SprayFloat(value)),
64
64
OutputType::Position => Ok(ClientDeviceOutputCommand::PositionFloat(value)),
···
84
84
ClientDeviceOutputCommand::Constrict(_) | ClientDeviceOutputCommand::ConstrictFloat(_) => {
85
85
OutputType::Constrict
86
86
}
87
87
-
ClientDeviceOutputCommand::Heater(_) | ClientDeviceOutputCommand::HeaterFloat(_) => {
88
88
-
OutputType::Heater
87
87
+
ClientDeviceOutputCommand::Temperature(_) | ClientDeviceOutputCommand::TemperatureFloat(_) => {
88
88
+
OutputType::Temperature
89
89
}
90
90
ClientDeviceOutputCommand::Led(_) | ClientDeviceOutputCommand::LedFloat(_) => OutputType::Led,
91
91
ClientDeviceOutputCommand::Spray(_) | ClientDeviceOutputCommand::SprayFloat(_) => {
+4
-4
crates/buttplug_client/src/device/feature.rs
···
135
135
ClientDeviceOutputCommand::ConstrictFloat(v) => {
136
136
OutputCommand::Constrict(OutputValue::new(self.convert_float_value(output, *v)?))
137
137
}
138
138
-
ClientDeviceOutputCommand::HeaterFloat(v) => {
139
139
-
OutputCommand::Heater(OutputValue::new(self.convert_float_value(output, *v)?))
138
138
+
ClientDeviceOutputCommand::TemperatureFloat(v) => {
139
139
+
OutputCommand::Temperature(OutputValue::new(self.convert_float_value(output, *v)?))
140
140
}
141
141
ClientDeviceOutputCommand::LedFloat(v) => {
142
142
OutputCommand::Led(OutputValue::new(self.convert_float_value(output, *v)?))
···
165
165
ClientDeviceOutputCommand::Constrict(v) => {
166
166
OutputCommand::Constrict(OutputValue::new(self.check_step_value(output, *v as i32)?))
167
167
}
168
168
-
ClientDeviceOutputCommand::Heater(v) => {
169
169
-
OutputCommand::Heater(OutputValue::new(self.check_step_value(output, *v as i32)?))
168
168
+
ClientDeviceOutputCommand::Temperature(v) => {
169
169
+
OutputCommand::Temperature(OutputValue::new(self.check_step_value(output, *v as i32)?))
170
170
}
171
171
ClientDeviceOutputCommand::Led(v) => {
172
172
OutputCommand::Led(OutputValue::new(self.check_step_value(output, *v as i32)?))
+2
-2
crates/buttplug_core/schema/buttplug-schema.json
···
380
380
"Output": {
381
381
"type": "object",
382
382
"patternProperties": {
383
383
-
"^(Vibrate|Rotate|Oscillate|Constrict|Spray|Position|Heater|Led)$": {
383
383
+
"^(Vibrate|Rotate|Oscillate|Constrict|Spray|Position|Temperature|Led)$": {
384
384
"type": "object",
385
385
"properties": {
386
386
"Value": {
···
455
455
"Command": {
456
456
"type": "object",
457
457
"patternProperties": {
458
458
-
"^(Vibrate|Rotate|Oscillate|Constrict|Spray|Position|Heater|Led)$": {
458
458
+
"^(Vibrate|Rotate|Oscillate|Constrict|Spray|Position|Temperature|Led)$": {
459
459
"type": "object",
460
460
"properties": {
461
461
"Value": {
+6
-6
crates/buttplug_core/src/message/device_feature.rs
···
24
24
Oscillate,
25
25
#[serde(alias = "constrict")]
26
26
Constrict,
27
27
-
#[serde(alias = "heater")]
28
28
-
Heater,
27
27
+
#[serde(alias = "temperature")]
28
28
+
Temperature,
29
29
#[serde(alias = "led")]
30
30
Led,
31
31
// For instances where we specify a position to move to ASAP. Usually servos, probably for the
···
198
198
#[serde(skip_serializing_if = "Option::is_none")]
199
199
constrict: Option<DeviceFeatureOutputValueProperties>,
200
200
#[serde(skip_serializing_if = "Option::is_none")]
201
201
-
heater: Option<DeviceFeatureOutputValueProperties>,
201
201
+
temperature: Option<DeviceFeatureOutputValueProperties>,
202
202
#[serde(skip_serializing_if = "Option::is_none")]
203
203
led: Option<DeviceFeatureOutputValueProperties>,
204
204
#[serde(skip_serializing_if = "Option::is_none")]
···
213
213
pub fn contains(&self, output_type: OutputType) -> bool {
214
214
match output_type {
215
215
OutputType::Constrict => self.constrict.is_some(),
216
216
-
OutputType::Heater => self.heater.is_some(),
216
216
+
OutputType::Temperature => self.temperature.is_some(),
217
217
OutputType::Led => self.led.is_some(),
218
218
OutputType::Oscillate => self.oscillate.is_some(),
219
219
OutputType::Position => self.position.is_some(),
···
231
231
.constrict()
232
232
.as_ref()
233
233
.map(|x| x as &dyn DeviceFeatureOutputLimits),
234
234
-
OutputType::Heater => self
235
235
-
.heater()
234
234
+
OutputType::Temperature => self
235
235
+
.temperature()
236
236
.as_ref()
237
237
.map(|x| x as &dyn DeviceFeatureOutputLimits),
238
238
OutputType::Led => self
+5
-5
crates/buttplug_core/src/message/v4/output_cmd.rs
···
55
55
Oscillate(OutputValue),
56
56
Constrict(OutputValue),
57
57
Spray(OutputValue),
58
58
-
Heater(OutputValue),
58
58
+
Temperature(OutputValue),
59
59
Led(OutputValue),
60
60
// For instances where we specify a position to move to ASAP. Usually servos, probably for the
61
61
// OSR-2/SR-6.
···
68
68
match self {
69
69
OutputCommand::Constrict(x)
70
70
| OutputCommand::Spray(x)
71
71
-
| OutputCommand::Heater(x)
71
71
+
| OutputCommand::Temperature(x)
72
72
| OutputCommand::Led(x)
73
73
| OutputCommand::Oscillate(x)
74
74
| OutputCommand::Position(x)
···
82
82
match self {
83
83
OutputCommand::Constrict(x)
84
84
| OutputCommand::Spray(x)
85
85
-
| OutputCommand::Heater(x)
85
85
+
| OutputCommand::Temperature(x)
86
86
| OutputCommand::Led(x)
87
87
| OutputCommand::Oscillate(x)
88
88
| OutputCommand::Position(x)
···
102
102
Self::Led(_) => OutputType::Led,
103
103
Self::Position(_) => OutputType::Position,
104
104
Self::PositionWithDuration(_) => OutputType::PositionWithDuration,
105
105
-
Self::Heater(_) => OutputType::Heater,
105
105
+
Self::Temperature(_) => OutputType::Temperature,
106
106
}
107
107
}
108
108
109
109
pub fn from_output_type(output_type: OutputType, value: i32) -> Result<Self, ButtplugError> {
110
110
match output_type {
111
111
OutputType::Constrict => Ok(Self::Constrict(OutputValue::new(value))),
112
112
-
OutputType::Heater => Ok(Self::Heater(OutputValue::new(value))),
112
112
+
OutputType::Temperature => Ok(Self::Temperature(OutputValue::new(value))),
113
113
OutputType::Spray => Ok(Self::Spray(OutputValue::new(value))),
114
114
OutputType::Led => Ok(Self::Led(OutputValue::new(value))),
115
115
OutputType::Oscillate => Ok(Self::Oscillate(OutputValue::new(value))),
+4
-6
crates/buttplug_server/src/device/protocol.rs
···
264
264
.try_into()
265
265
.map_err(|_| ButtplugDeviceError::DeviceCommandSignError)?,
266
266
),
267
267
-
OutputCommand::Heater(x) => self.handle_output_heater_cmd(
267
267
+
OutputCommand::Temperature(x) => self.handle_output_temperature_cmd(
268
268
cmd.feature_index(),
269
269
cmd.feature_id(),
270
270
x.value()
271
271
-
.try_into()
272
272
-
.map_err(|_| ButtplugDeviceError::DeviceCommandSignError)?,
273
271
),
274
272
OutputCommand::Led(x) => self.handle_output_led_cmd(
275
273
cmd.feature_index(),
···
332
330
self.command_unimplemented("OutputCmd (Constrict Actuator)")
333
331
}
334
332
335
335
-
fn handle_output_heater_cmd(
333
333
+
fn handle_output_temperature_cmd(
336
334
&self,
337
335
_feature_index: u32,
338
336
_feature_id: Uuid,
339
339
-
_level: u32,
337
337
+
_level: i32,
340
338
) -> Result<Vec<HardwareCommand>, ButtplugDeviceError> {
341
341
-
self.command_unimplemented("OutputCmd (Heater Actuator)")
339
339
+
self.command_unimplemented("OutputCmd (Temperature Actuator)")
342
340
}
343
341
344
342
fn handle_output_led_cmd(
+2
-2
crates/buttplug_server/src/device/server_device.rs
···
421
421
stop_cmd(message::OutputCommand::Constrict(OutputValue::new(0)));
422
422
break;
423
423
}
424
424
-
OutputType::Heater => {
425
425
-
stop_cmd(message::OutputCommand::Heater(OutputValue::new(0)));
424
424
+
OutputType::Temperature => {
425
425
+
stop_cmd(message::OutputCommand::Temperature(OutputValue::new(0)));
426
426
break;
427
427
}
428
428
OutputType::Spray => {
+2
-2
crates/buttplug_server/src/message/v3/client_device_message_attributes.rs
···
260
260
if let Some(x) = output_map.constrict().as_ref() {
261
261
create_actuator(OutputType::Constrict, x)
262
262
}
263
263
-
if let Some(x) = output_map.heater().as_ref() {
264
264
-
create_actuator(OutputType::Heater, x)
263
263
+
if let Some(x) = output_map.temperature().as_ref() {
264
264
+
create_actuator(OutputType::Temperature, x)
265
265
}
266
266
if let Some(x) = output_map.led().as_ref() {
267
267
create_actuator(OutputType::Led, x)
+2
-2
crates/buttplug_server/src/message/v3/server_device_message_attributes.rs
···
84
84
if let Some(attr) = output_map.rotate().as_ref() {
85
85
create_attribute(OutputType::Rotate, attr.value().step_count())
86
86
}
87
87
-
if let Some(attr) = output_map.heater().as_ref() {
88
88
-
create_attribute(OutputType::Heater, attr.value().step_count())
87
87
+
if let Some(attr) = output_map.temperature().as_ref() {
88
88
+
create_attribute(OutputType::Temperature, attr.value().step_count())
89
89
}
90
90
if let Some(attr) = output_map.led().as_ref() {
91
91
create_attribute(OutputType::Led, attr.value().step_count())
+2
-2
crates/buttplug_server_device_config/device-config-v4/buttplug-device-config-schema-v4.json
···
186
186
"output": {
187
187
"type": "object",
188
188
"patternProperties": {
189
189
-
"^(vibrate|rotate|oscillate|constrict|spray|position|heater|led)$": {
189
189
+
"^(vibrate|rotate|oscillate|constrict|spray|position|temperature|led)$": {
190
190
"type": "object",
191
191
"properties": {
192
192
"value": {
···
276
276
"output": {
277
277
"type": "object",
278
278
"patternProperties": {
279
279
-
"^(vibrate|rotate|oscillate|constrict|spray|heater|led)$": {
279
279
+
"^(vibrate|rotate|oscillate|constrict|spray|temperature|led)$": {
280
280
"type": "object",
281
281
"properties": {
282
282
"value": {
+9
-9
crates/buttplug_server_device_config/src/device_config_file/feature.rs
···
90
90
#[serde(skip_serializing_if = "Option::is_none")]
91
91
constrict: Option<BaseDeviceFeatureOutputValueProperties>,
92
92
#[serde(skip_serializing_if = "Option::is_none")]
93
93
-
heater: Option<BaseDeviceFeatureOutputValueProperties>,
93
93
+
temperature: Option<BaseDeviceFeatureOutputValueProperties>,
94
94
#[serde(skip_serializing_if = "Option::is_none")]
95
95
led: Option<BaseDeviceFeatureOutputValueProperties>,
96
96
#[serde(skip_serializing_if = "Option::is_none")]
···
116
116
if let Some(constrict) = val.constrict {
117
117
output.set_constrict(Some(constrict.into()));
118
118
}
119
119
-
if let Some(heater) = val.heater {
120
120
-
output.set_heater(Some(heater.into()));
119
119
+
if let Some(temperature) = val.temperature {
120
120
+
output.set_temperature(Some(temperature.into()));
121
121
}
122
122
if let Some(led) = val.led {
123
123
output.set_led(Some(led.into()));
···
268
268
#[serde(skip_serializing_if = "Option::is_none")]
269
269
constrict: Option<UserDeviceFeatureOutputValueProperties>,
270
270
#[serde(skip_serializing_if = "Option::is_none")]
271
271
-
heater: Option<UserDeviceFeatureOutputValueProperties>,
271
271
+
temperature: Option<UserDeviceFeatureOutputValueProperties>,
272
272
#[serde(skip_serializing_if = "Option::is_none")]
273
273
led: Option<UserDeviceFeatureOutputValueProperties>,
274
274
#[serde(skip_serializing_if = "Option::is_none")]
···
314
314
output.set_constrict(base_output.constrict().clone());
315
315
}
316
316
}
317
317
-
if let Some(user_heater) = &self.heater {
318
318
-
if let Some(base_heater) = base_output.heater() {
319
319
-
output.set_heater(Some(user_heater.with_base_properties(base_heater)?));
317
317
+
if let Some(user_temperature) = &self.temperature {
318
318
+
if let Some(base_temperature) = base_output.temperature() {
319
319
+
output.set_temperature(Some(user_temperature.with_base_properties(base_temperature)?));
320
320
} else {
321
321
-
output.set_heater(base_output.heater().clone());
321
321
+
output.set_temperature(base_output.temperature().clone());
322
322
}
323
323
}
324
324
if let Some(user_led) = &self.led {
···
360
360
rotate: value.rotate().as_ref().map(|x| x.into()),
361
361
oscillate: value.oscillate().as_ref().map(|x| x.into()),
362
362
constrict: value.constrict().as_ref().map(|x| x.into()),
363
363
-
heater: value.heater().as_ref().map(|x| x.into()),
363
363
+
temperature: value.temperature().as_ref().map(|x| x.into()),
364
364
led: value.led().as_ref().map(|x| x.into()),
365
365
position: value.position().as_ref().map(|x| x.into()),
366
366
position_with_duration: value.position_with_duration().as_ref().map(|x| x.into()),
+7
-7
crates/buttplug_server_device_config/src/server_device_feature.rs
···
292
292
rotate: Option<ServerDeviceFeatureOutputValueProperties>,
293
293
oscillate: Option<ServerDeviceFeatureOutputValueProperties>,
294
294
constrict: Option<ServerDeviceFeatureOutputValueProperties>,
295
295
-
heater: Option<ServerDeviceFeatureOutputValueProperties>,
295
295
+
temperature: Option<ServerDeviceFeatureOutputValueProperties>,
296
296
led: Option<ServerDeviceFeatureOutputValueProperties>,
297
297
position: Option<ServerDeviceFeatureOutputPositionProperties>,
298
298
position_with_duration: Option<ServerDeviceFeatureOutputPositionWithDurationProperties>,
···
303
303
pub fn contains(&self, output_type: OutputType) -> bool {
304
304
match output_type {
305
305
OutputType::Constrict => self.constrict.is_some(),
306
306
-
OutputType::Heater => self.heater.is_some(),
306
306
+
OutputType::Temperature => self.temperature.is_some(),
307
307
OutputType::Led => self.led.is_some(),
308
308
OutputType::Oscillate => self.oscillate.is_some(),
309
309
OutputType::Position => self.position.is_some(),
···
322
322
.is_some()
323
323
.then(|| types.push(OutputType::Constrict));
324
324
self
325
325
-
.heater
325
325
+
.temperature
326
326
.is_some()
327
327
-
.then(|| types.push(OutputType::Heater));
327
327
+
.then(|| types.push(OutputType::Temperature));
328
328
self.led.is_some().then(|| types.push(OutputType::Led));
329
329
self
330
330
.oscillate
···
361
361
Err(ButtplugDeviceConfigError::InvalidOutput(output_type)),
362
362
|x| x.calculate_scaled_value(value),
363
363
),
364
364
-
OutputType::Heater => self.heater.as_ref().map_or(
364
364
+
OutputType::Temperature => self.temperature.as_ref().map_or(
365
365
Err(ButtplugDeviceConfigError::InvalidOutput(output_type)),
366
366
|x| x.calculate_scaled_value(value),
367
367
),
···
407
407
Err(ButtplugDeviceConfigError::InvalidOutput(output_type)),
408
408
|x| x.calculate_scaled_float(value),
409
409
),
410
410
-
OutputType::Heater => self.heater.as_ref().map_or(
410
410
+
OutputType::Temperature => self.temperature.as_ref().map_or(
411
411
Err(ButtplugDeviceConfigError::InvalidOutput(output_type)),
412
412
|x| x.calculate_scaled_float(value),
413
413
),
···
451
451
val.rotate.as_ref().map(|x| builder.rotate(x.into()));
452
452
val.oscillate.as_ref().map(|x| builder.oscillate(x.into()));
453
453
val.constrict.as_ref().map(|x| builder.constrict(x.into()));
454
454
-
val.heater.as_ref().map(|x| builder.heater(x.into()));
454
454
+
val.temperature.as_ref().map(|x| builder.temperature(x.into()));
455
455
val.led.as_ref().map(|x| builder.led(x.into()));
456
456
val.position.as_ref().map(|x| builder.position(x.into()));
457
457
val
+1
-1
crates/buttplug_tests/tests/util/device_test/client/client_v4/mod.rs
···
28
28
fn from_type_and_value(output_type: OutputType, value: f64) -> ClientDeviceOutputCommand {
29
29
match output_type {
30
30
OutputType::Constrict => ClientDeviceOutputCommand::ConstrictFloat(value),
31
31
-
OutputType::Heater => ClientDeviceOutputCommand::HeaterFloat(value),
31
31
+
OutputType::Temperature => ClientDeviceOutputCommand::TemperatureFloat(value),
32
32
OutputType::Led => ClientDeviceOutputCommand::LedFloat(value),
33
33
OutputType::Oscillate => ClientDeviceOutputCommand::OscillateFloat(value),
34
34
OutputType::Position => ClientDeviceOutputCommand::PositionFloat(value),