Did you know? UBerserker loves the Dispersion Pistol.

[GUIDE] How to make new controls

For questions and discussion about UnrealEd, UnrealScript, and other aspects of Unreal Engine design.

Moderators: ividyon, Semfry, zYnthetic

User avatar LannFyre
Skaarj Scout Skaarj Scout
Posts: 31
Joined: 29 Dec 2014, 02:55

Subject: [GUIDE] How to make new controls

Post Posted: 21 Jul 2015, 18:18

REPOSTED FROM UT99.org:

A bit more cross posting (from OldUnreal) but I've answered my input questions and thought I'd share. This is in my experience with Unreal 227i. But this is more broadly intended for both Unreal Engine 1 based games as it is general knowledge. I learned about this through Deus Ex because seeing through the matrix ayy lmao

Keys the player can press are given functionality (or at least bindability through definition) in "Engine.Actor":

Code: Select all

// Input system states.
enum EInputAction
{
   IST_None,    // Not performing special input processing.
   IST_Press,   // Handling a keypress or button press.
   IST_Hold,    // Handling holding a key or button.
   IST_Release, // Handling a key or button release.
   IST_Axis,    // Handling analog axis movement.
};

// Input keys.
enum EInputKey
{
   /*00*/   IK_None         ,IK_LeftMouse   ,IK_RightMouse   ,IK_Cancel      ,
   /*04*/   IK_MiddleMouse   ,IK_Unknown05   ,IK_Unknown06   ,IK_Unknown07   ,
   /*08*/   IK_Backspace   ,IK_Tab         ,IK_Unknown0A   ,IK_Unknown0B   ,
   /*0C*/   IK_Unknown0C   ,IK_Enter       ,IK_Unknown0E   ,IK_Unknown0F   ,
   /*10*/   IK_Shift      ,IK_Ctrl       ,IK_Alt         ,IK_Pause       ,
   /*14*/   IK_CapsLock      ,IK_MouseButton4,IK_MouseButton5,IK_MouseButton6,
   /*18*/   IK_MouseButton7   ,IK_MouseButton8,IK_Unknown1A   ,IK_Escape      ,
   /*1C*/   IK_Unknown1C   ,IK_Unknown1D   ,IK_Unknown1E   ,IK_Unknown1F   ,
   /*20*/   IK_Space      ,IK_PageUp      ,IK_PageDown    ,IK_End         ,
   /*24*/   IK_Home         ,IK_Left        ,IK_Up          ,IK_Right       ,
   /*28*/   IK_Down         ,IK_Select      ,IK_Print       ,IK_Execute     ,
   /*2C*/   IK_PrintScrn   ,IK_Insert      ,IK_Delete      ,IK_Help      ,
   /*30*/   IK_0         ,IK_1         ,IK_2         ,IK_3         ,
   /*34*/   IK_4         ,IK_5         ,IK_6         ,IK_7         ,
   /*38*/   IK_8         ,IK_9         ,IK_Unknown3A   ,IK_Unknown3B   ,
   /*3C*/   IK_Unknown3C   ,IK_Unknown3D   ,IK_Unknown3E   ,IK_Unknown3F   ,
   /*40*/   IK_Unknown40   ,IK_A         ,IK_B         ,IK_C         ,
   /*44*/   IK_D         ,IK_E         ,IK_F         ,IK_G         ,
   /*48*/   IK_H         ,IK_I         ,IK_J         ,IK_K         ,
   /*4C*/   IK_L         ,IK_M         ,IK_N         ,IK_O         ,
   /*50*/   IK_P         ,IK_Q         ,IK_R         ,IK_S         ,
   /*54*/   IK_T         ,IK_U         ,IK_V         ,IK_W         ,
   /*58*/   IK_X         ,IK_Y         ,IK_Z         ,IK_Unknown5B   ,
   /*5C*/   IK_Unknown5C   ,IK_Unknown5D   ,IK_Unknown5E   ,IK_Unknown5F   ,
   /*60*/   IK_NumPad0      ,IK_NumPad1     ,IK_NumPad2     ,IK_NumPad3     ,
   /*64*/   IK_NumPad4      ,IK_NumPad5     ,IK_NumPad6     ,IK_NumPad7     ,
   /*68*/   IK_NumPad8      ,IK_NumPad9     ,IK_GreyStar    ,IK_GreyPlus    ,
   /*6C*/   IK_Separator   ,IK_GreyMinus   ,IK_NumPadPeriod,IK_GreySlash   ,
   /*70*/   IK_F1         ,IK_F2          ,IK_F3          ,IK_F4          ,
   /*74*/   IK_F5         ,IK_F6          ,IK_F7          ,IK_F8          ,
   /*78*/   IK_F9           ,IK_F10         ,IK_F11         ,IK_F12         ,
   /*7C*/   IK_F13         ,IK_F14         ,IK_F15         ,IK_F16         ,
   /*80*/   IK_F17         ,IK_F18         ,IK_F19         ,IK_F20         ,
   /*84*/   IK_F21         ,IK_F22         ,IK_F23         ,IK_F24         ,
   /*88*/   IK_Unknown88   ,IK_Unknown89   ,IK_Unknown8A   ,IK_Unknown8B   ,
   /*8C*/   IK_Unknown8C   ,IK_Unknown8D   ,IK_Unknown8E   ,IK_Unknown8F   ,
   /*90*/   IK_NumLock      ,IK_ScrollLock  ,IK_Unknown92   ,IK_Unknown93   ,
   /*94*/   IK_Unknown94   ,IK_Unknown95   ,IK_Unknown96   ,IK_Unknown97   ,
   /*98*/   IK_Unknown98   ,IK_Unknown99   ,IK_Unknown9A   ,IK_Unknown9B   ,
   /*9C*/   IK_Unknown9C   ,IK_Unknown9D   ,IK_Unknown9E   ,IK_Unknown9F   ,
   /*A0*/   IK_LShift      ,IK_RShift      ,IK_LControl    ,IK_RControl    ,
   /*A4*/   IK_UnknownA4   ,IK_UnknownA5   ,IK_UnknownA6   ,IK_UnknownA7   ,
   /*A8*/   IK_UnknownA8   ,IK_UnknownA9   ,IK_UnknownAA   ,IK_UnknownAB   ,
   /*AC*/   IK_UnknownAC   ,IK_UnknownAD   ,IK_UnknownAE   ,IK_UnknownAF   ,
   /*B0*/   IK_UnknownB0   ,IK_UnknownB1   ,IK_UnknownB2   ,IK_UnknownB3   ,
   /*B4*/   IK_UnknownB4   ,IK_UnknownB5   ,IK_UnknownB6   ,IK_UnknownB7   ,
   /*B8*/   IK_UnknownB8   ,IK_UnknownB9   ,IK_Semicolon   ,IK_Equals      ,
   /*BC*/   IK_Comma      ,IK_Minus      ,IK_Period      ,IK_Slash      ,
   /*C0*/   IK_Tilde      ,IK_UnknownC1   ,IK_UnknownC2   ,IK_UnknownC3   ,
   /*C4*/   IK_UnknownC4   ,IK_UnknownC5   ,IK_UnknownC6   ,IK_UnknownC7   ,
   /*C8*/   IK_Joy1           ,IK_Joy2       ,IK_Joy3       ,IK_Joy4       ,
   /*CC*/   IK_Joy5           ,IK_Joy6       ,IK_Joy7       ,IK_Joy8       ,
   /*D0*/   IK_Joy9           ,IK_Joy10       ,IK_Joy11       ,IK_Joy12      ,
   /*D4*/   IK_Joy13      ,IK_Joy14       ,IK_Joy15       ,IK_Joy16       ,
   /*D8*/   IK_UnknownD8   ,IK_UnknownD9   ,IK_UnknownDA   ,IK_LeftBracket   ,
   /*DC*/   IK_Backslash   ,IK_RightBracket,IK_SingleQuote   ,IK_UnknownDF   ,
   /*E0*/  IK_JoyX         ,IK_JoyY      ,IK_JoyZ      ,IK_JoyR      ,
   /*E4*/   IK_MouseX      ,IK_MouseY      ,IK_MouseZ      ,IK_MouseW      ,
   /*E8*/   IK_JoyU         ,IK_JoyV      ,IK_UnknownEA   ,IK_UnknownEB   ,
   /*EC*/   IK_MouseWheelUp ,IK_MouseWheelDown,IK_Unknown10E,UK_Unknown10F  ,
   /*F0*/   IK_JoyPovUp     ,IK_JoyPovDown   ,IK_JoyPovLeft   ,IK_JoyPovRight   ,
   /*F4*/   IK_UnknownF4   ,IK_UnknownF5   ,IK_Attn      ,IK_CrSel      ,
   /*F8*/   IK_ExSel      ,IK_ErEof      ,IK_Play      ,IK_Zoom      ,
   /*FC*/   IK_NoName      ,IK_PA1         ,IK_OEMClear
};

