![]()
Simple Joystick with SdpoJoystick Component on Linux
2023.09.22 00:55
unit Main;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs,
SdpoJoystick, ExtCtrls, StdCtrls;
type
{ TFMain }
TFMain = class(TForm)
CBActive: TCheckBox;
Edit1: TEdit;
Edit2: TEdit;
Memo1: TMemo;
RGReadMode: TRadioGroup;
SdpoJoystick: TSdpoJoystick;
TimerAll: TTimer;
procedure CBActiveChange(Sender: TObject);
procedure TimerAllTimer(Sender: TObject);
procedure ProcJoystickAll;
procedure ProcJoystickSingle;
private
{ private declarations }
public
{ public declarations }
end;
var
FMain: TFMain;
implementation
{ TFMain }
procedure TFMain.ProcJoystickAll;
var ax: array[0..5] of integer;
bt: array[0..11] of integer;
i: integer;
begin
if SdpoJoystick.Active then begin
SdpoJoystick.Read(ax,bt);
Edit1.Text:='A ';
Edit2.Text:='';
for i:=0 to 5 do begin
Edit1.Text:=Edit1.Text+IntToStr(ax[i])+' ';
end;
for i:=0 to 11 do begin
Edit2.Text:=Edit2.Text+IntToStr(bt[i])+' ';
end;
end;
end;
procedure TFMain.ProcJoystickSingle;
begin
if SdpoJoystick.Active then begin
Edit1.Text:='S '+IntToStr(SdpoJoystick.Axis[0])+' '+IntToStr(SdpoJoystick.Axis[1])+' '+IntToStr(SdpoJoystick.Axis[2])+' '+
IntToStr(SdpoJoystick.Axis[3])+' '+IntToStr(SdpoJoystick.Axis[4])+' '+IntToStr(SdpoJoystick.Axis[5])+' '+IntToStr(SdpoJoystick.Axis[6]);
Edit2.Text:=IntToStr(SdpoJoystick.Buttons[0])+' '+IntToStr(SdpoJoystick.Buttons[1])+' '+IntToStr(SdpoJoystick.Buttons[2])+' '+
IntToStr(SdpoJoystick.Buttons[3])+' '+IntToStr(SdpoJoystick.Buttons[4])+' '+IntToStr(SdpoJoystick.Buttons[5])+' '+
IntToStr(SdpoJoystick.Buttons[6])+' '+IntToStr(SdpoJoystick.Buttons[7])+' '+IntToStr(SdpoJoystick.Buttons[8])+' '+
IntToStr(SdpoJoystick.Buttons[9])+' '+IntToStr(SdpoJoystick.Buttons[10])+' '+IntToStr(SdpoJoystick.Buttons[11]);
end;
end;
procedure TFMain.TimerAllTimer(Sender: TObject);
begin
if RGReadMode.ItemIndex = 0 then
ProcJoystickAll
else
ProcJoystickSingle;
end;
procedure TFMain.CBActiveChange(Sender: TObject);
begin
if CBActive.Checked then begin
SdpoJoystick.Init;
end else begin
SdpoJoystick.Close;
end;
end;
initialization
{$I main.lrs}
end.
Comment 0
| No. | Subject | Author | Date | Views |
|---|---|---|---|---|
| 14 |
i2c ADC 4 channel (ADS1115)
| me | 2023.12.20 | 621 |
| 13 |
Ultrasonic with free pascal
| me | 2023.12.05 | 424 |
| 12 |
Trigger Test with pascalio
| me | 2023.12.04 | 370 |
| 11 |
3. my note for pascalio with MCP23017 - 16 bit I/O expanding board.
| me | 2023.12.03 | 707 |
| 10 |
2. my note for pascalio with MCP23017 - 16 bit I/O expanding board.
| me | 2023.12.03 | 700 |
| 9 |
Bitwise Operation in Object Pascal
| me | 2023.11.25 | 485 |
| 8 |
Making BNO-055 Library for Linux SBC in Object Pascal
[1] | me | 2023.11.22 | 850 |
| 7 |
Nano Seconds Control : Failed, but micro seconds levels worked.
| me | 2023.11.22 | 708 |
| 6 |
1. my note for pascalio with MCP23017 - 16 bit I/O expanding board.
| me | 2023.11.20 | 728 |
| 5 |
pascalio on Orange Pi 5 for I2C control
| me | 2023.11.20 | 759 |
| 4 |
Working UDP between Orange Pi 5 <=> PC
| me | 2023.09.29 | 460 |
| 3 | Simple UDP Sensor Server in Python <=> Object Pascal [1] | me | 2023.09.27 | 530 |
| » |
Simple Joystick with SdpoJoystick Component on Linux
| me | 2023.09.22 | 324 |
| 1 |
Virtual Lidar for test
[1] | me | 2023.07.20 | 552 |