/* Copyright (c) 2024 Alex Diener This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. Alex Diener alex@ludobloom.com */ #ifndef __GamepadLogicalInputController_H__ #define __GamepadLogicalInputController_H__ typedef struct GamepadLogicalInputController GamepadLogicalInputController; #define GamepadLogicalInputController_superclass StemObject #include "gamepad/Gamepad.h" #include "inputcontroller/GamepadMap.h" #include "stemobject/StemObject.h" #include "utilities/EventDispatcher.h" typedef struct GamepadLogicalInputController_buttonEvent { GamepadElement element; struct Gamepad_device * device; unsigned int hardwareButtonID; double timestamp; bool peek; } GamepadLogicalInputController_buttonEvent; typedef struct GamepadLogicalInputController_axisEvent { GamepadElement element; struct Gamepad_device * device; unsigned int hardwareAxisID; int sign; float value; float adjustedValue; float lastValue; double timestamp; bool peek; } GamepadLogicalInputController_axisEvent; // eventData -> GamepadLogicalInputController_buttonEvent * #define GAMEPAD_CONTROLLER_EVENT_BUTTON_DOWN "GAMEPAD_CONTROLLER_EVENT_BUTTON_DOWN" #define GAMEPAD_CONTROLLER_EVENT_BUTTON_UP "GAMEPAD_CONTROLLER_EVENT_BUTTON_UP" // eventData -> GamepadLogicalInputController_axisEvent * #define GAMEPAD_CONTROLLER_EVENT_AXIS_ACTIVATE "GAMEPAD_CONTROLLER_EVENT_AXIS_ACTIVATE" #define GAMEPAD_CONTROLLER_EVENT_AXIS_RELEASE "GAMEPAD_CONTROLLER_EVENT_AXIS_RELEASE" #define GAMEPAD_CONTROLLER_EVENT_AXIS_MOTION "GAMEPAD_CONTROLLER_EVENT_AXIS_MOTION" #define GamepadLogicalInputController_ivars \ StemObject_ivars \ \ GamepadMap * gamepadMap; \ EventDispatcher * eventDispatcher; \ float analogStickActionActivateThreshold; \ float analogStickActionReleaseThreshold; \ float analogStickInnerDeadZone; \ float analogStickOuterDeadZone; \ float analogTriggerActionActivateThreshold; \ float analogTriggerActionReleaseThreshold; \ float analogTriggerInnerDeadZone; \ float analogTriggerOuterDeadZone; \ #define GamepadLogicalInputController_vtable(self_type) \ StemObject_vtable(self_type) stemobject_declare(GamepadLogicalInputController) // Does not take ownership of or copy gamepadMap GamepadLogicalInputController * GamepadLogicalInputController_create(GamepadMap * gamepadMap); bool GamepadLogicalInputController_init(GamepadLogicalInputController * self, GamepadMap * gamepadMap); void GamepadLogicalInputController_dispose(GamepadLogicalInputController * self); bool GamepadLogicalInputController_gamepadButtonDown(GamepadLogicalInputController * self, struct Gamepad_device * device, unsigned int buttonID, double timestamp, bool peek); bool GamepadLogicalInputController_gamepadButtonUp(GamepadLogicalInputController * self, struct Gamepad_device * device, unsigned int buttonID, double timestamp, bool peek); bool GamepadLogicalInputController_gamepadAxisMoved(GamepadLogicalInputController * self, struct Gamepad_device * device, unsigned int axisID, float value, float lastValue, double timestamp, bool peek); #endif