xboxscene.org forums

Author Topic: Precompiled Libs Wanted For Latest Openxdk Sourcetree  (Read 107 times)

openxdkman

  • Archived User
  • Hero Member
  • *
  • Posts: 550
Precompiled Libs Wanted For Latest Openxdk Sourcetree
« on: March 24, 2007, 07:39:00 AM »

http://home.tele2.fr...785/openxdk.zip
Recent May 2007 libraries and includes, compiled under Cygwin

It's last summer that we discovered the problem of input (isr instead of isr+dpc). Since last summer interrupts are working fine. Polling was a temporary fix prior to last summer. Call to XInput_GetEvents just sets g_Pads.

But you may still have troubles if you don't see how inputs work in the g_Pads structure:
PressedButtons.ucAnalogButtons[CONSTANT] will detect unpressed->pressed transitions of analog buttons
PressedButtons.usDigitalButtons&CONSTANT will do the same for digital buttons (see below families)
CurrentButtons.ucAnalogButtons[CONSTANT] will detect current state
CurrentButtons.usDigitalButtons&CONSTANT will detect current state
LastButtons.ucAnalogButtons[CONSTANT] will detect last transition (I've never tested it)
LastButtons.usDigitalButtons&CONSTANT will detect last transition


XInput_GetEvents();
if (g_Pads[0].PressedButtons.ucAnalogButtons[XPAD_Y]) debugPrint("Y");
if (g_Pads[0].PressedButtons.ucAnalogButtons[XPAD_X]) debugPrint("X");
if (g_Pads[0].PressedButtons.ucAnalogButtons[XPAD_A]) debugPrint("A");
if (g_Pads[0].PressedButtons.ucAnalogButtons[XPAD_B]) debugPrint("B");
if (g_Pads[0].PressedButtons.ucAnalogButtons[XPAD_BLACK]) debugPrint("0");
if (g_Pads[0].PressedButtons.ucAnalogButtons[XPAD_WHITE]) debugPrint("1");
if (g_Pads[0].PressedButtons.ucAnalogButtons[XPAD_LEFT_TRIGGER]) debugPrint("LT");
if (g_Pads[0].PressedButtons.ucAnalogButtons[XPAD_RIGHT_TRIGGER]) debugPrint("RT");
if (g_Pads[0].PressedButtons.usDigitalButtons&XPAD_DPAD_UP) debugPrint("U");
if (g_Pads[0].PressedButtons.usDigitalButtons&XPAD_DPAD_DOWN) debugPrint("D");
if (g_Pads[0].PressedButtons.usDigitalButtons&XPAD_DPAD_RIGHT) debugPrint("R");
if (g_Pads[0].PressedButtons.usDigitalButtons&XPAD_DPAD_LEFT) debugPrint("L");
if (g_Pads[0].PressedButtons.usDigitalButtons&XPAD_LEFT_THUMB) debugPrint("LS");
if (g_Pads[0].PressedButtons.usDigitalButtons&XPAD_RIGHT_THUMB) debugPrint("RS");
if (g_Pads[0].PressedButtons.usDigitalButtons&XPAD_START) debugPrint("S");
if (g_Pads[0].PressedButtons.usDigitalButtons&XPAD_BACK) debugPrint("B");


for usb keyboard and mouse see other post named "usb keyboard and mouse in openxdk"
Logged

superogue

  • Archived User
  • Newbie
  • *
  • Posts: 12
Precompiled Libs Wanted For Latest Openxdk Sourcetree
« Reply #1 on: March 28, 2007, 01:06:00 PM »

thanks,

it works now with the new libs, i was able to compile a simple program.


however, i was using openxdk in a library i wrote, which worked fine with the last version, but now i get the following link error:

"couldnt find IoInputDword"  (or somethign similar, i can look up the exact langauge)...

i think its probably in the -l library link order, i tried moving things around a little, but no luck yet..

the way it connects

main.cpp - my program, includes my library and uses its own main function
mylibrary.a - my static lib, uses/includes openxdk/hal

current linkage is as follows:

-lmyownlib
-nostdlib -Wl,--file-alignment,0x20 -Wl,--section-alignment,0x20 -shared -Wl,--entry,_WinMainCRTStartup -Wl,--strip-all -lstdc++ -lopenxdk -lhal -lc -lhal -lusb -lc -lxboxkrnl

moving myownlib at the back dont seem to work either since its dependable on openxdk/libusb/etc.

any suggestions?
Logged

openxdkman

  • Archived User
  • Hero Member
  • *
  • Posts: 550
Precompiled Libs Wanted For Latest Openxdk Sourcetree
« Reply #2 on: March 29, 2007, 01:05:00 AM »

Yeah it's a bit painful to fix...
If libraries were considered as the nodes of tree and each upper node were only calling functions of lower nodes then we could have established a clean hierarchy and ask people to list libraries in a strict fixed order.

But there are many cross references, so you have to find the magic list...

I'm using this one at the moment :
LD_LIBS  = $(LD_DIRS) -lSDL -lm -lopenxdk -lhal -lc -lusb -lc -lxboxkrnl -lc -lhal -lxboxkrnl -lhal -lopenxdk -lc

(see makefiles in pbKit_demos.zip)

So you have to repeat libraries before any one using it I fear...
That doesn't mean you obtain duplicated codes in final binary though...
Logged

superogue

  • Archived User
  • Newbie
  • *
  • Posts: 12
Precompiled Libs Wanted For Latest Openxdk Sourcetree
« Reply #3 on: April 02, 2007, 07:05:00 AM »

Hi,

have by any chance the newlib or libc libraries been updated as well through this???
if so could you put them online as well???

i ask, because fopen does not work anymore...  it worked with the old libraries, now even if i try to read back the example code:

'example code i/o writing to c:\blah,.txt''

and read back like so
fp=fopen("c:/blah.txt","rb");
fread(buffer,sizeof(char),40,fp);
then print the contents of the buffer array byte for byte, will result in random stuff..
fclose(fp);

i hassled around and i think the problem is in the file i/o implementation which might have been updated since the last downloadable openxdk????  also, is there a lib which contains sin and cos functions?





Logged

openxdkman

  • Archived User
  • Hero Member
  • *
  • Posts: 550
Precompiled Libs Wanted For Latest Openxdk Sourcetree
« Reply #4 on: April 04, 2007, 02:10:00 AM »

CODE


#include

int file_handle;

strcpy(path,"d:\\mydata.dat"); //"d:\\" is an alias for "./"

//reading size of file
ret=XCreateFile(&file_handle,path,
    GENERIC_READ,FILE_SHARE_READ,
    OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL);
if (ret!=0)
{
    debugPrint("File not found\n"); return -1;
}
XGetFileSize(file_handle,(int *)&data_len);
XCloseHandle(file_handle);


//reading from file
ret=XCreateFile(&file_handle,path,
    GENERIC_READ,FILE_SHARE_READ,
    OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL);
if (ret!=0)
{
    debugPrint("File not found\n"); return -1;
}
if (!XReadFile(file_handle,data_buf,max_buf_size,(int *)&actuallyread))
{
    debugPrint("read error\n"); return -2;
}
XCloseHandle(file_handle);
    

//writing to file
ret=XCreateFile(&file_handle,path,
    GENERIC_WRITE,FILE_SHARE_WRITE,
    CREATE_NEW,FILE_ATTRIBUTE_NORMAL);
if (ret!=0)
{
    debugPrint("Can't create file\n"); return -1;
}
if (!XWriteFile(file_handle,data_buf,data_size,(int *)&actuallywritten))
{
    debugPrint("write error\n"); return -3;
}
XCloseHandle(file_handle);



Note that it's the same mess with ps2dev, mainly because you access memory cards, usb keyboard, etc...
Can't really use standard file i/o with open dev kits...
Logged

openxdkman

  • Archived User
  • Hero Member
  • *
  • Posts: 550
Precompiled Libs Wanted For Latest Openxdk Sourcetree
« Reply #5 on: April 04, 2007, 02:21:00 AM »

CODE

#include
Logged

superogue

  • Archived User
  • Newbie
  • *
  • Posts: 12
Precompiled Libs Wanted For Latest Openxdk Sourcetree
« Reply #6 on: April 17, 2007, 08:06:00 AM »

The above filestuff doesn't work at all here. No file is found.
Logged

openxdkman

  • Archived User
  • Hero Member
  • *
  • Posts: 550
Precompiled Libs Wanted For Latest Openxdk Sourcetree
« Reply #7 on: April 17, 2007, 08:06:00 AM »

The above filestuff doesn't work at all here. No file is found.
Logged

superogue

  • Archived User
  • Newbie
  • *
  • Posts: 12
Precompiled Libs Wanted For Latest Openxdk Sourcetree
« Reply #8 on: April 23, 2007, 01:55:00 AM »

hi,

i have tried adding and removing this but no such luck.
maybe you have a small example and xbe that i can test for just file reading/writing? maybe its just on this xbox?

i understand the point of openxdk, but i'm the author of a cross-platform library that will allow people to recompile to whatever platform without altering their code, and i would surely like to include xbox as well (as well as newer and older platforms). its basically a win/win situation for the users if i can get the thing to work.

everything worked fine except key input in the last official version. now key input works with the latest temp.version  but now the file i/o is broken :S    i only got the files you put online above, maybe the newlib/standard libs have been replaced also??? otherwise i wouldn't know why the file i/o broke down since the last online version.

Logged

openxdkman

  • Archived User
  • Hero Member
  • *
  • Posts: 550
Precompiled Libs Wanted For Latest Openxdk Sourcetree
« Reply #9 on: April 24, 2007, 04:38:00 AM »

CODE

    if (ret!=0)
    {
        debugPrint("...\n"); return -1;
    }

you SHOULDN'T write this (like you did):
CODE

    if (ret!=0) debutPrint("...\n"); return -1;

Because "return -1" now executes systematically and is no longer conditionned by the if.

Try this code by just copying/pasting it (don't change a single character) :
(have blah.txt copied in same directory as the .xbe binary you launch, too)

CODE

#include
#include
#include
//#include "comingSoon.h"
#include
#include
#include
#include
#include
#include

char path[256];

int filesizex(char *fn)
{
    int f;
    int data_len,ret;

    //reading size of file
    strcpy(path,fn);
    
    ret=XCreateFile(&f,path,
        GENERIC_READ,FILE_SHARE_READ,
        OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL);

    if (ret!=0)
    {
        debugPrint("File not found\n");
        return -1;
    }

    XGetFileSize(f,(int *)&data_len);    
    
    XCloseHandle(f);
    return data_len;
}


void XBoxStartup()
{
    FILE *fp;
    int read, written, newLocation;
    char buffer[20];
    int handle,ret;
    int actuallyread,filelength;
    int id;
    unsigned char id1,id2,id3,id4;
    char buf2[4];

    int *frame_buffer = (int*)XVideoGetFB();
    XKEYBOARD_STROKE xk;
    int i;
    int running = 1;

    debugPrint("Initialising...");

    XInput_Init();

    filelength=filesizex("d:\\blah.txt");
    debugPrint("filesize: %d\n",filelength);

    //reading from file
    strcpy(path,"d:\\blah.txt");
    
    ret=XCreateFile(&handle,path,
        GENERIC_READ,FILE_SHARE_READ,
        OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL);

    if (ret!=0) debugPrint("File not found\n"); //return -1;

    if (!XReadFile(handle,buffer,filelength,(int *)&actuallyread))
    {
        debugPrint("read error\n"); //return -2;
    }
    XCloseHandle(handle);

    debugPrint("- display buffer:\n");
    for (i=0;i);
    debugPrint("\n");

    //XSleep(10000); //let's use joypad please
    
    debugPrint("Press A\n");

    while(1)
    {
        XInput_GetEvents();
        if (g_Pads[0].PressedButtons.ucAnalogButtons[XPAD_A]) break;
    }

    XInput_Quit();
    //XLaunchXBE("c:\\evoxdash.xbe"); //useless, reboot will launch dashboard anyway
    XReboot();
}

Logged