and through "user.ini" or "DefUser.ini" (the default User settings template, edits here will reflect on all future "reset to default" attempts), functions are bound to keys. The following is an example "DefUser.ini" with additional non-default button commands added for an example:

Code: Select all

[DefaultPlayer]
Name=Player
Class=UnrealI.FemaleOne

[Engine.Input]
Aliases[0]=(Command="Button bFire | Fire",Alias=Fire)
Aliases[1]=(Command="Button bAltFire | AltFire",Alias=AltFire)
Aliases[2]=(Command="Axis aBaseY  Speed=+300.0",Alias=MoveForward)
Aliases[3]=(Command="Axis aBaseY  Speed=-300.0",Alias=MoveBackward)
Aliases[4]=(Command="Axis aBaseX Speed=-150.0",Alias=TurnLeft)
Aliases[5]=(Command="Axis aBaseX  Speed=+150.0",Alias=TurnRight)
Aliases[6]=(Command="Axis aStrafe Speed=-300.0",Alias=StrafeLeft)
Aliases[7]=(Command="Axis aStrafe Speed=+300.0",Alias=StrafeRight)
Aliases[8]=(Command="Jump | Axis aUp Speed=+300.0",Alias=Jump)
Aliases[9]=(Command="Button bDuck | Axis aUp Speed=-300.0",Alias=Duck)
Aliases[10]=(Command="Button bLook",Alias=Look)
Aliases[11]=(Command="Toggle bLook",Alias=LookToggle)
Aliases[12]=(Command="ActivateItem",Alias=InventoryActivate)
Aliases[13]=(Command="NextItem",Alias=InventoryNext)
Aliases[14]=(Command="PrevItem",Alias=InventoryPrevious)
Aliases[15]=(Command="Axis aLookUp Speed=+100.0",Alias=LookUp)
Aliases[16]=(Command="Axis aLookUp Speed=-100.0",Alias=LookDown)
Aliases[17]=(Command="Button bSnapLevel",Alias=CenterView)
Aliases[18]=(Command="Button bRun",Alias=Walking)
Aliases[19]=(Command="Button bStrafe",Alias=Strafe)
Aliases[20]=(Command="NextWeapon",Alias=NextWeapon)
Aliases[21]=(Command="ActivateTranslator",Alias=ActivateTranslator)
Aliases[22]=(Command="ActivateHint",Alias=ActivateHint)
Aliases[23]=(Command="Button bFreeLook",Alias=FreeLook)
Aliases[24]=(Command="ShowTeamStatus",Alias=Orders)
Aliases[25]=(Command="Button bCommandOne | CommandOne",Alias=CommandOne)
Aliases[26]=(Command="",Alias=None)
Aliases[27]=(Command="",Alias=None)
Aliases[28]=(Command="",Alias=None)
Aliases[29]=(Command="",Alias=None)
Aliases[30]=(Command="",Alias=None)
Aliases[31]=(Command="",Alias=None)
Aliases[32]=(Command="",Alias=None)
Aliases[33]=(Command="",Alias=None)
Aliases[34]=(Command="",Alias=None)
Aliases[35]=(Command="",Alias=None)
Aliases[36]=(Command="",Alias=None)
Aliases[37]=(Command="",Alias=None)
Aliases[38]=(Command="",Alias=None)
Aliases[39]=(Command="",Alias=None)
LeftMouse=Fire
RightMouse=AltFire
MiddleMouse=MoveForward
Tab=Type
Enter=InventoryActivate
Shift=Duck
Ctrl=Fire
Alt=AltFire
Pause=Pause
CapsLock=LookToggle
Escape=ShowMenu
Space=Jump
PageDown=LookDown
End=CenterView
Left=TurnLeft
Up=MoveForward
Right=TurnRight
Down=MoveBackward
Insert=FreeLook
Delete=LookUp
0=SwitchWeapon 10
1=SwitchWeapon 1
2=SwitchWeapon 2
3=SwitchWeapon 3
4=SwitchWeapon 4
5=SwitchWeapon 5
6=SwitchWeapon 6
7=SwitchWeapon 7
8=SwitchWeapon 8
9=SwitchWeapon 9
C=Duck
G=Grab
L=Taunt wave
M=Look
O=Toggle bExtra0
S=MoveBackward
T=Talk
Z=Strafe
F1=ShowScores
F2=ActivateTranslator | FunctionKey 2
F3=ActivateHint | FunctionKey 3
F4=Help | FunctionKey 4
F5=ChangeHud
F6=QuickSave
F7=QuickLoad
F8=Orders
F9=Shot
F10=Cancel
F11=Brightness
F12=EndFullscreen
Equals=ViewUp
Comma=StrafeLeft
Minus=ViewDown
Period=StrafeRight
Slash=NextWeapon
LeftBracket=InventoryPrevious
Backslash=ChangeHud
RightBracket=InventoryNext
MouseX=Axis aMouseX Speed=6.0
MouseY=Axis aMouseY Speed=6.0
MouseW=
None=
Cancel=
Backspace=
PageUp=
home=
Select=
Print=
Execute=
PrintScrn=
Help=
A=StrafeLeft
B=
D=StrafeRight
E=
f=Feigndeath
H=UShowMusicMenu
i=UShowAdminMenu
j=Taunt Taunt1
K=Taunt Victory1
P=
Q=
R=TeamTalk
U=
V=ShowSpeech
W=MoveForward
X=
NumPad0=Jump
NumPad1=
NumPad2=
NumPad3=
NumPad4=StrafeLeft
NumPad5=MoveBackward
NumPad6=StrafeRight
NumPad7=TurnLeft
NumPad8=MoveForward
NumPad9=TurnRight
GreyStar=
GreyPlus=NextWeapon
Separator=
GreyMinus=PrevWeapon
NumPadPeriod=Duck
GreySlash=
F13=
F14=
F15=
F16=
F17=
F18=
F19=
F20=
F21=
F22=
F23=
F24=
NumLock=
ScrollLock=showmenu
LShift=
RShift=
LControl=
RControl=
Semicolon=ThrowWeapon
Tilde=
SingleQuote=Strafe
Attn=
CrSel=
ExSel=
ErEof=
Play=
Zoom=
NoName=
PA1=
OemClear=
MouseZ=
MouseWheelDown=NextWeapon
MouseWheelUp=PrevWeapon
Joy1=Fire
Joy2=Jump
Joy3=AltFire
Joy4=Duck
Joy5=NextWeapon
Joy6=SwitchWeapon 2
Joy7=SwitchWeapon 3
Joy8=SwitchWeapon 4
Joy9=SwitchWeapon 9
Joy10=SwitchWeapon 0
Joy11=InventoryPrevious
Joy12=InventoryActivate
Joy13=InventoryNext
Joy14=
Joy15=
Joy16=
JoyX=Axis astrafe speed=2
JoyY=Axis aBaseY speed=2
JoyZ=
JoyR=
JoyU=Axis aturn speed=5.9
JoyV=Axis aLookUp speed=-3
JoyPovRight=SwitchWeapon 6
JoyPovLeft=SwitchWeapon 7
JoyPovUp=SwitchWeapon 8
JoyPovDown=SwitchWeapon 5

