RAW INPUT = BAADF00D, help please

#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <windows.h>
#ifdef _MSC_VER
#define lint __int64
#define LI( NUM ) NUM##i64
#elif defined( _UNIX_ )
#define lint long int
#define LI( NUM ) NUM##li
#else
#define lint long long
#define LI( NUM ) NUM##ll
#endif
#ifdef _WIN32
typedef SSIZE_T ssize_t;
#endif
typedef unsigned char uchar;
typedef signed char schar;
typedef unsigned short ushort;
typedef unsigned long ulong;
typedef unsigned int uint;
typedef unsigned lint ulint;
typedef size_t usize;
typedef ssize_t ssize;
typedef RAWINPUTDEVICE ZDEVICE;
typedef RAWINPUT ZINPUT;
typedef HWND ZHWND;
typedef struct _ZDEVICELIST
uint T;
uint c;
uint s;
RAWINPUTDEVICELIST *a;
} ZDEVICELIST;
typedef struct _ZINPUTLIST
uint T;
uint c;
uint s;
RAWINPUT *a;
} ZINPUTLIST;
/** \brief creates a device structure
\return globally allocated object
uchar ziAllocDeviceList( ZDEVICELIST* devList )
#ifdef _WIN32
devList->T = sizeof( RAWINPUTDEVICELIST );
GetRawInputDeviceList( NULL, &devList->c, devList->T );
// Just in case new devices are attached :)
devList->c += 10;
devList->s = devList->c * devList->T;
HeapAlloc( GetProcessHeap(), 0, devList->s );
if ( devList->a )
//memset( devList->a, 0, devList->s );
GetRawInputDeviceList( devList->a, &devList->c, devList->s );
return 1;
#endif
devList->c = 0;
devList->s = 0;
return 0;
void ziFreeDeviceList( ZDEVICELIST *devList )
#ifdef _WIN32
HeapFree( GetProcessHeap(), 0, devList->a );
#endif
devList->c = 0;
devList->s = 0;
devList->a = NULL;
/** \brief Attempts to acquire a joypad object
\param hwnd The window that should have focus when capturing joypad state
\param n The nth joypad to acquire (0 indicates next available joypad)
\return device handle on success, NULL on failure
ZDEVICE* ziAcquireJoypadDevice( ZHWND hwnd, uchar n )
uchar c = 0;
uint i = 0;
ZDEVICE *dev = NULL;
ZDEVICELIST devList = {0};
ziAllocDeviceList( &devList );
for ( ; i < devList.c; ++i )
#ifdef _WIN32
dev = (ZDEVICE*)(devList.a[i].hDevice);
if ( dev->usUsagePage == 1 && dev->usUsage == 5 )
#else
if ( 0 )
#endif
++c;
if ( c > n )
break;
ziFreeDeviceList( &devList );
return ( i < devList.c ) ? dev : NULL;
#define Z_XBTN_Y 0
#define Z_XBTN_B 1
#define Z_XBTN_A 2
#define Z_XBTN_X 3
#define Z_XBTN_BACK 5
#define Z_XBTN_START 6
#define Z_XBTN_HSU 6
#define Z_XBTN_HSR 7
#define Z_XBTN_HSD 8
#define Z_XBTN_HSL 9
#define Z_XBTN_LT 10
#define Z_XBTN_RT 11
#define Z_XBTN_LB 12
#define Z_XBTN_RB 13
#define Z_XBTN_LS 14
#define Z_XBTN_RS 15
// Not sure if these are even accessible
#define Z_XBTN_HOME 16
#define Z_XBTN_TURBO 17
#define Z_XBTN_STOP 18
#define Z_XBTN_COUNT 19
#define Z_AXIS_X 0
#define Z_AXIS_Y 1
#define Z_AXIS_XR 2
#define Z_AXIS_YR 3
#define Z_AXIS_Z 4
// Dualshock 3 and higher or Wiimote
#define Z_AXIS_XP 5
#define Z_AXIS_YP 7
// Will this ever be provided?
#define Z_AXIS_ZP 8
#define Z_AXIS_COUNT 9
typedef struct _ZJOYPAD_INPUT
uchar btn[Z_XBTN_COUNT];
long axis[Z_AXIS_COUNT];
} ZJOYPAD_INPUT;
void printBuff( uchar *buff, usize s )
usize i = 0;
uint _v = 0;
uchar *v = (uchar*)&_v, j = 0, k = 32;
char *hex = "0123456789ABCDEF";
if ( !buff || !s )
return;
do
v[ i & 0x3 ] = buff[i]; ++i;
if ( (i & 0x3) == 0)
j = 0; k = 28;
do
putc( hex[ (_v >> k) & 0xf ], stdout );
j += 4; k -= 4;
} while ( j < 32 );
_v = 0;
if ( ( i & 0xf ) == 0 )
putc( '\n', stdout );
else
putc( ' ', stdout );
while ( i < s );
if ( i & 0x3 )
j = 0; k = 28;
do
putc( hex[ (_v >> k) & 0xf ], stdout );
j += 4; k -= 4;
} while ( j < 32 );
uint ziAcquireJoypadInput( ZDEVICE *dev, ZINPUT** din )
ZINPUT *r = NULL;
ZINPUTLIST iList = {0};
ZJOYPAD_INPUT joy = {{0}};
#ifdef _WIN32
HANDLE hHeap = GetProcessHeap();
iList.T = sizeof(RAWINPUT);
iList.s = iList.T;
GetRawInputBuffer( NULL, &iList.s, 0 );
if ( !iList.s )
return 0;
iList.s *= 8;
iList.a = (RAWINPUT*)HeapAlloc( hHeap, 0, iList.s );
if ( !iList.a )
return 0;
iList.c = GetRawInputBuffer( iList.a, &iList.s, 0 );
printBuff( (uchar*)iList.a, iList.s );
HeapFree( hHeap, 0, iList.a );
/// \todo Finish getting Joypad data
#endif
*din = iList.a;
return iList.s;
int main( void )
ZDEVICE* dev = ziAcquireJoypadDevice( NULL, 0 );
ZINPUT* din = NULL;
usize s = ziAcquireJoypadInput( dev, &din );
return 0;
I'm attempting to grab the input from my xbox controller at the moment (please for crying out loud do NOT refer me to XInput or WM_INPUT) but I keep getting BAADF00D come out when I try to access the buffer itself. Could someone explain to me what I've been
doing wrong? I would like to do this in async style code for example:
if ( ziAcquireJoypadInput( dev, &padi ) )
  for ( i = 0; i < Z_XBTN_COUNT; ++i )
    if ( (vbtn & (1<< i)) && !padi.btn[i] )
      break;
  for ( i = 0; i < Z_AXIS_COUNT; ++i )
    if ( vaxis[i] && !padi.axis[i] )
      break;
  if ( i == Z_XBTN_COUNT )
    // Peform action
This is for a general purpose hacking app btw, it will be in an executable that can inject itself in another of user choice and the function that checks for input will only be called via a jmp code (like with armax/xploder on playstation).

Thank you, you now have my sincere apology for my earlier attitude, as for the uninitialised buffer I think I got round to fixing that sortof, I still get a weird error when attempting to acquire the controller though but I'll move onto that later. For now
my biggest issue is that I cannot acquire the input buffer, just keep getting size of zero which doesn't make sense to me when there is at least 3 devices attached to my computer. Here is the updated code, is there anything you can spot that might be causing
this?
uchar ziAllocDeviceList( ZDEVICELIST* devList )
#ifdef _WIN32
devList->T = sizeof( RAWINPUTDEVICELIST );
GetRawInputDeviceList( NULL, &devList->c, devList->T );
// Just in case new devices are attached :)
if ( devList->c )
devList->c += 10;
devList->s = devList->c * devList->T;
devList->a = (RAWINPUTDEVICELIST*)malloc( devList->s );
if ( devList->a )
memset( devList->a, 0, devList->s );
devList->c = GetRawInputDeviceList( devList->a, &devList->c, devList->T );
return 1;
#endif
devList->c = 0;
devList->s = 0;
return 0;
void ziFreeDeviceList( ZDEVICELIST *devList )
#ifdef _WIN32
free( devList->a );
#endif
devList->c = 0;
devList->s = 0;
devList->a = NULL;
/** \brief Attempts to acquire a joypad object
\param hwnd The window that should have focus when capturing joypad state
\param n The nth joypad to acquire (0 indicates next available joypad)
\return device handle on success, NULL on failure
uchar ziAcquireJoypadDevice( ZDEVICE* ptr, ZHWND hwnd, uchar n )
uchar c = 0;
uint i = 0;
ushort usage = 0, page = 0;
ZDEVICE *dev = NULL, *prv = NULL;
ZDEVICELIST devList = {0};
ziAllocDeviceList( &devList );
if ( devList.c == UINT_MAX )
devList.c = 0;
i = GetLastError();
goto finish;
for ( ; i < devList.c; ++i )
#ifdef _WIN32
(HANDLE)dev = devList.a[i].hDevice;
if ( !dev )
continue;
page = dev->usUsagePage & 0xff;
usage = dev->usUsage & 0xff;
if ( (page == 1 || page == 4) && (usage == 4 || usage == 5) )
#else
if ( 0 )
#endif
++c;
prv = dev;
if ( c > n )
break;
finish:
ziFreeDeviceList( &devList );
if ( c )
*ptr = *prv;
ptr->dwFlags = 0;
ptr->hwndTarget = NULL;
#ifdef _WIN32
if ( !RegisterRawInputDevices( ptr, 1, sizeof(RAWINPUTDEVICE) ) )
i = GetLastError();
return 0;
#endif // _WIN32
return 1;
return 0;
uint ziAcquireJoypadInput( ZDEVICE *dev, ZINPUT** din )
uint i = 0;
ZINPUT *r = NULL;
ZINPUTLIST iList = {0};
ZJOYPAD_INPUT joy = {{0}};
#ifdef _WIN32
iList.T = sizeof(RAWINPUT);
iList.s = iList.T;
if ( GetRawInputBuffer( NULL, &(iList.s), sizeof(RAWINPUTHEADER) ) || !iList.s )
i = GetLastError();
return 0;
iList.s *= 8;
iList.a = (RAWINPUT*)malloc( iList.s );
if ( !iList.a )
return 0;
iList.c = GetRawInputBuffer( iList.a, &iList.T, sizeof(RAWINPUTHEADER) );
while ( i < iList.c )
r = &iList.a[i];
if ( r->header.hDevice == (HANDLE)dev )
break;
if ( i == iList.c )
r = NULL;
if ( r && r->data.hid.dwSizeHid != 0xBAADF00D )
printBuff( (uchar*)(r->data.hid.bRawData), r->data.hid.dwSizeHid * r->data.hid.dwCount );
free( iList.a );
/// \todo Finish getting Joypad data
#endif
*din = iList.a;
return iList.s;

Similar Messages

  • Xcode entering input error help please

    When i run Xcode 4.5.2 on Lion and i need to enter some input (ex. cin.getline(array,10)), i need to press enter two times to keep going.
    Here is the code:    
    player1 and palindrom are arrays of char
    and here is the output:
    I enter Juan in player1 then i press [Enter] and i need to press another [Enter] if i want the prgram to continue
    and when i enter the palindrom is not stored in the array, instead the second [Enter] is stored on the palindrom array.
    Help please
    i dont know what to do i have looked on the internet but i havent found anything to solve this problem......

    You are mixing up two different ways of getting user input.
    1. getline -- a standard <stdio> function which reads user input and a return;
    2. cin -- a C++ <iostream> function which reads user input and a return.
    See http://crasseux.com/books/ctutorial/getline.html and http://www.htmlhelpcentral.com/messageboard/showthread.php?4359-C-Tutorial-1-cou t-cin for the proper way to use either one of them; you cannot use both in the same command.
    quiban92 wrote:
    i dont know what to do i have looked on the internet but i havent found anything to solve this problem......
    Those two links were the very first hits on a search for "getline tutorial" and "cin tutorial".

  • Audio Monitoring with Guitar input? HELP, please?

    Hi.
    Running a MacPro, with Logic Pro 7.2.3. I have recently purchased an IK Multimedia STEALTHPLUG, to record electric guitar.
    I am able to get the device to operate properly in Garageband, and Ableton Live 5. But, in Logic Pro, i cannot get the audio to be monitored through my USB speakers. I can only hear 'live' guitar/as i play it if i choose the Stealthplug audio 'driver' option in Audio Hardware and Drivers. In this case, the live guitar is heard through the headphones plugged into the Stealthplug's headphone jack. I can also hear the Logic softsynths through the headphones, as well as any audio tracks recorded. When i switch back to the Core Audio driver, i can hear the guitar tracks i've already recorded, as well as the synths. But, the switching back and forth is ridiculous, and Core Audio has to be 're-booted' each time.
    But, i need/want to monitor ALL sound through the speakers. I've tried all manner of settings, but i get nada. Spoke with iKMultimedia, but they seem to be shirking responsibility now because the device works with other apps.
    I've tried the Audio Midi Setup in Applications>Utilities, as well as System Preferences>Sound. No combination of settings work.
      Mac OS X (10.4.7)  

    You need to setup an Aggregate Device in Audio/MIDI setup. Design it with the Stealthplug as the input and the speakers as the output. Then select that device as the I/O within Logic. (I'm not sure where that particular setting is located, since I'm not in the studio at the moment, but I'm sure that the process is described in the manual.)
    Good Luck!

  • I can not open raw files in elements 12 any help please?

    I can not open raw files from my Nikon D610 in elements 12. (I have already downloaded raw converter 8.3 but to no avail) any help please would be appreciated.

    Hi,
    Can you confirm which Camera Raw PSE 12 is actually using by loading the editor and going to Help -> About Plug-in -> Camera Raw.
    If you do Help -> Updates it may install the latest camera raw of 8.4 - not on XP or Vista systems.
    Do you use any Nikon software to download the images? The older versions have been known to corrupt the files.
    See the following for more info.
    http://owl.phy.queensu.ca/~phil/exiftool/fix_corrupted_nef.html
    Brian

  • Photoshop CS6 will not open raw files even after I downloaded a DNG converter help please!

    Photoshop CS6 will not open raw files even after I downloaded a DNG converter help please!

    We are pleased to announce the Adobe Camera Raw 8.7 RC is now live on Labs! See the links below.
    Technology pages:
    CC - http://labs.adobe.com/technologies/cameraraw8-7-cc/
    CS6 - http://labs.adobe.com/technologies/cameraraw8-7/
    Download pages:
    CC - http://labs.adobe.com/downloads/cameraraw8-7-cc.html
    CS6 - http://labs.adobe.com/downloads/cameraraw8-7.html

  • I have a sony rx100 and my version of lightroom (4) will not recognize the raw (.ARW) files. Please help!

    I have a sony rx100 and my version of lightroom (4) will not recognize the raw (.ARW) files. Please help!

    I have version 4.4.1 on my computer now, which is functioning properly - but does not read the .ARW files. When I download the link you sent and try to open it, it pops up as version 5 and I get this image (attached). This is my first time in one of these threads, not sure if i have to reply to each of you individually?
    DdeGannes, could you please tell me how to recover the serial number from my operating system?
    Thank you SO much everyone!

  • How to read a file with value of RAW data type? Please help

    Hi Experts,
       I  have a file with RAW data like DE864E48833BFFF1B805001CC4EF4BFA
       I am using GUI_UPLOAD.
       But this FM is throwing error.
       I tried by giving FILETYPE as ASC. The output internal table for this FM contains a field of type c size 32.
       Now it is able to read the file but I want to assign this value to a RAW data type variable.
       This it is unable to do. How to convert the char value to RAW data type?
    Please help!
    Thanks
    Gopal

    Hi,
    The documentation for the function module contains an example for RAW upload.
                begin of itab,
                      raw(255) type x,
                end of itab occurs 0.
               CALL FUNCTION 'GUI_UPLOAD'
               exporting
                  filetype =  'BIN'
                  filename = 'C:\DOWNLOAD.BIN'
               tables
                 data_tab = itab.

  • I need help please. Raw photo's.

    Ok. I took some sunset photo's in Raw.  I downloaded them on my computer. I couldn't view them on my PC. It wouldn't let me. A friend recommended lightroom 5 to view Raw photo's.  I purchased and installed and it own't import my raw photo's. It said at one point that i don't have an updated software.  This is the newest one they have.. Can anyone help please?
    Thank you. 

    You shouldn't post the same question in multiple forums. But here is the list of cameras that are supported by Lightroom and Camera Raw. Locate your make and model and it will tell you what you need.
    Camera Raw plug-in | Supported cameras

  • How to open Nikon D5300 Raw files in PSE 11? [was:Help Please]

    With My old Nikon D90 Elements 8 would open raw files OK I now have a new Nikon D5300 and when trying to open a raw file it tells me that it is the wrong type of file Help Please
    Andy

    There isn't a generic nikon raw. Each camera has its own raw format and the camera raw plugin has to be updated every time a new camera comes out. The D5300 requires ACR 8.3, which is only compatible with PSE 12. So you have three options:
    1. Upgrade to PSE 12.
    2. Use the nikon software to convert the files and send the converted images to PSE for any further editing.
    3. Download the free Adobe DNG converter and use that to create dng files that your version of camera raw can understand.

  • I am trying to download and install OSX Mavericks but everytime i input my Apple ID it keeps asking to review my account and then starts looking for credit card info, I do not have a credit card, also I thought OSX Mavericks was free, some help please.

    I am trying to download and install OSX Mavericks but everytime i input my Apple ID it keeps asking to review my account and then starts looking for credit card info, I do not have a credit card, also I thought OSX Mavericks was free, some help please.

    Yes I know it's free, but Im trying to find out how to download it and install, but I keep getting account review and asked for CC details as I have no CC I can't get the download or install it, any help please, what i don't understand is why would I be asked for CC details if it is a free download ?? i just want to know is there anything I can do.

  • My Canon 5D Mark 3 camera..I cannot download Raw files using iPhoto help please

    Canon 5D Mark 3 I cannot download Raw file in iPhoto help please?

    You will need OS X 10.7.4 and iPhoto 11 or Aperture 3 for this.
    What do you have?

  • I can't load raw files from a Leica d-lux 6. Says it's an unsupported file. Help please!

    I cannot load raw files from a Leica d-lux 6.  Aperture says it's an unsupported file.  How do I get it to be a supported file?  Help, please!

    What is your Aperture version? Here is the list of supported raw formats for Aperture 3, see: Apple - Aperture - Technical Specifications - RAW Support
    Your camera is not on the list. Use the software that came with your camera to convert your raw files to dng or tiff images; then you can import the images into Aperture and work with them, while waiting for Apple to release raw support for your camera. Or shoot raw+jpeg pairs and use the jpeg while you are waiting.
    Is Mac OS X (10.5.1) really your current operating system? Then you may need to upgrade, when Apple finally releases raw support for your camera. The newest raw support required Aperture 3.4. to be installed.
    Regards
    Léonie

  • Have just work a load of Raw files as previous but they have saved as Video clips + JPG and turn all other CR2 files to video Help Please

    Have just worked a load of Raw Photo Files in Photoshop as on previous occasions but this time they have saved as VIDEO + JPG, also turned all other CR2 files into video in the folder. Can anybody help please.

    This forum is for discussions about downloading and installing Adobe software.  You need to find the forum that discusses using whichever software you are trying to use.
    Here is a link to a page that has links to all Adobe forums...
    Forum links page:
    https://forums.adobe.com/welcome

  • Have photoshop cs5 installed on desktop..got new Canon rebel T5i camera...cannot open RAW images...updated and installed plug-in...still now working.  Need help, please.

    I have photoshop cs5 installed on desktop...got new Canon rebel T5i camera...cannot open RAW images...updated and installed plug-in...still not working...help please.

    In any event, that camera was first supported by ACR version 7.4 which needs at least CS6 to run.  Naturally, all later versions support it too.
    Your choice is either to upgrade your Photoshop, or to look for, download, install, launch and run the free, stand-alone Adobe DNG Converter 8.6 on each folder containing your raw Canon files to convert them first to raw DNGs that you can open in CS5.
    In no case does an Adobe application belong "on your desktop".  The default install location should always be respected and left alone.

  • Just bought Elements 13. Input serial number (starting 1057), which is not recognised and the installation stalls here. Urgent help please...

    Just bought Elements 13. Input serial number (starting 1057), which is not recognised and the installation stalls here. Urgent help please...

    Maryrhire910 I am sorry that you are facing difficulty downloading and installing Photoshop Elements 12.  Are you downloading the installation files from Download Photoshop Elements products | 13, 12, 11, 10?  If so what specific error are you receiving?

Maybe you are looking for