Browse Source

Keybinds must match exactly; fix VersionedData

Keybinds must have exact modifier key combinations.
master
Macoy Madson 2 weeks ago
parent
commit
604cc191c3
  1. 23
      src/SDL.cake
  2. 6
      src/VersionedData.cake

23
src/SDL.cake

@ -242,18 +242,17 @@
(path bind > key)
(path key-states > this-frame-states)
(path key-states > last-frame-states))
(cond
((bit-and (path bind > modifier-flags) keybind-modifier-flags-ctrl)
(return (or (at SDL_SCANCODE_LCTRL (path key-states > this-frame-states))
(at SDL_SCANCODE_RCTRL (path key-states > this-frame-states)))))
((bit-and (path bind > modifier-flags) keybind-modifier-flags-shift)
(return (or (at SDL_SCANCODE_LSHIFT (path key-states > this-frame-states))
(at SDL_SCANCODE_RSHIFT (path key-states > this-frame-states)))))
((bit-and (path bind > modifier-flags) keybind-modifier-flags-alt)
(return (or (at SDL_SCANCODE_LALT (path key-states > this-frame-states))
(at SDL_SCANCODE_RALT (path key-states > this-frame-states)))))
(true
(return true)))))
(var modifier-state (unsigned int) 0)
(when (or (at SDL_SCANCODE_LCTRL (path key-states > this-frame-states))
(at SDL_SCANCODE_RCTRL (path key-states > this-frame-states)))
(set modifier-state (bit-or modifier-state keybind-modifier-flags-ctrl)))
(when (or (at SDL_SCANCODE_LSHIFT (path key-states > this-frame-states))
(at SDL_SCANCODE_RSHIFT (path key-states > this-frame-states)))
(set modifier-state (bit-or modifier-state keybind-modifier-flags-shift)))
(when (or (at SDL_SCANCODE_LALT (path key-states > this-frame-states))
(at SDL_SCANCODE_RALT (path key-states > this-frame-states)))
(set modifier-state (bit-or modifier-state keybind-modifier-flags-alt)))
(return (= modifier-state (path bind > modifier-flags)))))
(return false))
(defun-local append-to-string-buffer (buffer-out (* char) buffer-size size_t write-head (* (* char))

6
src/VersionedData.cake

@ -25,7 +25,8 @@
(defun-local write-version (out-file (* FILE) version (* (const version-header)) &return bool)
(unless (write-introspect-struct-s-expr version-header--metadata
version out-file
version
write-introspect-struct-file-writer out-file
write-introspect-struct-add-newline)
(return false))
(return true))
@ -134,7 +135,8 @@
(return result))
(unless (write-introspect-struct-s-expr data-metadata data-out
out-file write-introspect-struct-add-newline)
write-introspect-struct-file-writer out-file
write-introspect-struct-add-newline)
(fclose out-file)
(snprintf error-buffer error-buffer-size
"error: failed to save user data\n")

Loading…
Cancel
Save