[Engine.PawnShadow]
ShadowDetailRes=128
ShadowScaling=1.000000


For this to get to the PlayerPawn, if said PlayerPawn has the functions to allow for interaction with certain keys, a ".int file" needs to be made to make the keys bindable within the game interface's "preferences -> controls". Name it the same as your ".u package" and you should be fine. Read the below included links on ".int files" for more information on how to use them. For visual example, include the following in the ".int file" you've made:

Code: Select all

[public]
Object=(Name="CommandOne",Class=Class,MetaClass=Engine.Input,Description="RPGuser,Command One")


So now player input can be bound to keys, and the example "CommandOne" gets to the player pawn as the playerpawn recognizes these "buttons" through code found in our custom example pawn's variable declarations:

Code: Select all

//=============================================================================
// CustomPlayerPawn.
//=============================================================================
class CustomPlayerPawn extends PlayerPawn
   config(Custom.ini_name_goes_here_with_no_spaces)
      abstract;

var(groupname) config input byte
bCommandOne;

event PostBeginPlay()
{
   SaveConfig(); // saves current config after spawning in all actors
   Super.PostBeginPlay();
}

calling functions via player input (an example would be bfire and how it operates with the Flak Cannon). For example:

Code: Select all

exec function CommandOne( optional float F )
{
   Jump();
}


