void setup_dsound_options(void) { char buffer[MAX_PATH+16]; HKEY hkey, appkey = 0; DWORD len; buffer[MAX_PATH]='\0'; /* @@ Wine registry key: HKCU\Software\Wine\DirectSound */ if (RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\DirectSound", &hkey )) hkey = 0; len = GetModuleFileNameA( 0, buffer, MAX_PATH ); if (len && len < MAX_PATH) { HKEY tmpkey; /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\DirectSound */ if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\AppDefaults", &tmpkey )) { char *p, *appname = buffer; if ((p = strrchr( appname, '/' ))) appname = p + 1; if ((p = strrchr( appname, '\\' ))) appname = p + 1; strcat( appname, "\\DirectSound" ); TRACE("appname = [%s]\n", appname); if (RegOpenKeyA( tmpkey, appname, &appkey )) appkey = 0; RegCloseKey( tmpkey ); } } /* get options */ if (!get_config_key( hkey, appkey, "HelBuflen", buffer, MAX_PATH )) ds_hel_buflen = atoi(buffer); if (!get_config_key( hkey, appkey, "SndQueueMax", buffer, MAX_PATH )) ds_snd_queue_max = atoi(buffer); if (!get_config_key( hkey, appkey, "MaxShadowSize", buffer, MAX_PATH )) ds_snd_shadow_maxsize = atoi(buffer); if (!get_config_key( hkey, appkey, "DefaultSampleRate", buffer, MAX_PATH )) ds_default_sample_rate = atoi(buffer); if (!get_config_key( hkey, appkey, "DefaultBitsPerSample", buffer, MAX_PATH )) ds_default_bits_per_sample = atoi(buffer); if (appkey) RegCloseKey( appkey ); if (hkey) RegCloseKey( hkey ); TRACE("ds_hel_buflen = %d\n", ds_hel_buflen); TRACE("ds_snd_queue_max = %d\n", ds_snd_queue_max); TRACE("ds_default_sample_rate = %d\n", ds_default_sample_rate); TRACE("ds_default_bits_per_sample = %d\n", ds_default_bits_per_sample); TRACE("ds_snd_shadow_maxsize = %d\n", ds_snd_shadow_maxsize); }
/*********************************************************************** * setup_options * * Set up the Mac driver options. */ static void setup_options(void) { char buffer[MAX_PATH + 16]; HKEY hkey, appkey = 0; DWORD len; /* @@ Wine registry key: HKCU\Software\Wine\Mac Driver */ if (RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Mac Driver", &hkey)) hkey = 0; /* open the app-specific key */ len = GetModuleFileNameA(0, buffer, MAX_PATH); if (len && len < MAX_PATH) { HKEY tmpkey; char *p, *appname = buffer; if ((p = strrchr(appname, '/'))) appname = p + 1; if ((p = strrchr(appname, '\\'))) appname = p + 1; strcat(appname, "\\Mac Driver"); /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\Mac Driver */ if (!RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\AppDefaults", &tmpkey)) { if (RegOpenKeyA(tmpkey, appname, &appkey)) appkey = 0; RegCloseKey(tmpkey); } } if (!get_config_key(hkey, appkey, "WindowsFloatWhenInactive", buffer, sizeof(buffer))) { if (!strcmp(buffer, "none")) topmost_float_inactive = TOPMOST_FLOAT_INACTIVE_NONE; else if (!strcmp(buffer, "all")) topmost_float_inactive = TOPMOST_FLOAT_INACTIVE_ALL; else topmost_float_inactive = TOPMOST_FLOAT_INACTIVE_NONFULLSCREEN; } if (!get_config_key(hkey, appkey, "CaptureDisplaysForFullscreen", buffer, sizeof(buffer))) capture_displays_for_fullscreen = IS_OPTION_TRUE(buffer[0]); if (!get_config_key(hkey, appkey, "SkipSingleBufferFlushes", buffer, sizeof(buffer))) skip_single_buffer_flushes = IS_OPTION_TRUE(buffer[0]); if (!get_config_key(hkey, appkey, "AllowVerticalSync", buffer, sizeof(buffer))) allow_vsync = IS_OPTION_TRUE(buffer[0]); if (!get_config_key(hkey, appkey, "AllowSetGamma", buffer, sizeof(buffer))) allow_set_gamma = IS_OPTION_TRUE(buffer[0]); if (appkey) RegCloseKey(appkey); if (hkey) RegCloseKey(hkey); }
void setup_dsound_options(void) { char buffer[MAX_PATH+16]; HKEY hkey, appkey = 0; DWORD len; buffer[MAX_PATH]='\0'; /* @@ Wine registry key: HKCU\Software\Wine\DirectSound */ if (RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\DirectSound", &hkey )) hkey = 0; len = GetModuleFileNameA( 0, buffer, MAX_PATH ); if (len && len < MAX_PATH) { HKEY tmpkey; /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\DirectSound */ if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\AppDefaults", &tmpkey )) { char *p, *appname = buffer; if ((p = strrchr( appname, '/' ))) appname = p + 1; if ((p = strrchr( appname, '\\' ))) appname = p + 1; strcat( appname, "\\DirectSound" ); TRACE("appname = [%s]\n", appname); if (RegOpenKeyA( tmpkey, appname, &appkey )) appkey = 0; RegCloseKey( tmpkey ); } } /* get options */ if (!get_config_key( hkey, appkey, "HelBuflen", buffer, MAX_PATH )) ds_hel_buflen = atoi(buffer); if (!get_config_key( hkey, appkey, "SndQueueMax", buffer, MAX_PATH )) ds_snd_queue_max = atoi(buffer); if (!get_config_key( hkey, appkey, "HQBuffersMax", buffer, MAX_PATH )) ds_hq_buffers_max = atoi(buffer); if (!get_config_key( hkey, appkey, "EAXEnabled", buffer, MAX_PATH )) ds_eax_enabled = IS_OPTION_TRUE( buffer[0] ); if (appkey) RegCloseKey( appkey ); if (hkey) RegCloseKey( hkey ); TRACE("ds_hel_buflen = %d\n", ds_hel_buflen); TRACE("ds_snd_queue_max = %d\n", ds_snd_queue_max); TRACE("ds_hq_buffers_max = %d\n", ds_hq_buffers_max); TRACE("ds_eax_enabled = %u\n", ds_eax_enabled); }
static SysMouseImpl *alloc_device(REFGUID rguid, IDirectInputImpl *dinput) { SysMouseImpl* newDevice; LPDIDATAFORMAT df = NULL; unsigned i; char buffer[20]; HKEY hkey, appkey; newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysMouseImpl)); if (!newDevice) return NULL; newDevice->base.IDirectInputDevice8A_iface.lpVtbl = &SysMouseAvt; newDevice->base.IDirectInputDevice8W_iface.lpVtbl = &SysMouseWvt; newDevice->base.ref = 1; newDevice->base.dwCoopLevel = DISCL_NONEXCLUSIVE | DISCL_BACKGROUND; newDevice->base.guid = *rguid; InitializeCriticalSection(&newDevice->base.crit); newDevice->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": SysMouseImpl*->base.crit"); newDevice->base.dinput = dinput; newDevice->base.event_proc = dinput_mouse_hook; get_app_key(&hkey, &appkey); if (!get_config_key(hkey, appkey, "MouseWarpOverride", buffer, sizeof(buffer))) { if (!strcasecmp(buffer, "disable")) newDevice->warp_override = WARP_DISABLE; else if (!strcasecmp(buffer, "force")) newDevice->warp_override = WARP_FORCE_ON; } if (appkey) RegCloseKey(appkey); if (hkey) RegCloseKey(hkey); /* Create copy of default data format */ if (!(df = HeapAlloc(GetProcessHeap(), 0, c_dfDIMouse2.dwSize))) goto failed; memcpy(df, &c_dfDIMouse2, c_dfDIMouse2.dwSize); if (!(df->rgodf = HeapAlloc(GetProcessHeap(), 0, df->dwNumObjs * df->dwObjSize))) goto failed; memcpy(df->rgodf, c_dfDIMouse2.rgodf, df->dwNumObjs * df->dwObjSize); /* Because we don't do any detection yet just modify instance and type */ for (i = 0; i < df->dwNumObjs; i++) if (DIDFT_GETTYPE(df->rgodf[i].dwType) & DIDFT_AXIS) df->rgodf[i].dwType = DIDFT_MAKEINSTANCE(i) | DIDFT_RELAXIS; else df->rgodf[i].dwType = DIDFT_MAKEINSTANCE(i) | DIDFT_PSHBUTTON; newDevice->base.data_format.wine_df = df; IDirectInput_AddRef(&newDevice->base.dinput->IDirectInput7A_iface); EnterCriticalSection(&dinput->crit); list_add_tail(&dinput->devices_list, &newDevice->base.entry); LeaveCriticalSection(&dinput->crit); return newDevice; failed: if (df) HeapFree(GetProcessHeap(), 0, df->rgodf); HeapFree(GetProcessHeap(), 0, df); HeapFree(GetProcessHeap(), 0, newDevice); return NULL; }
STATIC int pf_gametype_new(char *text, void *_context) { GameTypeContext *context = (GameTypeContext *)_context; char *token; int key; token = first_token(text); if (token == NULL) { return (0); } if (strcmp(token, "end") == 0) { add_config_type(context->gametype); parse_func = pf_top_level; parse_context = NULL; return (0); } key = get_config_key(token, new_keys); if (key <= 0) { return (key); } token = next_token(); if (strcmp(token, "=") != 0) { REPORT_ERROR((stderr, "Expecting \"=\", found \"%s\"", token)); return (-1); } token = next_value(); if ((token == NULL) && ((key != CK_MASTER_PROTOCOL) && (key != CK_MASTER_QUERY))) { REPORT_ERROR((stderr, "Missing value after \"=\"")); return (-1); } if (debug) { printf("%d %s = <%s>\n", key, new_keys[key - 1].key_name, token ? token : ""); } return (set_game_type_value(context->gametype, key, token)); }
STATIC int pf_gametype_modify(char *text, void *_context) { GameTypeContext *context = (GameTypeContext *)_context; char *token; int key; token = first_token(text); if (token == NULL) { return (0); } if (strcmp(token, "end") == 0) { parse_func = pf_top_level; parse_context = NULL; return (0); } key = get_config_key(token, modify_keys); token = next_token(); if (strcmp(token, "=") != 0) { REPORT_ERROR((stderr, "Expecting \"=\", found \"%s\"", token)); return (-1); } token = next_value(); if (token == NULL) { REPORT_ERROR((stderr, "Missing value after \"=\"")); return (-1); } if (debug) { printf("%d %s = <%s>\n", key, modify_keys[key - 1].key_name, token ? token : ""); } return (modify_game_type_value(context->gametype, key, token)); }
{ s = LIST_ENTRY(cursor, struct setting, entry); if (root != s->root) continue; if (lstrcmpiW(path, s->path) != 0) continue; if (!s->name) continue; if (lstrcmpiW(name, s->name) != 0) continue; WINE_TRACE("found %s:%s in settings list, returning %s\n", wine_dbgstr_w(path), wine_dbgstr_w(name), wine_dbgstr_w(s->value)); return s->value ? strdupW(s->value) : NULL; } /* no, so get from the registry */ val = get_config_key(root, path, name, def); WINE_TRACE("returning %s\n", wine_dbgstr_w(val)); return val; } char *get_reg_key(HKEY root, const char *path, const char *name, const char *def) { WCHAR *wpath, *wname, *wdef = NULL, *wRet = NULL; char *szRet = NULL; int len; WINE_TRACE("path=%s, name=%s, def=%s\n", path, name, def); wpath = HeapAlloc(GetProcessHeap(), 0, (strlen(path)+1)*sizeof(WCHAR));
HRESULT setup_dinput_options(JoystickGenericImpl *This, const int *default_axis_map) { char buffer[MAX_PATH+16]; HKEY hkey, appkey; int tokens = 0; int axis = 0; int pov = 0; get_app_key(&hkey, &appkey); /* get options */ if (!get_config_key(hkey, appkey, "DefaultDeadZone", buffer, sizeof(buffer))) { This->deadzone = atoi(buffer); TRACE("setting default deadzone to: \"%s\" %d\n", buffer, This->deadzone); } This->axis_map = HeapAlloc(GetProcessHeap(), 0, This->device_axis_count * sizeof(int)); if (!This->axis_map) return DIERR_OUTOFMEMORY; if (!get_config_key(hkey, appkey, This->name, buffer, sizeof(buffer))) { static const char *axis_names[] = {"X", "Y", "Z", "Rx", "Ry", "Rz", "Slider1", "Slider2", "POV1", "POV2", "POV3", "POV4"}; const char *delim = ","; char * ptr; TRACE("\"%s\" = \"%s\"\n", This->name, buffer); if ((ptr = strtok(buffer, delim)) != NULL) { do { int i; for (i = 0; i < sizeof(axis_names) / sizeof(axis_names[0]); i++) { if (!strcmp(ptr, axis_names[i])) { if (!strncmp(ptr, "POV", 3)) { if (pov >= 4) { WARN("Only 4 POVs supported - ignoring extra\n"); i = -1; } else { /* Pov takes two axes */ This->axis_map[tokens++] = i; pov++; } } else { if (axis >= 8) { FIXME("Only 8 Axes supported - ignoring extra\n"); i = -1; } else axis++; } break; } } if (i == sizeof(axis_names) / sizeof(axis_names[0])) { ERR("invalid joystick axis type: \"%s\"\n", ptr); i = -1; } This->axis_map[tokens] = i; tokens++; } while ((ptr = strtok(NULL, delim)) != NULL); if (tokens != This->device_axis_count) { ERR("not all joystick axes mapped: %d axes(%d,%d), %d arguments\n", This->device_axis_count, axis, pov, tokens); while (tokens < This->device_axis_count) { This->axis_map[tokens] = -1; tokens++; } } } } else { int i; if (default_axis_map) { /* Use default mapping from the driver */ for (i = 0; i < This->device_axis_count; i++) { This->axis_map[i] = default_axis_map[i]; tokens = default_axis_map[i]; if (tokens < 0) continue; if (tokens < 8) axis++; else if (tokens < 15) { i++; pov++; This->axis_map[i] = default_axis_map[i]; } } } else { /* No config - set default mapping. */ for (i = 0; i < This->device_axis_count; i++) { if (i < 8) This->axis_map[i] = axis++; else if (i < 15) { This->axis_map[i++] = 8 + pov; This->axis_map[i ] = 8 + pov++; } else This->axis_map[i] = -1; } } } This->devcaps.dwAxes = axis; This->devcaps.dwPOVs = pov; if (appkey) RegCloseKey(appkey); if (hkey) RegCloseKey(hkey); return DI_OK; }
static BOOL wined3d_dll_init(HINSTANCE hInstDLL) { DWORD wined3d_context_tls_idx; HMODULE mod; char buffer[MAX_PATH+10]; DWORD size = sizeof(buffer); HKEY hkey = 0; HKEY appkey = 0; DWORD len, tmpvalue; WNDCLASSA wc; wined3d_context_tls_idx = TlsAlloc(); if (wined3d_context_tls_idx == TLS_OUT_OF_INDEXES) { DWORD err = GetLastError(); ERR("Failed to allocate context TLS index, err %#x.\n", err); return FALSE; } context_set_tls_idx(wined3d_context_tls_idx); /* We need our own window class for a fake window which we use to retrieve GL capabilities */ /* We might need CS_OWNDC in the future if we notice strange things on Windows. * Various articles/posts about OpenGL problems on Windows recommend this. */ wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = DefWindowProcA; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstDLL; wc.hIcon = LoadIconA(NULL, (LPCSTR)IDI_WINLOGO); wc.hCursor = LoadCursorA(NULL, (LPCSTR)IDC_ARROW); wc.hbrBackground = NULL; wc.lpszMenuName = NULL; wc.lpszClassName = WINED3D_OPENGL_WINDOW_CLASS_NAME; if (!RegisterClassA(&wc)) { ERR("Failed to register window class 'WineD3D_OpenGL'!\n"); if (!TlsFree(wined3d_context_tls_idx)) { DWORD err = GetLastError(); ERR("Failed to free context TLS index, err %#x.\n", err); } return FALSE; } DisableThreadLibraryCalls(hInstDLL); mod = GetModuleHandleA( "winex11.drv" ); if (mod) { wine_tsx11_lock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_lock" ); wine_tsx11_unlock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_unlock" ); } else /* We are most likely on Windows */ { wine_tsx11_lock_ptr = wined3d_do_nothing; wine_tsx11_unlock_ptr = wined3d_do_nothing; } /* @@ Wine registry key: HKCU\Software\Wine\Direct3D */ if ( RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Direct3D", &hkey ) ) hkey = 0; len = GetModuleFileNameA( 0, buffer, MAX_PATH ); if (len && len < MAX_PATH) { HKEY tmpkey; /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\Direct3D */ if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\AppDefaults", &tmpkey )) { char *p, *appname = buffer; if ((p = strrchr( appname, '/' ))) appname = p + 1; if ((p = strrchr( appname, '\\' ))) appname = p + 1; strcat( appname, "\\Direct3D" ); TRACE("appname = [%s]\n", appname); if (RegOpenKeyA( tmpkey, appname, &appkey )) appkey = 0; RegCloseKey( tmpkey ); } } if (hkey || appkey) { if ( !get_config_key( hkey, appkey, "VertexShaderMode", buffer, size) ) { if (!strcmp(buffer,"none")) { TRACE("Disable vertex shaders\n"); wined3d_settings.vs_mode = VS_NONE; } } if ( !get_config_key( hkey, appkey, "PixelShaderMode", buffer, size) ) { if (!strcmp(buffer,"enabled")) { TRACE("Allow pixel shaders\n"); wined3d_settings.ps_mode = PS_HW; } if (!strcmp(buffer,"disabled")) { TRACE("Disable pixel shaders\n"); wined3d_settings.ps_mode = PS_NONE; } } if ( !get_config_key( hkey, appkey, "UseGLSL", buffer, size) ) { if (!strcmp(buffer,"disabled")) { ERR_(winediag)("The GLSL shader backend has been disabled. You get to keep all the pieces if it breaks.\n"); TRACE("Use of GL Shading Language disabled\n"); wined3d_settings.glslRequested = FALSE; } } if ( !get_config_key( hkey, appkey, "OffscreenRenderingMode", buffer, size) ) { if (!strcmp(buffer,"backbuffer")) { TRACE("Using the backbuffer for offscreen rendering\n"); wined3d_settings.offscreen_rendering_mode = ORM_BACKBUFFER; } else if (!strcmp(buffer,"fbo")) { TRACE("Using FBOs for offscreen rendering\n"); wined3d_settings.offscreen_rendering_mode = ORM_FBO; } } if ( !get_config_key( hkey, appkey, "RenderTargetLockMode", buffer, size) ) { if (!strcmp(buffer,"readdraw")) { TRACE("Using glReadPixels for render target reading and glDrawPixels for writing\n"); wined3d_settings.rendertargetlock_mode = RTL_READDRAW; } else if (!strcmp(buffer,"readtex")) { TRACE("Using glReadPixels for render target reading and textures for writing\n"); wined3d_settings.rendertargetlock_mode = RTL_READTEX; } } if ( !get_config_key_dword( hkey, appkey, "VideoPciDeviceID", &tmpvalue) ) { int pci_device_id = tmpvalue; /* A pci device id is 16-bit */ if(pci_device_id > 0xffff) { ERR("Invalid value for VideoPciDeviceID. The value should be smaller or equal to 65535 or 0xffff\n"); } else { TRACE("Using PCI Device ID %04x\n", pci_device_id); wined3d_settings.pci_device_id = pci_device_id; } } if ( !get_config_key_dword( hkey, appkey, "VideoPciVendorID", &tmpvalue) ) { int pci_vendor_id = tmpvalue; /* A pci device id is 16-bit */ if(pci_vendor_id > 0xffff) { ERR("Invalid value for VideoPciVendorID. The value should be smaller or equal to 65535 or 0xffff\n"); } else { TRACE("Using PCI Vendor ID %04x\n", pci_vendor_id); wined3d_settings.pci_vendor_id = pci_vendor_id; } } if ( !get_config_key( hkey, appkey, "VideoMemorySize", buffer, size) ) { int TmpVideoMemorySize = atoi(buffer); if(TmpVideoMemorySize > 0) { wined3d_settings.emulated_textureram = TmpVideoMemorySize *1024*1024; TRACE("Use %iMB = %d byte for emulated_textureram\n", TmpVideoMemorySize, wined3d_settings.emulated_textureram); } else ERR("VideoMemorySize is %i but must be >0\n", TmpVideoMemorySize); } if ( !get_config_key( hkey, appkey, "WineLogo", buffer, size) ) { size_t len = strlen(buffer) + 1; wined3d_settings.logo = HeapAlloc(GetProcessHeap(), 0, len); if (!wined3d_settings.logo) ERR("Failed to allocate logo path memory.\n"); else memcpy(wined3d_settings.logo, buffer, len); } if ( !get_config_key( hkey, appkey, "Multisampling", buffer, size) ) { if (!strcmp(buffer, "disabled")) { TRACE("Multisampling disabled.\n"); wined3d_settings.allow_multisampling = FALSE; } } if (!get_config_key(hkey, appkey, "StrictDrawOrdering", buffer, size) && !strcmp(buffer,"enabled")) { TRACE("Enforcing strict draw ordering.\n"); wined3d_settings.strict_draw_ordering = TRUE; } if (!get_config_key(hkey, appkey, "AlwaysOffscreen", buffer, size) && !strcmp(buffer,"enabled")) { TRACE("Always rendering backbuffers offscreen.\n"); wined3d_settings.always_offscreen = TRUE; } } if (wined3d_settings.vs_mode == VS_HW) TRACE("Allow HW vertex shaders\n"); if (wined3d_settings.ps_mode == PS_NONE) TRACE("Disable pixel shaders\n"); if (wined3d_settings.glslRequested) TRACE("If supported by your system, GL Shading Language will be used\n"); if (appkey) RegCloseKey( appkey ); if (hkey) RegCloseKey( hkey ); return TRUE; }
static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *dinput, unsigned short index) { JoystickImpl* newDevice; LPDIDATAFORMAT df = NULL; int i, idx = 0; char buffer[MAX_PATH+16]; HKEY hkey, appkey; LONG def_deadzone = 0; newDevice = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(JoystickImpl)); if (!newDevice) return NULL; newDevice->base.lpVtbl = jvt; newDevice->base.ref = 1; newDevice->base.guid = *rguid; newDevice->base.dinput = dinput; newDevice->joyfd = -1; newDevice->joydev = &joydevs[index]; #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION newDevice->ff_state = FF_STATUS_STOPPED; #endif InitializeCriticalSection(&newDevice->base.crit); newDevice->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JoystickImpl*->base.crit"); /* get options */ get_app_key(&hkey, &appkey); if (!get_config_key(hkey, appkey, "DefaultDeadZone", buffer, MAX_PATH)) { def_deadzone = atoi(buffer); TRACE("setting default deadzone to: %d\n", def_deadzone); } if (appkey) RegCloseKey(appkey); if (hkey) RegCloseKey(hkey); /* Create copy of default data format */ if (!(df = HeapAlloc(GetProcessHeap(), 0, c_dfDIJoystick2.dwSize))) goto failed; memcpy(df, &c_dfDIJoystick2, c_dfDIJoystick2.dwSize); if (!(df->rgodf = HeapAlloc(GetProcessHeap(), 0, df->dwNumObjs * df->dwObjSize))) goto failed; /* Supported Axis & POVs should map 1-to-1 */ for (i = 0; i < WINE_JOYSTICK_MAX_AXES; i++) { if (!test_bit(newDevice->joydev->absbits, i)) { newDevice->axes[i] = -1; continue; } memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[i], df->dwObjSize); newDevice->axes[i] = idx; newDevice->props[idx].lDevMin = newDevice->joydev->axes[i].minimum; newDevice->props[idx].lDevMax = newDevice->joydev->axes[i].maximum; newDevice->props[idx].lMin = 0; newDevice->props[idx].lMax = 0xffff; newDevice->props[idx].lSaturation = 0; newDevice->props[idx].lDeadZone = def_deadzone; df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(newDevice->numAxes++) | DIDFT_ABSAXIS; } for (i = 0; i < WINE_JOYSTICK_MAX_POVS; i++) { if (!test_bit(newDevice->joydev->absbits, ABS_HAT0X + i * 2) || !test_bit(newDevice->joydev->absbits, ABS_HAT0Y + i * 2)) { newDevice->axes[ABS_HAT0X + i * 2] = newDevice->axes[ABS_HAT0Y + i * 2] = -1; continue; } memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[i + WINE_JOYSTICK_MAX_AXES], df->dwObjSize); newDevice->axes[ABS_HAT0X + i * 2] = newDevice->axes[ABS_HAT0Y + i * 2] = i; df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(newDevice->numPOVs++) | DIDFT_POV; } /* Buttons can be anywhere, so check all */ for (i = 0; i < KEY_MAX && newDevice->numButtons < WINE_JOYSTICK_MAX_BUTTONS; i++) { if (!test_bit(newDevice->joydev->keybits, i)) continue; memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[newDevice->numButtons + WINE_JOYSTICK_MAX_AXES + WINE_JOYSTICK_MAX_POVS], df->dwObjSize); newDevice->buttons[i] = 0x80 | newDevice->numButtons; df->rgodf[idx ].pguid = &GUID_Button; df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(newDevice->numButtons++) | DIDFT_PSHBUTTON; } df->dwNumObjs = idx; fake_current_js_state(newDevice); newDevice->base.data_format.wine_df = df; IDirectInput_AddRef((LPDIRECTINPUTDEVICE8A)newDevice->base.dinput); return newDevice; failed: if (df) HeapFree(GetProcessHeap(), 0, df->rgodf); HeapFree(GetProcessHeap(), 0, df); HeapFree(GetProcessHeap(), 0, newDevice); return NULL; }
void setup_dsound_options(void) { char buffer[MAX_PATH+16]; HKEY hkey, appkey = 0; DWORD len; buffer[MAX_PATH]='\0'; /* @@ Wine registry key: HKCU\Software\Wine\DirectSound */ if (RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\DirectSound", &hkey )) hkey = 0; len = GetModuleFileNameA( 0, buffer, MAX_PATH ); if (len && len < MAX_PATH) { HKEY tmpkey; /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\DirectSound */ if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\AppDefaults", &tmpkey )) { char *p, *appname = buffer; if ((p = strrchr( appname, '/' ))) appname = p + 1; if ((p = strrchr( appname, '\\' ))) appname = p + 1; strcat( appname, "\\DirectSound" ); TRACE("appname = [%s]\n", appname); if (RegOpenKeyA( tmpkey, appname, &appkey )) appkey = 0; RegCloseKey( tmpkey ); } } /* get options */ if (!get_config_key( hkey, appkey, "EmulDriver", buffer, MAX_PATH )) ds_emuldriver = strcmp(buffer, "N"); if (!get_config_key( hkey, appkey, "HelBuflen", buffer, MAX_PATH )) ds_hel_buflen = atoi(buffer); if (!get_config_key( hkey, appkey, "SndQueueMax", buffer, MAX_PATH )) ds_snd_queue_max = atoi(buffer); if (!get_config_key( hkey, appkey, "SndQueueMin", buffer, MAX_PATH )) ds_snd_queue_min = atoi(buffer); if (!get_config_key( hkey, appkey, "HardwareAcceleration", buffer, MAX_PATH )) { if (strcmp(buffer, "Full") == 0) ds_hw_accel = DS_HW_ACCEL_FULL; else if (strcmp(buffer, "Standard") == 0) ds_hw_accel = DS_HW_ACCEL_STANDARD; else if (strcmp(buffer, "Basic") == 0) ds_hw_accel = DS_HW_ACCEL_BASIC; else if (strcmp(buffer, "Emulation") == 0) ds_hw_accel = DS_HW_ACCEL_EMULATION; } if (!get_config_key( hkey, appkey, "DefaultPlayback", buffer, MAX_PATH )) ds_default_playback = atoi(buffer); if (!get_config_key( hkey, appkey, "MaxShadowSize", buffer, MAX_PATH )) ds_snd_shadow_maxsize = atoi(buffer); if (!get_config_key( hkey, appkey, "DefaultCapture", buffer, MAX_PATH )) ds_default_capture = atoi(buffer); if (!get_config_key( hkey, appkey, "DefaultSampleRate", buffer, MAX_PATH )) ds_default_sample_rate = atoi(buffer); if (!get_config_key( hkey, appkey, "DefaultBitsPerSample", buffer, MAX_PATH )) ds_default_bits_per_sample = atoi(buffer); if (appkey) RegCloseKey( appkey ); if (hkey) RegCloseKey( hkey ); TRACE("ds_emuldriver = %d\n", ds_emuldriver); TRACE("ds_hel_buflen = %d\n", ds_hel_buflen); TRACE("ds_snd_queue_max = %d\n", ds_snd_queue_max); TRACE("ds_snd_queue_min = %d\n", ds_snd_queue_min); TRACE("ds_hw_accel = %s\n", ds_hw_accel==DS_HW_ACCEL_FULL ? "Full" : ds_hw_accel==DS_HW_ACCEL_STANDARD ? "Standard" : ds_hw_accel==DS_HW_ACCEL_BASIC ? "Basic" : ds_hw_accel==DS_HW_ACCEL_EMULATION ? "Emulation" : "Unknown"); TRACE("ds_default_playback = %d\n", ds_default_playback); TRACE("ds_default_capture = %d\n", ds_default_playback); TRACE("ds_default_sample_rate = %d\n", ds_default_sample_rate); TRACE("ds_default_bits_per_sample = %d\n", ds_default_bits_per_sample); TRACE("ds_snd_shadow_maxsize = %d\n", ds_snd_shadow_maxsize); }
/*********************************************************************** * setup_options * * Set up the Mac driver options. */ static void setup_options(void) { char buffer[MAX_PATH + 16]; HKEY hkey, appkey = 0; DWORD len; /* @@ Wine registry key: HKCU\Software\Wine\Mac Driver */ if (RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Mac Driver", &hkey)) hkey = 0; /* open the app-specific key */ len = GetModuleFileNameA(0, buffer, MAX_PATH); if (len && len < MAX_PATH) { HKEY tmpkey; char *p, *appname = buffer; if ((p = strrchr(appname, '/'))) appname = p + 1; if ((p = strrchr(appname, '\\'))) appname = p + 1; strcat(appname, "\\Mac Driver"); /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\Mac Driver */ if (!RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\AppDefaults", &tmpkey)) { if (RegOpenKeyA(tmpkey, appname, &appkey)) appkey = 0; RegCloseKey(tmpkey); } } if (!get_config_key(hkey, appkey, "WindowsFloatWhenInactive", buffer, sizeof(buffer))) { if (!strcmp(buffer, "none")) topmost_float_inactive = TOPMOST_FLOAT_INACTIVE_NONE; else if (!strcmp(buffer, "all")) topmost_float_inactive = TOPMOST_FLOAT_INACTIVE_ALL; else topmost_float_inactive = TOPMOST_FLOAT_INACTIVE_NONFULLSCREEN; } if (!get_config_key(hkey, appkey, "CaptureDisplaysForFullscreen", buffer, sizeof(buffer))) capture_displays_for_fullscreen = IS_OPTION_TRUE(buffer[0]); if (!get_config_key(hkey, appkey, "SkipSingleBufferFlushes", buffer, sizeof(buffer))) skip_single_buffer_flushes = IS_OPTION_TRUE(buffer[0]); if (!get_config_key(hkey, appkey, "AllowVerticalSync", buffer, sizeof(buffer))) allow_vsync = IS_OPTION_TRUE(buffer[0]); if (!get_config_key(hkey, appkey, "AllowSetGamma", buffer, sizeof(buffer))) allow_set_gamma = IS_OPTION_TRUE(buffer[0]); if (!get_config_key(hkey, appkey, "LeftOptionIsAlt", buffer, sizeof(buffer))) left_option_is_alt = IS_OPTION_TRUE(buffer[0]); if (!get_config_key(hkey, appkey, "RightOptionIsAlt", buffer, sizeof(buffer))) right_option_is_alt = IS_OPTION_TRUE(buffer[0]); if (!get_config_key(hkey, appkey, "AllowSoftwareRendering", buffer, sizeof(buffer))) allow_software_rendering = IS_OPTION_TRUE(buffer[0]); /* Value name chosen to match what's used in the X11 driver. */ if (!get_config_key(hkey, appkey, "Decorated", buffer, sizeof(buffer))) disable_window_decorations = !IS_OPTION_TRUE(buffer[0]); if (!get_config_key(hkey, appkey, "AllowImmovableWindows", buffer, sizeof(buffer))) allow_immovable_windows = IS_OPTION_TRUE(buffer[0]); if (!get_config_key(hkey, appkey, "CursorClippingLocksWindows", buffer, sizeof(buffer))) cursor_clipping_locks_windows = IS_OPTION_TRUE(buffer[0]); if (!get_config_key(hkey, appkey, "UsePreciseScrolling", buffer, sizeof(buffer))) use_precise_scrolling = IS_OPTION_TRUE(buffer[0]); if (!get_config_key(hkey, appkey, "OpenGLSurfaceMode", buffer, sizeof(buffer))) { if (!strcmp(buffer, "transparent")) gl_surface_mode = GL_SURFACE_IN_FRONT_TRANSPARENT; else if (!strcmp(buffer, "behind")) gl_surface_mode = GL_SURFACE_BEHIND; else gl_surface_mode = GL_SURFACE_IN_FRONT_OPAQUE; } if (appkey) RegCloseKey(appkey); if (hkey) RegCloseKey(hkey); }
/* At process attach */ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv) { TRACE("WineD3D DLLMain Reason=%d\n", fdwReason); if (fdwReason == DLL_PROCESS_ATTACH) { HMODULE mod; char buffer[MAX_PATH+10]; DWORD size = sizeof(buffer); HKEY hkey = 0; HKEY appkey = 0; DWORD len; WNDCLASSA wc; atifs_shader_backend.shader_dll_load_init(); glsl_shader_backend.shader_dll_load_init(); arb_program_shader_backend.shader_dll_load_init(); none_shader_backend.shader_dll_load_init(); /* We need our own window class for a fake window which we use to retrieve GL capabilities */ /* We might need CS_OWNDC in the future if we notice strange things on Windows. * Various articles/posts about OpenGL problems on Windows recommend this. */ wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = DefWindowProcA; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstDLL; wc.hIcon = LoadIconA(NULL, (LPCSTR)IDI_WINLOGO); wc.hCursor = LoadCursorA(NULL, (LPCSTR)IDC_ARROW); wc.hbrBackground = NULL; wc.lpszMenuName = NULL; wc.lpszClassName = "WineD3D_OpenGL"; if (!RegisterClassA(&wc) && GetLastError() != ERROR_CLASS_ALREADY_EXISTS) { ERR("Failed to register window class 'WineD3D_OpenGL'!\n"); return FALSE; } DisableThreadLibraryCalls(hInstDLL); mod = GetModuleHandleA( "winex11.drv" ); if (mod) { wine_tsx11_lock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_lock" ); wine_tsx11_unlock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_unlock" ); } else /* We are most likely on Windows */ { wine_tsx11_lock_ptr = wined3d_do_nothing; wine_tsx11_unlock_ptr = wined3d_do_nothing; } /* @@ Wine registry key: HKCU\Software\Wine\Direct3D */ if ( RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Direct3D", &hkey ) ) hkey = 0; len = GetModuleFileNameA( 0, buffer, MAX_PATH ); if (len && len < MAX_PATH) { HKEY tmpkey; /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\Direct3D */ if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\AppDefaults", &tmpkey )) { char *p, *appname = buffer; if ((p = strrchr( appname, '/' ))) appname = p + 1; if ((p = strrchr( appname, '\\' ))) appname = p + 1; strcat( appname, "\\Direct3D" ); TRACE("appname = [%s]\n", appname); if (RegOpenKeyA( tmpkey, appname, &appkey )) appkey = 0; RegCloseKey( tmpkey ); } } if ( 0 != hkey || 0 != appkey ) { if ( !get_config_key( hkey, appkey, "VertexShaderMode", buffer, size) ) { if (!strcmp(buffer,"none")) { TRACE("Disable vertex shaders\n"); wined3d_settings.vs_mode = VS_NONE; } } if ( !get_config_key( hkey, appkey, "PixelShaderMode", buffer, size) ) { if (!strcmp(buffer,"enabled")) { TRACE("Allow pixel shaders\n"); wined3d_settings.ps_mode = PS_HW; } if (!strcmp(buffer,"disabled")) { TRACE("Disable pixel shaders\n"); wined3d_settings.ps_mode = PS_NONE; } } if ( !get_config_key( hkey, appkey, "VertexBufferMode", buffer, size) ) { if (!strcmp(buffer,"none")) { TRACE("Disable Vertex Buffer Hardware support\n"); wined3d_settings.vbo_mode = VBO_NONE; } else if (!strcmp(buffer,"hardware")) { TRACE("Allow Vertex Buffer Hardware support\n"); wined3d_settings.vbo_mode = VBO_HW; } } if ( !get_config_key( hkey, appkey, "UseGLSL", buffer, size) ) { if (!strcmp(buffer,"disabled")) { TRACE("Use of GL Shading Language disabled\n"); wined3d_settings.glslRequested = FALSE; } } if ( !get_config_key( hkey, appkey, "OffscreenRenderingMode", buffer, size) ) { if (!strcmp(buffer,"backbuffer")) { TRACE("Using the backbuffer for offscreen rendering\n"); wined3d_settings.offscreen_rendering_mode = ORM_BACKBUFFER; } else if (!strcmp(buffer,"pbuffer")) { TRACE("Using PBuffers for offscreen rendering\n"); wined3d_settings.offscreen_rendering_mode = ORM_PBUFFER; } else if (!strcmp(buffer,"fbo")) { TRACE("Using FBOs for offscreen rendering\n"); wined3d_settings.offscreen_rendering_mode = ORM_FBO; } } if ( !get_config_key( hkey, appkey, "RenderTargetLockMode", buffer, size) ) { if (!strcmp(buffer,"disabled")) { TRACE("Disabling render target locking\n"); wined3d_settings.rendertargetlock_mode = RTL_DISABLE; } else if (!strcmp(buffer,"readdraw")) { TRACE("Using glReadPixels for render target reading and glDrawPixels for writing\n"); wined3d_settings.rendertargetlock_mode = RTL_READDRAW; } else if (!strcmp(buffer,"readtex")) { TRACE("Using glReadPixels for render target reading and textures for writing\n"); wined3d_settings.rendertargetlock_mode = RTL_READTEX; } else if (!strcmp(buffer,"texdraw")) { TRACE("Using textures for render target reading and glDrawPixels for writing\n"); wined3d_settings.rendertargetlock_mode = RTL_TEXDRAW; } else if (!strcmp(buffer,"textex")) { TRACE("Reading render targets via textures and writing via textures\n"); wined3d_settings.rendertargetlock_mode = RTL_TEXTEX; } } if ( !get_config_key( hkey, appkey, "VideoMemorySize", buffer, size) ) { int TmpVideoMemorySize = atoi(buffer); if(TmpVideoMemorySize > 0) { wined3d_settings.emulated_textureram = TmpVideoMemorySize *1024*1024; TRACE("Use %iMB = %d byte for emulated_textureram\n", TmpVideoMemorySize, wined3d_settings.emulated_textureram); } else ERR("VideoMemorySize is %i but must be >0\n", TmpVideoMemorySize); } if ( !get_config_key( hkey, appkey, "WineLogo", buffer, size) ) { wined3d_settings.logo = HeapAlloc(GetProcessHeap(), 0, strlen(buffer) + 1); if(wined3d_settings.logo) strcpy(wined3d_settings.logo, buffer); } if ( !get_config_key( hkey, appkey, "Multisampling", buffer, size) ) { if (!strcmp(buffer,"enabled")) { TRACE("Allow multisampling\n"); wined3d_settings.allow_multisampling = TRUE; } } } if (wined3d_settings.vs_mode == VS_HW) TRACE("Allow HW vertex shaders\n"); if (wined3d_settings.ps_mode == PS_NONE) TRACE("Disable pixel shaders\n"); if (wined3d_settings.vbo_mode == VBO_NONE) TRACE("Disable Vertex Buffer Hardware support\n"); if (wined3d_settings.glslRequested) TRACE("If supported by your system, GL Shading Language will be used\n"); if (appkey) RegCloseKey( appkey ); if (hkey) RegCloseKey( hkey ); } return TRUE; }
void test() { bool result; const uint8_t* filename = (const uint8_t*)"/home/user/test.conf"; uint8_t buffer[64]; config_parser_t cfg; for(;;) { toggle_led(LED2); log_info(&log, "remove file %s", filename); // delete the file unlink((const char*)filename); // check the file is not present if(open_config_file(&cfg, buffer, sizeof(buffer), filename)) { while(get_next_config(&cfg)) log_info(&log, "read %s=%s", get_config_key(&cfg), get_config_value(&cfg)); close_config_file(&cfg); } else log_info(&log, "file %s removed successfully", filename); // add to a new file result = add_config_entry(buffer, sizeof(buffer), filename, (const uint8_t*)"testkey", (const uint8_t*)"testvalue"); log_info(&log, "wrote %s=%s to %s, result=%d", "testkey", "testvalue", filename, result); result = add_config_entry(buffer, sizeof(buffer), filename, (const uint8_t*)"testkey1", (const uint8_t*)"testvalue1"); log_info(&log, "wrote %s=%s to %s, result=%d", "testkey1", "testvalue1", filename, result); // check the file is now present with if(open_config_file(&cfg, buffer, sizeof(buffer), filename)) { while(get_next_config(&cfg)) log_info(&log, "read %s=%s", get_config_key(&cfg), get_config_value(&cfg)); close_config_file(&cfg); } // edit within file result = edit_config_entry(buffer, sizeof(buffer), filename, (const uint8_t*)"testkey", (const uint8_t*)"newtestvalue"); log_info(&log, "wrote %s=%s to %s, result=%d", "testkey", "testvalue", filename, result); result = edit_config_entry(buffer, sizeof(buffer), filename, (const uint8_t*)"testkey1", (const uint8_t*)"newtestvalue1"); log_info(&log, "wrote %s=%s to %s, result=%d", "testkey1", "testvalue1", filename, result); // check the file is now present with new values if(open_config_file(&cfg, buffer, sizeof(buffer), filename)) { while(get_next_config(&cfg)) log_info(&log, "read %s=%s", get_config_key(&cfg), get_config_value(&cfg)); close_config_file(&cfg); } sleep(10); } pthread_exit(0); }
static HRESULT setup_dinput_options(JoystickImpl * device) { char buffer[MAX_PATH+16]; HKEY hkey, appkey; int tokens = 0; int axis = 0; int pov = 0; buffer[MAX_PATH]='\0'; get_app_key(&hkey, &appkey); /* get options */ if (!get_config_key( hkey, appkey, "DefaultDeadZone", buffer, MAX_PATH )) { device->deadzone = atoi(buffer); TRACE("setting default deadzone to: \"%s\" %d\n", buffer, device->deadzone); } device->axis_map = HeapAlloc(GetProcessHeap(), 0, device->axes * sizeof(int)); if (!device->axis_map) return DIERR_OUTOFMEMORY; if (!get_config_key( hkey, appkey, device->name, buffer, MAX_PATH )) { static const char *axis_names[] = {"X", "Y", "Z", "Rx", "Ry", "Rz", "Slider1", "Slider2", "POV1", "POV2", "POV3", "POV4"}; const char *delim = ","; char * ptr; TRACE("\"%s\" = \"%s\"\n", device->name, buffer); if ((ptr = strtok(buffer, delim)) != NULL) { do { int i; for (i = 0; i < sizeof(axis_names) / sizeof(axis_names[0]); i++) if (!strcmp(ptr, axis_names[i])) { if (!strncmp(ptr, "POV", 3)) { if (pov >= 4) { WARN("Only 4 POVs supported - ignoring extra\n"); i = -1; } else { /* Pov takes two axes */ device->axis_map[tokens++] = i; pov++; } } else { if (axis >= 8) { FIXME("Only 8 Axes supported - ignoring extra\n"); i = -1; } else axis++; } break; } if (i == sizeof(axis_names) / sizeof(axis_names[0])) { ERR("invalid joystick axis type: \"%s\"\n", ptr); i = -1; } device->axis_map[tokens] = i; tokens++; } while ((ptr = strtok(NULL, delim)) != NULL); if (tokens != device->axes) { ERR("not all joystick axes mapped: %d axes(%d,%d), %d arguments\n", device->axes, axis, pov,tokens); while (tokens < device->axes) { device->axis_map[tokens] = -1; tokens++; } } } } else { for (tokens = 0; tokens < device->axes; tokens++) { if (tokens < 8) device->axis_map[tokens] = axis++; else if (tokens < 16) { device->axis_map[tokens++] = 8 + pov; device->axis_map[tokens ] = 8 + pov++; } else device->axis_map[tokens] = -1; } } device->devcaps.dwAxes = axis; device->devcaps.dwPOVs = pov; if (appkey) RegCloseKey( appkey ); if (hkey) RegCloseKey( hkey ); return DI_OK; }