Patch 2.2 compatibility: ? I don't know if the mod will require to be updated, but core frameworks (CET) will In the past, the first CET updates for a new patch have been prone to be not stable and missing important features used by mods, thus I recommend waiting until all core frameworks have been fully updated.
Can you post the keybinding names you used for the entire controller because yours are different from the official ones? I'd specifically like to bind it to R3 and I think this would help a lot of people out.
I created my own solution by mounting it to dpad_right and setting a threshold so that the flashlight toggles on button presses, but doesn't toggle when holding it so it doesn't interfere with you summoning your car. It doesn't seem to toggle while in menus either when just pressed. Here's the updated code for the init file! Hope this helps!
function flashlight:new() registerForEvent("onInit", function() self.archiveInstalled = ModArchiveExists("flashlight.archive") if not self.archiveInstalled then print("[Flashlight] Error: \"flashlight.archive\" file could not be found inside \"archive/pc/mod\". Mod has been disabled to avoid crashes.") return end
Observe("PlayerPuppet", "OnAction", function(_, action) if not self.settings.controllerMode or self.logic.callState == questPhoneCallPhase.IncomingCall or not (self.runtimeData.inGame and not self.runtimeData.inMenu) then return end
local actionName = Game.NameToString(action:GetName(action)) local actionType = action:GetType(action).value
if actionName == "dpad_right" and not self.runtimeData.inputUsed then if actionType == "BUTTON_PRESSED" then self.runtimeData.holding = false -- Reset holding status on press self.Cron.After(0.2, function() if not self.runtimeData.holding then -- Only toggle if NOT held self.runtimeData.inputUsed = true self.logic.toggle(flashlight) self.Cron.NextTick(function() self.runtimeData.inputUsed = false end) end end) elseif actionType == "BUTTON_HOLD_PROGRESS" then self.runtimeData.holding = true -- Mark as holding to prevent toggling elseif actionType == "BUTTON_RELEASED" then self.runtimeData.holding = false -- Ensure reset on release end end end)
self.runtimeData.inGame = not self.GameUI.IsDetached() end)
registerForEvent("onShutdown", function () self.logic.despawn() end)
registerForEvent("onUpdate", function (deltaTime) if not self.archiveInstalled then return end
if self.runtimeData.inGame and not self.runtimeData.inMenu then self.Cron.Update(deltaTime) self.logic.run(self) end end)
registerInput("flashLightToggleIn", "Toggle Flashlight", function(down) if not self.archiveInstalled then return end
if down then if self.runtimeData.inGame and not self.runtimeData.inMenu then self.logic.toggle(flashlight) end end end)
Seriously, this has been bugging me for such a long time but only just thought to check the posts here. All I wanted was not to be turning my radio on all the time. Preem, thanks choom.
Just go into the init file and change "dpad_left" to whatever controller button config you want. I changed mine to dpad_up just so it's still quick to get to.
I find one solution that works well by far: 1. Define the action: Open Cyberpunk>>2077>>r6>>config>>inputContexts.xml (Remember to backup),find <context name="Locomotion" >, and add one line above </context>: <action name="Flash"map="Flash"priority="-1" /> Then find <!-- HOLD ACTIONS --> and add this: <hold action="Flash"timeout="0.5" /> Then find <!-- EVENTS --> and add this line <acceptedEvents action="Flash" > <event name="BUTTON_PRESSED" /> <event name="BUTTON_RELEASED" /> <event name="BUTTON_HOLD_PROGRESS" /> <event name="BUTTON_HOLD_COMPLETE" /> </acceptedEvents> Just make what you add be like the original ones. 2. Binding: Open inputUserMappings.xml in the same folder, add this: <mapping name="Flash" type="Button" SIEJADependent="true" > <button id="IK_Pad_RightThumb"/> </mapping> It seems work well no matter where you put it, to make sure, you can put it below the entry of "dpad_left". You can try any other button you want (check the other entries, like "IK_PAD_LR_THUMB"), but "IK_Pad_RightThumb" seems good enough for me. 3. Modify the mod: Open Cyberpunk 2077>>bin>>x64>>plugins>>cyber_engine_tweaks>>mods>>flashlight>>init.lua, change "dpad_left" into "Flash". 4. Done It will only function in the normal context, which means you won't turn on the flashlight while driving. Hope this useful :>
@lyff2333, Thank you sooooo much for the tip and subsequent eureka moment on my end ! See, I've unsuccessfully been trying to figure out how to achieve that a while back without ever understanding the proper way to make it work in an input loader .xml file and I have been hoping for months a proper update to customize controller keybind(s) would come but your tip is what I needed, along with so many others, so Kudos to you dear fellow player ! :)
So, to anyone interested in using InputLoader instead of editing vanilla inputUserContexts and inputUserMappings files, here are my SimpleFlashlight.xml file (to be placed in r6\input\ - with Input Loader installed, of course) contents :
Of course, it also requires editing Simple Flashlight's init.lua to use "Flashlight" instead of "Flash" but that's just my choice, as long as they match in both files, use whatever name you want. Finally, completely optional but for sake of completeness, I also edit the SettingsUI.lua descriptive text to reflect the chosen keybind/combo in the NativeSettingsUI side tip when hovering on the Controller Support toggle entry.
Thank you veeery much once again ! :)
PS: I got rid of the SIEJADependent="true" part as I've never seen it used in any mod and it doesn't seem to be required at all. (Never been able to find what it stands for either tbh)
I couldnt get your way to work. When I do my game crashes and I notice when I start the game and it says to press a button to continue....that button is not display and when I press any button on my controller it crashes. Using PS5 controller. If I remember correct it is asking me to press the game pad which is mapped to "_" or at least that is what it looks like on screen.
But everyway when I try and edit all those files it just doesnt work and I cant figure out why.
EDIT: Found what was causing it. This line "priority="-1". Once I removed that the mod loads and works when I press in on the right thumbstick for a second. Not sure what the priority line does but it seems to break something with all my other mods I assume.
@Jmolinares03, sorry I didn't explain well (if at all) initially. It refers to Lyff2333's instructions, step 3 : Simple Flashlight's original init.lua has a part where it makes the mod listen to a vanilla "action name" : "dpad_left" (at line 94)
But since we introduce a new "action name", be it "Flash" (like Lyff2333 chose), "Flashlight" (like I chose) or whatever we choose to name it (basically anything other than a vanilla action name), we need to reflect that in the init.lua by replacing "dpad_left" with "Flashlight" or whatever that "action name" we introduced is.
Hope this makes sense to you and you can make it work :)
The left joystick press does nothing by default in the game, this is the best binding for it if you want a controller binding that otherwise does nothing and has its own unique button press.
I tried changing it in the init file but all that seemed to do is disable the radio while on foot. Now the menu doesn't even come up for the radio. The little graph for the radio button on the UI is red and the left d-pad only operates the flashlight while on foot, which is still fine for me. (It does still also skip conversations but will turn the flashlight on and off if you use it during a conversation also). If anyone has a correctly modified init file they could simply upload it so we can replace it with ours.
If you want to use the key combination, you need to change step two to this: <mapping name="Flash" type="Button" SIEJADependent="true" > <button id="Flashlight" /> </mapping> <buttonGroup id="Flashlight" timeWindow="0.1f" > <button id="IK_Pad_LeftThumb" /> <button id="IK_Pad_B_CIRCLE" /> </buttonGroup>
You can freely combine keys, but not every combination is useful.
just a quick note, renaming the archive file disables the mod (at least for me). Strange, I've never had a mod stop working by putting a number in front of it's original file name, but sure enough, flashlight will only work for me if I leave the archive file name unchanged. :)
Can you please elaborate?? Recently there have been a lot of issues with this mod along with other mods that use the config.json file like night vision, sit anywhere, etc.
works great, but how do i disable controller dpad. it comes on when skipping dialogue. i have controller with extra buttons and mapped it to keyboard which works great for me. just want disable dpad button.
Awesome mod, it's so dark in some places especially with RT+PT so this mod is a must have and it also adds to the immersive because i mean....who does NOT have a flashlight in a world like this when out shooting people and doing spy work ;)
740 comments
I don't know if the mod will require to be updated, but core frameworks (CET) will
In the past, the first CET updates for a new patch have been prone to be not stable and missing important features used by mods, thus I recommend waiting until all core frameworks have been fully updated.
local flashlight = {
runtimeData = {
inMenu = false,
inGame = false,
holding = false,
cetOpen = false,
inputUsed = false
},
defaultSettings = {
fadeTime = 0.15,
offset = 0.3,
brightness = 20,
angle = 40,
falloff = 10,
range = 100,
color = 2,
red = 255,
green = 255,
blue = 255,
controllerMode = true
},
settings = {},
config = require("modules/utils/config"),
settingsUI = require("modules/settingsUI"),
logic = require("modules/logic"),
Cron = require("modules/external/Cron"),
GameUI = require("modules/external/GameUI")
}
function flashlight:new()
registerForEvent("onInit", function()
self.archiveInstalled = ModArchiveExists("flashlight.archive")
if not self.archiveInstalled then
print("[Flashlight] Error: \"flashlight.archive\" file could not be found inside \"archive/pc/mod\". Mod has been disabled to avoid crashes.")
return
end
self.config.tryCreateConfig("config.json", self.defaultSettings)
self.config.backwardComp("config.json", self.defaultSettings)
self.settings = self.config.loadFile("config.json")
self.logic.initColors()
self.settingsUI.setupNative(self)
self.logic.addObserver(flashlight)
self.logic.callState = questPhoneCallPhase.Undefined
Observe("RadialWheelController", "OnIsInMenuChanged", function(_, isInMenu)
self.runtimeData.inMenu = isInMenu
end)
self.GameUI.OnSessionStart(function()
self.runtimeData.inGame = true
self.logic.initColors()
end)
self.GameUI.OnSessionEnd(function()
self.runtimeData.inGame = false
self.logic.despawn()
self.logic.active = false
end)
self.GameUI.OnPhotoModeOpen(function()
self.runtimeData.inMenu = true
end)
self.GameUI.OnPhotoModeClose(function()
self.runtimeData.inMenu = false
end)
Observe("PlayerPuppet", "OnGameAttached", function(this)
this:RegisterInputListener(this)
end)
Observe("PlayerPuppet", "OnAction", function(_, action)
if not self.settings.controllerMode or self.logic.callState == questPhoneCallPhase.IncomingCall
or not (self.runtimeData.inGame and not self.runtimeData.inMenu) then return end
local actionName = Game.NameToString(action:GetName(action))
local actionType = action:GetType(action).value
if actionName == "dpad_right" and not self.runtimeData.inputUsed then
if actionType == "BUTTON_PRESSED" then
self.runtimeData.holding = false -- Reset holding status on press
self.Cron.After(0.2, function()
if not self.runtimeData.holding then -- Only toggle if NOT held
self.runtimeData.inputUsed = true
self.logic.toggle(flashlight)
self.Cron.NextTick(function()
self.runtimeData.inputUsed = false
end)
end
end)
elseif actionType == "BUTTON_HOLD_PROGRESS" then
self.runtimeData.holding = true -- Mark as holding to prevent toggling
elseif actionType == "BUTTON_RELEASED" then
self.runtimeData.holding = false -- Ensure reset on release
end
end
end)
self.runtimeData.inGame = not self.GameUI.IsDetached()
end)
registerForEvent("onShutdown", function ()
self.logic.despawn()
end)
registerForEvent("onUpdate", function (deltaTime)
if not self.archiveInstalled then return end
if self.runtimeData.inGame and not self.runtimeData.inMenu then
self.Cron.Update(deltaTime)
self.logic.run(self)
end
end)
registerInput("flashLightToggleIn", "Toggle Flashlight", function(down)
if not self.archiveInstalled then return end
if down then
if self.runtimeData.inGame and not self.runtimeData.inMenu then
self.logic.toggle(flashlight)
end
end
end)
return self
end
return flashlight:new()
Seriously, this has been bugging me for such a long time but only just thought to check the posts here. All I wanted was not to be turning my radio on all the time. Preem, thanks choom.
NexusGuy999 please try to make this possible.
If you do this, you will get a definitive edition. that is sure
1. Define the action:
Open Cyberpunk>>2077>>r6>>config>>inputContexts.xml (Remember to backup),find <context name="Locomotion" >, and add one line above </context>:
<action name="Flash"map="Flash"priority="-1" />
Then find <!-- HOLD ACTIONS --> and add this:<hold action="Flash"timeout="0.5" />
Then find <!-- EVENTS --> and add this line<acceptedEvents action="Flash" >
Just make what you add be like the original ones.<event name="BUTTON_PRESSED" />
<event name="BUTTON_RELEASED" />
<event name="BUTTON_HOLD_PROGRESS" />
<event name="BUTTON_HOLD_COMPLETE" />
</acceptedEvents>
2. Binding:
Open inputUserMappings.xml in the same folder, add this:
<mapping name="Flash" type="Button" SIEJADependent="true" >
It seems work well no matter where you put it, to make sure, you can put it below the entry of "dpad_left".<button id="IK_Pad_RightThumb"/>
</mapping>
You can try any other button you want (check the other entries, like "IK_PAD_LR_THUMB"), but "IK_Pad_RightThumb" seems good enough for me.
3. Modify the mod:
Open Cyberpunk 2077>>bin>>x64>>plugins>>cyber_engine_tweaks>>mods>>flashlight>>init.lua, change "dpad_left" into "Flash".
4. Done
It will only function in the normal context, which means you won't turn on the flashlight while driving. Hope this useful :>
See, I've unsuccessfully been trying to figure out how to achieve that a while back without ever understanding the proper way to make it work in an input loader .xml file and I have been hoping for months a proper update to customize controller keybind(s) would come but your tip is what I needed, along with so many others, so Kudos to you dear fellow player ! :)
So, to anyone interested in using InputLoader instead of editing vanilla inputUserContexts and inputUserMappings files, here are my SimpleFlashlight.xml file (to be placed in r6\input\ - with Input Loader installed, of course) contents :
<?xml version="1.0"?>
<bindings>
<!-- inputContexts -->
<context name="Flashlight" >
<action name="Flashlight" map="Flashlight" priority="-1" />
</context>
<context name="Locomotion" append="true">
<include name="Flashlight" />
</context>
<hold action="Flashlight" timeout="0.3" />
<acceptedEvents action="Flashlight" >
<event name="BUTTON_PRESSED" />
<event name="BUTTON_RELEASED" />
<event name="BUTTON_HOLD_PROGRESS" />
<event name="BUTTON_HOLD_COMPLETE" />
</acceptedEvents>
<!-- inputUserMapping -->
<mapping name="Flashlight" type="Button" >
<button id="IK_Pad_DigitRightDown"/>
</mapping>
<!-- Flashlight Gamepad Combo -->
<buttonGroup id="IK_Pad_DigitRightDown" timeWindow="0.08f" >
<button id="IK_Pad_DigitRight" />
<button id="IK_Pad_DigitDown" />
</buttonGroup>
</bindings>
Of course, it also requires editing Simple Flashlight's init.lua to use "Flashlight" instead of "Flash" but that's just my choice, as long as they match in both files, use whatever name you want.
Finally, completely optional but for sake of completeness, I also edit the SettingsUI.lua descriptive text to reflect the chosen keybind/combo in the NativeSettingsUI side tip when hovering on the Controller Support toggle entry.
Thank you veeery much once again ! :)
PS: I got rid of the SIEJADependent="true" part as I've never seen it used in any mod and it doesn't seem to be required at all.
(Never been able to find what it stands for either tbh)
For the PS issue: just some lazy guy tired of testing, never mind XD
I couldnt get your way to work. When I do my game crashes and I notice when I start the game and it says to press a button to continue....that button is not display and when I press any button on my controller it crashes. Using PS5 controller. If I remember correct it is asking me to press the game pad which is mapped to "_" or at least that is what it looks like on screen.
But everyway when I try and edit all those files it just doesnt work and I cant figure out why.
EDIT: Found what was causing it. This line "priority="-1". Once I removed that the mod loads and works when I press in on the right thumbstick for a second. Not sure what the priority line does but it seems to break something with all my other mods I assume.
could you explain me better pls, or upload this configurations files in your account. thanks
Simple Flashlight's original init.lua has a part where it makes the mod listen to a vanilla "action name" : "dpad_left" (at line 94)
But since we introduce a new "action name", be it "Flash" (like Lyff2333 chose), "Flashlight" (like I chose) or whatever we choose to name it (basically anything other than a vanilla action name), we need to reflect that in the init.lua by replacing "dpad_left" with "Flashlight" or whatever that "action name" we introduced is.
Hope this makes sense to you and you can make it work :)
Thank you!
Thanks!
Thanks man, i was wondering why my game will crash when using any control input. After deleting the priority -1 it works flawless
<mapping name="Flash" type="Button" SIEJADependent="true" >
You can freely combine keys, but not every combination is useful.<button id="Flashlight" />
</mapping>
<buttonGroup id="Flashlight" timeWindow="0.1f" >
<button id="IK_Pad_LeftThumb" />
<button id="IK_Pad_B_CIRCLE" />
</buttonGroup>
When you first open the .ini file, the highlighted text will read dpad_left. Change it to whatever you want, I just used dpad_up on mine.