sixaxis or userinput with BD-J

Technical discussion on the newly released and hard to find PS3.

Moderators: cheriff, emoon

Post Reply
jmdetiege
Posts: 10
Joined: Thu Jul 17, 2008 12:05 am

sixaxis or userinput with BD-J

Post by jmdetiege »

Hello,

After file access,internet access, it's now time to user input, sixaxis/dualshock use with BD-J.

After a lot of search, i'm trying some samples (there are few sample) with ControllerListener, UserEvent, UserEventListener but nothing work.

Somebody have some working samples, some support where i can found it ?

Thanks a lot.

Jm
User avatar
mc
Posts: 211
Joined: Wed Jan 12, 2005 7:32 am
Location: Linköping

Post by mc »

UserEventListener is right. You need to do this in initXlet:

UserEventRepository userEventRepo = new UserEventRepository("evt");
userEventRepo.addAllArrowKeys();
userEventRepo.addAllColourKeys();
userEventRepo.addAllNumericKeys();
userEventRepo.addKey(HRcEvent.VK_ENTER);
userEventRepo.addKey(HRcEvent.VK_POPUP_MENU);
EventManager.getInstance().addUserEventListener(this, userEventRepo);

Then the method userEventReceived() will be called in this when the direction keys or X/square or color keys (only available as virtual keys with the sixaxis) are pressed.
Flying at a high speed
Having the courage
Getting over crisis
I rescue the people
jmdetiege
Posts: 10
Joined: Thu Jul 17, 2008 12:05 am

Post by jmdetiege »

Thank you so much, i'm try it and you the result asap.
jmdetiege
Posts: 10
Joined: Thu Jul 17, 2008 12:05 am

Post by jmdetiege »

Hello

I implement the function but i'm not able to display a message on the screen.

I have this in my Xlet:

public class MyXlet implements Xlet, UserEventListener{

private HScene scene;
private Container gui;
private XletContext context;
private final ArrayList messages = new ArrayList();
private UserEventRepository userEventRepo ;


public void initXlet(XletContext context) {
this.context = context;

scene = HSceneFactory.getInstance().getDefaultHScene();


messages.add("Hi, this is a small homebrew test.");
messages.add("let's start ");
messages.add("");

gui = new Screen(messages);

gui.setSize(1920, 1080); // BD screen size
scene.add(gui, BorderLayout.CENTER);


try {
userEventRepo = new UserEventRepository("evt");
userEventRepo.addAllArrowKeys();
userEventRepo.addKey(HRcEvent.VK_ENTER);
//add input event

/*userEventRepo.addAllColourKeys();
userEventRepo.addAllNumericKeys();

userEventRepo.addKey(HRcEvent.VK_POPUP_MENU);*/

} catch (Exception e) {
messages.add(e.getMessage());
}


scene.validate();


}

public void startXlet() {


EventManager.getInstance().addUserEventListener(this, userEventRepo);
gui.setVisible(true);
scene.setVisible(true);
gui.requestFocus();
}

public void pauseXlet() {
gui.setVisible(false);
//EventManager.getInstance().removeUserEventListener(userEventRepo);
}

public void destroyXlet(boolean unconditional) {
scene.remove(gui);
scene = null;
}


/**
* Callback from the system via UserEventListener when a remote
* control keypress is received.
**/
public synchronized void userEventReceived(UserEvent e) {

if (e.getType() == HRcEvent.KEY_PRESSED) {

switch(e.getCode()){

case HRcEvent.VK_POPUP_MENU:
popupKeyPressed();
break;

case HRcEvent.VK_0:
case HRcEvent.VK_1:
case HRcEvent.VK_2:
case HRcEvent.VK_3:
case HRcEvent.VK_4:
case HRcEvent.VK_5:
case HRcEvent.VK_6:
case HRcEvent.VK_7:
case HRcEvent.VK_8:
case HRcEvent.VK_9:
numberKeyPressed(e.getCode() - HRcEvent.VK_0);
break;

case HRcEvent.VK_COLORED_KEY_0:
case HRcEvent.VK_COLORED_KEY_1:
case HRcEvent.VK_COLORED_KEY_2:
case HRcEvent.VK_COLORED_KEY_3:
case HRcEvent.VK_COLORED_KEY_4:
case HRcEvent.VK_COLORED_KEY_5:
colorKeyPressed(e.getCode() - HRcEvent.VK_COLORED_KEY_0);
break;

case HRcEvent.VK_ENTER:
enterKeyPressed();
break;

case HRcEvent.VK_LEFT:
arrowLeftKeyPressed();
break;

case HRcEvent.VK_RIGHT:
arrowRightPressed();
break;

case HRcEvent.VK_UP:
arrowUpPressed();
break;

case HRcEvent.VK_DOWN:
arrowDownPressed();
break;

}
}

}

/**
* Subclasses should override this if they're interested in getting
* this event.
**/
protected void numberKeyPressed(int value){}

/**
* Subclasses should override this if they're interested in getting
* this event.
**/
protected void colorKeyPressed(int value){}

/**
* Subclasses should override this if they're interested in getting
* this event.
**/
protected void popupKeyPressed(){}

/**
* Subclasses should override this if they're interested in getting
* this event.
**/
protected void enterKeyPressed()
{
messages.add("Touche ENTER pressée");
}

/**
* Subclasses should override this if they're interested in getting
* this event.
**/
protected void arrowLeftKeyPressed()
{
messages.add("Fleche vers la gauche pressée");
}
/**
* Subclasses should override this if they're interested in getting
* this event.
**/
protected void arrowRightPressed()
{
messages.add("Fleche vers la droite pressée");
}

/**
* Subclasses should override this if they're interested in getting
* this event.
**/
protected void arrowUpPressed()
{
messages.add("Fleche vers le haut pressée");
}

/**
* Subclasses should override this if they're interested in getting
* this event.
**/
protected void arrowDownPressed()
{
messages.add("Fleche vers le bas pressée");
}

public void controllerUpdate(ControllerEvent arg0) {
// TODO Auto-generated method stub

}


}[/code]

it works fine and display

Hi, this is a small homebrew test.
let's start

but no more messages when i push on UP, DOWN, LEFT, RIGHT on my sixaxis

Any idea ?

Thanks in advance

jm
User avatar
mc
Posts: 211
Joined: Wed Jan 12, 2005 7:32 am
Location: Linköping

Post by mc »

Without knowing what your "Screen" class looks like, I expect you need to repaint
the component after adding stuff to messages for them to appear on screen.
Flying at a high speed
Having the courage
Getting over crisis
I rescue the people
jmdetiege
Posts: 10
Joined: Thu Jul 17, 2008 12:05 am

Post by jmdetiege »

Tks again,

yes i don't give the Screen classe code because this is the default Screen class gived with th bd-j samples.
There's a "Paint" function in this class.

I'm tried to use it and say you it's ok.

I'm thinking that's fired up when a message was put in the list.

A+

jm
jmdetiege
Posts: 10
Joined: Thu Jul 17, 2008 12:05 am

Post by jmdetiege »

Yes it's work fine, i'm just have to repaint my Screen object.

Another question, do you know how to ask and save a user input ?

Tks again mc !!

Jm
Post Reply