Also here are some interesting stats people should know about for player input:
aMouseX: tracking mouse x-axis movement
aMouseY: tracking mouse y-axis movement
aBaseX: tracking player x-axis movement
aBaseY: tracking player y-axis movement
aTurn: [INFORMATION NEEDED]
aLookUp: tracking player looking up or down, based on "+-" values.
aForward: [INFORMATION NEEDED]

> Sources:
INI File
http://wiki.beyondunreal.com/Legacy:INI_File
Config Vars and .Ini Files
http://wiki.beyondunreal.com/Legacy:Config_Vars_And_.Ini_Files
Game Ini File
http://wiki.beyondunreal.com/Legacy:Game_Ini_File
.Int File
https://web.archive.org/web/20150608232526/http://wiki.beyondunreal.com/Legacy:INT_File
Create an .Int File
https://web.archive.org/web/20130820235713/http://wiki.beyondunreal.com/Legacy:Create_An_INT_File

> Also links to off-topic but interesting reads on binding to controllers. This is more for myself, but I thought I would share the information:

UT99 With a PS3 Controller?
https://ut99.org/viewtopic.php?f=12&t=1588
"split-screen" in Unreal Engine 1 games
https://ut99.org/viewtopic.php?f=6&t=2707


EDIT:
Overriding functions can be a work around to add new controls. For instance, I wanted to make a new command key for the player. So instead of making a new command, the Fire() function can be overridden to use the code in function UseHotkeyOne(), which for me would write to log and play a beep.

