Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo Hace 3 Semanas
MaxiDucoli MaxiDucoli is offline
Miembro
 
Registrado: feb 2006
Posts: 81
Poder: 14
MaxiDucoli Va por buen camino
Question Ayuda con TJvHidDeviceController

Hola, estoy queriendo saber la información del modelo de cualquier joystick que tenga conectado a mi PC y no doy como.
Uso TJoyInfoEX que me dá mucha información, pero en realidad lo que yo necesito no me lo dá.
En el panel de control de Windows cuando voy a dispositivos de juego y me da la lista de joysticks conectados dice en mi caso USB JOYSTICK, pero la info que me dá JoyInfoEx solo dice Microsoft PC driver.

Alguien sabe si con el componente TJvHidDeviceController se puede saber el modelo (eso es lo que estoy buscando) de los joysticks conectados y si me explicaría como usar ese componente?
Por que en realidad la web carece de tutorial o explicacion de ese componente, pero varias personas lo usan.
Les aclaro que aunque no soy nuevo en delphi lo uso solo para hobbie y no sé mucho que digamos,

Ah! lo que quiero hacer es generar un archivo con la configuración de los botones de los joysticks que tengo para el emulador RETROARCH.

Les dejo el código a ver si está lo que quiero al alcance y no lo sé usar.

Código Delphi [-]
unit JoyPress;

interface

uses
  Winapi.Windows, Winapi.Messages,strutils, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, JvComponentBase, JvJoystick, MMSystem,
  Vcl.ExtCtrls, Vcl.StdCtrls, DXInput, DXClass, Vcl.ComCtrls,
  JvHidControllerClass, Vcl.Imaging.pngimage, JvExControls, JvLabel, MisFunciones, clipbrd;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    RadioButton3: TRadioButton;
    RadioButton4: TRadioButton;
    Image1: TImage;
    Label1: TLabel;
    EdtDpadUP: TEdit;
    EdtDpadLEFT: TEdit;
    EdtDPADDOWN: TEdit;
    EdtDPADRIGHT: TEdit;
    EdtY: TEdit;
    EdtX: TEdit;
    EdtA: TEdit;
    EdtB: TEdit;
    EdtL2: TEdit;
    EdtL1: TEdit;
    EdtL3: TEdit;
    EdtR1: TEdit;
    EdtR2: TEdit;
    EdtR3: TEdit;
    EdtLSTICKUP: TEdit;
    EdtLSTICKDOWN: TEdit;
    EdtLSTICKLEFT: TEdit;
    EdtLSTICKRIGHT: TEdit;
    EdtRSTICKUP: TEdit;
    EdtRSTICKDOWN: TEdit;
    EdtRSTICKLEFT: TEdit;
    EdtRSTICKRIGHT: TEdit;
    EdtSELECT: TEdit;
    EdtSTART: TEdit;
    HIDc: TJvHidDeviceController;
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure DXTimer1Timer(Sender: TObject; LagCount: Integer);
    procedure LabeledEdit1Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure RadioButton1Click(Sender: TObject);
    procedure RadioButton2Click(Sender: TObject);
    procedure RadioButton3Click(Sender: TObject);
    procedure RadioButton4Click(Sender: TObject);
    procedure EdtDpadUPClick(Sender: TObject);
    procedure EdtDpadLEFTClick(Sender: TObject);
    procedure EdtDPADDOWNClick(Sender: TObject);
    procedure EdtDPADRIGHTClick(Sender: TObject);
    function HIDcEnumerate(HidDev: TJvHidDevice;
      const Idx: Integer): Boolean;
  private
    { Private declarations }
        FPrevious: string;
//    function GetButtonStatus: string;

  public
  myjoy: TJoyInfoEx;
    { Public declarations }
    procedure readinputs(Player : String);
    procedure writeinputs(Player : String);
    procedure ClickDPAD(sender : Tobject);
//    procedure ClickBUTTONS(sender : Tobject);
//    procedure ClickSTICKS(sender : Tobject);
    procedure Changes(sender : TObject);
  end;
  TPOVControl = record
    up,down,left,right:boolean;
  end;

  { TGamepad - A wrapper class for the Windows-Joystick-API}
  {TGamepad - Una clase envoltura para Windows-Joystick-API}
  TGamepad = class
    private
      FRange:integer;
      FDeadZone:integer;
      function GetButton(index:integer):boolean;
      function GetX:integer;
      function GetY:integer;
      function GetZ:integer;
      function GetR:integer;
      function GetU:integer;
      function GetV:integer;
      function GetPOV:TPOVControl;
      procedure UpdateDeviceNr(nr:cardinal);
    protected
      Device:TJoyInfoEx;
      DeviceInfo:TJoyCaps;
      FDeviceNr:Cardinal;
      CenterX,CenterY,CenterZ:Integer;
      CenterR,CenterU,CenterV:Integer;
    public
      property DeviceNr:Cardinal read FDeviceNr write UpdateDeviceNr;
      procedure Update;
      procedure Calibrate;
      constructor Create;
      property X:integer read GetX;
      property Y:integer read GetY;
      property Z:integer read GetZ;
      property R:integer read GetR;
      property U:integer read GetU;
      property V:integer read GetV;
      property Range:integer read FRange write FRange;
      property DeadZone:integer read FDeadZone write FDeadZone;
      property POV:TPOVControl read GetPov;
      property Buttons[index:integer]:boolean read GetButton;
  end;
