mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-08-21 16:31:51 +02:00
Update to v106r26 release.
byuu says: Changelog: - nall: added -static-libgcc -static-libstdc++ to Windows/GCC link flags - bsnes, higan: added program icons to main window when game isn't loaded - bsnes: improved recent games menu sorting - bsnes: fixed multi-game recent game loading on Windows - bsnes: completed path override support - bsnes, higan: added screensaver suppression on Windows - icarus: add 32K volatile RAM to SuperFX boards that report no RAM (fixes Starfox) - bsnes, higan: added automatic dependency generation [Talarubi] - hiro/GTK: appending actions to menus restores enabled() state - higan: use board node inside manifest.bml if it exists - bsnes: added blur emulation and color emulation options to view menu - ruby: upgraded input.sdl to SDL 2.0 (though it makes no functional difference sadly) - ruby: removed video.sdl (due to deprecating SDL 1.2) - nall, ruby: improvements to HID class (generic vendor and product IDs) Errata: - bsnes, higan: on Windows, Application::Windows::onScreenSaver needs `[&]` lambda capture, not `[]` - find it in presentation/presentation.cpp
This commit is contained in:
@@ -5,7 +5,7 @@ else
|
||||
endif
|
||||
|
||||
rubyflags += $(foreach c,$(subst .,_,$(call strupper,$(ruby))),-D$c)
|
||||
rubyflags += $(if $(findstring .sdl,$(ruby)),$(shell sdl-config --cflags))
|
||||
rubyflags += $(if $(findstring input.sdl,$(ruby)),$(shell sdl2-config --cflags))
|
||||
|
||||
rubylink =
|
||||
|
||||
@@ -24,11 +24,10 @@ rubylink += $(if $(findstring audio.pulseaudiosimple,$(ruby)),-lpulse-simple)
|
||||
rubylink += $(if $(findstring audio.wasapi,$(ruby)),-lavrt -luuid)
|
||||
rubylink += $(if $(findstring audio.xaudio2,$(ruby)),-lole32)
|
||||
|
||||
rubylink += $(if $(findstring input.sdl,$(ruby)),$(shell sdl2-config --libs))
|
||||
rubylink += $(if $(findstring input.udev,$(ruby)),-ludev)
|
||||
rubylink += $(if $(findstring input.windows,$(ruby)),-ldinput8 -ldxguid)
|
||||
|
||||
rubylink += $(if $(findstring .sdl,$(ruby)),$(shell sdl-config --libs))
|
||||
|
||||
ifeq ($(platform),windows)
|
||||
rubylink += $(if $(findstring audio.openal,$(ruby)),-lopenal32)
|
||||
endif
|
||||
|
@@ -1,5 +1,4 @@
|
||||
#ifndef RUBY_INPUT_JOYPAD_DIRECTINPUT
|
||||
#define RUBY_INPUT_JOYPAD_DIRECTINPUT
|
||||
#pragma once
|
||||
|
||||
auto CALLBACK DirectInput_EnumJoypadsCallback(const DIDEVICEINSTANCE* instance, void* p) -> BOOL;
|
||||
auto CALLBACK DirectInput_EnumJoypadAxesCallback(const DIDEVICEOBJECTINSTANCE* instance, void* p) -> BOOL;
|
||||
@@ -26,9 +25,9 @@ struct InputJoypadDirectInput {
|
||||
LPDIRECTINPUT8 context = nullptr;
|
||||
LPDIRECTINPUTDEVICE8 device = nullptr;
|
||||
bool xinputAvailable = false;
|
||||
unsigned effects = 0;
|
||||
uint effects = 0;
|
||||
|
||||
auto assign(shared_pointer<HID::Joypad> hid, unsigned groupID, unsigned inputID, int16_t value) -> void {
|
||||
auto assign(shared_pointer<HID::Joypad> hid, uint groupID, uint inputID, int16_t value) -> void {
|
||||
auto& group = hid->group(groupID);
|
||||
if(group.input(inputID).value() == value) return;
|
||||
input.doChange(hid, groupID, inputID, group.input(inputID).value(), value);
|
||||
@@ -42,7 +41,7 @@ struct InputJoypadDirectInput {
|
||||
DIJOYSTATE2 state;
|
||||
if(FAILED(jp.device->GetDeviceState(sizeof(DIJOYSTATE2), &state))) continue;
|
||||
|
||||
for(unsigned n = 0; n < 4; n++) {
|
||||
for(auto n : range(4)) {
|
||||
assign(jp.hid, HID::Joypad::GroupID::Axis, 0, state.lX);
|
||||
assign(jp.hid, HID::Joypad::GroupID::Axis, 1, state.lY);
|
||||
assign(jp.hid, HID::Joypad::GroupID::Axis, 2, state.lZ);
|
||||
@@ -50,7 +49,7 @@ struct InputJoypadDirectInput {
|
||||
assign(jp.hid, HID::Joypad::GroupID::Axis, 4, state.lRy);
|
||||
assign(jp.hid, HID::Joypad::GroupID::Axis, 5, state.lRz);
|
||||
|
||||
unsigned pov = state.rgdwPOV[n];
|
||||
uint pov = state.rgdwPOV[n];
|
||||
int16_t xaxis = 0;
|
||||
int16_t yaxis = 0;
|
||||
|
||||
@@ -65,7 +64,7 @@ struct InputJoypadDirectInput {
|
||||
assign(jp.hid, HID::Joypad::GroupID::Hat, n * 2 + 1, yaxis);
|
||||
}
|
||||
|
||||
for(unsigned n = 0; n < 128; n++) {
|
||||
for(auto n : range(128)) {
|
||||
assign(jp.hid, HID::Joypad::GroupID::Button, n, (bool)state.rgbButtons[n]);
|
||||
}
|
||||
|
||||
@@ -140,7 +139,9 @@ struct InputJoypadDirectInput {
|
||||
device->GetProperty(DIPROP_GUIDANDPATH, &property.diph);
|
||||
string devicePath = (const char*)utf8_t(property.wszPath);
|
||||
jp.pathID = Hash::CRC32(devicePath.data(), devicePath.size()).value();
|
||||
jp.hid->setID((uint64_t)jp.pathID << 32 | jp.vendorID << 16 | jp.productID << 0);
|
||||
jp.hid->setVendorID(jp.vendorID);
|
||||
jp.hid->setProductID(jp.productID);
|
||||
jp.hid->setPathID(jp.pathID);
|
||||
|
||||
if(jp.hid->rumble()) {
|
||||
//disable auto-centering spring for rumble support
|
||||
@@ -176,9 +177,9 @@ struct InputJoypadDirectInput {
|
||||
device->CreateEffect(GUID_ConstantForce, &effect, &jp.effect, NULL);
|
||||
}
|
||||
|
||||
for(unsigned n = 0; n < 6; n++) jp.hid->axes().append(n);
|
||||
for(unsigned n = 0; n < 8; n++) jp.hid->hats().append(n);
|
||||
for(unsigned n = 0; n < 128; n++) jp.hid->buttons().append(n);
|
||||
for(auto n : range(6)) jp.hid->axes().append(n);
|
||||
for(auto n : range(8)) jp.hid->hats().append(n);
|
||||
for(auto n : range(128)) jp.hid->buttons().append(n);
|
||||
joypads.append(jp);
|
||||
|
||||
return DIENUM_CONTINUE;
|
||||
@@ -214,5 +215,3 @@ auto CALLBACK DirectInput_EnumJoypadAxesCallback(const DIDEVICEOBJECTINSTANCE* i
|
||||
auto CALLBACK DirectInput_EnumJoypadEffectsCallback(const DIDEVICEOBJECTINSTANCE* instance, void* p) -> BOOL {
|
||||
return ((InputJoypadDirectInput*)p)->initEffect(instance);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -1,5 +1,4 @@
|
||||
#ifndef RUBY_INPUT_JOYPAD_SDL
|
||||
#define RUBY_INPUT_JOYPAD_SDL
|
||||
#pragma once
|
||||
|
||||
struct InputJoypadSDL {
|
||||
Input& input;
|
||||
@@ -8,12 +7,12 @@ struct InputJoypadSDL {
|
||||
struct Joypad {
|
||||
shared_pointer<HID::Joypad> hid{new HID::Joypad};
|
||||
|
||||
unsigned id = 0;
|
||||
uint id = 0;
|
||||
SDL_Joystick* handle = nullptr;
|
||||
};
|
||||
vector<Joypad> joypads;
|
||||
|
||||
auto assign(shared_pointer<HID::Joypad> hid, unsigned groupID, unsigned inputID, int16_t value) -> void {
|
||||
auto assign(shared_pointer<HID::Joypad> hid, uint groupID, uint inputID, int16_t value) -> void {
|
||||
auto& group = hid->group(groupID);
|
||||
if(group.input(inputID).value() == value) return;
|
||||
input.doChange(hid, groupID, inputID, group.input(inputID).value(), value);
|
||||
@@ -28,10 +27,10 @@ struct InputJoypadSDL {
|
||||
assign(jp.hid, HID::Joypad::GroupID::Axis, n, (int16_t)SDL_JoystickGetAxis(jp.handle, n));
|
||||
}
|
||||
|
||||
for(signed n = 0; n < (signed)jp.hid->hats().size() - 1; n += 2) {
|
||||
for(int n = 0; n < (int)jp.hid->hats().size() - 1; n += 2) {
|
||||
uint8_t state = SDL_JoystickGetHat(jp.handle, n >> 1);
|
||||
assign(jp.hid, HID::Joypad::GroupID::Hat, n + 0, state & SDL_HAT_LEFT ? -32767 : state & SDL_HAT_RIGHT ? +32767 : 0);
|
||||
assign(jp.hid, HID::Joypad::GroupID::Hat, n + 1, state & SDL_HAT_UP ? -32767 : state & SDL_HAT_DOWN ? +32767 : 0);
|
||||
assign(jp.hid, HID::Joypad::GroupID::Hat, n + 1, state & SDL_HAT_UP ? -32767 : state & SDL_HAT_DOWN ? +32767 : 0);
|
||||
}
|
||||
|
||||
for(auto n : range(jp.hid->buttons())) {
|
||||
@@ -49,13 +48,15 @@ struct InputJoypadSDL {
|
||||
for(auto id : range(SDL_NumJoysticks())) {
|
||||
Joypad jp;
|
||||
jp.id = id;
|
||||
jp.handle = SDL_JoystickOpen(id);
|
||||
jp.handle = SDL_JoystickOpen(jp.id);
|
||||
|
||||
unsigned axes = SDL_JoystickNumAxes(jp.handle);
|
||||
unsigned hats = SDL_JoystickNumHats(jp.handle) * 2;
|
||||
unsigned buttons = 32; //there is no SDL_JoystickNumButtons()
|
||||
uint axes = SDL_JoystickNumAxes(jp.handle);
|
||||
uint hats = SDL_JoystickNumHats(jp.handle) * 2;
|
||||
uint buttons = SDL_JoystickNumButtons(jp.handle);
|
||||
|
||||
jp.hid->setID(3 + jp.id);
|
||||
jp.hid->setVendorID(HID::Joypad::GenericVendorID);
|
||||
jp.hid->setProductID(HID::Joypad::GenericProductID);
|
||||
jp.hid->setPathID(jp.id);
|
||||
for(auto n : range(axes)) jp.hid->axes().append(n);
|
||||
for(auto n : range(hats)) jp.hid->hats().append(n);
|
||||
for(auto n : range(buttons)) jp.hid->buttons().append(n);
|
||||
@@ -75,5 +76,3 @@ struct InputJoypadSDL {
|
||||
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -1,5 +1,4 @@
|
||||
#ifndef RUBY_INPUT_JOYPAD_UDEV
|
||||
#define RUBY_INPUT_JOYPAD_UDEV
|
||||
#pragma once
|
||||
|
||||
struct InputJoypadUdev {
|
||||
Input& input;
|
||||
@@ -265,8 +264,9 @@ private:
|
||||
}
|
||||
|
||||
auto createJoypadHID(Joypad& jp) -> void {
|
||||
uint64_t pathID = Hash::CRC32(jp.deviceName.data(), jp.deviceName.size()).value();
|
||||
jp.hid->setID(pathID << 32 | jp.vendorID.hex() << 16 | jp.productID.hex() << 0);
|
||||
jp.hid->setVendorID(jp.vendorID.hex());
|
||||
jp.hid->setProductID(jp.productID.hex());
|
||||
jp.hid->setPathID(Hash::CRC32(jp.deviceName.data(), jp.deviceName.size()).value());
|
||||
|
||||
for(uint n : range(jp.axes.size())) jp.hid->axes().append(n);
|
||||
for(uint n : range(jp.hats.size())) jp.hid->hats().append(n);
|
||||
@@ -284,5 +284,3 @@ private:
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -1,5 +1,4 @@
|
||||
#ifndef RUBY_INPUT_JOYPAD_XINPUT
|
||||
#define RUBY_INPUT_JOYPAD_XINPUT
|
||||
#pragma once
|
||||
|
||||
//documented functionality
|
||||
#define oXInputGetState "XInputGetState"
|
||||
@@ -29,11 +28,11 @@ struct InputJoypadXInput {
|
||||
|
||||
struct Joypad {
|
||||
shared_pointer<HID::Joypad> hid{new HID::Joypad};
|
||||
unsigned id = 0;
|
||||
uint id = 0;
|
||||
};
|
||||
vector<Joypad> joypads;
|
||||
|
||||
auto assign(shared_pointer<HID::Joypad> hid, unsigned groupID, unsigned inputID, int16_t value) -> void {
|
||||
auto assign(shared_pointer<HID::Joypad> hid, uint groupID, uint inputID, int16_t value) -> void {
|
||||
auto& group = hid->group(groupID);
|
||||
if(group.input(inputID).value() == value) return;
|
||||
input.doChange(hid, groupID, inputID, group.input(inputID).value(), value);
|
||||
@@ -116,10 +115,12 @@ struct InputJoypadXInput {
|
||||
|
||||
//XInput supports a maximum of four controllers
|
||||
//add all four to devices list now. If they are not connected, they will not show up in poll() results
|
||||
for(unsigned id = 0; id < 4; id++) {
|
||||
for(auto id : range(4)) {
|
||||
Joypad jp;
|
||||
jp.id = id;
|
||||
jp.hid->setID((uint64_t)(1 + id) << 32 | 0x045e << 16 | 0x028e << 0); //Xbox 360 Player# + VendorID + ProductID
|
||||
jp.hid->setVendorID(0x045e);
|
||||
jp.hid->setProductID(0x028e);
|
||||
jp.hid->setPathID(id);
|
||||
jp.hid->setRumble(true);
|
||||
|
||||
jp.hid->axes().append("LeftThumbX");
|
||||
@@ -158,5 +159,3 @@ struct InputJoypadXInput {
|
||||
libxinput = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -1,3 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
struct InputKeyboardCarbon {
|
||||
Input& input;
|
||||
InputKeyboardCarbon(Input& input) : input(input) {}
|
||||
@@ -145,7 +147,9 @@ struct InputKeyboardCarbon {
|
||||
keys.append({0x3a, "Alt"});
|
||||
keys.append({0x37, "Super"});
|
||||
|
||||
hid->setID(1);
|
||||
hid->setVendorID(HID::Keyboard::GenericVendorID);
|
||||
hid->setProductID(HID::Keyboard::GenericProductID);
|
||||
hid->setPathID(0);
|
||||
for(auto& key : keys) {
|
||||
hid->buttons().append(key.name);
|
||||
}
|
||||
|
@@ -1,3 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
struct InputKeyboardQuartz {
|
||||
Input& input;
|
||||
InputKeyboardQuartz(Input& input) : input(input) {}
|
||||
@@ -140,7 +142,9 @@ struct InputKeyboardQuartz {
|
||||
keys.append({"Option", kVK_Option});
|
||||
keys.append({"Command", kVK_Command});
|
||||
|
||||
hid->setID(1);
|
||||
hid->setVendorID(HID::Keyboard::GenericVendorID);
|
||||
hid->setProductID(HID::Keyboard::GenericProductID);
|
||||
hid->setPath(0);
|
||||
for(auto& key : keys) {
|
||||
hid->buttons().append(key.name);
|
||||
}
|
||||
|
@@ -1,5 +1,4 @@
|
||||
#ifndef RUBY_INPUT_KEYBOARD_RAWINPUT
|
||||
#define RUBY_INPUT_KEYBOARD_RAWINPUT
|
||||
#pragma once
|
||||
|
||||
struct InputKeyboardRawInput {
|
||||
Input& input;
|
||||
@@ -18,8 +17,8 @@ struct InputKeyboardRawInput {
|
||||
} kb;
|
||||
|
||||
auto update(RAWINPUT* input) -> void {
|
||||
unsigned code = input->data.keyboard.MakeCode;
|
||||
unsigned flag = input->data.keyboard.Flags;
|
||||
uint code = input->data.keyboard.MakeCode;
|
||||
uint flag = input->data.keyboard.Flags;
|
||||
|
||||
for(auto& key : keys) {
|
||||
if(key.code != code) continue;
|
||||
@@ -27,7 +26,7 @@ struct InputKeyboardRawInput {
|
||||
}
|
||||
}
|
||||
|
||||
auto assign(unsigned inputID, bool value) -> void {
|
||||
auto assign(uint inputID, bool value) -> void {
|
||||
auto& group = kb.hid->buttons();
|
||||
if(group.input(inputID).value() == value) return;
|
||||
input.doChange(kb.hid, HID::Keyboard::GroupID::Button, inputID, group.input(inputID).value(), value);
|
||||
@@ -35,7 +34,7 @@ struct InputKeyboardRawInput {
|
||||
}
|
||||
|
||||
auto poll(vector<shared_pointer<HID::Device>>& devices) -> void {
|
||||
for(unsigned n = 0; n < keys.size(); n++) assign(n, keys[n].value);
|
||||
for(auto n : range(keys)) assign(n, keys[n].value);
|
||||
devices.append(kb.hid);
|
||||
}
|
||||
|
||||
@@ -164,7 +163,9 @@ struct InputKeyboardRawInput {
|
||||
keys.append({0x005c, 2, "RightSuper"});
|
||||
keys.append({0x005d, 2, "Menu"});
|
||||
|
||||
kb.hid->setID(1);
|
||||
kb.hid->setVendorID(HID::Keyboard::GenericVendorID);
|
||||
kb.hid->setProductID(HID::Keyboard::GenericProductID);
|
||||
kb.hid->setPathID(0);
|
||||
for(auto& key : keys) kb.hid->buttons().append(key.name);
|
||||
|
||||
return true;
|
||||
@@ -174,5 +175,3 @@ struct InputKeyboardRawInput {
|
||||
rawinput.updateKeyboard.reset();
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -1,5 +1,4 @@
|
||||
#ifndef RUBY_INPUT_KEYBOARD_XLIB
|
||||
#define RUBY_INPUT_KEYBOARD_XLIB
|
||||
#pragma once
|
||||
|
||||
struct InputKeyboardXlib {
|
||||
Input& input;
|
||||
@@ -153,7 +152,9 @@ struct InputKeyboardXlib {
|
||||
keys.append({"RightSuper", XK_Super_R});
|
||||
keys.append({"Menu", XK_Menu});
|
||||
|
||||
hid->setID(1);
|
||||
hid->setVendorID(HID::Keyboard::GenericVendorID);
|
||||
hid->setProductID(HID::Keyboard::GenericProductID);
|
||||
hid->setPathID(0);
|
||||
|
||||
for(auto& key : keys) {
|
||||
hid->buttons().append(key.name);
|
||||
@@ -170,5 +171,3 @@ struct InputKeyboardXlib {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -1,5 +1,4 @@
|
||||
#ifndef RUBY_INPUT_MOUSE_RAWINPUT
|
||||
#define RUBY_INPUT_MOUSE_RAWINPUT
|
||||
#pragma once
|
||||
|
||||
struct InputMouseRawInput {
|
||||
Input& input;
|
||||
@@ -11,9 +10,9 @@ struct InputMouseRawInput {
|
||||
struct Mouse {
|
||||
shared_pointer<HID::Mouse> hid{new HID::Mouse};
|
||||
|
||||
signed relativeX = 0;
|
||||
signed relativeY = 0;
|
||||
signed relativeZ = 0;
|
||||
int relativeX = 0;
|
||||
int relativeY = 0;
|
||||
int relativeZ = 0;
|
||||
bool buttons[5] = {0};
|
||||
} ms;
|
||||
|
||||
@@ -68,7 +67,7 @@ struct InputMouseRawInput {
|
||||
if(input->data.mouse.usButtonFlags & RI_MOUSE_BUTTON_5_UP ) ms.buttons[4] = 0;
|
||||
}
|
||||
|
||||
auto assign(unsigned groupID, unsigned inputID, int16_t value) -> void {
|
||||
auto assign(uint groupID, uint inputID, int16_t value) -> void {
|
||||
auto& group = ms.hid->group(groupID);
|
||||
if(group.input(inputID).value() == value) return;
|
||||
input.doChange(ms.hid, groupID, inputID, group.input(inputID).value(), value);
|
||||
@@ -99,7 +98,9 @@ struct InputMouseRawInput {
|
||||
if(!handle) return false;
|
||||
this->handle = handle;
|
||||
|
||||
ms.hid->setID(2);
|
||||
ms.hid->setVendorID(HID::Mouse::GenericVendorID);
|
||||
ms.hid->setProductID(HID::Mouse::GenericProductID);
|
||||
ms.hid->setPathID(0);
|
||||
|
||||
ms.hid->axes().append("X");
|
||||
ms.hid->axes().append("Y");
|
||||
@@ -120,5 +121,3 @@ struct InputMouseRawInput {
|
||||
release();
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -1,5 +1,4 @@
|
||||
#ifndef RUBY_INPUT_MOUSE_XLIB
|
||||
#define RUBY_INPUT_MOUSE_XLIB
|
||||
#pragma once
|
||||
|
||||
struct InputMouseXlib {
|
||||
Input& input;
|
||||
@@ -12,16 +11,16 @@ struct InputMouseXlib {
|
||||
Display* display = nullptr;
|
||||
Window rootWindow = 0;
|
||||
Cursor invisibleCursor = 0;
|
||||
unsigned screenWidth = 0;
|
||||
unsigned screenHeight = 0;
|
||||
uint screenWidth = 0;
|
||||
uint screenHeight = 0;
|
||||
|
||||
struct Mouse {
|
||||
bool acquired = false;
|
||||
signed numerator = 0;
|
||||
signed denominator = 0;
|
||||
signed threshold = 0;
|
||||
unsigned relativeX = 0;
|
||||
unsigned relativeY = 0;
|
||||
int numerator = 0;
|
||||
int denominator = 0;
|
||||
int threshold = 0;
|
||||
uint relativeX = 0;
|
||||
uint relativeY = 0;
|
||||
} ms;
|
||||
|
||||
auto acquired() -> bool {
|
||||
@@ -57,7 +56,7 @@ struct InputMouseXlib {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto assign(unsigned groupID, unsigned inputID, int16_t value) -> void {
|
||||
auto assign(uint groupID, uint inputID, int16_t value) -> void {
|
||||
auto& group = hid->group(groupID);
|
||||
if(group.input(inputID).value() == value) return;
|
||||
input.doChange(hid, groupID, inputID, group.input(inputID).value(), value);
|
||||
@@ -67,11 +66,11 @@ struct InputMouseXlib {
|
||||
auto poll(vector<shared_pointer<HID::Device>>& devices) -> void {
|
||||
Window rootReturn;
|
||||
Window childReturn;
|
||||
signed rootXReturn = 0;
|
||||
signed rootYReturn = 0;
|
||||
signed windowXReturn = 0;
|
||||
signed windowYReturn = 0;
|
||||
unsigned maskReturn = 0;
|
||||
int rootXReturn = 0;
|
||||
int rootYReturn = 0;
|
||||
int windowXReturn = 0;
|
||||
int windowYReturn = 0;
|
||||
uint maskReturn = 0;
|
||||
XQueryPointer(display, handle, &rootReturn, &childReturn, &rootXReturn, &rootYReturn, &windowXReturn, &windowYReturn, &maskReturn);
|
||||
|
||||
if(acquired()) {
|
||||
@@ -132,7 +131,9 @@ struct InputMouseXlib {
|
||||
ms.relativeX = 0;
|
||||
ms.relativeY = 0;
|
||||
|
||||
hid->setID(2);
|
||||
hid->setVendorID(HID::Mouse::GenericVendorID);
|
||||
hid->setProductID(HID::Mouse::GenericProductID);
|
||||
hid->setPathID(0);
|
||||
|
||||
hid->axes().append("X");
|
||||
hid->axes().append("Y");
|
||||
@@ -158,5 +159,3 @@ struct InputMouseXlib {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include <SDL/SDL.h>
|
||||
#include <SDL2/SDL.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
|
||||
|
@@ -1,5 +1,4 @@
|
||||
#ifndef RUBY_INPUT_SHARED_RAWINPUT
|
||||
#define RUBY_INPUT_SHARED_RAWINPUT
|
||||
#pragma once
|
||||
|
||||
auto CALLBACK RawInputWindowProc(HWND, UINT, WPARAM, LPARAM) -> LRESULT;
|
||||
|
||||
@@ -14,7 +13,7 @@ struct RawInput {
|
||||
struct Device {
|
||||
HANDLE handle = nullptr;
|
||||
string path;
|
||||
enum class Type : unsigned { Keyboard, Mouse, Joypad } type;
|
||||
enum class Type : uint { Keyboard, Mouse, Joypad } type;
|
||||
uint16_t vendorID = 0;
|
||||
uint16_t productID = 0;
|
||||
bool isXInputDevice = false;
|
||||
@@ -31,14 +30,14 @@ struct RawInput {
|
||||
auto scanDevices() -> void {
|
||||
devices.reset();
|
||||
|
||||
unsigned deviceCount = 0;
|
||||
uint deviceCount = 0;
|
||||
GetRawInputDeviceList(NULL, &deviceCount, sizeof(RAWINPUTDEVICELIST));
|
||||
RAWINPUTDEVICELIST* list = new RAWINPUTDEVICELIST[deviceCount];
|
||||
GetRawInputDeviceList(list, &deviceCount, sizeof(RAWINPUTDEVICELIST));
|
||||
|
||||
for(unsigned n = 0; n < deviceCount; n++) {
|
||||
for(auto n : range(deviceCount)) {
|
||||
wchar_t path[4096];
|
||||
unsigned size = sizeof(path) - 1;
|
||||
uint size = sizeof(path) - 1;
|
||||
GetRawInputDeviceInfo(list[n].hDevice, RIDI_DEVICENAME, &path, &size);
|
||||
|
||||
RID_DEVICE_INFO info;
|
||||
@@ -80,7 +79,7 @@ struct RawInput {
|
||||
auto windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) -> LRESULT {
|
||||
if(msg != WM_INPUT) return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
|
||||
unsigned size = 0;
|
||||
uint size = 0;
|
||||
GetRawInputData((HRAWINPUT)lparam, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER));
|
||||
RAWINPUT* input = new RAWINPUT[size];
|
||||
GetRawInputData((HRAWINPUT)lparam, RID_INPUT, input, &size, sizeof(RAWINPUTHEADER));
|
||||
@@ -154,5 +153,3 @@ auto WINAPI RawInputThreadProc(void*) -> DWORD {
|
||||
auto CALLBACK RawInputWindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) -> LRESULT {
|
||||
return rawinput.windowProc(hwnd, msg, wparam, lparam);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -54,10 +54,6 @@ using namespace ruby;
|
||||
#include <ruby/video/glx2.cpp>
|
||||
#endif
|
||||
|
||||
#if defined(VIDEO_SDL)
|
||||
#include <ruby/video/sdl.cpp>
|
||||
#endif
|
||||
|
||||
#if defined(VIDEO_WGL)
|
||||
#include <ruby/video/wgl.cpp>
|
||||
#endif
|
||||
@@ -99,10 +95,6 @@ auto Video::create(const string& driver) -> Video* {
|
||||
if(driver == "OpenGL2") return new VideoGLX2;
|
||||
#endif
|
||||
|
||||
#if defined(VIDEO_SDL)
|
||||
if(driver == "SDL") return new VideoSDL;
|
||||
#endif
|
||||
|
||||
#if defined(VIDEO_WGL)
|
||||
if(driver == "OpenGL") return new VideoWGL;
|
||||
#endif
|
||||
@@ -137,8 +129,6 @@ auto Video::optimalDriver() -> string {
|
||||
return "XVideo";
|
||||
#elif defined(VIDEO_XSHM)
|
||||
return "XShm";
|
||||
#elif defined(VIDEO_SDL)
|
||||
return "SDL";
|
||||
#else
|
||||
return "None";
|
||||
#endif
|
||||
@@ -157,8 +147,6 @@ auto Video::safestDriver() -> string {
|
||||
return "OpenGL";
|
||||
#elif defined(VIDEO_XSHM)
|
||||
return "XShm";
|
||||
#elif defined(VIDEO_SDL)
|
||||
return "SDL";
|
||||
#elif defined(VIDEO_XVIDEO)
|
||||
return "XVideo";
|
||||
#elif defined(VIDEO_GLX2)
|
||||
@@ -209,10 +197,6 @@ auto Video::availableDrivers() -> string_vector {
|
||||
"XShm",
|
||||
#endif
|
||||
|
||||
#if defined(VIDEO_SDL)
|
||||
"SDL",
|
||||
#endif
|
||||
|
||||
"None"};
|
||||
}
|
||||
|
||||
|
@@ -1,132 +0,0 @@
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
#include <X11/extensions/Xv.h>
|
||||
#include <X11/extensions/Xvlib.h>
|
||||
#include <X11/extensions/XShm.h>
|
||||
#include <SDL/SDL.h>
|
||||
|
||||
struct VideoSDL : Video {
|
||||
VideoSDL() { initialize(); }
|
||||
~VideoSDL() { terminate(); }
|
||||
|
||||
auto ready() -> bool { return _ready; }
|
||||
|
||||
auto context() -> uintptr { return _context; }
|
||||
|
||||
auto setContext(uintptr context) -> bool {
|
||||
if(_context == context) return true;
|
||||
_context = context;
|
||||
return initialize();
|
||||
}
|
||||
|
||||
auto clear() -> void {
|
||||
if(!ready()) return;
|
||||
if(SDL_MUSTLOCK(_buffer)) SDL_LockSurface(_buffer);
|
||||
for(uint y : range(_bufferHeight)) {
|
||||
uint32_t* data = (uint32_t*)_buffer->pixels + y * (_buffer->pitch >> 2);
|
||||
for(uint x : range(_bufferWidth)) *data++ = 0xff000000;
|
||||
}
|
||||
if(SDL_MUSTLOCK(_buffer)) SDL_UnlockSurface(_buffer);
|
||||
output();
|
||||
}
|
||||
|
||||
auto lock(uint32_t*& data, uint& pitch, uint width, uint height) -> bool {
|
||||
if(!ready()) return false;
|
||||
if(width != _width || height != _height) resize(_width = width, _height = height);
|
||||
if(SDL_MUSTLOCK(_buffer)) SDL_LockSurface(_buffer);
|
||||
pitch = _buffer->pitch;
|
||||
return data = (uint32_t*)_buffer->pixels;
|
||||
}
|
||||
|
||||
auto unlock() -> void {
|
||||
if(!ready()) return;
|
||||
if(SDL_MUSTLOCK(_buffer)) SDL_UnlockSurface(_buffer);
|
||||
}
|
||||
|
||||
auto output() -> void {
|
||||
if(!ready()) return;
|
||||
|
||||
//ruby input is X8R8G8B8, top 8-bits are ignored.
|
||||
//as SDL forces us to use a 32-bit buffer, we must set alpha to 255 (full opacity)
|
||||
//to prevent blending against the window beneath when X window visual is 32-bits.
|
||||
if(SDL_MUSTLOCK(_buffer)) SDL_LockSurface(_buffer);
|
||||
for(uint y : range(_height)) {
|
||||
uint32_t* data = (uint32_t*)_buffer->pixels + y * (_buffer->pitch >> 2);
|
||||
for(uint x : range(_width)) *data++ |= 0xff000000;
|
||||
}
|
||||
if(SDL_MUSTLOCK(_buffer)) SDL_UnlockSurface(_buffer);
|
||||
|
||||
XWindowAttributes attributes;
|
||||
XGetWindowAttributes(_display, _context, &attributes);
|
||||
|
||||
SDL_Rect source;
|
||||
SDL_Rect target;
|
||||
|
||||
source.x = 0;
|
||||
source.y = 0;
|
||||
source.w = _width;
|
||||
source.h = _height;
|
||||
|
||||
target.x = 0;
|
||||
target.y = 0;
|
||||
target.w = attributes.width;
|
||||
target.h = attributes.height;
|
||||
|
||||
SDL_SoftStretch(_buffer, &source, _screen, &target);
|
||||
SDL_UpdateRect(_screen, target.x, target.y, target.w, target.h);
|
||||
}
|
||||
|
||||
private:
|
||||
auto initialize() -> bool {
|
||||
terminate();
|
||||
if(!_context) return false;
|
||||
|
||||
_display = XOpenDisplay(0);
|
||||
|
||||
char env[512];
|
||||
sprintf(env, "SDL_WINDOWID=%ld", (long)_context);
|
||||
putenv(env);
|
||||
|
||||
SDL_InitSubSystem(SDL_INIT_VIDEO);
|
||||
_screen = SDL_SetVideoMode(2560, 1600, 32, SDL_HWSURFACE);
|
||||
XUndefineCursor(_display, _context);
|
||||
|
||||
_buffer = nullptr;
|
||||
_bufferWidth = 0;
|
||||
_bufferHeight = 0;
|
||||
resize(_width = 256, _height = 256);
|
||||
|
||||
return _ready = true;
|
||||
}
|
||||
|
||||
auto terminate() -> void {
|
||||
_ready = false;
|
||||
if(_buffer) SDL_FreeSurface(_buffer), _buffer = nullptr;
|
||||
if(_screen) SDL_QuitSubSystem(SDL_INIT_VIDEO), _screen = nullptr;
|
||||
if(_display) XCloseDisplay(_display), _display = nullptr;
|
||||
}
|
||||
|
||||
auto resize(uint width, uint height) -> void {
|
||||
if(_bufferWidth >= width && _bufferHeight >= height) return;
|
||||
|
||||
_bufferWidth = max(width, _bufferWidth);
|
||||
_bufferHeight = max(height, _bufferHeight);
|
||||
|
||||
if(_buffer) SDL_FreeSurface(_buffer);
|
||||
_buffer = SDL_CreateRGBSurface(
|
||||
SDL_SWSURFACE, _bufferWidth, _bufferHeight, 32,
|
||||
0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000
|
||||
);
|
||||
}
|
||||
|
||||
bool _ready = false;
|
||||
uintptr _context = 0;
|
||||
|
||||
Display* _display = nullptr;
|
||||
SDL_Surface* _screen = nullptr;
|
||||
SDL_Surface* _buffer = nullptr;
|
||||
uint _bufferWidth = 0;
|
||||
uint _bufferHeight = 0;
|
||||
uint _width = 0;
|
||||
uint _height = 0;
|
||||
};
|
Reference in New Issue
Block a user