├── LICENSE
├── Makefile
├── README
├── lib
└── x86_64-linux
│ ├── tpconfig.compiled
│ ├── tpconfig.o
│ ├── tpconfig.or
│ ├── tpconfig.res
│ ├── unit1.lfm
│ ├── unit1.o
│ └── unit1.ppu
├── tpconfig.lpi
├── tpconfig.lpr
├── tpconfig.lps
├── unit1.lfm
└── unit1.pas
/LICENSE:
--------------------------------------------------------------------------------
1 | BSD 2-Clause License
2 |
3 | Copyright (c) 2018, thedarkb
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | TPConfig: tpconfig.lpr
2 | lazbuild tpconfig.lpr
3 | strip tpconfig
4 |
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 | TPConfig V1.2 is a configuration tool for the ThinkPad TrackPoint.
2 | It requires SystemD and requires Lazarus to build.
3 | It also has to be run as root.
4 | If you'd like to uninstall this, make sure to delete tpconfig.conf from /etc/tmpfiles.d
5 |
6 | This tool is known to work on the R30, X40, X61s, T60, X200, X230, P50, T460s and X250.
7 |
--------------------------------------------------------------------------------
/lib/x86_64-linux/tpconfig.compiled:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/lib/x86_64-linux/tpconfig.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thedarkb/TPconfig/fdbf50793f293eafa80de0d87c0e2a693041b35d/lib/x86_64-linux/tpconfig.o
--------------------------------------------------------------------------------
/lib/x86_64-linux/tpconfig.or:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thedarkb/TPconfig/fdbf50793f293eafa80de0d87c0e2a693041b35d/lib/x86_64-linux/tpconfig.or
--------------------------------------------------------------------------------
/lib/x86_64-linux/tpconfig.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thedarkb/TPconfig/fdbf50793f293eafa80de0d87c0e2a693041b35d/lib/x86_64-linux/tpconfig.res
--------------------------------------------------------------------------------
/lib/x86_64-linux/unit1.lfm:
--------------------------------------------------------------------------------
1 | object Form1: TForm1
2 | Left = 515
3 | Height = 268
4 | Top = 216
5 | Width = 201
6 | BorderStyle = bsDialog
7 | Caption = 'TPConfig V1.2 ALPHA'
8 | ClientHeight = 268
9 | ClientWidth = 201
10 | OnCreate = FormCreate
11 | LCLVersion = '2.0.2.0'
12 | object speedGroup: TGroupBox
13 | Left = 8
14 | Height = 56
15 | Top = 48
16 | Width = 185
17 | Caption = 'Speed'
18 | ClientHeight = 39
19 | ClientWidth = 181
20 | TabOrder = 0
21 | object speedBar: TTrackBar
22 | Left = 0
23 | Height = 36
24 | Top = 0
25 | Width = 176
26 | Max = 255
27 | Position = 0
28 | TabOrder = 0
29 | end
30 | end
31 | object senseGroup: TGroupBox
32 | Left = 8
33 | Height = 56
34 | Top = 104
35 | Width = 185
36 | Caption = 'Sensitivity'
37 | ClientHeight = 39
38 | ClientWidth = 181
39 | TabOrder = 1
40 | object senseBar: TTrackBar
41 | Left = 0
42 | Height = 36
43 | Top = 0
44 | Width = 176
45 | Max = 255
46 | Position = 0
47 | TabOrder = 0
48 | end
49 | end
50 | object quit: TButton
51 | Left = 8
52 | Height = 25
53 | Top = 240
54 | Width = 88
55 | Caption = 'Quit'
56 | OnClick = quitClick
57 | TabOrder = 2
58 | end
59 | object apply: TButton
60 | Left = 104
61 | Height = 25
62 | Top = 240
63 | Width = 89
64 | Caption = 'Apply'
65 | OnClick = applyClick
66 | TabOrder = 3
67 | end
68 | object pathGroup: TGroupBox
69 | Left = 8
70 | Height = 49
71 | Top = 0
72 | Width = 185
73 | Caption = 'Path'
74 | ClientHeight = 32
75 | ClientWidth = 181
76 | TabOrder = 4
77 | object pathbox: TEdit
78 | Left = 8
79 | Height = 25
80 | Top = 0
81 | Width = 128
82 | Enabled = False
83 | ParentShowHint = False
84 | TabOrder = 0
85 | end
86 | object pathset: TButton
87 | Left = 144
88 | Height = 25
89 | Top = 0
90 | Width = 31
91 | Caption = 'Set'
92 | Enabled = False
93 | OnClick = pathsetClick
94 | TabOrder = 1
95 | end
96 | end
97 | object driftGroup: TGroupBox
98 | Left = 8
99 | Height = 56
100 | Top = 160
101 | Width = 185
102 | Caption = 'Drift Time'
103 | ClientHeight = 39
104 | ClientWidth = 181
105 | TabOrder = 5
106 | object driftBar: TTrackBar
107 | Left = 0
108 | Height = 36
109 | Top = 0
110 | Width = 176
111 | Max = 255
112 | Position = 0
113 | TabOrder = 0
114 | end
115 | end
116 | object setbox: TCheckBox
117 | Left = 8
118 | Height = 22
119 | Top = 216
120 | Width = 180
121 | Caption = 'Enable "Press to Select"'
122 | TabOrder = 6
123 | end
124 | end
125 |
--------------------------------------------------------------------------------
/lib/x86_64-linux/unit1.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thedarkb/TPconfig/fdbf50793f293eafa80de0d87c0e2a693041b35d/lib/x86_64-linux/unit1.o
--------------------------------------------------------------------------------
/lib/x86_64-linux/unit1.ppu:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/thedarkb/TPconfig/fdbf50793f293eafa80de0d87c0e2a693041b35d/lib/x86_64-linux/unit1.ppu
--------------------------------------------------------------------------------
/tpconfig.lpi:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/tpconfig.lpr:
--------------------------------------------------------------------------------
1 | program tpconfig;
2 |
3 | {$mode objfpc}{$H+}
4 |
5 | uses
6 | {$IFDEF UNIX}{$IFDEF UseCThreads}
7 | cthreads,
8 | {$ENDIF}{$ENDIF}
9 | Interfaces, // this includes the LCL widgetset
10 | Forms, Unit1
11 | { you can add units after this };
12 |
13 | {$R *.res}
14 |
15 | begin
16 | RequireDerivedFormResource:=True;
17 | Application.Initialize;
18 | Application.CreateForm(TForm1, Form1);
19 | Application.Run;
20 | end.
21 |
22 |
--------------------------------------------------------------------------------
/tpconfig.lps:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
--------------------------------------------------------------------------------
/unit1.lfm:
--------------------------------------------------------------------------------
1 | object Form1: TForm1
2 | Left = 515
3 | Height = 268
4 | Top = 216
5 | Width = 201
6 | BorderStyle = bsDialog
7 | Caption = 'TPConfig V1.2'
8 | ClientHeight = 268
9 | ClientWidth = 201
10 | OnCreate = FormCreate
11 | LCLVersion = '2.0.2.0'
12 | object speedGroup: TGroupBox
13 | Left = 8
14 | Height = 56
15 | Top = 48
16 | Width = 185
17 | Caption = 'Speed'
18 | ClientHeight = 39
19 | ClientWidth = 181
20 | TabOrder = 0
21 | object speedBar: TTrackBar
22 | Left = 0
23 | Height = 36
24 | Top = 0
25 | Width = 176
26 | Max = 255
27 | Position = 0
28 | TabOrder = 0
29 | end
30 | end
31 | object senseGroup: TGroupBox
32 | Left = 8
33 | Height = 56
34 | Top = 104
35 | Width = 185
36 | Caption = 'Sensitivity'
37 | ClientHeight = 39
38 | ClientWidth = 181
39 | TabOrder = 1
40 | object senseBar: TTrackBar
41 | Left = 0
42 | Height = 36
43 | Top = 0
44 | Width = 176
45 | Max = 255
46 | Position = 0
47 | TabOrder = 0
48 | end
49 | end
50 | object quit: TButton
51 | Left = 8
52 | Height = 25
53 | Top = 240
54 | Width = 88
55 | Caption = 'Quit'
56 | OnClick = quitClick
57 | TabOrder = 2
58 | end
59 | object apply: TButton
60 | Left = 104
61 | Height = 25
62 | Top = 240
63 | Width = 89
64 | Caption = 'Apply'
65 | OnClick = applyClick
66 | TabOrder = 3
67 | end
68 | object pathGroup: TGroupBox
69 | Left = 8
70 | Height = 49
71 | Top = 0
72 | Width = 185
73 | Caption = 'Path'
74 | ClientHeight = 32
75 | ClientWidth = 181
76 | TabOrder = 4
77 | object pathbox: TEdit
78 | Left = 8
79 | Height = 25
80 | Top = 0
81 | Width = 128
82 | Enabled = False
83 | ParentShowHint = False
84 | TabOrder = 0
85 | end
86 | object pathset: TButton
87 | Left = 144
88 | Height = 25
89 | Top = 0
90 | Width = 31
91 | Caption = 'Set'
92 | Enabled = False
93 | OnClick = pathsetClick
94 | TabOrder = 1
95 | end
96 | end
97 | object driftGroup: TGroupBox
98 | Left = 8
99 | Height = 56
100 | Top = 160
101 | Width = 185
102 | Caption = 'Drift Time'
103 | ClientHeight = 39
104 | ClientWidth = 181
105 | TabOrder = 5
106 | object driftBar: TTrackBar
107 | Left = 0
108 | Height = 36
109 | Top = 0
110 | Width = 176
111 | Max = 255
112 | Position = 0
113 | TabOrder = 0
114 | end
115 | end
116 | object setbox: TCheckBox
117 | Left = 8
118 | Height = 22
119 | Top = 216
120 | Width = 180
121 | Caption = 'Enable "Press to Select"'
122 | TabOrder = 6
123 | end
124 | end
125 |
--------------------------------------------------------------------------------
/unit1.pas:
--------------------------------------------------------------------------------
1 | unit Unit1;
2 |
3 | {$mode objfpc}{$H+}
4 |
5 | interface
6 |
7 | uses
8 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
9 | ComCtrls, Unix, BaseUnix;
10 |
11 | type
12 |
13 | { TForm1 }
14 |
15 | TForm1 = class(TForm)
16 | pathset: TButton;
17 | setbox: TCheckBox;
18 | pathbox: TEdit;
19 | pathGroup: TGroupBox;
20 | quit: TButton;
21 | apply: TButton;
22 | driftBar: TTrackBar;
23 | driftGroup: TGroupBox;
24 | speedGroup: TGroupBox;
25 | senseGroup: TGroupBox;
26 | speedBar: TTrackBar;
27 | senseBar: TTrackBar;
28 | procedure applyClick(Sender: TObject);
29 | procedure FormCreate(Sender: TObject);
30 | procedure pathsetClick(Sender: TObject);
31 | procedure quitClick(Sender: TObject);
32 | private
33 | { private declarations }
34 | public
35 | { public declarations }
36 | end;
37 |
38 | const
39 | conpath = '/etc/tmpfiles.d/tpconfig.conf';
40 | devpath1 = '/sys/devices/platform/i8042/serio1/serio2/'; //hardcoded paths to devices
41 | devpath2 = '/sys/devices/platform/i8042/serio1/'; //TODO: make less arse
42 |
43 | var
44 | Form1: TForm1;
45 | confH: textfile;
46 | confile: string;
47 | tp: boolean;
48 | workingpath: string;
49 | sysfile: text;
50 | sensitivityt: string;
51 | speedt: string;
52 | driftt: string;
53 | sett: string;
54 | sensitivity: byte;
55 | speed: byte;
56 | drift: byte;
57 | setnum: byte;
58 | setstr: string;
59 | tempfile: text;
60 | user: LongWord;
61 | messagereturn: longint;
62 | assembledStr: string;
63 | checkStr: string;
64 |
65 | implementation
66 |
67 | {$R *.lfm}
68 |
69 | { TForm1 }
70 |
71 | procedure TForm1.FormCreate(Sender: TObject);
72 | begin
73 | fpsystem('touch '+conpath);
74 | tp := false;
75 | if FileExists(devpath1+'sensitivity') then
76 | begin
77 | tp := true;
78 | workingpath := devpath1;
79 | pathbox.Text := workingpath;
80 | end;
81 | if FileExists(devpath2+'sensitivity') then
82 | begin
83 | tp := true;
84 | workingpath := devpath2;
85 | pathbox.Text := workingpath;
86 | end;
87 | if not tp then
88 | begin
89 | messagereturn := Application.MessageBox('No TrackPoint found at the default path, you must specify one.', 'Error');
90 | apply.Enabled := false;
91 | pathbox.Enabled := true;
92 | pathset.Enabled := true;
93 | end;
94 | if FileExists(conpath) then
95 | begin
96 | user := fpgeteuid;
97 | if not (user=0) then
98 | begin
99 | messagereturn := Application.MessageBox('ERROR: Must be run as root!', 'Fatal Error');
100 | halt;
101 | end;
102 | if FileExists(workingpath+'sensitivity') then
103 | begin
104 | {check current sensitivity}
105 | AssignFile(sysfile, workingpath+'sensitivity');
106 | reset(sysfile);
107 | readln(sysfile, sensitivityt);
108 | val(sensitivityt, sensitivity);
109 | senseBar.Position := sensitivity; {initialises the slider with current setting}
110 |
111 | {check current speed}
112 | AssignFile(sysfile, workingpath+'speed');
113 | reset(sysfile);
114 | readln(sysfile, speedt);
115 | val(speedt, speed);
116 | speedBar.Position := speed; {ditto above}
117 |
118 | {check current drift time}
119 | AssignFile(sysfile, workingpath+'drift_time');
120 | reset(sysfile);
121 | readln(sysfile, driftt);
122 | val(driftt, drift);
123 | driftBar.Position := drift; {ditto above}
124 |
125 | {check current "press to select" setting}
126 | AssignFile(sysfile, workingpath+'press_to_select');
127 | reset(sysfile);
128 | readln(sysfile, sett);
129 | val(sett, setnum);
130 | if not setnum = 0 then
131 | begin
132 | setbox.Checked := true; {ditto above, just substitute box for slider}
133 | end;
134 | end;
135 | end;
136 | end;
137 |
138 | procedure TForm1.pathsetClick(Sender: TObject);
139 | begin
140 | checkStr := pathbox.Text;
141 | if FileExists(checkStr+'sensitivity') then
142 | begin
143 | workingpath := checkStr;
144 | apply.Enabled := true;
145 |
146 | {check current sensitivity}
147 | AssignFile(sysfile, workingpath+'sensitivity');
148 | reset(sysfile);
149 | readln(sysfile, sensitivityt);
150 | val(sensitivityt, sensitivity);
151 | senseBar.Position := sensitivity; {initialises the slider with current setting}
152 |
153 | {check current speed}
154 | AssignFile(sysfile, workingpath+'speed');
155 | reset(sysfile);
156 | readln(sysfile, speedt);
157 | val(speedt, speed);
158 | speedBar.Position := speed; {ditto above}
159 |
160 | {check current drift time}
161 | AssignFile(sysfile, workingpath+'drift_time');
162 | reset(sysfile);
163 | readln(sysfile, driftt);
164 | val(driftt, drift);
165 | driftBar.Position := drift; {ditto above}
166 |
167 | {check current "press to select" setting}
168 | AssignFile(sysfile, workingpath+'press_to_select');
169 | reset(sysfile);
170 | readln(sysfile, sett);
171 | val(sett, setnum);
172 | if not setnum = 0 then
173 | begin
174 | setbox.Checked := true; {ditto above, just substitute box for slider}
175 | end; //I'm well aware that having two of these check blocks is redundant
176 | messagereturn := Application.MessageBox('TrackPoint found at path.', 'Success');
177 | end;
178 | if not FileExists(workingpath+'sensitivity') then
179 | messagereturn := Application.MessageBox('No TrackPoint found at path.', 'Error');
180 | end; //I'm just too lazy to put them in a procedure when I can ctrl+c ctrl+v
181 |
182 | procedure TForm1.applyClick(Sender: TObject);
183 | begin
184 | //copies the value on the sliders into bytes for IntToStr later.
185 | sensitivity := senseBar.Position;
186 | speed := speedBar.Position;
187 | drift := driftBar.Position;
188 | setstr := '0';
189 | if setbox.Checked then
190 | setstr := '1';
191 |
192 | AssignFile(confH, conpath);
193 | rewrite(confH);
194 | {puts together the lines of the SystemD script which sets the sensitivity
195 | on boot}
196 | assembledStr := 'w '+workingpath+'sensitivity - - - - '+IntToStr(sensitivity);
197 | writeln(confH, assembledStr);
198 | //ditto above but for speed.
199 | assembledStr := 'w '+workingpath+'speed - - - - '+IntToStr(speed);
200 | writeln(confH, assembledStr);
201 | //drift this time
202 | assembledStr := 'w '+workingpath+'drift_time - - - - '+IntToStr(drift);
203 | writeln(confH, assembledStr);
204 | //now for press to select
205 | assembledStr := 'w '+workingpath+'press_to_select - - - - '+setstr;
206 | writeln(confH, assembledStr);
207 |
208 | CloseFile(confH); //closes the script, writing the contents to the disk
209 | fpsystem('systemd-tmpfiles --prefix=/sys --create'); {tells systemD to run the script}
210 | end;
211 |
212 | procedure TForm1.quitClick(Sender: TObject);
213 | begin
214 | {$I-}
215 | halt;
216 | end;
217 |
218 |
219 | end.
220 |
221 |
--------------------------------------------------------------------------------