log("*************************\n"); log("Joystick buttons : %d\n",    currentDevice->nButtons); log("Joystick center X: %08lx\n", currentDevice->centerX); log("Joystick center Y: %08lx\n", currentDevice->centerY); log("Joystick left    : %08lx\n", currentDevice->thresholdLeft); log("Joystick right   : %08lx\n", currentDevice->thresholdRight); log("Joystick up      : %08lx\n", currentDevice->thresholdUp); log("Joystick down    : %08lx\n", currentDevice->thresholdDown); log("Joystick polled  : %d\n",    currentDevice->isPolled);
winlog("Joystick %2d polled  : %d\n",    i, currentDevice->isPolled); winlog("Joystick %2d buttons : %d\n",    i, currentDevice->nButtons); winlog("Joystick %2d povs    : %d\n",    i, currentDevice->nPovs); winlog("Joystick %2d axes    : %d\n",    i, currentDevice->nAxes); for(int j = 0; j < currentDevice->nAxes; j++) { winlog("Axis %2d offset      : %08lx\n", j, currentDevice->axis[j]. offset); winlog("Axis %2d center      : %08lx\n", j, currentDevice->axis[j]. center); winlog("Axis %2d negative    : %08lx\n",   j, currentDevice->axis[j]. negative); winlog("Axis %2d positive    : %08lx\n",   j, currentDevice->axis[j]. positive); }
BOOL initDirectInput(){  dinputDLL = LoadLibrary("DINPUT.DLL");  HRESULT (WINAPI *DInputCreate)(HINSTANCE,DWORD,LPDIRECTINPUT *,IUnknown *);    if(dinputDLL != NULL) {        DInputCreate = (HRESULT (WINAPI *)(HINSTANCE,DWORD,LPDIRECTINPUT *,IUnknown *))      GetProcAddress(dinputDLL, "DirectInputCreateA");        if(DInputCreate == NULL) {      directXMessage("DirectInputCreateA");      return FALSE;    }  } else {    directXMessage("DINPUT.DLL");    return FALSE;  }    HRESULT hret = DInputCreate(hInstance,                              DIRECTINPUT_VERSION,                              &pDirectInput,                              NULL);  if(hret != DI_OK) {    //    errorMessage(myLoadString(IDS_ERROR_DISP_CREATE), hret);    return FALSE;  }  hret = pDirectInput->EnumDevices(DIDEVTYPE_JOYSTICK,                                   DIEnumDevicesCallback2,                                   NULL,                                   DIEDFL_ATTACHEDONLY);      pDevices = (deviceInfo *)malloc(sizeof(deviceInfo) * numDevices);  hret = pDirectInput->CreateDevice(GUID_SysKeyboard,&pDevices[0].device,NULL);  pDevices[0].isPolled = FALSE;  pDevices[0].needed  = TRUE;  if(hret != DI_OK) {    //    errorMessage(myLoadString(IDS_ERROR_DISP_CREATEDEVICE), hret);    return FALSE;  }    numDevices = 1;  hret = pDirectInput->EnumDevices(DIDEVTYPE_JOYSTICK,                                   DIEnumDevicesCallback,                                   NULL,                                   DIEDFL_ATTACHEDONLY);    //  hret = pDevices[0].device->SetCooperativeLevel(hWindow,  //                                             DISCL_FOREGROUND|  //                                             DISCL_NONEXCLUSIVE);    if(hret != DI_OK) {    //    errorMessage(myLoadString(IDS_ERROR_DISP_LEVEL), hret);    return FALSE;  }    hret = pDevices[0].device->SetDataFormat(&c_dfDIKeyboard);  if(hret != DI_OK) {    //    errorMessage(myLoadString(IDS_ERROR_DISP_DATAFORMAT), hret);    return FALSE;  }  for(int i = 1; i < numDevices; i++) {    pDevices[i].device->SetDataFormat(&c_dfDIJoystick);    pDevices[i].needed = FALSE;    currentDevice = &pDevices[i];    axisNumber = 0;    currentDevice->device->EnumObjects(EnumAxesCallback, NULL, DIDFT_AXIS);    currentDevice->device->EnumObjects(EnumPovsCallback, NULL, DIDFT_POV);    /*    if(joydebug) {      // don't translate. debug only      log("*************************\n");      log("Joystick buttons : %d\n",    currentDevice->nButtons);      log("Joystick center X: %08lx\n", currentDevice->centerX);      log("Joystick center Y: %08lx\n", currentDevice->centerY);      log("Joystick left    : %08lx\n", currentDevice->thresholdLeft);      log("Joystick right   : %08lx\n", currentDevice->thresholdRight);      log("Joystick up      : %08lx\n", currentDevice->thresholdUp);      log("Joystick down    : %08lx\n", currentDevice->thresholdDown);      log("Joystick polled  : %d\n",    currentDevice->isPolled);    }    */        currentDevice = NULL;  }  for(i = 0; i < numDevices; i++)    pDevices[i].device->Acquire();    return TRUE;}