Playing with XBOX controller

The place for all discussion of the Oculus Rift compatible open source 3D drivers.
Post Reply
User avatar
baggyg
Vireio Perception Developer
Vireio Perception Developer
Posts: 491
Joined: Sat May 19, 2012 5:20 am
Location: BB, Slovakia

Playing with XBOX controller

Post by baggyg »

Hi,

It is my understanding that Perception uses mouse emulation to to the head movement. Therefore the user must use the mouse plus keyboard for additional rotation and movement. I believe this would be far better if you could use a XBOX controller. Therefore would it be possible (maybe via freePIE) to script the Xbox to also emulate the mouse (and the left thumbstick to WASD). The triggers could be mapped to left / right mouse button.

Does anyone see any issues with this or can suggest a better way?

I.e.

mouse.deltaX = xbox360.LeftStickX
mouse.deltaY = -xbox360.LeftStickY
or
vireioSMT.yaw = xbox360.LeftStickX
vireioSMT.pitch = xbox360.LeftStickY

Obviously the above is not right but can someone confirm the concept is right and I can start working on this?
User avatar
cybereality
3D Angel Eyes (Moderator)
Posts: 11407
Joined: Sat Apr 12, 2008 8:18 pm

Re: Playing with XBOX controller

Post by cybereality »

Probably best to do this through FreePIE, unless you want to code joystick support into Vireio yourself. That would be awesome too.
User avatar
baggyg
Vireio Perception Developer
Vireio Perception Developer
Posts: 491
Joined: Sat May 19, 2012 5:20 am
Location: BB, Slovakia

Re: Playing with XBOX controller

Post by baggyg »

Im gonna get some working tests up and running in freePIE over the next couple of days and will post scripts here when happy with one. If it is useful enough I would like to get this into Perception as joystick emulation. Doing some work with my company at the moment with DirectX / DirectInput / XInput so in a good place to give it a go once I've confirmed I can get it working as I would like.
User avatar
baggyg
Vireio Perception Developer
Vireio Perception Developer
Posts: 491
Joined: Sat May 19, 2012 5:20 am
Location: BB, Slovakia

Re: Playing with XBOX controller

Post by baggyg »

For anyone who is interested here is a freePIE script that allows you to play Dear Esther with a controller (and tracking).
You can obviously adapt this as you please to fit in with your key bindings. I have separated the yaw and pitch multipliers since I prefer to have a slower pitch.

Code: Select all

def update():
		
	#LMouseClick  
	mouse.leftButton = xbox360.rightTrigger
	#RMouseClick  Zoom In 
	mouse.rightButton = xbox360.leftTrigger

	#Esc    Menu
	keyboard.setKey(Key.Escape, xbox360.start)
		
	#Q      Swim Up
	keyboard.setKey(Key.Q, xbox360.a)
	
	#F6      Quick Save
	keyboard.setKey(Key.F6, xbox360.leftShoulder)
	
	#F7      Quick Load
	keyboard.setKey(Key.F7, xbox360.rightShoulder)
	
	#Movement	
	keyboard.setKey(Key.A, xbox360.leftStickX < -0.2) #strafe-left
	keyboard.setKey(Key.S, xbox360.leftStickY < -0.2) #backward
	keyboard.setKey(Key.D, xbox360.leftStickX > 0.2) #strafe-right
	keyboard.setKey(Key.W, xbox360.leftStickY > 0.2) #forward	
	
	#MouseLook
	vireioSMT.yaw = (xbox360.rightStickX*g_yawSensitivityMultiplier)
	vireioSMT.pitch = (-xbox360.rightStickY*g_pitchSensitivityMultiplier)	
   
if starting:
	enabled = False
	global g_yawSensitivityMultiplier, g_pitchSensitivityMultiplier 
	g_yawSensitivityMultiplier = 1.5
	g_pitchSensitivityMultiplier = 1.3
	freeTrack.update += update
User avatar
baggyg
Vireio Perception Developer
Vireio Perception Developer
Posts: 491
Joined: Sat May 19, 2012 5:20 am
Location: BB, Slovakia

Re: Playing with XBOX controller

Post by baggyg »

And one for Skyrim (customise buttons as you see fit)
#The screens will obviously not show the bindings - you must learn these
#Skyrim is not a great example as there are far too many buttons (controller mode doubles up on these depending on the context). A standard fps would be far easier to do. Feel free to adapt as you see fit. Ive not played a lot of Skyrim so wasnt wholly sure what could be left out.

Code: Select all

