~ubuntu-branches/ubuntu/wily/hedgewars/wily

« back to all changes in this revision

Viewing changes to hedgewars/uKeys.pas

  • Committer: Package Import Robot
  • Author(s): Dmitry E. Oboukhov
  • Date: 2011-09-23 10:16:55 UTC
  • mfrom: (1.2.11 upstream)
  • Revision ID: package-import@ubuntu.com-20110923101655-3977th2gc5n0a3pv
Tags: 0.9.16-1
* New upstream version.
 + Downloadable content! Simply click to install any content.
   New voices, hats, maps, themes, translations, music, scripts...
   Hedgewars is now more customisable than ever before! As time goes
   by we will be soliciting community content to feature on this page,
   so remember to check it from time to time. If you decide you want
   to go back to standard Hedgewars, just remove the Data directory
   from your Hedgewars config directory.
 + 3-D rendering! Diorama-like rendering of the game in a variety
   of 3D modes. Let us know which ones work best for you, we didn't
   really have the equipment to test them all.
 + Resizable game window.
 + New utilities! The Time Box will remove one of your hedgehogs
   from the game for a while, protecting from attack until it returns,
   somewhere else on the map. Land spray will allow you to build bridges,
   seal up holes, or just make life unpleasant for your enemies.
 + New single player: Bamboo Thicket, That Sinking Feeling, Newton and
   the Tree and multi-player: The Specialists, Space Invaders,
   Racer - scripts! And a ton more script hooks for scripters
 + New twists on old weapons. Drill strike, seduction and fire have
   been adjusted. Defective mines have been added, rope can attach to
   hogs/crates/barrels again, grenades now have variable bounce (use
   precise key + 1-5). Portal gun is now more usable in flight and
   all game actions are a lot faster.
 + New theme - Golf, dozens of new community hats and a new
   localised Default voice, Ukranian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
(*
2
2
 * Hedgewars, a free turn based strategy game
3
 
 * Copyright (c) 2004-2008 Andrey Korotaev <unC0Rr@gmail.com>
 
3
 * Copyright (c) 2004-2011 Andrey Korotaev <unC0Rr@gmail.com>
4
4
 *
5
5
 * This program is free software; you can redistribute it and/or modify
6
6
 * it under the terms of the GNU General Public License as published by
40
40
procedure ControllerHatEvent(joy, hat, value: Byte);
41
41
procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean);
42
42
 
43
 
var hideAmmoMenu: boolean;
44
 
    wheelUp: boolean;
45
 
    wheelDown: boolean;
46
 
 
47
 
    ControllerNumControllers: Integer;
48
 
    ControllerEnabled: Integer;
49
 
    ControllerNumAxes: array[0..5] of Integer;
50
 
    //ControllerNumBalls: array[0..5] of Integer;
51
 
    ControllerNumHats: array[0..5] of Integer;
52
 
    ControllerNumButtons: array[0..5] of Integer;
53
 
    ControllerAxes: array[0..5] of array[0..19] of Integer;
54
 
    //ControllerBalls: array[0..5] of array[0..19] of array[0..1] of Integer;
55
 
    ControllerHats: array[0..5] of array[0..19] of Byte;
56
 
    ControllerButtons: array[0..5] of array[0..19] of Byte;
57
 
 
58
 
    DefaultBinds, CurrentBinds: TBinds;
59
 
 
60
 
    coeff: LongInt;
61
 
{$IFDEF HWLIBRARY}
62
 
    leftClick: boolean;
63
 
    middleClick: boolean;
64
 
    rightClick: boolean;
65
 
 
66
 
    upKey: boolean;
67
 
    downKey: boolean;
68
 
    rightKey: boolean;
69
 
    leftKey: boolean;
70
 
    preciseKey: boolean;
71
 
 
72
 
    backspaceKey: boolean;
73
 
    spaceKey: boolean;
74
 
    enterKey: boolean;
75
 
    tabKey: boolean;
76
 
 
77
 
    chatAction: boolean;
