Rotation on roll axis inverts pitch and yaw axis

I’m trying to make a character that is capable of 360 degrees of movement, basically as if gravity didn’t apply to them (which it won’t). I implemented the keys to change my roll input, and they properly work - they rotate the object depending on how long it is held, up to a point. The issue is, at this point, the x and y movements of my mouse are suddenly inverted, making it so the camera movement is completely unintuitive.

I think this is because when the roll rotates, it doesn’t properly change the other two axis to be relative to the new view. For example, if I rotate 90 degrees, it is suddenly perfectly inverted, as if the x and y movements were moving along the same axis that they were when the object was created.

My question is this: is it possible to make it so that the x and y rotation from mouse movements can be kept in sync with the roll, so that its always rotating properly? I can provide source code if needed, I’m not sure how this forum works quite yet.

Thanks in advance.