irishgreencitrus / Godot-SDL-Gyro

Add Gamepad Gyro Funtionality to Godot

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Godot SDL Gyro

GDextention that allows to read Gyro from a controller in Godot 4, it utilizes SDL and JibbSmart GamepadMotionHelpers libraries

Usage

Download the latest build from the Releases tab Extract the addons folder and place it in the root of your project

in your GDscript make a new SDLGyro object

...
var Gyro=SDLGyro.new()
...

initialize SDL and The controller ready function

...
func _ready():
  Gyro.sdl_init()
  Gyro.controller_init()
...

call any of the folloing functions in the process fuction

      gamepadPolling()            //returns controller orientation(this function needs to be called so that the others can work)

      calibrate()                //starts continous calibrations
      stop_calibrate()           //stops continius calibration
     
      getPlayer_space()          //not working
      getWorld_space()           //not working
      getGravity()               //not working
  
      getCalibratedGyro();       //retutns the controller's angular velocity in degrees per second
      getProcessedAcceleration();//returns the controller's current acceleration in g-force with gravity removed

Build Instructions

Windows

Download SDL2-devel-X.XX.X-mingw.zip uncompreess and place hte contetns of SDL2-X.XX.X\x86_64-w64-mingw32 in here -> libs/mingw_dev_lib (you can change that location in the SConstruct file)
then:

$ git clone https://github.com/SagaPDev/Godot-SDL-Gamepad-Test.git
$ cd Godot-SDL-Gamepad-Test
$ scons use_minwg=yes

Linux

$ git clone https://github.com/SagaPDev/Godot-SDL-Gamepad-Test.git
$ cd Godot-SDL-Gamepad-Test
$ scons

TO DO:

Hot Plugin
Suport for Multiple Gamepads
Release on Godot's Asset Library

Aditional Credits

Source of the 3Dmodel by larf

About

Add Gamepad Gyro Funtionality to Godot

License:MIT License


Languages

Language:C++ 77.6%Language:Python 10.1%Language:C 7.6%Language:Shell 1.9%Language:GDScript 1.3%Language:CMake 1.2%Language:PowerShell 0.2%Language:Makefile 0.1%