var
  Form1: TForm1;
  Joy:TGamepad;
  Editable : Boolean;
 buttonpressed, ComponentName, PLAYER : string;
 Focussed, JoyNr : integer;
implementation
uses
 System.IOUtils;

{$R *.dfm}
{ TGamepad }

function TGamepad.GetX:integer;
begin
result := round(range/32767*(Device.wXpos-CenterX));
//result := result div 1000;
 //result := Device.wXpos-CenterX;
  if abs(result) <= deadzone then result := 0;
end;

function TGamepad.GetY:integer;
begin
  result := round(range/32767*(Device.wYpos-CenterY));
//result := result div 1000;
  if abs(result) <= deadzone then result := 0;
end;

function TGamepad.GetZ:integer;
begin
  result := round(range/32767*(Device.wZpos-CenterZ));
  if abs(result) <= deadzone then result := 0;
end;

function TGamepad.GetR:integer;
begin
  result := round(range/32767*(Device.dwRpos-CenterR));
  if abs(result) <= deadzone then result := 0;
end;

function TGamepad.GetU:integer;
begin
  result := round(range/32767*(Device.dwUpos-CenterU));
  if abs(result) <= deadzone then result := 0;
end;

function TGamepad.GetV:integer;
begin
  result := round(range/32767*(Device.dwVpos-CenterV));
  if abs(result) <= deadzone then result := 0;
end;

function TGamepad.GetPOV:TPOVControl;
begin
  //Verarbeitet die Daten des Steuerkreuzes
  //Procesa los datos del pad direccional.
  result.up := false;
  result.left := false;
  result.down := false;
  result.right := false;
  if Device.dwPOV = 0 then begin result.up := true; end;
  if Device.dwPOV = 4500 then begin result.up := true; result.right := true end;
  if Device.dwPOV = 9000 then begin result.right := true; end;
  if Device.dwPOV = 13500 then begin result.down := true; result.right := true end;
  if Device.dwPOV = 18000 then begin result.down := true; end;
  if Device.dwPOV = 22500 then begin result.down := true; result.left := true; end;
  if Device.dwPOV = 27000 then begin result.left := true; end;
  if Device.dwPOV = 31500 then begin result.left := true; result.up := true; end;
end;

procedure TGamepad.Update;
begin
  //Liest die Joystick-Daten ein und schreibt sie in die "Device" Variable
  // Lee los datos del joystick y los escribe en la variable "Device"
  if (DeviceInfo.wCaps and JOYCAPS_HASZ) <> 0 then Device.dwSize := sizeof(tjoyInfoEx);
  Device.dwFlags:=JOY_RETURNALL;
  JoygetposEx(DeviceNr,@device);
end;

procedure TGamepad.UpdateDeviceNr(nr:cardinal);
begin
  //0...15 Devices/Gampads/Joysticks
  //0...15 Dispositivos / Gampads / joysticks
  FDeviceNr := nr;
  joyGetDevCaps(FDeviceNr, @DeviceInfo, sizeof(DeviceInfo));
end;

constructor TGamepad.Create;
begin
  inherited Create;
  DeviceNr := 0;
  Range := 1000;
  DeadZone := 200;
  Calibrate;
end;

procedure TGamepad.Calibrate;
begin
  //Liest die Nullstellung der Achsen ein
  // Lee la posición cero de los ejes.
  if (DeviceInfo.wCaps and JOYCAPS_HASZ) <> 0 then Device.dwSize := sizeof(tjoyInfoEx);
  Device.dwFlags:=JOY_RETURNCENTERED;
  JoygetposEx(DeviceNr,@device);
  CenterX := device.wXpos;
  CenterY := device.wYpos;
  CenterZ := device.wZpos;
  CenterU := device.dwUpos;
  CenterV := device.dwVpos;
  CenterR := device.dwRpos;
end;

function TGamepad.GetButton(index:integer):boolean;
begin
  //Liest die Position der Buttons ein.
  // Leer la posición de los botones.
  result := false;
  if index in [0..31] then
  begin
    result := device.wbuttons and (1 shl (index)) > 0;
  end;
end;



