From f6c7d000c05d5e0f0c24bc43cc0916a53fd39d58 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Tue, 10 Dec 2024 11:36:11 -0500 Subject: [PATCH] Add missing gamepad module. Sigh... --- modules/dom/gamepad.scm | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 modules/dom/gamepad.scm diff --git a/modules/dom/gamepad.scm b/modules/dom/gamepad.scm new file mode 100644 index 0000000..878f652 --- /dev/null +++ b/modules/dom/gamepad.scm @@ -0,0 +1,39 @@ +;;; Copyright (C) 2024 David Thompson +;;; +;;; Licensed under the Apache License, Version 2.0 (the "License"); +;;; you may not use this file except in compliance with the License. +;;; You may obtain a copy of the License at +;;; +;;; http://www.apache.org/licenses/LICENSE-2.0 +;;; +;;; Unless required by applicable law or agreed to in writing, software +;;; distributed under the License is distributed on an "AS IS" BASIS, +;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +;;; See the License for the specific language governing permissions and +;;; limitations under the License. + +;;; Commentary: +;;; +;;; Document bindings. +;;; +;;; Code: + +(define-module (dom gamepad) + #:use-module (hoot ffi) + #:export (gamepad-index + gamepad-button-ref + + gamepad-button-pressed?)) + +(define-foreign gamepad-index + "gamepad" "index" + (ref extern) -> i32) +(define-foreign gamepad-button-ref + "gamepad" "button" + (ref extern) i32 -> (ref null extern)) + +(define-foreign %gamepad-button-pressed? + "gamepad" "buttonPressed" + (ref extern) -> i32) +(define (gamepad-button-pressed? button) + (eq? (%gamepad-button-pressed? button) 1))