Install a simple Gamepad

From JReality Wiki
Jump to: navigation, search

System requirements

At first you have install your device-drivers. After you have checked, that the device is running for your system, run the jReality-class DeviceJinputController (de.jreality.toolsystem.raw.DeviceJinputController) which will show you the supported axis and buttons of the controller.

The gamepad which is used for this tutorial just has 4 buttons and 2 axis. The DeviceJinputController-class provides:

 Linux plugin claims to have found 1 controllers
 Mega World USB 2-Axis 4-Button Gamepad :: [A, B, C, X, x, y]

Now we can create at de.jreality.toolsystem.config.chunks a xml-file for this gamepad, e.g. toolconfig-MegaWorldGamepad.xml . We use the following setup: You have to keep attention, to your controller settings and name!

		<rawdevice id="Gamepad"
			<prop name="id_string">
				<string>Mega World USB 2-Axis 4-Button Gamepad</string>
		<mapping device="Gamepad" src="button_3" target="Button3" />
		<mapping device="Gamepad" src="button_0" target="Button0" />
		<mapping device="Gamepad" src="button_1" target="Button1" />
		<mapping device="Gamepad" src="button_2" target="Button2" />
		<mapping device="Gamepad" src="axis_4" target="RightLeftAxis" />
		<mapping device="Gamepad" src="axis_5" target="ForwardBackwardAxis" />
		<virtualdevice type="de.jreality.toolsystem.virtual.VirtualReverseAxis">
		<virtualdevice type="de.jreality.toolsystem.virtual.VirtualMergedAxis">
		<virtualdevice type="de.jreality.toolsystem.virtual.VirtualMergedAxis">

Now we have to include the new Controller to jReality. Open the toolconfig-split.xml file (de.jreality.toolsystem.config), toggle the mouse-import and add the following lines:

  <!--import href="chunks/toolconfig-mouse-keyboard.xml" /-->
  <import href="chunks/toolconfig-MegaWorldGamepad.xml" />
  <import href="chunks/toolconfig-no-mouse.xml" />

Save and run any tutorial to test the controller.