procedure TForm1.Timer1Timer(Sender: TObject);
var
i : integer;
//  Current: string;
//  LogLine: string;
TComp : TComponent;
begin
TComp := FindComponent(ComponentName);
//Memo1.Lines.Add(  'Joystick-Y '+inttostr(joy.Y));
//Memo1.Lines.Add(  'Joystick-X '+inttostr(joy.X));

  //Achse 2
//Memo1.Lines.Add(  'Joystick-Z '+inttostr(joy.Z));
//Memo1.Lines.Add(  'Joystick-R '+inttostr(joy.R));

  //Achse 3
//Memo1.Lines.Add(  'Joystick-U '+inttostr(joy.U));
//Memo1.Lines.Add(  'Joystick-V '+inttostr(joy.V));
TEdit(TComp).SetFocus;

//  Current := GetButtonStatus;
//  if FPrevious <> Current then
//  begin
//    FPrevious := Current;
//    LogLine := DateTimeToStr(Now) + ' - ' + Current;
//    Memo1.Lines.Add(LogLine);
//    TFile.AppendAllText('joystick.log', LogLine + sLineBreak);
  //end;
 //ShowMessage(IntToStr(Joy.GetR));
joy.update;

//Gedrückte Buttons anzeigen
//Label6.Caption := '';
//  for i := 0 to 31 do
//  begin
//    if joy.buttons[i] then   Memo1.Lines.Add(inttostr(i+1)+' ' + booltostr(joy.Buttons[i+1]));
//  end;
//Label1.Caption := Joy.DeviceInfo.szOEMVxD;
    //Achse 1
//Memo1.Lines.Add( 'ProductID : '+inttostr(joy.DeviceInfo.wPid));
//Memo1.Lines.Add( 'VendorID = '+inttostr(joy.DeviceInfo.wMid));


//Memo1.Lines.Add(  'Joystick-Y '+inttostr(joy.Y));
//Memo1.Lines.Add(  'Joystick-X '+inttostr(joy.X));

  //Achse 2
//Memo1.Lines.Add(  'Joystick-Z '+inttostr(joy.Z));
//Memo1.Lines.Add(  'Joystick-R '+inttostr(joy.R));

  //Achse 3
//Memo1.Lines.Add(  'Joystick-U '+inttostr(joy.U));
//Memo1.Lines.Add(  'Joystick-V '+inttostr(joy.V));


//Memo1.Lines.Add(  'Joystick-Y '+inttostr(joy.Y));
//Memo1.Lines.Add(  'Joystick-X '+inttostr(joy.X));

  //Achse 2
//Memo1.Lines.Add(  'Joystick-Z '+inttostr(joy.Z));
//Memo1.Lines.Add(  'Joystick-R '+inttostr(joy.R));

  //Achse 3
//Memo1.Lines.Add(  'Joystick-U '+inttostr(joy.U));
//Memo1.Lines.Add(  'Joystick-V '+inttostr(joy.V));
//Memo1.Lines.Add(  'Joystick-Y '+inttostr(joy.Y));
//Memo1.Lines.Add(  'Joystick-X '+inttostr(joy.X));

  //Achse 2
//Memo1.Lines.Add(  'Joystick-Z '+inttostr(joy.Z));
//Memo1.Lines.Add(  'Joystick-R '+inttostr(joy.R));

  //Achse 3
//Memo1.Lines.Add(  'Joystick-U '+inttostr(joy.U));
//Memo1.Lines.Add(  'Joystick-V '+inttostr(joy.V));
If joy.Y <> 0 then
begin
if joy.Y >0 then TEdit(TComp).Text  := '1';
if joy.Y <0 then TEdit(TComp).Text  := '-1';
end;


If joy.X <> 0 then
begin
if joy.X >0 then TEdit(TComp).Text  := '1';
if joy.X <0 then TEdit(TComp).Text  := '-1';
end;


  //Achse 2
If joy.Z <> 0 then
begin
if joy.Z >0 then TEdit(TComp).Text  := '1';
if joy.Z <0 then TEdit(TComp).Text  := '-1';
end;

If joy.R <> 0 then
begin
if joy.R >0 then TEdit(TComp).Text  := '1';
if joy.R <0 then TEdit(TComp).Text  := '-1';
end;

  //Achse 3
