hedgewars/uInputHandler.pas
changeset 15028 9d00a873bbcc
parent 15027 f81b46f584c7
child 15300 7ab5cf405686
equal deleted inserted replaced
15027:f81b46f584c7 15028:9d00a873bbcc
   186 
   186 
   187 procedure ProcessKey(code: LongInt; KeyDown: boolean);
   187 procedure ProcessKey(code: LongInt; KeyDown: boolean);
   188 var
   188 var
   189     Trusted: boolean;
   189     Trusted: boolean;
   190     curBind, s: shortstring;
   190     curBind, s: shortstring;
       
   191     readyAborter: boolean;
   191 begin
   192 begin
   192 if not(tkbd[code] xor KeyDown) then exit;
   193 if not(tkbd[code] xor KeyDown) then exit;
   193 tkbd[code]:= KeyDown;
   194 tkbd[code]:= KeyDown;
   194 
   195 
   195 Trusted:= (CurrentTeam <> nil)
   196 Trusted:= (CurrentTeam <> nil)
   226     end;
   227     end;
   227 
   228 
   228 if CurrentBinds.indices[code] > 0 then
   229 if CurrentBinds.indices[code] > 0 then
   229     begin
   230     begin
   230     curBind:= CurrentBinds.binds[CurrentBinds.indices[code]];
   231     curBind:= CurrentBinds.binds[CurrentBinds.indices[code]];
       
   232 
       
   233     // Check if the keypress should end the ready phase.
       
   234     // Camera movement keys are "safe" since its equivalent to moving the mouse,
       
   235     // which also does not end the ready phase.
       
   236     readyAborter:= (curBind <> '+cur_u') and (curBind <> '+cur_d') and (curBind <> '+cur_l') and (curBind <> '+cur_r');
       
   237 
   231     if (code < cKeyMaxIndex - 2) // means not mouse buttons
   238     if (code < cKeyMaxIndex - 2) // means not mouse buttons
   232         and KeyDown
   239         and KeyDown
   233         and (not ((curBind = 'put')
   240         and (not ((curBind = 'put')
   234                   or (curBind = 'ammomenu')
   241                   or (curBind = 'ammomenu')
   235                   or (curBind = '+cur_u')
   242                   or (curBind = '+cur_u')
   253             updateCursorMovementDelta(true, CursorMovementX, CursorMovementX);
   260             updateCursorMovementDelta(true, CursorMovementX, CursorMovementX);
   254             updateCursorMovementDelta(true, CursorMovementY, CursorMovementY);
   261             updateCursorMovementDelta(true, CursorMovementY, CursorMovementY);
   255             end;
   262             end;
   256 
   263 
   257         ParseCommand(curBind, Trusted);
   264         ParseCommand(curBind, Trusted);
   258         if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then
   265         // End ready phase
       
   266         if (readyAborter) and (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then
   259             ParseCommand('gencmd R', true)
   267             ParseCommand('gencmd R', true)
   260         end
   268         end
   261     else if (curBind[1] = '+') then
   269     else if (curBind[1] = '+') then
   262         begin
   270         begin
   263         if curBind = '+precise' then
   271         if curBind = '+precise' then
   268             updateCursorMovementDelta(false, CursorMovementY, CursorMovementY);
   276             updateCursorMovementDelta(false, CursorMovementY, CursorMovementY);
   269             end;
   277             end;
   270         s:= curBind;
   278         s:= curBind;
   271         s[1]:= '-';
   279         s[1]:= '-';
   272         ParseCommand(s, Trusted);
   280         ParseCommand(s, Trusted);
   273         if (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then
   281         // End ready phase
       
   282         if (readyAborter) and (CurrentTeam <> nil) and (not CurrentTeam^.ExtDriven) and (ReadyTimeLeft > 1) then
   274             ParseCommand('gencmd R', true)
   283             ParseCommand('gencmd R', true)
   275         end
   284         end
   276     else
   285     else
   277         begin
   286         begin
   278         if curBind = 'switch' then
   287         if curBind = 'switch' then