Code: Select all

exec function Fire( optional float f)
{
    CommandOne();
}


Code: Select all

exec function CommandOne( optional float F )
{
   log("Using command one. . .");
   bUsedCommandOne = true;
   if ( bShowMenu || Len(Level.Pauser)>0 )
      return;
   else
   {
      log("Command one used!");
      self.PlaySound ( Sound'RPG_Test.RPG_HaloCount');
   }
}
Last edited by LannFyre on 04 Dec 2015, 14:12, edited 4 times in total.
way2goslugger

User avatar []KAOS[]Casey
Skaarj Berserker Skaarj Berserker
Posts: 425
Joined: 25 Sep 2008, 07:25

Subject: Re: Question: Custom Pawn, Custom .INI Help?

Post Posted: 02 Aug 2015, 04:09

LannFyre wrote:Someone posted a reply on oldunreal--

Image

User avatar AlCapowned
Skaarj Warlord Skaarj Warlord
Posts: 882
Joined: 19 Dec 2009, 22:25

Subject: Re: Question: Custom Pawn, Custom .INI Help?

Post Posted: 02 Aug 2015, 05:59

When half your replies are "let me Google that for you" and irrelevant images, it's no wonder that he would ask for help somewhere else. :rolleyes:

It's more than possible to be helpful without being so condescending. If that's such a problem for you, you might want to consider not posting.