If joy.U <> 0 then TEdit(TComp).Text  :=  inttostr(joy.U);
If joy.V <> 0 then TEdit(TComp).Text  :=  inttostr(joy.V);

  //POV (Point of View Control/Steuerkreuz)

  for I := 0 to 31 do
    begin
     if joy.buttons[i] then   TEdit(TComp).Text  :=  IntTostr(i);
    end;
  if joy.POV.up then
  begin
  ButtonPressed := 'h' + IntToStr(JoyNr) + 'up';
  TEDit(TComp).Text := buttonpressed;
  end;

  if joy.POV.right then
  begin
   buttonpressed :=  'h' + IntToStr(JoyNr) + 'right';
  TEDit(TComp).Text := buttonpressed;
  end;

  if joy.POV.down then
  begin
   buttonpressed  :=  'h' + IntToStr(JoyNr) + 'down';
  TEDit(TComp).Text := buttonpressed;
  end;

  if joy.POV.left then
  begin
   buttonpressed  :=  'h' + IntToStr(JoyNr) + 'left';
  TEDit(TComp).Text := buttonpressed;
  end;

//ShowMessage(IntToStr(Joy.DeviceNr));


end;



procedure TForm1.Button1Click(Sender: TObject);
begin
Joy.Update;

//Memo1.Lines.Add( 'VendorID = '+inttostr(joy.DeviceInfo.wMid));
//Memo1.Lines.Add( 'ProductID = '+inttostr(joy.DeviceInfo.wPid));
//Memo1.Lines.Add( 'VendorID = '+ joy.DeviceInfo.szPname);
//Memo1.Lines.Add( 'VendorID = '+ joy.DeviceInfo.szRegKey);
//Memo1.Lines.Add( 'VendorID = '+ joy.DeviceInfo.szOEMVxD);
//Memo1.Lines.Add( 'VendorID = '+ joy.DeviceInfo.wCaps.ToString);
//Memo1.Lines.Add( 'VendorID = '+ joy.ToString);



end;

procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);
var i:integer;
begin
  //Den Joystick updaten
 // Joy.UpdateDeviceNr(1);
//  joy.update;

  //Daten ausgeben
  //Achse 1
  //Memo1.Lines.Add( 'ProductID : '+inttostr(joy.DeviceInfo.wPid));
  //Memo1.Lines.Add( 'VendorID = '+inttostr(joy.DeviceInfo.wMid));


//    Memo1.Lines.Add(  'Joystick-Y '+inttostr(joy.Y));

  //Achse 2
//    Memo1.Lines.Add(  'Joystick-Z '+inttostr(joy.Z));
//    Memo1.Lines.Add(  'Joystick-R '+inttostr(joy.R));

  //Achse 3
 //   Memo1.Lines.Add(  'Joystick-U '+inttostr(joy.U));
 //   Memo1.Lines.Add(  'Joystick-V '+inttostr(joy.V));

  //POV (Point of View Control/Steuerkreuz)
//  if joy.POV.up then shape1.Brush.Color := clRed else shape1.Brush.Color := clWhite;
//  if joy.POV.right then shape2.Brush.Color := clRed else shape2.Brush.Color := clWhite;
//  if joy.POV.down then shape3.Brush.Color := clRed else shape3.Brush.Color := clWhite;
//  if joy.POV.left then shape4.Brush.Color := clRed else shape4.Brush.Color := clWhite;

  //Gedrückte Buttons anzeigen
//  Label6.Caption := '';
//  for i := 0 to 31 do
//  begin
//    if joy.buttons[i] then   Memo1.Lines.Add(  inttostr(i+1)+' ');
//  end;

end;

procedure TForm1.EdtDPADDOWNClick(Sender: TObject);
begin
//Focussed := Activecontrol.TabOrder;
//timer1.Enabled := true;
end;

procedure TForm1.EdtDpadLEFTClick(Sender: TObject);
begin
//Focussed := Activecontrol.TabOrder;
//timer1.Enabled := true;
end;

procedure TForm1.EdtDPADRIGHTClick(Sender: TObject);
begin
//Focussed := Activecontrol.TabOrder;
//timer1.Enabled := true;
end;

procedure TForm1.EdtDpadUPClick(Sender: TObject);
var
i : integer;
begin
//ComponentName :=
//Focussed := Activecontrol.TabOrder;
for I := 0 to ControlCount -1 do
  begin
  if Controls[i] is TEdit and (Controls[i] as TEdit).Focused then
  ComponentName := TEdit(Components[i]).Name;
  end;
timer1.Enabled := true;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Joy.Free;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
dv : TJvHidDevice;
begin
//dv := TJvHidDevice.Create;
//dv.Caps.
//hidc.CheckOutByID(dv,121,6);
Showmessage(IntToStr(hidc.NumCheckedInDevices));
  //Klasse erzeugen
  joy := TGamepad.Create;
  editable := False;
//  memo2.Lines.Add(IntTostr(  HIDJoy.));
EdtA.OnClick := clickDPAD;
EdtB.OnClick := clickDPAD;
EdtX.OnClick := clickDPAD;
EdtY.OnClick := clickDPAD;
EdtL1.OnClick := clickDPAD;
EdtL2.OnClick := clickDPAD;
EdtL3.OnClick := clickDPAD;
EdtR1.OnClick := clickDPAD;
EdtR2.OnClick := clickDPAD;
EdtR3.OnClick := clickDPAD;
EdtSELECT.OnClick := clickDPAD;
EdtSTART.OnClick := clickDPAD;


