Skip to content

Commit

Permalink
custom steering handler
Browse files Browse the repository at this point in the history
  • Loading branch information
xan1242 committed Oct 2, 2022
1 parent feb1f07 commit 31f9857
Show file tree
Hide file tree
Showing 7 changed files with 245 additions and 400 deletions.
22 changes: 20 additions & 2 deletions Config-UG/EventReference.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,24 @@ Both ports are monitored for XInput separately, whereas on keyboard they're not

NOTE: some events (such as quitting with Q key or launching the tutorial video with LT) are hardcoded due to the way they're coded in the game

== STEER INPUT SPECIAL NOTES ==

Due to the buggy nature of the steer input handler, its code had to be rewritten.
This *only* affects regular races, as drag races use a different event.
This also enables higher resolution readout from the gamepad axis, as well as the ability to assign steering to both the analog axis and the digital buttons.

These are the special assignments available for steering input (gamepad):
SteerLeftButton -- you may only assign buttons to these, not analog axis
SteerRightButton
SteerLeftAxis -- you may only assign analog axis to these, not buttons
SteerRightAxis

These are the special assignments available for steering input (keyboard):
KeyboardSteerLeft
KeyboardSteerRight

== REGULAR EVENTS ==

JOY_EVENT_NULL
JOY_EVENT_TYPE_CHANGED
JOY_EVENT_EXIT_DEMO_DISC
Expand Down Expand Up @@ -200,8 +218,8 @@ JOY_EVENT_REPLAY_HIDE_TIMELINE
JOY_EVENT_REPLAY_MARK_DEMO
JOY_EVENT_REPLAY_TEST_DEMO
JOY_EVENT_REPLAY_ERASE_DEMO
JOY_EVENT_STEER -- you may only assign an analog axis or DPAD, nothing else
JOY_EVENT_STEER_ANALOG -- breaks right after using JOY_EVENT_STEER (JOY_EVENT_STEER is analog as well anyway)
JOY_EVENT_STEER -- steer input is NOT handled by the game code, therefore this event is not read
JOY_EVENT_STEER_ANALOG -- same as previous steer event - not handled by game code, not parsed
JOY_EVENT_THROTTLE
JOY_EVENT_THROTTLE_ANALOG
JOY_EVENT_THROTTLE_ANALOG_ALTERNATE
Expand Down
37 changes: 19 additions & 18 deletions Config-UG/NFSU_XtendedInput.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ControllerIconMode = 0 // 0 = Xbox, 1 = PlayStation 4 -- MAKE SURE TO DISABLE WI
FirstControlDevice = 0 // 0 = Keyboard, 1 = Controller -- for setting the first state

