xbox-scene.com - your xbox news information source
Quick Links: Main Forums | Xbox360 Forums | Xbox1 Forums | PS3 Forums
Xbox-Scene Forum Help  Search Xbox-Scene Forums   Xbox-Scene Forum Members   Xbox-Scene Calendar

Giganews Offers: days binary retention, 99%+ Completion, and Unlimited Access!
Try Giganews' no obligation free trial!

Support this site - buy the X-Scene Tshirt $17.95


Welcome Guest ( Log In | Register )

 Forum Rules Rules
 
Reply to this topicStart new topic
> Usb Mouse And Keyboard In Openxdk
openxdkman
post Mar 20 2007, 05:59 PM
Post #1


X-S Genius
****

Group: Moderator
Posts: 790
Joined: 2-August 06
Member No.: 292548
Xbox Version: unk
360 version: unknown



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
User is offlineProfile CardPM
Go to the top of the page
+Quote Post





Reply to this topicStart new topic

 

Lo-Fi Version Time is now: 9th September 2010 - 08:16 AM