I've got the small joypad=>memorycard=>usb adapter (could fit in my madcatz joypad), so I decided to try to plug into it a usb keyboard and since the usb keyboard (small packard bell model) has also a usb adapter behind it (for mouse), I also connected a usb mouse to it.
The adapter is named "Madrics Gameware China Interface X".
Works fine with current version of openxdk! Great!
However, for the mouse, you can't really use g_mouse.
In libusb.a, when a relative mouse coordinates update is received through usb wire, XMOUSE_current is updated. Later when you request input states, g_mouse gets a copy of it.
BUT... if you stop moving the mouse, your mouse can decide it's useless to send a +0,+0 relative update. And so your mouse cursor will still move because XMOUSE_current will keep the last non null update.
If you use g_mouse and immediately set x and y to zero, it doesn't work since x and y will be overwritten again with (old) last update. So you have to use directly XMOUSE_current and set x and y to zero.
CODE
#include <hal/input.h>
extern struct xmouse_data XMOUSE_current;
...
XKEYBOARD_STROKE Stroke;
char s[41]="";
int mx=640/2,my=480/2;
...
XInput_GetEvents();
if (XInputGetKeystroke(&Stroke)==0)
{
if ((Stroke.ucFlags&XKEYBOARD_KEYUP)==0)
{
if (strlen(s)==40) strcpy(s,"");
s[strlen(s)+1]='\0';
s[strlen(s)]=Stroke.ucAsciiValue;
}
}
pb_print("[%s]\n",s);
mx+=XMOUSE_current.x;
my+=XMOUSE_current.y;
XMOUSE_current.x=0;
XMOUSE_current.y=0;
if (mx<0) mx=0;
if (my<0) my=0;
if (mx>640-10) mx=640-10;
if (my>480-10) my=480-10;
pb_fill(mx,my,10,10,0xffffff);
pb_draw_text_screen();
Have fun with... your new complete computer!
This post has been edited by openxdkman: Mar 20 2007, 06:00 PM