View Single Post
  #1   Spotlight this post!  
Unread 25-05-2015, 16:24
TheModMaster8's Avatar
TheModMaster8 TheModMaster8 is offline
Active Alumni
FRC #5492 (Robo Jockeys)
Team Role: Alumni
 
Join Date: Apr 2015
Rookie Year: 2009
Location: USA, Kentucky
Posts: 119
TheModMaster8 is a jewel in the roughTheModMaster8 is a jewel in the roughTheModMaster8 is a jewel in the rough
Need help with lego NXT lejos xbox controlling

I'm attempting to use an Xbox One wired controller on my MacBook Pro laptop, Im using Java with Eclipse that has lejos and LWJGL installed on it in order to control an NXT via my controller, like how we control our robots. I have a gamepad driver installed, it's called "XOne Controller" (link)https://github.com/FranticRain/Xone-OSX Also i have a little program to test the data from the joysticks and buttons of the controller
Code:
import org.lwjgl.LWJGLException;
import org.lwjgl.input.Controller;
import org.lwjgl.input.Controllers;
public class Start extends Virtual_JoyStick 
{
	public static Controller control;
	public static boolean Start;
	
	
	public static void main(String[] args)
	{
		try
		{
			Controllers.create();			
		}
		catch(LWJGLException e)
		{
			e.printStackTrace();
		}
		Controllers.poll();
		
		for(int i=0;i<Controllers.getControllerCount();i++)
		{
			control=Controllers.getController(i);
			System.out.print(control.getName());
		}
		
		control=Controllers.getController(0);
		
		for(int i=0; i < control.getAxisCount(); i++)
		{
			System.out.print(i+ ": "+ control.getAxisName(i));
			//System.out.print("c");
			control.setDeadZone(i, (float) 0.30);
			
		}
		
		for(int i=0; i < control.getButtonCount(); i++)
		{
			System.out.print(i+ ": "+ control.getButtonName(i));
		}	

		while(true)
		{
			control.poll();
		    //Start=control.isButtonPressed(7);
			/**System.out.print(control.getAxisValue(0));
			System.out.print("   ");
			System.out.print(control.getAxisValue(1));
			System.out.print("   ");
			System.out.print(control.getAxisValue(2));
			System.out.print("   ");
			System.out.print(control.getAxisValue(3));
			System.out.print("   ");
			System.out.print(control.getAxisValue(4));
			System.out.print("   ");
			System.out.print(control.getAxisValue(5));
			System.out.println(); */
			Virtual_JoyStick joy = new Virtual_JoyStick();
			joy.repaint();
	  }	    
   }
}
my problem is i don't know how to make the main program listen to live input data and send it to the robot wirelessly, Also note that I'm not at basic but not advanced in the realms of coding. JSYK (just so you know).
__________________
2009-2011: (FLL) Robot Builder / Operator
2012: (FRC Team 2783) Fabrication / HumanPlayer / FLL Ref
2013: (FRC Team 2783) Fabrication / HumanPlayer / FLL Ref
2014: (FRC Team 2783) Fabrication Student Lead / HumanPlayer / FLL Ref
2015: (FRC Team 2783) Fab Student, Teacher / HumanPlayer / Backup Driver / FLL Ref / FLL Mentor of 6 Teams
2016: (FRC Team 5492) Fabrication Student Lead / Driver / FLL Mentor of Crestwood Elementary
Past Alliance:(2783, 1208, 4154)(2783, 1002, 4265)(2783, 1182, 3868)(2783, 451, 4028)(2783, 1208!, 1288)(5492, 63, 1014) I Will Never Forget