78
 
    pauseAction: boolean;
79
 
 
80
43
{$IFDEF IPHONEOS}
81
44
procedure setiPhoneBinds;
82
45
{$ENDIF}
83
 
{$ENDIF}
 
46
 
84
47
implementation
85
48
uses uConsole, uCommands, uMisc, uVariables, uConsts, uUtils, uDebug;
86
49
 
109
72
 
110
73
// move cursor/camera
111
74
// TODO: Scale on screen dimensions and/or axis value (game controller)?
112
 
movecursor(coeff * CursorMovementX, coeff * CursorMovementY);
 
75
movecursor(5 * CursorMovementX, 5 * CursorMovementY);
113
76
 
114
77
k:= SDL_GetMouseState(nil, nil);
115
78
 
139
102
 
140
103
{$IFDEF IPHONEOS}
141
104
setiPhoneBinds();
142
 
{$ENDIF}
143
 
 
 
105
{$ELSE}
144
106
// Controller(s)
145
107
k:= j; // should we test k for hitting the limit? sounds rather unlikely to ever reach it
146
108
for j:= 0 to Pred(ControllerNumControllers) do
165
127
        inc(k, 1);
166
128
        end;
167
129
    end;
 
130
{$ENDIF}
 
131
 
 
132
// ctrl/cmd + w/q to close engine and/or frontend
 
133
{$IFDEF DARWIN}
 
134
    if ((tkbdn[KeyNameToCode('left_meta')] = 1) or (tkbdn[KeyNameToCode('right_meta')] = 1)) then
 
135
{$ELSE}
 
136
    if ((tkbdn[KeyNameToCode('left_ctrl')] = 1) or (tkbdn[KeyNameToCode('right_ctrl')] = 1)) then
 
137
{$ENDIF}
 
138
    begin
 
139
        if tkbdn[KeyNameToCode('q')] = 1 then ParseCommand ('halt', true)
 
140
        else if tkbdn[KeyNameToCode('w')] = 1 then ParseCommand ('forcequit', true);
 
141
    end;
168
142
 
169
143
// now process strokes
170
144
for i:= 0 to cKeyMaxIndex do
190
164
end;
191
165
 
192
166
procedure ResetKbd;
193
 
var i, j, k, t: LongInt;
194
 
{$IFNDEF IPHONEOS}pkbd: PByteArray;{$ENDIF}
 
167
var j, k, t: LongInt;
 
168
{$IFNDEF IPHONEOS}
 
169
    i: LongInt;
 
170
    pkbd: PByteArray;
 
171
{$ENDIF}
195
172
begin
196
173
 
197
174
k:= SDL_GetMouseState(nil, nil);
222
199
 
223
200
{$IFDEF IPHONEOS}
224
201
setiPhoneBinds();
225
 
{$ENDIF}
226
 
 
 
202
{$ELSE}
227
203
// Controller(s)
228
204
k:= j; // should we test k for hitting the limit? sounds rather unlikely to ever reach it
229
205
for j:= 0 to Pred(ControllerNumControllers) do
248
224
        inc(k, 1);
249
225
        end;
250
226
    end;
 
227
{$ENDIF}
251
228
 
 
229
// what is this final loop for?
252
230
for t:= 0 to cKeyMaxIndex do
253
 
    tkbd[i]:= tkbdn[i]
 
231
    tkbd[t]:= tkbdn[t]
254
232
end;
255
233
 
256
234
procedure InitKbdKeyTable;
408
386
 
409
387
procedure FreezeEnterKey;
410
388
begin
 
389
    tkbd[3]:= 1;
411
390
    tkbd[13]:= 1;
 
391
    tkbd[27]:= 1;
412
392
    tkbd[271]:= 1;
413
393
end;
414
394
 
502
482
begin
503
483
    wheelUp:= false;
504
484
    wheelDown:= false;
505
 
    coeff:= 5;
506
485
{$IFDEF HWLIBRARY}
507
486
    // this function is called by HW_allKeysUp so be careful
508
487