EdtDpadUP.OnClick := clickDPAD;
EdtDPADDOWN.OnClick := clickDPAD;
EdtDPADLEFT.OnClick := clickDPAD;
EdtDPADRIGHT.OnClick := clickDPAD;

EdtLSTICKUP.OnClick := clickDPAD;
EdtLSTICKDOWN.OnClick := clickDPAD;
EdtLSTICKLEFT.OnClick := clickDPAD;
EdtLSTICKRIGHT.OnClick := clickDPAD;

EdtRSTICKUP.OnClick := clickDPAD;
EdtRSTICKDOWN.OnClick := clickDPAD;
EdtRSTICKLEFT.OnClick := clickDPAD;
EdtRSTICKRIGHT.OnClick := clickDPAD;


//EdtCHANGES
EdtA.Onchange := changes;
EdtB.Onchange := changes;
EdtX.Onchange := changes;
EdtY.Onchange := changes;
EdtL1.Onchange := changes;
EdtL2.Onchange := changes;
EdtL3.Onchange := changes;
EdtR1.Onchange := changes;
EdtR2.Onchange := changes;
EdtR3.Onchange := changes;
EdtSELECT.Onchange := changes;
EdtSTART.Onchange := changes;


EdtDpadUP.Onchange := changes;
EdtDPADDOWN.Onchange := changes;
EdtDPADLEFT.Onchange := changes;
EdtDPADRIGHT.Onchange := changes;

EdtLSTICKUP.Onchange := changes;
EdtLSTICKDOWN.Onchange := changes;
EdtLSTICKLEFT.Onchange := changes;
EdtLSTICKRIGHT.Onchange := changes;

EdtRSTICKUP.OnChange := changes;
EdtRSTICKDOWN.OnChange := changes;
EdtRSTICKLEFT.OnChange := changes;
EdtRSTICKRIGHT.OnChange := changes;


end;

function TForm1.HIDcEnumerate(HidDev: TJvHidDevice;
  const Idx: Integer): Boolean;
begin

end;

//function TForm1.GetButtonStatus: string;
//begin

//end;



procedure TForm1.LabeledEdit1Click(Sender: TObject);
begin
//Editable := true;
//DXTimer1.Enabled := true;
//LabeledEdit1.Text := BoolToStr(Joy.POV.up);
end;

procedure TForm1.RadioButton1Click(Sender: TObject);
begin
JoyNr := 0;
Label1.Caption := 'PLAYER 1 - JOY1';
Joy.UpdateDeviceNr(0);
readinputs('player1');
PLAYER:= 'player1';
end;

procedure TForm1.RadioButton2Click(Sender: TObject);
begin
JoyNr := 1;
Label1.Caption := 'PLAYER 2 - JOY2';
Joy.UpdateDeviceNr(1);
readinputs('player2');
PLAYER:= 'player2';
end;

procedure TForm1.RadioButton3Click(Sender: TObject);
begin
JoyNr := 2;
Label1.Caption := 'PLAYER 3 - JOY3';
Joy.UpdateDeviceNr(2);
readinputs('player3');
PLAYER:= 'player3';
end;

procedure TForm1.RadioButton4Click(Sender: TObject);
begin
JoyNr := 3;
Label1.Caption := 'PLAYER 4 - JOY4';
Joy.UpdateDeviceNr(3);
readinputs('player4');
PLAYER:= 'player4';
end;

{READ RETROARCH.CFG INPUTS}

procedure Tform1.readinputs(Player : String);
var
cfgfile : TStringlist;
i : integer;
DeviceDrive : string;
begin

cfgfile := TStringList.Create;
DeviceDrive := ExtractFileDrive(Application.ExeName);
try
cfgfile.LoadFromFile(DeviceDrive + '\RetroLife\emulators\retroarch\configs\all\retroarch.cfg');
//showmessage(cfgfile[7]);

