Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
190 user(s) are online (176 user(s) are browsing Forums)

Members: 0
Guests: 190

more...

Support us!

Headlines

 
  Register To Post  

Joystick on OS4: GamePort or AmigaInput ???
Not too shy to talk
Not too shy to talk


See User information

I am trying to make one of my programs use the joystick on a Sam440 + USB joystick (Trustmaster4)

Now the program works with GamePort on OS3

Do I need to program that the same way as OS3 with GamePort or do I truly need to use AmigaInput ???

What exactly do GamePort or AmigaInput ?? (It is a kind of mystery for me ...) Is AmigaInput a wrapper on GamePort ??

What will give the better compatibility ?
Questions like :
Same code OS3 and OS4 ?
Using classic joystick on Amiga Classic ?
Using USB pads,joysticks,etc... on Amiga NG ?

MANY THANKS

Alain Thellier

Note: Please dont answer me "just use SDL"

Go to top
Re: Joystick on OS4: GamePort or AmigaInput ???
Home away from home
Home away from home


See User information

Go to top
Re: Joystick on OS4: GamePort or AmigaInput ???
Not too shy to talk
Not too shy to talk


See User information
You can use lowlevel.library and that will give you compatibility with 3.1 and above - AmigaInput will emulate lowlevel.library with whatever controller you choose on OS4.

I haven't come across GamePort as an API - it's not part of OS3 AFAIK so I assume it's an alternative to AmigaInput rather than something AmigaInput creates a wrapper around - it might even conflict with AmigaInput if that's the case.

Go to top
Re: Joystick on OS4: GamePort or AmigaInput ???
Quite a regular
Quite a regular


See User information
Gameport.device has been part of AmigaOS since version 1.x.

This is just like television, only you can see much further.
Go to top
Re: Joystick on OS4: GamePort or AmigaInput ???
Not too shy to talk
Not too shy to talk


See User information
Thanks for answers

Yes I had a look to Huno's library but it is a big beast for doing such a basic function

I am just porting "Abbaye des Morts" game
http://www.amiga-ng.org/viewtopic.php ... cre=1&start=0#14200730421
It is just a 92 k binary game so linking with "a some mega bytes library" hurts me

> Yes I was talking about the Gameport.device : I use it on OS3 and it seems (in WinUAE) to works fine
So now there are 3 choices
lowlevel.library
Gameport.device
AmigaInput
arghh...

Certainly BSzili know how to use the joystick with all the great ports he did
BSzili please ???

Alain

Go to top
Re: Joystick on OS4: GamePort or AmigaInput ???
Not too shy to talk
Not too shy to talk


See User information
@BSzili

So it has! I'm sorry about that, I've never come across it before surprisingly. Looking at the documentation now...

Anyway, the OS4 documentation specifically talks about lowlevel.library emulation so it's possible gameport.device isn't supported.

Huno's library mentioned above looks like it's what you need, but I haven't used it myself...

Go to top
Re: Joystick on OS4: GamePort or AmigaInput ???
Quite a regular
Quite a regular


See User information
@thellier
If you want cross-platform compatibility, then use lowlevel.library. It's available in OS3, OS4, MOS, AROS. So is gameport.device, but it's rather limited even compared to lowlevel.library. Unless you want to support AmigaOS 2.x or older, you shouldn't use it.
AmigaInput supports more buttons, analog axes, etc, but it's only available on OS4.

edit: I read the initial post more carefully, and you've said the game already uses gameport.device. In that case you are good to go, since it's already supported everywhere.


Edited by BSzili on 2015/3/5 16:14:41
This is just like television, only you can see much further.
Go to top
Re: Joystick on OS4: GamePort or AmigaInput ???
Not too shy to talk
Not too shy to talk


See User information
@BSzili
Thanks for help

>gameport.device. In that case you are good to go, since it's already supported everywhere.
Oh Nice
But in fact it dont works : on the Sam440 AbbayeDesMortsOS3 as AbbayeDesMortsOS4 dont see the Trustmaster4 = the game runs but no input from joystick : something failed with GamePort device inits

If I launch Mace for example the Trustmaster4 joystick works well on the Sam440

Certainly a problem related to GamePort device units ?!?

Alain



Go to top
Re: Joystick on OS4: GamePort or AmigaInput ???
Quite a regular
Quite a regular


See User information
I never actually tried gameport.device on OS4 myself. It could be that it only works in the classic edition, although the kernel module is loaded on my Pegasos 2 too. BTW, I just checked the AROS sources, and gameport.device only supports the mouse there, so it's probably not the best cross-platform solution after all.

