Ver Mensaje Individual
  #1  
Antiguo 13-01-2020
MaxiDucoli MaxiDucoli is offline
Miembro
 
Registrado: feb 2006
Posts: 134
Reputación: 19
MaxiDucoli Va por buen camino
SDL2 en Delphi

Buenas noches (acá en Argentina)
Estoy teniendo un problema con las librerías SDL2 para Delphi que no puedo resolver y en la web están todos los códigos fuentes como yo lo estoy haciendo.
Quizás alguien que entienda un poco me pueda guiar en qué estoy haciendo mal.

El asunto es el siguiente:

Estoy queriendo hacer que al presionar un botón del joystick, el programa se dé cuenta y me diga qué joystick es, el nombre el GUID, etc,etc.
Pero no me reconoce las presiones de los botones.

El código es el siguiente:

Código Delphi [-]
unit GetSDL2Joy;


interface

uses
  SDL2,Forms, System.Classes,sysutils,dialogs,Vcl.Controls, Vcl.StdCtrls, Vcl.ExtCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Timer1: TTimer;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);

  private
  public
  end;

var
  Form1: TForm1;
  NJoysticks : integer;
  SDL_JOY : PSDL_JOYSTICK;

implementation

{$R *.dfm}

function SDL_JOYS() : string;
var
i :integer;
s : String;
sdlEvent: PSDL_Event;
exitloop: boolean;
begin
NJoysticks := SDL_NumJoysticks;
if SDL_Init(SDL_INIT_JOYSTICK) = -1 then  ShowMessage('No Joysticks Found');
if  NJoysticks >= 1 then
    begin
        SDL_JOY := SDL_JoystickOpen(0);
          if SDL_JOY = nil then ShowMessage('Joystick open error');
    end;

    for i := 0 to NJoysticks -1  do
      begin
      SDL_JOY := SDL_JoystickOpen(i);
      SDL_JoystickEventState(SDL_ENABLE);
      SDL_JOYSTICKUPDATE();
     // s := SDL_JoystickName(SDL_JOY);

          new( sdlEvent );
               while SDL_PollEvent( sdlEvent) = 1 do
                begin
                      case Evento^.type_ of

                      SDL_JOYBUTTONDOWN: begin
                      s :=  'FUNCIONA!!!!!!';
                      end;

                end;;

 SDL_JoystickClose(SDL_JOY);

 Result := s;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
//NJoysticks := SDL_NumJoysticks;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
Memo1.Text := SDL_JOYS();

end;

end.

Por lo que creo, en el while del evento SDL_JOYBUTTONDOWN cuando presione la variable "s" me tiene que cargar un dato y mostrarlo en el MEMO.

Por ahora cargaría cualquier dato, eso no me importa. Una vez que me cargue el dato sé que funciona y ahí intento poner el código para que haga lo que quiero.

Alguien tiene idea de esto?
Responder Con Cita