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
sixaxis or userinput with BD-J
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.
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
Having the courage
Getting over crisis
I rescue the people
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
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