[Events]
// FE controls
; FE controls
JOY_EVENT_FENG_PAD_UP = XINPUT_GAMEPAD_DPAD_UP
JOY_EVENT_FENG_PAD_DOWN = XINPUT_GAMEPAD_DPAD_DOWN
JOY_EVENT_FENG_PAD_LEFT = XINPUT_GAMEPAD_DPAD_LEFT
Expand Down Expand Up @@ -55,15 +55,16 @@ JOY_EVENT_CARSEL_CHANGE_MODE = XINPUT_GAMEPAD_RT
JOY_EVENT_START = XINPUT_GAMEPAD_START
JOY_EVENT_SELECT = XINPUT_GAMEPAD_A
JOY_EVENT_SKIP = XINPUT_GAMEPAD_A
// In-Game controls
; In-Game controls
SteerLeftButton = 0
SteerRightButton = 0
SteerLeftAxis = XINPUT_GAMEPAD_LS_LEFT
SteerRightAxis = XINPUT_GAMEPAD_LS_RIGHT
JOY_EVENT_THROTTLE_ANALOG = XINPUT_GAMEPAD_RT
JOY_EVENT_BRAKE_ANALOG = XINPUT_GAMEPAD_LT
JOY_EVENT_STEER = XINPUT_GAMEPAD_LS_X
// commented out analog because it causes issues, when regular steer is activated, analog steering dies
//JOY_EVENT_STEER_ANALOG = XINPUT_GAMEPAD_LS_X
// horribly broken - goes full left or right...
//JOY_EVENT_DRAG_RACE_CHANGE_LANE_LEFT_ANALOG = XINPUT_GAMEPAD_LS_X
//JOY_EVENT_DRAG_RACE_CHANGE_LANE_RIGHT_ANALOG = XINPUT_GAMEPAD_LS_X
; horribly broken - goes full left or right...
;JOY_EVENT_DRAG_RACE_CHANGE_LANE_LEFT_ANALOG = XINPUT_GAMEPAD_LS_X
;JOY_EVENT_DRAG_RACE_CHANGE_LANE_RIGHT_ANALOG = XINPUT_GAMEPAD_LS_X
JOY_EVENT_DRAG_RACE_CHANGE_LANE_LEFT = XINPUT_GAMEPAD_LS_LEFT
JOY_EVENT_DRAG_RACE_CHANGE_LANE_RIGHT = XINPUT_GAMEPAD_LS_RIGHT
JOY_EVENT_SHIFTUP = XINPUT_GAMEPAD_RS_UP
Expand All @@ -74,13 +75,13 @@ JOY_EVENT_CAMERA_LOOKBACK = XINPUT_GAMEPAD_X
JOY_EVENT_CAMERA_POV_CHANGE = XINPUT_GAMEPAD_Y
JOY_EVENT_PAUSE = XINPUT_GAMEPAD_START
JOY_EVENT_RESET_CAR = XINPUT_GAMEPAD_BACK
// HP2 leftovers -- these all work
; HP2 leftovers -- these all work
JOY_EVENT_ZONE_PREVIEW = XINPUT_GAMEPAD_RIGHT_SHOULDER
JOY_EVENT_ZONE_FREEZE = XINPUT_GAMEPAD_LEFT_SHOULDER
JOY_EVENT_HONK_HORN = XINPUT_GAMEPAD_LEFT_THUMB
JOY_EVENT_CYCLE_HUD = XINPUT_GAMEPAD_DPAD_UP
JOY_EVENT_ZONE_SLOMO = XINPUT_GAMEPAD_DPAD_DOWN
// debug camera -- only on port 2
; debug camera -- only on port 2
JOY_EVENT_CHANGE_DEBUG_CAMERA = XINPUT_GAMEPAD_BACK
JOY_EVENT_DEBUG_CAMERA_DROP_CAR = XINPUT_GAMEPAD_START
JOY_EVENT_DEBUG_CAMERA_INOUT = XINPUT_GAMEPAD_LS_Y
Expand Down Expand Up @@ -112,7 +113,7 @@ JOY_EVENT_DEBUG_CAMERA_SLOW = XINPUT_GAMEPAD_LEFT_THUMB
JOY_EVENT_DEBUG_CAMERA_FORWARD_BLINK = XINPUT_GAMEPAD_DPAD_UP
JOY_EVENT_DEBUG_CAMERA_BACKWARD_BLINK = XINPUT_GAMEPAD_DPAD_DOWN
[EventsKB]
// FE controls
; FE controls
JOY_EVENT_FENG_PAD_UP = VK_UP
JOY_EVENT_FENG_PAD_DOWN = VK_DOWN
JOY_EVENT_FENG_PAD_LEFT = VK_LEFT
Expand All @@ -123,7 +124,7 @@ JOY_EVENT_FENG_BUTTON0 = G
JOY_EVENT_FENG_BUTTON1 = F
JOY_EVENT_FENG_BUTTON2 = 9
JOY_EVENT_FENG_BUTTON3 = 0
//JOY_EVENT_FENG_START = VK_ESCAPE
;JOY_EVENT_FENG_START = VK_ESCAPE
JOY_EVENT_FENG_HELP = H
JOY_EVENT_FENG_LTRIGGER = 9
JOY_EVENT_FENG_RTRIGGER = 0
Expand All @@ -136,13 +137,13 @@ JOY_EVENT_MENU_R1 = 0
JOY_EVENT_MENU_R2 = P
JOY_EVENT_MENU_SQUARE = Z
JOY_EVENT_CARSEL_UNLOCK = U
//JOY_EVENT_START = VK_ESCAPE
;JOY_EVENT_START = VK_ESCAPE
JOY_EVENT_SELECT = VK_RETURN
JOY_EVENT_CARSEL_ORBIT_UP = W
JOY_EVENT_CARSEL_ORBIT_DOWN = S
JOY_EVENT_CARSEL_ORBIT_RIGHT = A
JOY_EVENT_CARSEL_ORBIT_LEFT = D
// In-Game controls
; In-Game controls
KeyboardSteerLeft = VK_LEFT
KeyboardSteerRight = VK_RIGHT
JOY_EVENT_THROTTLE = VK_UP
Expand All @@ -158,13 +159,13 @@ JOY_EVENT_CAMERA_POV_CHANGE = C
JOY_EVENT_RESET_CAR = R
JOY_EVENT_DRAG_RACE_CHANGE_LANE_LEFT = VK_LEFT
JOY_EVENT_DRAG_RACE_CHANGE_LANE_RIGHT = VK_RIGHT
// HP2 leftovers -- these all work
; HP2 leftovers -- these all work
JOY_EVENT_ZONE_PREVIEW = VK_DELETE
JOY_EVENT_ZONE_FREEZE = VK_NEXT
JOY_EVENT_HONK_HORN = H
//JOY_EVENT_CYCLE_HUD = XINPUT_GAMEPAD_DPAD_UP
//JOY_EVENT_ZONE_SLOMO = XINPUT_GAMEPAD_DPAD_DOWN
// debug camera
;JOY_EVENT_CYCLE_HUD = XINPUT_GAMEPAD_DPAD_UP
;JOY_EVENT_ZONE_SLOMO = XINPUT_GAMEPAD_DPAD_DOWN
; debug camera
JOY_EVENT_CHANGE_DEBUG_CAMERA = M
JOY_EVENT_DEBUG_CAMERA_DROP_CAR = 5
JOY_EVENT_DEBUG_CAMERA_MOVE_FWD = W
Expand Down
24 changes: 21 additions & 3 deletions Config-UG2/EventReference.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,24 @@ Both ports are monitored for XInput separately, whereas on keyboard they're not

