1 (* Copyright (C) Doom 2D: Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 {$INCLUDE ../../../shared/a_modes.inc}
20 procedure r_Touch_GetKeyRect (key
: Integer; out x
, y
, w
, h
: Integer; out founded
: Boolean);
21 procedure r_Touch_Draw
;
30 e_input
, g_options
, g_system
, g_game
,
35 function GetKeyName (key
: Integer): String;
38 VK_SHOWKBD
: result
:= 'KBD';
39 VK_HIDEKBD
: result
:= 'KBD';
40 VK_LEFT
: result
:= 'LEFT';
41 VK_RIGHT
: result
:= 'RIGHT';
42 VK_UP
: result
:= 'UP';
43 VK_DOWN
: result
:= 'DOWN';
44 VK_FIRE
: result
:= 'FIRE';
45 VK_OPEN
: result
:= 'OPEN';
46 VK_JUMP
: result
:= 'JUMP';
47 VK_CHAT
: result
:= 'CHAT';
48 VK_ESCAPE
: result
:= 'ESC';
65 VK_CONSOLE
: result
:= 'CON';
66 VK_STATUS
: result
:= 'STAT';
67 VK_TEAM
: result
:= 'TEAM';
68 VK_PREV
: result
:= '<PREV';
69 VK_NEXT
: result
:= 'NEXT>';
70 VK_LSTRAFE
: result
:= '<';
71 VK_RSTRAFE
: result
:= '>';
73 if (key
> 0) and (key
< e_MaxInputKeys
) then
74 result
:= e_KeyNames
[key
]
76 result
:= '<' + IntToStr(key
) + '>'
80 procedure r_Touch_GetKeyRect (key
: Integer; out x
, y
, w
, h
: Integer; out founded
: Boolean);
85 procedure S (xx
, yy
, ww
, hh
: Single);
96 {$IF DEFINED(USE_SDL2) AND NOT DEFINED(SDL2_NODPI)}
97 if SDL_GetDisplayDPI(0, @dpi
, nil, nil) <> 0 then
103 sz
:= Trunc(g_touch_size
* dpi
); sw
:= gWinSizeX
; sh
:= gWinSizeY
;
104 x
:= 0; y
:= Round(sh
* g_touch_offset
/ 100);
107 if sys_IsTextInputActive() then
109 VK_HIDEKBD
: S(sw
- (sz
/2), 0, sz
/ 2, sz
/ 2);
111 else if g_touch_alt
then
113 (* top ------- x ------------------------------- y w ----- h -- *)
114 VK_CONSOLE
: S(0, 0, sz
/ 2, sz
/ 2);
115 VK_ESCAPE
: S(sw
- 1*(sz
/2) - 1, 0, sz
/ 2, sz
/ 2);
116 VK_SHOWKBD
: S(sw
- 2*(sz
/2) - 1, 0, sz
/ 2, sz
/ 2);
117 VK_CHAT
: S(sw
/ 2 - (sz
/2) / 2 - (sz
/2) - 1, 0, sz
/ 2, sz
/ 2);
118 VK_STATUS
: S(sw
/ 2 - (sz
/2) / 2 - 1, 0, sz
/ 2, sz
/ 2);
119 VK_TEAM
: S(sw
/ 2 - (sz
/2) / 2 + (sz
/2) - 1, 0, sz
/ 2, sz
/ 2);
120 (* left --- x - y -------------- w - h --- *)
121 VK_PREV
: S(0, sh
- 3.0*sz
- 1, sz
, sz
/ 2);
122 VK_LEFT
: S(0, sh
- 2.0*sz
- 1, sz
, sz
* 2);
123 VK_RIGHT
: S(sz
, sh
- 2.0*sz
- 1, sz
, sz
* 2);
124 (* right - x ------------ y -------------- w - h -- *)
125 VK_NEXT
: S(sw
- 1*sz
- 1, sh
- 3.0*sz
- 1, sz
, sz
/ 2);
126 VK_UP
: S(sw
- 2*sz
- 1, sh
- 2.0*sz
- 1, sz
, sz
/ 2);
127 VK_FIRE
: S(sw
- 2*sz
- 1, sh
- 1.5*sz
- 1, sz
, sz
);
128 VK_DOWN
: S(sw
- 2*sz
- 1, sh
- 0.5*sz
- 1, sz
, sz
/ 2);
129 VK_JUMP
: S(sw
- 1*sz
- 1, sh
- 2.0*sz
- 1, sz
, sz
);
130 VK_OPEN
: S(sw
- 1*sz
- 1, sh
- 1.0*sz
- 1, sz
, sz
);
134 (* left ----- x ----- y -------------- w ----- h -- *)
135 VK_ESCAPE
: S(0.0*sz
, y
- 1*sz
- sz
/2, sz
, sz
/ 2);
136 VK_LSTRAFE
: S(0.0*sz
, y
- 0*sz
- sz
/2, sz
/ 2, sz
);
137 VK_LEFT
: S(0.5*sz
, y
- 0*sz
- sz
/2, sz
, sz
);
138 VK_RIGHT
: S(1.5*sz
, y
- 0*sz
- sz
/2, sz
, sz
);
139 VK_RSTRAFE
: S(2.5*sz
, y
- 0*sz
- sz
/2, sz
/ 2, sz
);
140 (* right - x ------------ y --------------- w - h *)
141 VK_UP
: S(sw
- 1*sz
- 1, y
- 1*sz
- sz
/2, sz
, sz
);
142 VK_FIRE
: S(sw
- 1*sz
- 1, y
- 0*sz
- sz
/2, sz
, sz
);
143 VK_DOWN
: S(sw
- 1*sz
- 1, y
- -1*sz
- sz
/2, sz
, sz
);
144 VK_NEXT
: S(sw
- 2*sz
- 1, y
- 1*sz
- sz
/2, sz
, sz
);
145 VK_JUMP
: S(sw
- 2*sz
- 1, y
- 0*sz
- sz
/2, sz
, sz
);
146 VK_PREV
: S(sw
- 3*sz
- 1, y
- 1*sz
- sz
/2, sz
, sz
);
147 VK_OPEN
: S(sw
- 3*sz
- 1, y
- 0*sz
- sz
/2, sz
, sz
);
148 (* bottom ---- x -------------------------- y ---------------- w ----- h -- *)
149 VK_CHAT
: S(sw
/2 - sz
/4 - 2*(sz
/2) - 1, sh
- 2*(sz
/2) - 1, sz
/ 2, sz
/ 2);
150 VK_CONSOLE
: S(sw
/2 - sz
/4 - 1*(sz
/2) - 1, sh
- 2*(sz
/2) - 1, sz
/ 2, sz
/ 2);
151 VK_STATUS
: S(sw
/2 - sz
/4 - 0*(sz
/2) - 1, sh
- 2*(sz
/2) - 1, sz
/ 2, sz
/ 2);
152 VK_TEAM
: S(sw
/2 - sz
/4 - -1*(sz
/2) - 1, sh
- 2*(sz
/2) - 1, sz
/ 2, sz
/ 2);
153 VK_SHOWKBD
: S(sw
/2 - sz
/4 - -2*(sz
/2) - 1, sh
- 2*(sz
/2) - 1, sz
/ 2, sz
/ 2);
154 VK_0
: S(sw
/2 - sz
/4 - 5*(sz
/2) - 1, sh
- 1*(sz
/2) - 1, sz
/ 2, sz
/ 2);
155 VK_1
: S(sw
/2 - sz
/4 - 4*(sz
/2) - 1, sh
- 1*(sz
/2) - 1, sz
/ 2, sz
/ 2);
156 VK_2
: S(sw
/2 - sz
/4 - 3*(sz
/2) - 1, sh
- 1*(sz
/2) - 1, sz
/ 2, sz
/ 2);
157 VK_3
: S(sw
/2 - sz
/4 - 2*(sz
/2) - 1, sh
- 1*(sz
/2) - 1, sz
/ 2, sz
/ 2);
158 VK_4
: S(sw
/2 - sz
/4 - 1*(sz
/2) - 1, sh
- 1*(sz
/2) - 1, sz
/ 2, sz
/ 2);
159 VK_5
: S(sw
/2 - sz
/4 - 0*(sz
/2) - 1, sh
- 1*(sz
/2) - 1, sz
/ 2, sz
/ 2);
160 VK_6
: S(sw
/2 - sz
/4 - -1*(sz
/2) - 1, sh
- 1*(sz
/2) - 1, sz
/ 2, sz
/ 2);
161 VK_7
: S(sw
/2 - sz
/4 - -2*(sz
/2) - 1, sh
- 1*(sz
/2) - 1, sz
/ 2, sz
/ 2);
162 VK_8
: S(sw
/2 - sz
/4 - -3*(sz
/2) - 1, sh
- 1*(sz
/2) - 1, sz
/ 2, sz
/ 2);
163 VK_9
: S(sw
/2 - sz
/4 - -4*(sz
/2) - 1, sh
- 1*(sz
/2) - 1, sz
/ 2, sz
/ 2);
164 VK_A
: S(sw
/2 - sz
/4 - -5*(sz
/2) - 1, sh
- 1*(sz
/2) - 1, sz
/ 2, sz
/ 2);
168 procedure r_Touch_Draw
;
169 var i
, x
, y
, w
, h
: Integer; founded
: Boolean;
171 if g_touch_enabled
then
173 for i
:= VK_FIRSTKEY
to VK_LASTKEY
do
175 r_Touch_GetKeyRect(i
, x
, y
, w
, h
, founded
);
178 r_Draw_Rect(x
, y
, x
+ w
, y
+ h
, 0, 255, 0, 225);
179 r_Draw_Text(GetKeyName(i
), x
, y
, 255, 255, 255, 225, stdfont
);