| View previous topic :: View next topic |
| Author |
Message |
jmdetiege
Joined: 17 Jul 2008 Posts: 10
|
Posted: Tue Sep 16, 2008 9:10 pm Post subject: sixaxis or userinput with BD-J |
|
|
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 |
|
| Back to top |
|
 |
mc

Joined: 12 Jan 2005 Posts: 212 Location: Linköping
|
Posted: Thu Sep 18, 2008 1:16 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
jmdetiege
Joined: 17 Jul 2008 Posts: 10
|
Posted: Fri Sep 19, 2008 5:23 am Post subject: |
|
|
| Thank you so much, i'm try it and you the result asap. |
|
| Back to top |
|
 |
jmdetiege
Joined: 17 Jul 2008 Posts: 10
|
Posted: Fri Sep 19, 2008 7:09 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
mc

Joined: 12 Jan 2005 Posts: 212 Location: Linköping
|
Posted: Sun Sep 21, 2008 2:11 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
jmdetiege
Joined: 17 Jul 2008 Posts: 10
|
Posted: Tue Sep 23, 2008 2:57 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
jmdetiege
Joined: 17 Jul 2008 Posts: 10
|
Posted: Wed Sep 24, 2008 5:47 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
|