void F_API INPKBGetKeyName(u8 kCode, tCHAR *outbuffer, u32 size) { DIPROPSTRING string={0}; string.diph.dwSize = sizeof(DIPROPSTRING); string.diph.dwHeaderSize = sizeof(DIPROPHEADER); string.diph.dwObj = kCode; string.diph.dwHow = DIPH_BYOFFSET; HRESULT hr = g_pDKeyboard->GetProperty(DIPROP_KEYNAME, &string.diph); if(FAILED(hr)) { *outbuffer=0; } else { if(size > 260) { memcpy(outbuffer, string.wsz, sizeof(string.wsz)); } else { memcpy(outbuffer, string.wsz, sizeof(tCHAR)*size); outbuffer[size-1] = 0; } //wcscpy(outbuffer, string.wsz); } /*WideCharToMultiByte(CP_ACP, 0, string.wsz, -1, outbuffer, outbuffersize, NULL, NULL);*/ }
std::string GetDeviceName(const LPDIRECTINPUTDEVICE8 device) { DIPROPSTRING str = {}; str.diph.dwSize = sizeof(str); str.diph.dwHeaderSize = sizeof(str.diph); str.diph.dwHow = DIPH_DEVICE; std::string result; if (SUCCEEDED(device->GetProperty(DIPROP_PRODUCTNAME, &str.diph))) { result = StripSpaces(UTF16ToUTF8(str.wsz)); } return result; }
std::string GetDeviceName(const LPDIRECTINPUTDEVICE8 device) { std::string out; DIPROPSTRING str; ZeroMemory(&str, sizeof(str)); str.diph.dwSize = sizeof(str); str.diph.dwHeaderSize = sizeof(str.diph); str.diph.dwHow = DIPH_DEVICE; if (SUCCEEDED(device->GetProperty(DIPROP_PRODUCTNAME, &str.diph))) { const int size = WideCharToMultiByte(CP_UTF8, 0, str.wsz, -1, NULL, 0, NULL, NULL); char* const data = new char[size]; if (size == WideCharToMultiByte(CP_UTF8, 0, str.wsz, -1, data, size, NULL, NULL)) out.assign(data); delete[] data; } return StripSpaces(out); }
//======================================================================= // get range for an axis static HRESULT GetDIAxisRange(LPDIRECTINPUTDEVICE8 device, uint offset, DWORD type, sint &min, sint &max) { DIPROPRANGE diprg; diprg.diph.dwSize = sizeof(DIPROPRANGE); diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER); diprg.diph.dwHow = DIPH_BYOFFSET; diprg.diph.dwObj = offset; // Set the range for the axis HRESULT r = device->GetProperty(DIPROP_RANGE, &diprg.diph); if (r == DIERR_OBJECTNOTFOUND) { // try from its ID diprg.diph.dwHow = DIPH_BYID; diprg.diph.dwObj = type; // Set the range for the axis HRESULT r = device->GetProperty(DIPROP_RANGE, &diprg.diph); if (r != DI_OK) { // setup default values ... min = 0; max = 65535; return r; } } else if (r != DI_OK) { min = 0; max = 65535; return r; } /* switch (r) { default: nlinfo("ok"); break; case DIERR_INVALIDPARAM: nlinfo("invalid param"); break; case DIERR_NOTEXCLUSIVEACQUIRED: nlinfo("DIERR_NOTEXCLUSIVEACQUIRED"); break; case DIERR_NOTINITIALIZED: nlinfo("DIERR_NOTINITIALIZED"); break; case DIERR_OBJECTNOTFOUND: nlinfo("DIERR_OBJECTNOTFOUND"); break; case DIERR_UNSUPPORTED: nlinfo("DIERR_UNSUPPORTED"); break; }*/ min = (sint) diprg.lMin; max = (sint) diprg.lMax; return r; }
HRESULT _stdcall GetProperty(REFGUID a,LPDIPROPHEADER b) { return RealDevice->GetProperty(a,b); }