First off, if this belongs in the C/C++ section go ahead and move it, figured I'd get better attention here
I'm trying to use the nubs as joysticks with allegro, and so far its not going very good. I can't seem to get any values from them at all.
Well, heres my code:
run.sh (used to run it when i throw it into a .pnd, been running it from this for testing)
Nub mode code conveniently stolen from mupen
Actual C++/Allegro code: (the important stuff anyway)
calls this funtion
The problem is that no matter what i seem to do i cant get a reading form axis[0].pos or axis[1].pos.
And I tried the whole calibrate_joystick_name() thing, but my compiler yelled at me
I feel like i'm either initializing them wrong, or calibrating them wrong.
Any suggestions?
I'm trying to use the nubs as joysticks with allegro, and so far its not going very good. I can't seem to get any values from them at all.
Well, heres my code:
run.sh (used to run it when i throw it into a .pnd, been running it from this for testing)
Nub mode code conveniently stolen from mupen
Code:
#!/bin/sh
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mnt/utmp/pfoiy
NUB0MODE=`cat /proc/pandora/nub0/mode`
NUB1MODE=`cat /proc/pandora/nub1/mode`
echo absolute > /proc/pandora/nub0/mode
echo absolute > /proc/pandora/nub1/mode
./pfoiy
echo $NUB0MODE > /proc/pandora/nub0/mode
echo $NUB1MODE > /proc/pandora/nub1/mode
Actual C++/Allegro code: (the important stuff anyway)
Code:
int main()
{
allegro_init();
install_keyboard();
install_timer();
install_pmask();
//install_mouse();
install_joystick(JOY_TYPE_AUTODETECT);
calibrate_joystick(0);
set_color_depth(32);
if (set_gfx_mode(GFX_AUTODETECT, WIDTH, HEIGHT, 0, 0) < 0)
{
allegro_message("Couldn't set gfx mode: %s\n", allegro_error);
return 1;
}
show_mouse(NULL);
title();
//delete_bitmap(buffer);
}
calls this funtion
Code:
void title()
{
int a=40;
//clear_to_color(screen,makecol(0,0,0));
border = load_bmp("titlescreen.bmp",NULL);
blit(border,screen,0,0,0,0,800,480);
textprintf_ex(screen,font, 40,40,makecol(255,255,255),-1,"Play");
textprintf_ex(screen,font, 40,50,makecol(255,255,255),-1,"Difficulty");
textprintf_ex(screen,font, 40,60,makecol(255,255,255),-1,"Quit");
textprintf_ex(screen,font, 200,200,makecol(255,255,255),-1,"You are the BLUE CIRCLE,");
textprintf_ex(screen,font, 200,210,makecol(255,255,255),-1,"use the D-pad to avoid the RED TRIANGLE");
textprintf_ex(screen,font, 200,220,makecol(255,255,255),-1,"and get the GREEN SQUARE.");
//const char *msg = calibrate_joystick_name(0);
//textprintf_ex(screen,font,40,390,makecol(255,255,255),-1,"%s ",msg); GIANT WTF
textprintf_ex(screen,font,40,400,makecol(255,255,255),-1,"Flags: %d, numsticks: %d, numbuttons: %d",joy[0].flags,joy[0].num_sticks,joy[0].num_buttons);
textprintf_ex(screen,font,40,410,makecol(255,255,255),-1,"Flags: %d, numaxis: %d, name: %s",joy[0].stick[0].flags,joy[0].stick[0].num_axis,joy[0].stick[0].name);
rest(100);
while (true)
{
rest(90);
blit(border,screen,0,0,0,0,39,70);
blit(border,screen,40,420,40,420,700,440);
poll_joystick();
textprintf_ex(screen,font,40,420,makecol(255,255,255),-1,"analogue pos: %d, digpos: %d:%d, name:%s",joy[0].stick[0].axis[0].pos,joy[0].stick[0].axis[0].d1,joy[0].stick[0].axis[0].d2,joy[0].stick[0].axis[0].name);
textprintf_ex(screen,font,40,430,makecol(255,255,255),-1,"analogue pos: %d, digpos: %d:%d, name: %s",joy[0].stick[0].axis[1].pos,joy[0].stick[0].axis[1].d1,joy[0].stick[0].axis[1].d2,joy[0].stick[0].axis[1].name);
if (key[KEY_UP] && a != 40) a-=10;
if (key[KEY_DOWN] && a != 60) a+=10;
textprintf_ex(screen,font, 30,a,makecol(255,255,255),-1,">");
if ((key[KEY_ENTER] || key[KEY_PGDN] || key[KEY_PGUP] || key[KEY_END] || key[KEY_HOME] || key[KEY_ALT]) && a == 60) exit(0);
if ((key[KEY_ENTER] || key[KEY_PGDN] || key[KEY_PGUP] || key[KEY_END] || key[KEY_HOME] || key[KEY_ALT]) && a == 40) reset();
if ((key[KEY_ENTER] || key[KEY_PGDN] || key[KEY_PGUP] || key[KEY_END] || key[KEY_HOME] || key[KEY_ALT]) && a == 50) options();
}
}
The problem is that no matter what i seem to do i cant get a reading form axis[0].pos or axis[1].pos.
And I tried the whole calibrate_joystick_name() thing, but my compiler yelled at me
I feel like i'm either initializing them wrong, or calibrating them wrong.
Any suggestions?
Last edited by a moderator: