document the remaining win32 safety contracts
This commit is contained in:
@@ -52,10 +52,14 @@ pub(crate) fn start() -> ClickRecorder {
|
||||
|
||||
while running_clone.load(Ordering::Relaxed) {
|
||||
for (i, &(vk, button)) in buttons.iter().enumerate() {
|
||||
// SAFETY: both calls are self-contained Win32 queries. `pt` is
|
||||
// a local that GetCursorPos writes, and it is only read after
|
||||
// the call reports success.
|
||||
let state = unsafe { GetAsyncKeyState(vk) };
|
||||
let pressed = (state.cast_unsigned() & 0x8000) != 0;
|
||||
if pressed && !last_pressed[i] {
|
||||
let mut pt = POINT::default();
|
||||
// SAFETY: `pt` is a live local the call writes through.
|
||||
if unsafe { GetCursorPos(&raw mut pt) }.is_ok() {
|
||||
let click = Click {
|
||||
time_secs: start.elapsed().as_secs_f64(),
|
||||
|
||||
Reference in New Issue
Block a user