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:
Tim Allen
2018-05-24 12:14:17 +10:00
parent 3353efd3a1
commit 5961ea9c03
80 changed files with 745 additions and 519 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -1,4 +1,4 @@
#include <SDL/SDL.h>
#include <SDL2/SDL.h>
#include <sys/ipc.h>
#include <sys/shm.h>

View File

@@ -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