forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

sixaxis or userinput with BD-J

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS3 Development
View previous topic :: View next topic  
Author Message
jmdetiege



Joined: 17 Jul 2008
Posts: 10

PostPosted: Tue Sep 16, 2008 9:10 pm    Post subject: sixaxis or userinput with BD-J Reply with quote

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
View user's profile Send private message
mc



Joined: 12 Jan 2005
Posts: 212
Location: Linköping

PostPosted: Thu Sep 18, 2008 1:16 am    Post subject: Reply with quote

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
View user's profile Send private message
jmdetiege



Joined: 17 Jul 2008
Posts: 10

PostPosted: Fri Sep 19, 2008 5:23 am    Post subject: Reply with quote

Thank you so much, i'm try it and you the result asap.
Back to top
View user's profile Send private message
jmdetiege



Joined: 17 Jul 2008
Posts: 10

PostPosted: Fri Sep 19, 2008 7:09 am    Post subject: Reply with quote

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
View user's profile Send private message
mc



Joined: 12 Jan 2005
Posts: 212
Location: Linköping

PostPosted: Sun Sep 21, 2008 2:11 am    Post subject: Reply with quote

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
View user's profile Send private message
jmdetiege



Joined: 17 Jul 2008
Posts: 10

PostPosted: Tue Sep 23, 2008 2:57 am    Post subject: Reply with quote

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
View user's profile Send private message
jmdetiege



Joined: 17 Jul 2008
Posts: 10

PostPosted: Wed Sep 24, 2008 5:47 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS3 Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group