-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.rs
More file actions
127 lines (109 loc) · 5 KB
/
test.rs
File metadata and controls
127 lines (109 loc) · 5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#[cfg(test)]
mod tests {
use vjoy_sys::AXES_HID_USAGE;
#[test]
fn open_device() {
unsafe {
//Success of this test can be observed via the vJoyMonitor and vJoyList executables bundled with vJoy.
let vjoy = vjoy_sys::vJoyInterface::new("C:/Program Files/vJoy/x64/vJoyInterface.dll")
.unwrap();
assert!(vjoy.vJoyEnabled() == 1, "vJoy is not installed");
assert!(vjoy.isVJDExists(1) == 1, "device 1 does not exist");
assert!(
vjoy.AcquireVJD(1) == 1,
"device 1 is busy and could not be acquired"
);
println!("Setting button 1 of device 1");
assert!(
vjoy.SetBtn(1, 1, 1) == 1,
"button 1 of device 1 could not be set"
);
std::thread::sleep(std::time::Duration::from_millis(100));
println!("Resetting button 1 of device 1");
assert!(
vjoy.SetBtn(0, 1, 1) == 1,
"button 1 of device 1 could not be reset"
);
std::thread::sleep(std::time::Duration::from_millis(100));
println!("Setting axis 1 of device 1");
assert!(
vjoy.SetAxis(32_767_i32, 1, AXES_HID_USAGE[0]) == 1,
"axis 1 of device 1 could not be set"
);
std::thread::sleep(std::time::Duration::from_millis(100));
println!("Resetting axis 1 of device 1");
assert!(
vjoy.SetAxis(0, 1, AXES_HID_USAGE[0]) == 1,
"axis 1 of device 1 could not be reset"
);
std::thread::sleep(std::time::Duration::from_millis(100));
let num_cont_hat = vjoy.GetVJDContPovNumber(1);
let num_disc_hat = vjoy.GetVJDDiscPovNumber(1);
if num_disc_hat >= 1 {
println!("Setting discrete hat 1 of device 1 NORTH");
assert!(
vjoy.SetDiscPov(0, 1, 1) == 1,
"discrete hat 1 of device 1 could not be set"
);
std::thread::sleep(std::time::Duration::from_millis(100));
println!("Setting discrete hat 1 of device 1 EAST");
assert!(
vjoy.SetDiscPov(1, 1, 1) == 1,
"discrete hat 1 of device 1 could not be set"
);
std::thread::sleep(std::time::Duration::from_millis(100));
println!("Setting discrete hat 1 of device 1 SOUTH");
assert!(
vjoy.SetDiscPov(2, 1, 1) == 1,
"discrete hat 1 of device 1 could not be set"
);
std::thread::sleep(std::time::Duration::from_millis(100));
println!("Setting discrete hat 1 of device 1 WEST");
assert!(
vjoy.SetDiscPov(3, 1, 1) == 1,
"discrete hat 1 of device 1 could not be set"
);
std::thread::sleep(std::time::Duration::from_millis(100));
println!("Resetting discrete hat 1 of device 1");
assert!(
vjoy.SetDiscPov(-1, 1, 1) == 1,
"discrete hat 1 of device 1 could not be reset"
);
std::thread::sleep(std::time::Duration::from_millis(100));
}
if num_cont_hat >= 1 {
println!("Setting continuous hat 1 of device 1 45°");
assert!(
vjoy.SetContPov(45 * 100, 1, 1) == 1,
"continuous hat 1 of device 1 could not be set"
);
std::thread::sleep(std::time::Duration::from_millis(100));
println!("Setting continuous hat 1 of device 1 135°");
assert!(
vjoy.SetContPov(135 * 100, 1, 1) == 1,
"continuous hat 1 of device 1 could not be set"
);
std::thread::sleep(std::time::Duration::from_millis(100));
println!("Setting continuous hat 1 of device 1 225°");
assert!(
vjoy.SetContPov(225 * 100, 1, 1) == 1,
"continuous hat 1 of device 1 could not be set"
);
std::thread::sleep(std::time::Duration::from_millis(100));
println!("Setting continuous hat 1 of device 1 315°");
assert!(
vjoy.SetContPov(315 * 100, 1, 1) == 1,
"continuous hat 1 of device 1 could not be set"
);
std::thread::sleep(std::time::Duration::from_millis(100));
println!("Resetting continuous hat 1 of device 1");
assert!(
vjoy.SetContPov(u32::MAX, 1, 1) == 1,
"continuous hat 1 of device 1 could not be reset"
);
std::thread::sleep(std::time::Duration::from_millis(100));
}
vjoy.RelinquishVJD(1);
}
}
}