hedgewars/uInputHandler.pas
branchsdl2transition
changeset 11368 c481d087f653
parent 11365 b8b208501475
child 11403 b894922d58cc
child 11486 2b30283a402c
equal deleted inserted replaced
11367:a91c4c4fd85c 11368:c481d087f653
   324         KeyNames[i]:= LowerCase(s)
   324         KeyNames[i]:= LowerCase(s)
   325         end;
   325         end;
   326 
   326 
   327 
   327 
   328     // get the size of keyboard array
   328     // get the size of keyboard array
   329     SDL_GetKeyState(@k);
   329     SDL_GetKeyboardState(@k);
   330 
   330 
   331     // Controller(s)
   331     // Controller(s)
   332     for j:= 0 to Pred(ControllerNumControllers) do
   332     for j:= 0 to Pred(ControllerNumControllers) do
   333         begin
   333         begin
   334         for i:= 0 to Pred(ControllerNumAxes[j]) do
   334         for i:= 0 to Pred(ControllerNumAxes[j]) do
   460 
   460 
   461 procedure ControllerAxisEvent(joy, axis: Byte; value: Integer);
   461 procedure ControllerAxisEvent(joy, axis: Byte; value: Integer);
   462 var
   462 var
   463     k: LongInt;
   463     k: LongInt;
   464 begin
   464 begin
   465     SDL_GetKeyState(@k);
   465     SDL_GetKeyboardState(@k);
   466     k:= k + joy * (ControllerNumAxes[joy]*2 + ControllerNumHats[joy]*4 + ControllerNumButtons[joy]*2);
   466     k:= k + joy * (ControllerNumAxes[joy]*2 + ControllerNumHats[joy]*4 + ControllerNumButtons[joy]*2);
   467     ProcessKey(k +  axis*2, value > 20000);
   467     ProcessKey(k +  axis*2, value > 20000);
   468     ProcessKey(k + (axis*2)+1, value < -20000);
   468     ProcessKey(k + (axis*2)+1, value < -20000);
   469 end;
   469 end;
   470 
   470 
   471 procedure ControllerHatEvent(joy, hat, value: Byte);
   471 procedure ControllerHatEvent(joy, hat, value: Byte);
   472 var
   472 var
   473     k: LongInt;
   473     k: LongInt;
   474 begin
   474 begin
   475     SDL_GetKeyState(@k);
   475     SDL_GetKeyboardState(@k);
   476     k:= k + joy * (ControllerNumAxes[joy]*2 + ControllerNumHats[joy]*4 + ControllerNumButtons[joy]*2);
   476     k:= k + joy * (ControllerNumAxes[joy]*2 + ControllerNumHats[joy]*4 + ControllerNumButtons[joy]*2);
   477     ProcessKey(k +  ControllerNumAxes[joy]*2 + hat*4 + 0, (value and SDL_HAT_UP)   <> 0);
   477     ProcessKey(k +  ControllerNumAxes[joy]*2 + hat*4 + 0, (value and SDL_HAT_UP)   <> 0);
   478     ProcessKey(k +  ControllerNumAxes[joy]*2 + hat*4 + 1, (value and SDL_HAT_RIGHT)<> 0);
   478     ProcessKey(k +  ControllerNumAxes[joy]*2 + hat*4 + 1, (value and SDL_HAT_RIGHT)<> 0);
   479     ProcessKey(k +  ControllerNumAxes[joy]*2 + hat*4 + 2, (value and SDL_HAT_DOWN) <> 0);
   479     ProcessKey(k +  ControllerNumAxes[joy]*2 + hat*4 + 2, (value and SDL_HAT_DOWN) <> 0);
   480     ProcessKey(k +  ControllerNumAxes[joy]*2 + hat*4 + 3, (value and SDL_HAT_LEFT) <> 0);
   480     ProcessKey(k +  ControllerNumAxes[joy]*2 + hat*4 + 3, (value and SDL_HAT_LEFT) <> 0);
   482 
   482 
   483 procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean);
   483 procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean);
   484 var
   484 var
   485     k: LongInt;
   485     k: LongInt;
   486 begin
   486 begin
   487     SDL_GetKeyState(@k);
   487     SDL_GetKeyboardState(@k);
   488     k:= k + joy * (ControllerNumAxes[joy]*2 + ControllerNumHats[joy]*4 + ControllerNumButtons[joy]*2);
   488     k:= k + joy * (ControllerNumAxes[joy]*2 + ControllerNumHats[joy]*4 + ControllerNumButtons[joy]*2);
   489     ProcessKey(k +  ControllerNumAxes[joy]*2 + ControllerNumHats[joy]*4 + button, pressed);
   489     ProcessKey(k +  ControllerNumAxes[joy]*2 + ControllerNumHats[joy]*4 + button, pressed);
   490 end;
   490 end;
   491 
   491 
   492 procedure loadBinds(cmd, s: shortstring);
   492 procedure loadBinds(cmd, s: shortstring);