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
FPrevious: string;
public
myjoy: TJoyInfoEx;
procedure readinputs(Player : String);
procedure writeinputs(Player : String);
procedure ClickDPAD(sender : Tobject);
procedure Changes(sender : TObject);
end;
TPOVControl = record
up,down,left,right:boolean;
end;
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}
function TGamepad.GetX:integer;
begin
result := round(range/32767*(Device.wXpos-CenterX));
if abs(result) <= deadzone then result := 0;
end;
function TGamepad.GetY:integer;
begin
result := round(range/32767*(Device.wYpos-CenterY));
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
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
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
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
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
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;
TComp : TComponent;
begin
TComp := FindComponent(ComponentName);
TEdit(TComp).SetFocus;
joy.update;
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;
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;
If joy.U <> 0 then TEdit(TComp).Text := inttostr(joy.U);
If joy.V <> 0 then TEdit(TComp).Text := inttostr(joy.V);
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;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Joy.Update;
end;
procedure TForm1.DXTimer1Timer(Sender: TObject; LagCount: Integer);
var i:integer;
begin
end;
procedure TForm1.EdtDPADDOWNClick(Sender: TObject);
begin
end;
procedure TForm1.EdtDpadLEFTClick(Sender: TObject);
begin
end;
procedure TForm1.EdtDPADRIGHTClick(Sender: TObject);
begin
end;
procedure TForm1.EdtDpadUPClick(Sender: TObject);
var
i : integer;
begin
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
Showmessage(IntToStr(hidc.NumCheckedInDevices));
joy := TGamepad.Create;
editable := False;
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;
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;
procedure TForm1.LabeledEdit1Click(Sender: TObject);
begin
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;
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');
for I := 0 to cfgfile.Count -1 do
begin
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 = "','"');
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 = "','"');
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 = "','"');
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;
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');
if Editable = true then
begin
for I := 0 to cfgfile.Count -1 do
begin
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;
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;
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;
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
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.