NOTE: some events (such as quitting with Q key) are hardcoded due to the way they're coded in the game

== STEER INPUT SPECIAL NOTES ==

Due to the buggy nature of the steer input handler, its code had to be rewritten.
This *only* affects regular races, as drag races use a different event.
This also enables higher resolution readout from the gamepad axis, as well as the ability to assign steering to both the analog axis and the digital buttons.

These are the special assignments available for steering input (gamepad):
SteerLeftButton -- you may only assign buttons to these, not analog axis
SteerRightButton
SteerLeftAxis -- you may only assign analog axis to these, not buttons
SteerRightAxis

These are the special assignments available for steering input (keyboard):
KeyboardSteerLeft
KeyboardSteerRight

== REGULAR EVENTS ==

JOY_EVENT_NULL
JOY_EVENT_TYPE_CHANGED
JOY_EVENT_LIVE_TYPE_CHANGED
Expand Down Expand Up @@ -202,8 +220,8 @@ JOY_EVENT_REPLAY_HIDE_TIMELINE
JOY_EVENT_REPLAY_MARK_DEMO
JOY_EVENT_REPLAY_TEST_DEMO
JOY_EVENT_REPLAY_ERASE_DEMO
JOY_EVENT_STEER -- you may only assign an analog axis or DPAD, nothing else
JOY_EVENT_STEER_ANALOG -- breaks right after using JOY_EVENT_STEER (JOY_EVENT_STEER is analog as well anyway)
JOY_EVENT_STEER -- steer input is NOT handled by the game code, therefore this event is not read
JOY_EVENT_STEER_ANALOG -- same as previous steer event - not handled by game code, not parsed
JOY_EVENT_THROTTLE
JOY_EVENT_THROTTLE_ANALOG
JOY_EVENT_THROTTLE_ANALOG_ALTERNATE
Expand Down Expand Up @@ -289,4 +307,4 @@ JOY_EVENT_CAMERA_EDITOR_BUBBLE_BACK_FORTH
JOY_EVENT_CAMERA_EDITOR_SHAKE_MAG
JOY_EVENT_CAMERA_EDITOR_SHAKE_FRQ
JOY_EVENT_CAMERA_EDITOR_SHUTTLE_LEFT_RIGHT
JOY_EVENT_CAMERA_EDITOR_SHUTTLE_SPEED
JOY_EVENT_CAMERA_EDITOR_SHUTTLE_SPEED
Loading

0 comments on commit 31f9857

Please sign in to comment.