def update():
		
	#LMouseClick  Attack with weapon or cast spell in right hand (primary hand maps to primary mouse)
	mouse.leftButton = xbox360.rightTrigger
	#RMouseClick  Attack with weapon or cast spell in left hand / Block if available
	mouse.rightButton = xbox360.leftTrigger

	#E      Activate/use/hold to manipulate objects
	keyboard.setKey(Key.E, xbox360.x)
	
	#Alt    Sprint
	keyboard.setKey(Key.LeftAlt, xbox360.rightShoulder)
	
	#Shift  Walk (slower and quieter than default movement)
	keyboard.setKey(Key.LeftShift, xbox360.b)
	
	#Space  Jump
	keyboard.setKey(Key.Space, xbox360.a)
	
	#Ctrl   Crouch/sneak mode
	keyboard.setKey(Key.LeftControl, xbox360.leftShoulder)
	
	#R      Ready/sheathe weapon	
	keyboard.setKey(Key.R, xbox360.leftThumb)
	
	#F      Change views (1st and 3rd person)
	keyboard.setKey(Key.F, xbox360.y)
	
	#Tab    Character Menu
	keyboard.setKey(Key.Tab, xbox360.back)
	
	#Esc    Menu
	keyboard.setKey(Key.Escape, xbox360.start)
		
	#J      Open journal
	keyboard.setKey(Key.J, xbox360.rightThumb)
	
	#P      Magic menu
	keyboard.setKey(Key.P, xbox360.up)
	
	#M      Map	
	keyboard.setKey(Key.M, xbox360.left)
	
	#I      inventory
	keyboard.setKey(Key.I, xbox360.down)
	
	#T      Wait		
	keyboard.setKey(Key.T, xbox360.right)
	
	#Q      Favorites - not supported
	#C      Toggle Automove / Zoom item in inventory - not supported
	#/      Perk menu - not supported
	#Z      Racial power/Dragon shout - not supported
	#Mwheel  Scroll in menus or zoom while in 3rd person - not supported
	#1-8    Hotkeys (no numpad) - Not supported
	#`      Open/close the console (~ key) - not supported
	
	#Movement	
	keyboard.setKey(Key.A, xbox360.leftStickX < -0.2) #strafe-left
	keyboard.setKey(Key.S, xbox360.leftStickY < -0.2) #backward
	keyboard.setKey(Key.D, xbox360.leftStickX > 0.2) #strafe-right
	keyboard.setKey(Key.W, xbox360.leftStickY > 0.2) #forward	
	
	#MouseLook
	vireioSMT.yaw = (xbox360.rightStickX*g_yawSensitivityMultiplier)
	vireioSMT.pitch = (-xbox360.rightStickY*g_pitchSensitivityMultiplier)	
   
if starting:
	global g_yawSensitivityMultiplier, g_pitchSensitivityMultiplier 
	g_yawSensitivityMultiplier = 1.5
	g_pitchSensitivityMultiplier = 1.3
	freeTrack.update += update
User avatar
shiva
Cross Eyed!
Posts: 125
Joined: Wed Jan 16, 2013 11:29 am

Re: Playing with XBOX controller

Post by shiva »

baggyg wrote:Hi,
It is my understanding that Perception uses mouse emulation to to the head movement. Therefore the user must use the mouse plus keyboard for additional rotation and movement. I believe this would be far better if you could use a XBOX controller
You can have both the mouse and xbox controller working at the same time (waiting for my rift to test it, but it should work)
http://forums.nexusmods.com/index.php?/ ... e-support/
If you do it right, you can get xpadder to provide a smooth joystick experience and also use the mouse and keyboard at the same time. I did it with Oblivion and was going to do it with Skyrim too, but Skyrim had better Xbox controller support than Oblivion did, so it didn't seem worth the trouble. You bind keyboard and mice buttons to the gamepad, but that doesn't inherently stop you from still using the keyboard and mouse at the same time.
The key is preventing Skyrim (or Oblivion) from recognizing or doing anything with a gamepad that's plugged in. If it "sees" the gamepad, it will disable the mouse and keyboard and activate it's native gamepad support. What you want, if you're using xpadder, is for the game to stay in keyboard and mouse mode. Then you can use the keyboard and mouse all you want and also pickup your gamepad at the same time because, through xpadder, the gamepad is using the keyboard and mouse. In Oblivion, I was able to completely disable it's gamepad support mostly by removing lines from the config.ini.
As I mentioned, you can get a smooth joystick experience with xpadder. You just have to pick the right options. In "Mouse Settings" for each stick, I recommend setting it to "Cursor" mode and setting the emulation speed to whatever is comfortable. For some games I do about 80, for others 150. It depends on the game. From there, you just have to adjust to the feel for each game. Anyone who has played a lot of console FPS's knows what I mean.
Image
User avatar
baggyg
Vireio Perception Developer
Vireio Perception Developer
Posts: 491
Joined: Sat May 19, 2012 5:20 am
Location: BB, Slovakia

Re: Playing with XBOX controller

Post by baggyg »

shiva wrote:(waiting for my rift to test it, but it should work)
In the same boat here. I currently use TrackIR with a HMZ to plug into perception hence it made more sense to combine the two. Xpadder would work just as well. The best option still remains to have Joystick Emulation in Perception I guess.
User avatar
squibbfire
Certif-Eyed!
Posts: 511
Joined: Fri Jan 18, 2013 10:38 am

Re: Playing with XBOX controller

Post by squibbfire »

Screw the Xbox controller!...bring on the Hydra!
Rift Demos
Total List of Demos
Enter the Rift http://www.entertherift.fr/gamecenter/f ... ?langue=en
Official Oculus Shared Demos https://share.oculusvr.com/
Post Reply

Return to “Development / General Discussion”