for I := 0 to cfgfile.Count -1 do
  begin
  {BUTTONS}
  If AnsiContainsText(cfgfile[i],Player + '_a_btn') then EdtA.text := ExtractTextBetween(cfgfile[i],'"','"');
  If AnsiContainsText(cfgfile[i],Player +'_b_btn') then   EdtB.text := ExtractTextBetween(cfgfile[i],'input_' + Player + '_b_btn = "','"');
  If AnsiContainsText(cfgfile[i],Player +'_x_btn') then   EdtX.text := ExtractTextBetween(cfgfile[i],'input_' + Player + '_x_btn = "','"');
  If AnsiContainsText(cfgfile[i],Player +'_y_btn') then   EdtY.text := ExtractTextBetween(cfgfile[i],'input_' + Player + '_y_btn = "','"');
  If AnsiContainsText(cfgfile[i],Player +'_select_btn') then   EdtSELECT.text := ExtractTextBetween(cfgfile[i],'input_' + Player + '_select_btn = "','"');
  If AnsiContainsText(cfgfile[i],Player +'_start_btn') then   EdtSTART.text := ExtractTextBetween(cfgfile[i],'input_' + Player + '_start_btn = "','"');
  If AnsiContainsText(cfgfile[i],Player +'_r_btn') then   EdtR1.text := ExtractTextBetween(cfgfile[i],'input_' + Player + '_r_btn = "','"');
  If AnsiContainsText(cfgfile[i],Player +'_r2_btn') then   EdtR2.text := ExtractTextBetween(cfgfile[i],'input_' + Player + '_r2_btn = "','"');
  If AnsiContainsText(cfgfile[i],Player +'_r3_btn') then   EdtR3.text := ExtractTextBetween(cfgfile[i],'input_' + Player + '_r3_btn = "','"');
  If AnsiContainsText(cfgfile[i],Player +'_l_btn') then   EdtL1.text := ExtractTextBetween(cfgfile[i],'input_' + Player + '_l_btn = "','"');
  If AnsiContainsText(cfgfile[i],Player +'_l2_btn') then   EdtL2.text := ExtractTextBetween(cfgfile[i],'input_' + Player + '_l2_btn = "','"');
  If AnsiContainsText(cfgfile[i],Player +'_l3_btn') then   EdtL3.text := ExtractTextBetween(cfgfile[i],'input_' + Player + '_l3_btn = "','"');
  {DPAD BUTTONS}
  If AnsiContainsText(cfgfile[i],Player +'_up_btn') then   EdtDPADUP.text := ExtractTextBetween(cfgfile[i],'input_' + Player + '_up_btn = "','"');
  If AnsiContainsText(cfgfile[i],Player +'_down_btn') then   EdtDPADDOWN.text := ExtractTextBetween(cfgfile[i],'input_' + Player + '_down_btn = "','"');
  If AnsiContainsText(cfgfile[i],Player +'_left_btn') then   EdtDPADLEFT.text := ExtractTextBetween(cfgfile[i],'input_' + Player + '_left_btn = "','"');
  If AnsiContainsText(cfgfile[i],Player +'_right_btn') then   EdtDPADRIGHT.text := ExtractTextBetween(cfgfile[i],'input_' + Player + '_right_btn = "','"');
  {LSTICK}
  If AnsiContainsText(cfgfile[i],Player +'_l_x_minus_axis') then   EdtLSTICKDOWN.text := ExtractTextBetween(cfgfile[i],'input_' + Player + '_l_x_minus_axis = "','"');
  If AnsiContainsText(cfgfile[i],Player +'_l_x_plus_axis') then   EdtLSTICKUP.text := ExtractTextBetween(cfgfile[i],'input_' + Player + '_l_x_plus_axis = "','"');
  If AnsiContainsText(cfgfile[i],Player +'_l_y_minus_axis') then   EdtLSTICKLEFT.text := ExtractTextBetween(cfgfile[i],'input_' + Player + '_l_y_minus_axis = "','"');
  If AnsiContainsText(cfgfile[i],Player +'_l_y_plus_axis') then   EdtLSTICKRIGHT.text := ExtractTextBetween(cfgfile[i],'input_' + Player + '_l_y_plus_axis = "','"');
  {RSTICK}
  If AnsiContainsText(cfgfile[i],Player +'_r_x_minus_axis') then   EdtRSTICKDOWN.text := ExtractTextBetween(cfgfile[i],'input_' + Player + '_r_x_minus_axis = "','"');
  If AnsiContainsText(cfgfile[i],Player +'_r_x_plus_axis') then   EdtRSTICKUP.text := ExtractTextBetween(cfgfile[i],'input_' + Player + '_r_x_plus_axis = "','"');
  If AnsiContainsText(cfgfile[i],Player +'_r_y_minus_axis') then   EdtRSTICKLEFT.text := ExtractTextBetween(cfgfile[i],'input_' + Player + '_r_y_minus_axis = "','"');
  If AnsiContainsText(cfgfile[i],Player +'_r_y_plus_axis') then   EdtRSTICKRIGHT.text := ExtractTextBetween(cfgfile[i],'input_' + Player + '_r_y_plus_axis = "','"');
  end;

finally
cfgfile.Free;
end;


end;

{WRITE RETROARCH.CFG INPUTS}
procedure TForm1.writeinputs(Player : String);
var
cfgfile : TStringlist;
i : integer;
texto,DeviceDrive : string;
begin