User avatar LannFyre
Skaarj Scout Skaarj Scout
Posts: 31
Joined: 29 Dec 2014, 02:55

Subject: Re: Question: How to make new controls

Post Posted: 11 Aug 2015, 06:07

Okay so now the .ini and .int issues have mostly been resolved. However the OP has now changed to "how do I make new controls?" The .int and .ini files have been written, config input byte variables have been inserted into the RPG_PlatformPawn actor, and there is a custom game type written to spawn the custom pawn.

How do I:
1) Make key aliases such as

Code: Select all

Aliases[10]=(Command="Button bLook",Alias="Look")

show up in my .ini or .int file? I need something like this:

Code: Select all

Aliases[x]=(Command="Button bCommandOne",Alias="Command One")
Aliases[x]=(Command="Button bHotkeyOne",Alias="Hotkey One")
Aliases[x]=(Command="Button bHotkeyTwo",Alias="Hotkey Two")

2) Make three more boxes such as the one shown in the OP screenshot appear under "preferences -> controls"?
way2goslugger

Taidef1972
Pupae Pupae
Posts: 1
Joined: 10 Aug 2015, 07:29

Subject: Re: Question: Custom Pawn, Custom .INI Help?

Post Posted: 22 Aug 2015, 09:18

AlCapowned wrote:When half your replies are "let me Google that for you" and irrelevant images, it's no wonder that he would ask for help somewhere else. :rolleyes:

It's more than possible to be helpful without being so condescending. If that's such a problem for you, you might want to consider not posting.


I could not understand that why you are writing this that getting help from google is means we are not eligible to find what you are asking? In my experience we do search for each and everything on Google for sure. Don't you?

User avatar AlCapowned
Skaarj Warlord Skaarj Warlord
Posts: 882
Joined: 19 Dec 2009, 22:25

Subject: Re: Question: How to make new controls

Post Posted: 22 Aug 2015, 09:35

I don't think I understand what you're saying. Of course I use Google. And when I don't understand something or can't find something, I ask about it here with the expectation that even if I missed the obvious, I'm not going to get a condescending response. Most of the people here are really good about that.

User avatar LannFyre
Skaarj Scout Skaarj Scout
Posts: 31
Joined: 29 Dec 2014, 02:55

Subject: Re: [GUIDE] How to make new controls

Post Posted: 04 Dec 2015, 14:14

EDIT:

I'm bumping this topic because it has been solved. Also the below is my original post I deleted to insert this edit/bump.

Higor suggested an alternative: just override functions. For instance, I wanted to make a hotkey command for the player. So instead of making a new command, the Fire() function can be overridden to use the code in function UseHotkeyOne(), which for me would write to log and play a beep.

Code: Select all

exec function Fire( optional float f)
{
    UseHotkeyOne();
}


Code: Select all

exec function UseHotkeyOne( optional float F )
{
   log("Using hotkey one. . .");
   bUsedHotkeyOne = true;
   if ( bShowMenu || Len(Level.Pauser)>0 )
      return;
   else
   {
      log("Hotkey one used!");
      self.PlaySound ( Sound'RPG_Test.RPG_HaloCount');
   }
}
way2goslugger

User avatar FXANBSS
Skaarj Assassin Skaarj Assassin
Posts: 135
Joined: 11 Oct 2013, 16:26
Location: EXU3-CA-AtAa0X

Subject: Re: [GUIDE] How to make new controls

Post Posted: 04 Dec 2015, 20:15

I don't know if this is true but maybe...

aTurn: tracking player looking right or left.
aForward: It balances the camera, if you climb stairs, the camera adjusts, you can remove the mode by moving the camera up or down.
You're just expecting confusion.


Who is online

Users browsing this forum: No registered users and 4 guests