I used lowlevel.library pretty much everywhere, it's available on OS3, OS4, AROS, MOS. The only limitation is, that on OS4 you can't read the the analog sticks via lowlevel.library. If this is not something the game needs, then it's safe to go with it.

This is just like television, only you can see much further.
Go to top
Re: Joystick on OS4: GamePort or AmigaInput ???
Not too shy to talk
Not too shy to talk


See User information
Thanks again

I will try lowlevel.library : it seems very simple to use

http://en.wikibooks.org/wiki/Aros/Dev ... r/Docs/Libraries/LowLevel

Go to top
Re: Joystick on OS4: GamePort or AmigaInput ???
Quite a regular
Quite a regular


See User information
How many units were there for gameport.device on classic? If on OS4 it has the same hard limit then it's likely not handling any USB HID things.

Go to top
Re: Joystick on OS4: GamePort or AmigaInput ???
Not too shy to talk
Not too shy to talk


See User information
@all

Ok it works
lowlevel.library is TOOOO simple

Just add Open/close lowlevel.library to your game
and this et Voilà

/*==================================================================*/
static void printbuttons(ULONG joy)
{
if (joy & JPF_BUTTON_PLAY) printf("[PLAY/MMB]");
if (joy & JPF_BUTTON_REVERSE) printf("[REVERSE]");
if (joy & JPF_BUTTON_FORWARD) printf("[FORWARD]");
if (joy & JPF_BUTTON_GREEN) printf("[SHUFFLE]");
if (joy & JPF_BUTTON_RED) printf("[SELECT/LMB/FIRE]");
if (joy & JPF_BUTTON_BLUE) printf("[STOP/RMB]");
}
/*==================================================================*/
static void printmousedirections(ULONG joy)
{
printf("[%d,%d]", (joy & JP_MHORZ_MASK), (joy & JP_MVERT_MASK) >> 8);
}
/*==================================================================*/
static void printjoydirections(ULONG joy)
{
if (joy & JPF_JOY_UP) printf("[UP]");
if (joy & JPF_JOY_DOWN) printf("[DOWN]");
if (joy & JPF_JOY_LEFT) printf("[LEFT]");
if (joy & JPF_JOY_RIGHT) printf("[RIGHT]");
}
/*==================================================================*/
static void printjoyport(ULONG unit,ULONG joy)
{
int i;

printf("UNIT%d: ",unit);
for(i = 31; i >= 0; i--)
{
printf("%d", (joy & (1 << i)) ? 1 : 0);
}

printf(" - ");

if ((joy & JP_TYPE_MASK) == JP_TYPE_NOTAVAIL) printf("NOT AVAILABLE");
if ((joy & JP_TYPE_MASK) == JP_TYPE_UNKNOWN) printf("UNKNOWN");

if ((joy & JP_TYPE_MASK) == JP_TYPE_JOYSTK)
{
printf("JOYSTICK - ");
printjoydirections(joy);
printbuttons(joy);
}

if ((joy & JP_TYPE_MASK) == JP_TYPE_GAMECTLR)
{
printf("GAME CONTROLLER - ");
printjoydirections(joy);
printbuttons(joy);
}

if ((joy & JP_TYPE_MASK) == JP_TYPE_MOUSE)
{
printf("MOUSE - ");
printmousedirections(joy);
printbuttons(joy);
}

printf("\n");
}
/*==================================================================*/
void MyProcessJoystickNew(struct game *G)
{
ULONG joy,n;

NLOOP(4)
{
joy = ReadJoyPort(n);
if(joy)
if(!((joy & JP_TYPE_MASK) == JP_TYPE_MOUSE) )
if(!((joy & JP_TYPE_MASK) == JP_TYPE_NOTAVAIL) )
break;
}


G->joystick.right =(joy & JPF_JOY_RIGHT);
G->joystick.left =(joy & JPF_JOY_LEFT);
G->joystick.down =(joy & JPF_JOY_DOWN);
G->joystick.up =(joy & JPF_JOY_UP);
G->joystick.b0 =0;
G->joystick.b1 =0;
if (joy & JPF_BUTTON_RED) G->joystick.b0 =TRUE;
if (joy & JPF_BUTTON_PLAY) G->joystick.b1 =TRUE;

G->key=1;
if(debug) printjoyport(n,joy);
}

Go to top
Re: Joystick on OS4: GamePort or AmigaInput ???
Quite a regular
Quite a regular


See User information
Yep, it's very simple :P You do everything with one function. You can avoid the two ifs for the buttons if you do this:
G->joystick.b0 =!!(joy JPF_BUTTON_RED);
G->joystick.b1 =!!(joy JPF_BUTTON_PLAY);


This is just like television, only you can see much further.
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project