cfgfile := TStringList.Create;
DeviceDrive := ExtractFileDrive(Application.ExeName);
try
cfgfile.LoadFromFile(DeviceDrive + '\RetroLife\emulators\retroarch\configs\all\retroarch.cfg');
//showmessage(cfgfile[7]);
if Editable = true then

begin

for I := 0 to cfgfile.Count -1 do
  begin
  {BUTTONS}
  If AnsiContainsText(cfgfile[i],Player + '_a_btn') then
  begin
  texto := ExtractTextBetween(cfgfile[i],'"','"');
  cfgfile[i] := AnsiReplaceStr(cfgfile[i],'"'+texto+'"','"'+EdtA.Text+'"');
  end;
  If AnsiContainsText(cfgfile[i],Player +'_b_btn') then
    begin
  texto := ExtractTextBetween(cfgfile[i],'"','"');
  cfgfile[i] := AnsiReplaceStr(cfgfile[i],'"'+texto+'"','"'+EdtB.Text+'"');
  end;
  If AnsiContainsText(cfgfile[i],Player +'_x_btn') then    begin
  texto := ExtractTextBetween(cfgfile[i],'"','"');
  cfgfile[i] := AnsiReplaceStr(cfgfile[i],'"'+texto+'"','"'+EdtX.Text+'"');
  end;
  If AnsiContainsText(cfgfile[i],Player +'_y_btn') then    begin
  texto := ExtractTextBetween(cfgfile[i],'"','"');
  cfgfile[i] := AnsiReplaceStr(cfgfile[i],'"'+texto+'"','"'+EdtY.Text+'"');
  end;
  If AnsiContainsText(cfgfile[i],Player +'_select_btn') then    begin
  texto := ExtractTextBetween(cfgfile[i],'"','"');
  cfgfile[i] := AnsiReplaceStr(cfgfile[i],'"'+texto+'"','"'+EdtSELECT.Text+'"');
  end;
  If AnsiContainsText(cfgfile[i],Player +'_start_btn') then     begin
  texto := ExtractTextBetween(cfgfile[i],'"','"');
  cfgfile[i] := AnsiReplaceStr(cfgfile[i],'"'+texto+'"','"'+EdtSTART.Text+'"');
  end;
  If AnsiContainsText(cfgfile[i],Player +'_r_btn') then    begin
  texto := ExtractTextBetween(cfgfile[i],'"','"');
  cfgfile[i] := AnsiReplaceStr(cfgfile[i],'"'+texto+'"','"'+EdtR1.Text+'"');
  end;
  If AnsiContainsText(cfgfile[i],Player +'_r2_btn') then     begin
  texto := ExtractTextBetween(cfgfile[i],'"','"');
  cfgfile[i] := AnsiReplaceStr(cfgfile[i],'"'+texto+'"','"'+EdtR2.Text+'"');
  end;
  If AnsiContainsText(cfgfile[i],Player +'_r3_btn') then    begin
  texto := ExtractTextBetween(cfgfile[i],'"','"');
  cfgfile[i] := AnsiReplaceStr(cfgfile[i],'"'+texto+'"','"'+EdtR3.Text+'"');
  end;
  If AnsiContainsText(cfgfile[i],Player +'_l_btn') then    begin
  texto := ExtractTextBetween(cfgfile[i],'"','"');
  cfgfile[i] := AnsiReplaceStr(cfgfile[i],'"'+texto+'"','"'+EdtL1.Text+'"');
  end;
  If AnsiContainsText(cfgfile[i],Player +'_l2_btn') then    begin
  texto := ExtractTextBetween(cfgfile[i],'"','"');
  cfgfile[i] := AnsiReplaceStr(cfgfile[i],'"'+texto+'"','"'+EdtL2.Text+'"');
  end;
  If AnsiContainsText(cfgfile[i],Player +'_l3_btn') then    begin
  texto := ExtractTextBetween(cfgfile[i],'"','"');
  cfgfile[i] := AnsiReplaceStr(cfgfile[i],'"'+texto+'"','"'+EdtL3.Text+'"');
  end;
  {DPAD BUTTONS}
  If AnsiContainsText(cfgfile[i],Player +'_up_btn') then    begin
  texto := ExtractTextBetween(cfgfile[i],'"','"');
  cfgfile[i] := AnsiReplaceStr(cfgfile[i],'"'+texto+'"','"'+EdtDpadUP.Text+'"');
  end;
  If AnsiContainsText(cfgfile[i],Player +'_down_btn') then    begin
  texto := ExtractTextBetween(cfgfile[i],'"','"');
  cfgfile[i] := AnsiReplaceStr(cfgfile[i],'"'+texto+'"','"'+EdtDPADDOWN.Text+'"');
  end;
  If AnsiContainsText(cfgfile[i],Player +'_left_btn') then    begin
  texto := ExtractTextBetween(cfgfile[i],'"','"');
  cfgfile[i] := AnsiReplaceStr(cfgfile[i],'"'+texto+'"','"'+EdtDPADLEFT.Text+'"');
  end;
  If AnsiContainsText(cfgfile[i],Player +'_right_btn') then    begin
  texto := ExtractTextBetween(cfgfile[i],'"','"');
  cfgfile[i] := AnsiReplaceStr(cfgfile[i],'"'+texto+'"','"'+EdtDPADRIGHT.Text+'"');
  end;
  {LSTICK}
  If AnsiContainsText(cfgfile[i],Player +'_l_x_minus_axis') then    begin
  texto := ExtractTextBetween(cfgfile[i],'"','"');
  cfgfile[i] := AnsiReplaceStr(cfgfile[i],'"'+texto+'"','"'+EdtLSTICKDOWN.Text+'"');
  end;
  If AnsiContainsText(cfgfile[i],Player +'_l_x_plus_axis') then    begin
  texto := ExtractTextBetween(cfgfile[i],'"','"');
  cfgfile[i] := AnsiReplaceStr(cfgfile[i],'"'+texto+'"','"'+EdtLSTICKUP.Text+'"');
  end;
  If AnsiContainsText(cfgfile[i],Player +'_l_y_minus_axis') then    begin
  texto := ExtractTextBetween(cfgfile[i],'"','"');
  cfgfile[i] := AnsiReplaceStr(cfgfile[i],'"'+texto+'"','"'+EdtLSTICKLEFT.Text+'"');
  end;
  If AnsiContainsText(cfgfile[i],Player +'_l_y_plus_axis') then    begin
  texto := ExtractTextBetween(cfgfile[i],'"','"');
  cfgfile[i] := AnsiReplaceStr(cfgfile[i],'"'+texto+'"','"'+EdtLSTICKRIGHT.Text+'"');
  end;
  {RSTICK}
  If AnsiContainsText(cfgfile[i],Player +'_r_x_minus_axis') then    begin
  texto := ExtractTextBetween(cfgfile[i],'"','"');
  cfgfile[i] := AnsiReplaceStr(cfgfile[i],'"'+texto+'"','"'+EdtRSTICKDOWN.Text+'"');
  end;
  If AnsiContainsText(cfgfile[i],Player +'_r_x_plus_axis') then    begin
  texto := ExtractTextBetween(cfgfile[i],'"','"');
  cfgfile[i] := AnsiReplaceStr(cfgfile[i],'"'+texto+'"','"'+EdtRSTICKUP.Text+'"');
  end;
  If AnsiContainsText(cfgfile[i],Player +'_r_y_minus_axis') then    begin
  texto := ExtractTextBetween(cfgfile[i],'"','"');
  cfgfile[i] := AnsiReplaceStr(cfgfile[i],'"'+texto+'"','"'+EdtRSTICKLEFT.Text+'"');
  end;
  If AnsiContainsText(cfgfile[i],Player +'_r_y_plus_axis') then    begin
  texto := ExtractTextBetween(cfgfile[i],'"','"');
  cfgfile[i] := AnsiReplaceStr(cfgfile[i],'"'+texto+'"','"'+EdtRSTICKRIGHT.Text+'"');
  end;
  end;
end;
finally
cfgfile.savetofile(DeviceDrive + '\RetroLife\emulators\retroarch\configs\all\retroarch.cfg');
cfgfile.Free;
editable := false;
end;
end;





procedure TForm1.ClickDPAD(sender: TObject);
var
i : integer;
begin
//ComponentName :=
//Focussed := Activecontrol.TabOrder;
editable := true;
for I := 0 to ControlCount -1 do
  begin
  if Controls[i] is TEdit and (Controls[i] as TEdit).Focused then
  ComponentName := TEdit(Components[i]).Name;
  end;
timer1.Enabled := true;
end;


procedure TForm1.Changes(sender : TObject);
begin
ComponentName := '';
timer1.Enabled := false;
writeinputs(PLAYER);
end;

end.
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Ayuda BD Access? Ayuda al modificar!! DarkArias Conexión con bases de datos 4 24-08-2013 23:47:41
Instalar Ayuda (.HLP) en la Ayuda de Delphi? MasterXP Varios 6 12-04-2006 06:57:49
Ayuda para crear ayuda... Gabriel2 Varios 2 10-06-2005 00:15:18
ayuda con strtofloat, ayuda punto flotante TURING Varios 5 30-04-2004 08:03:59
Ayuda Con Instalacion De Archivos De Ayuda Legolas Varios 1 01-12-2003 14:48:03


La franja horaria es GMT +2. Ahora son las 00:40:11.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi