Merge pull request #1530 from reicast/fh/saveport-vmu
Save maple port of connected gamepads between runs. Display VMU LCD on pause
This commit is contained in:
commit
66580b16c6
|
@ -644,9 +644,7 @@ struct maple_sega_vmu: maple_base
|
|||
}
|
||||
}
|
||||
config->SetImage(lcd_data_decoded);
|
||||
#if !defined(TARGET_PANDORA) && HOST_OS != OS_DARWIN
|
||||
push_vmu_screen(lcd_data_decoded);
|
||||
#endif
|
||||
push_vmu_screen(bus_id, bus_port, lcd_data_decoded);
|
||||
#if 0
|
||||
// Update LCD window
|
||||
if (!dev->lcd.visible)
|
||||
|
@ -791,7 +789,7 @@ struct maple_microphone: maple_base
|
|||
switch (cmd)
|
||||
{
|
||||
case MDC_DeviceRequest:
|
||||
LOGI("maple_microphone::dma MDC_DeviceRequest");
|
||||
LOGI("maple_microphone::dma MDC_DeviceRequest\n");
|
||||
//this was copied from the controller case with just the id and name replaced!
|
||||
|
||||
//caps
|
||||
|
@ -826,7 +824,7 @@ struct maple_microphone: maple_base
|
|||
|
||||
case MDCF_GetCondition:
|
||||
{
|
||||
LOGI("maple_microphone::dma MDCF_GetCondition");
|
||||
LOGI("maple_microphone::dma MDCF_GetCondition\n");
|
||||
//this was copied from the controller case with just the id replaced!
|
||||
|
||||
//PlainJoystickState pjs;
|
||||
|
@ -863,7 +861,7 @@ struct maple_microphone: maple_base
|
|||
|
||||
case MDC_DeviceReset:
|
||||
//uhhh do nothing?
|
||||
LOGI("maple_microphone::dma MDC_DeviceReset");
|
||||
LOGI("maple_microphone::dma MDC_DeviceReset\n");
|
||||
return MDRS_DeviceReply;
|
||||
|
||||
case MDCF_MICControl:
|
||||
|
@ -932,7 +930,7 @@ struct maple_microphone: maple_base
|
|||
LOGI("maple_microphone::dma MDCF_MICControl set gain %#010x\n",secondword);
|
||||
return MDRS_DeviceReply;
|
||||
case MDRE_TransmitAgain:
|
||||
LOGW("maple_microphone::dma MDCF_MICControl MDRE_TransminAgain");
|
||||
LOGW("maple_microphone::dma MDCF_MICControl MDRE_TransmitAgain\n");
|
||||
//apparently this doesnt matter
|
||||
//wptr(micdata, SIZE_OF_MIC_DATA);
|
||||
return MDRS_DeviceReply;//MDRS_DataTransfer;
|
||||
|
|
|
@ -101,6 +101,6 @@ maple_device* maple_Create(MapleDeviceType type);
|
|||
#define SIZE_OF_MIC_DATA 480 //ALSO DEFINED IN SipEmulator.java
|
||||
#ifndef TARGET_PANDORA
|
||||
int get_mic_data(u8* buffer); //implemented in Android.cpp
|
||||
int push_vmu_screen(u8* buffer); //implemented in Android.cpp
|
||||
#endif
|
||||
void push_vmu_screen(int bus_id, int bus_port, u8* buffer);
|
||||
#define MAPLE_PORTS 4
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
#include "gamepad_device.h"
|
||||
#include "rend/gui.h"
|
||||
#include "oslib/oslib.h"
|
||||
#include "cfg/cfg.h"
|
||||
|
||||
#define MAPLE_PORT_CFG_PREFIX "maple_"
|
||||
|
||||
extern void dc_exit();
|
||||
|
||||
|
@ -253,3 +256,36 @@ void GamepadDevice::detect_axis_input(input_detected_cb axis_moved)
|
|||
_detection_start_time = os_GetSeconds() + 0.2;
|
||||
}
|
||||
|
||||
void GamepadDevice::Register(std::shared_ptr<GamepadDevice> gamepad)
|
||||
{
|
||||
int maple_port = cfgLoadInt("input",
|
||||
(MAPLE_PORT_CFG_PREFIX + gamepad->unique_id()).c_str(), 12345);
|
||||
if (maple_port != 12345)
|
||||
gamepad->set_maple_port(maple_port);
|
||||
|
||||
_gamepads_mutex.lock();
|
||||
_gamepads.push_back(gamepad);
|
||||
_gamepads_mutex.unlock();
|
||||
}
|
||||
|
||||
void GamepadDevice::Unregister(std::shared_ptr<GamepadDevice> gamepad)
|
||||
{
|
||||
gamepad->save_mapping();
|
||||
_gamepads_mutex.lock();
|
||||
for (auto it = _gamepads.begin(); it != _gamepads.end(); it++)
|
||||
if (*it == gamepad) {
|
||||
_gamepads.erase(it);
|
||||
break;
|
||||
}
|
||||
_gamepads_mutex.unlock();
|
||||
}
|
||||
|
||||
void GamepadDevice::SaveMaplePorts()
|
||||
{
|
||||
for (int i = 0; i < GamepadDevice::GetGamepadCount(); i++)
|
||||
{
|
||||
std::shared_ptr<GamepadDevice> gamepad = GamepadDevice::GetGamepad(i);
|
||||
if (gamepad != NULL && !gamepad->unique_id().empty())
|
||||
cfgSaveInt("input", (MAPLE_PORT_CFG_PREFIX + gamepad->unique_id()).c_str(), gamepad->maple_port());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ public:
|
|||
const std::string& name() { return _name; }
|
||||
int maple_port() { return _maple_port; }
|
||||
void set_maple_port(int port) { _maple_port = port; }
|
||||
const std::string& unique_id() { return _unique_id; }
|
||||
virtual bool gamepad_btn_input(u32 code, bool pressed);
|
||||
bool gamepad_axis_input(u32 code, int value);
|
||||
virtual ~GamepadDevice() {}
|
||||
|
@ -50,28 +51,13 @@ public:
|
|||
virtual void update_rumble() {}
|
||||
bool is_rumble_enabled() { return _rumble_enabled; }
|
||||
|
||||
static void Register(std::shared_ptr<GamepadDevice> gamepad)
|
||||
{
|
||||
_gamepads_mutex.lock();
|
||||
_gamepads.push_back(gamepad);
|
||||
_gamepads_mutex.unlock();
|
||||
}
|
||||
static void Register(std::shared_ptr<GamepadDevice> gamepad);
|
||||
|
||||
static void Unregister(std::shared_ptr<GamepadDevice> gamepad)
|
||||
{
|
||||
gamepad->save_mapping();
|
||||
_gamepads_mutex.lock();
|
||||
for (auto it = _gamepads.begin(); it != _gamepads.end(); it++)
|
||||
if (*it == gamepad)
|
||||
{
|
||||
_gamepads.erase(it);
|
||||
break;
|
||||
}
|
||||
_gamepads_mutex.unlock();
|
||||
}
|
||||
static void Unregister(std::shared_ptr<GamepadDevice> gamepad);
|
||||
|
||||
static int GetGamepadCount();
|
||||
static std::shared_ptr<GamepadDevice> GetGamepad(int index);
|
||||
static void SaveMaplePorts();
|
||||
|
||||
protected:
|
||||
GamepadDevice(int maple_port, const char *api_name, bool remappable = true)
|
||||
|
@ -83,6 +69,7 @@ protected:
|
|||
virtual void load_axis_min_max(u32 axis) {}
|
||||
|
||||
std::string _name;
|
||||
std::string _unique_id = "";
|
||||
InputMapping *input_mapper;
|
||||
std::map<u32, int> axis_min_values;
|
||||
std::map<u32, unsigned int> axis_ranges;
|
||||
|
|
|
@ -9,12 +9,18 @@ public:
|
|||
: GamepadDevice(maple_port, "evdev"), _fd(fd), _rumble_effect_id(-1), _devnode(devnode)
|
||||
{
|
||||
fcntl(fd, F_SETFL, O_NONBLOCK);
|
||||
char name[256] = "Unknown";
|
||||
if (ioctl(fd, EVIOCGNAME(sizeof(name)), name) < 0)
|
||||
char buf[256] = "Unknown";
|
||||
if (ioctl(fd, EVIOCGNAME(sizeof(buf) - 1), buf) < 0)
|
||||
perror("evdev: ioctl(EVIOCGNAME)");
|
||||
else
|
||||
printf("evdev: Opened device '%s' ", name);
|
||||
_name = name;
|
||||
printf("evdev: Opened device '%s' ", buf);
|
||||
_name = buf;
|
||||
buf[0] = 0;
|
||||
if (ioctl(fd, EVIOCGUNIQ(sizeof(buf) - 1), buf) == 0)
|
||||
_unique_id = buf;
|
||||
if (_unique_id.empty())
|
||||
_unique_id = devnode;
|
||||
|
||||
if (!find_mapping(mapping_file))
|
||||
{
|
||||
#if defined(TARGET_PANDORA)
|
||||
|
@ -22,18 +28,18 @@ public:
|
|||
#elif defined(TARGET_GCW0)
|
||||
mapping_file = "controller_gcwz.cfg";
|
||||
#else
|
||||
if (!strcmp(name, "Microsoft X-Box 360 pad")
|
||||
|| !strcmp(name, "Xbox 360 Wireless Receiver")
|
||||
|| !strcmp(name, "Xbox 360 Wireless Receiver (XBOX)"))
|
||||
if (_name == "Microsoft X-Box 360 pad"
|
||||
|| _name == "Xbox 360 Wireless Receiver"
|
||||
|| _name == "Xbox 360 Wireless Receiver (XBOX)")
|
||||
{
|
||||
mapping_file = "controller_xpad.cfg";
|
||||
}
|
||||
else if (strstr(name, "Xbox Gamepad (userspace driver)") != NULL)
|
||||
else if (_name.find("Xbox Gamepad (userspace driver)") != std::string::npos)
|
||||
{
|
||||
mapping_file = "controller_xboxdrv.cfg";
|
||||
}
|
||||
else if (strstr(name, "keyboard") != NULL ||
|
||||
strstr(name, "Keyboard") != NULL)
|
||||
else if (_name.find("keyboard") != std::string::npos
|
||||
|| _name.find("Keyboard") != std::string::npos)
|
||||
{
|
||||
mapping_file = "keyboard.cfg";
|
||||
}
|
||||
|
|
|
@ -408,7 +408,6 @@ int main(int argc, wchar* argv[])
|
|||
#endif
|
||||
|
||||
int get_mic_data(u8* buffer) { return 0; }
|
||||
int push_vmu_screen(u8* buffer) { return 0; }
|
||||
|
||||
void os_DebugBreak()
|
||||
{
|
||||
|
|
|
@ -52,6 +52,7 @@ public:
|
|||
X11MouseGamepadDevice(int maple_port) : GamepadDevice(maple_port, "X11")
|
||||
{
|
||||
_name = "Mouse";
|
||||
_unique_id = "x11_mouse";
|
||||
if (!find_mapping())
|
||||
input_mapper = new MouseInputMapping();
|
||||
}
|
||||
|
|
|
@ -181,6 +181,7 @@ public:
|
|||
X11KbGamepadDevice(int maple_port) : GamepadDevice(maple_port, "X11")
|
||||
{
|
||||
_name = "Keyboard";
|
||||
_unique_id = "x11_keyboard";
|
||||
if (!find_mapping())
|
||||
input_mapper = new KbInputMapping();
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "imgread/common.h"
|
||||
#include "rend/gui.h"
|
||||
#include "profiler/profiler.h"
|
||||
#include "input/gamepad_device.h"
|
||||
|
||||
void FlushCache();
|
||||
void LoadCustom();
|
||||
|
@ -741,6 +742,9 @@ void SaveSettings()
|
|||
paths += path;
|
||||
}
|
||||
cfgSaveStr("config", "Dreamcast.ContentPath", paths.c_str());
|
||||
|
||||
GamepadDevice::SaveMaplePorts();
|
||||
|
||||
#ifdef _ANDROID
|
||||
void SaveAndroidSettings();
|
||||
SaveAndroidSettings();
|
||||
|
|
|
@ -585,3 +585,20 @@ void ImGui_ImplOpenGL3_DrawBackground()
|
|||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
}
|
||||
|
||||
ImTextureID ImGui_ImplOpenGL3_CreateVmuTexture(const unsigned int *data)
|
||||
{
|
||||
GLuint tex_id;
|
||||
glGenTextures(1, &tex_id);
|
||||
glBindTexture(GL_TEXTURE_2D, tex_id);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 48, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
|
||||
|
||||
return reinterpret_cast<ImTextureID>(tex_id);
|
||||
}
|
||||
|
||||
void ImGui_ImplOpenGL3_DeleteVmuTexture(ImTextureID tex_id)
|
||||
{
|
||||
glDeleteTextures(1, &(GLuint &)tex_id);
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@ IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown();
|
|||
IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame();
|
||||
IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data, bool save_background = false);
|
||||
IMGUI_IMPL_API void ImGui_ImplOpenGL3_DrawBackground();
|
||||
IMGUI_IMPL_API ImTextureID ImGui_ImplOpenGL3_CreateVmuTexture(const unsigned int *);
|
||||
IMGUI_IMPL_API void ImGui_ImplOpenGL3_DeleteVmuTexture(ImTextureID);
|
||||
|
||||
// Called by Init/NewFrame/Shutdown
|
||||
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateFontsTexture();
|
||||
|
|
|
@ -64,6 +64,10 @@ GuiState gui_state = Main;
|
|||
static bool settings_opening;
|
||||
static bool touch_up;
|
||||
|
||||
static void display_vmus();
|
||||
static void reset_vmus();
|
||||
static void term_vmus();
|
||||
|
||||
void gui_init()
|
||||
{
|
||||
if (inited)
|
||||
|
@ -290,6 +294,8 @@ static void gui_display_commands()
|
|||
if (!settings_opening)
|
||||
ImGui_ImplOpenGL3_DrawBackground();
|
||||
|
||||
display_vmus();
|
||||
|
||||
ImGui::SetNextWindowPos(ImVec2(screen_width / 2.f, screen_height / 2.f), ImGuiCond_Always, ImVec2(0.5f, 0.5f));
|
||||
ImGui::SetNextWindowSize(ImVec2(330 * scaling, 0));
|
||||
|
||||
|
@ -635,6 +641,7 @@ static void gui_display_settings()
|
|||
gui_state = Main;
|
||||
#if DC_PLATFORM == DC_PLATFORM_DREAMCAST
|
||||
maple_ReconnectDevices();
|
||||
reset_vmus();
|
||||
#endif
|
||||
SaveSettings();
|
||||
}
|
||||
|
@ -1470,6 +1477,7 @@ void gui_open_onboarding()
|
|||
void gui_term()
|
||||
{
|
||||
inited = false;
|
||||
term_vmus();
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
}
|
||||
|
@ -1495,3 +1503,94 @@ void gui_refresh_files()
|
|||
game_list_done = false;
|
||||
subfolders_read = false;
|
||||
}
|
||||
|
||||
#define VMU_WIDTH (70 * 48 * scaling / 32)
|
||||
#define VMU_HEIGHT (70 * scaling)
|
||||
#define VMU_PADDING (8 * scaling)
|
||||
static u32 vmu_lcd_data[8][48 * 32];
|
||||
static bool vmu_lcd_status[8];
|
||||
static ImTextureID vmu_lcd_tex_ids[8];
|
||||
|
||||
void push_vmu_screen(int bus_id, int bus_port, u8* buffer)
|
||||
{
|
||||
int vmu_id = bus_id * 2 + bus_port;
|
||||
if (vmu_id < 0 || vmu_id >= ARRAY_SIZE(vmu_lcd_data))
|
||||
return;
|
||||
u32 *p = &vmu_lcd_data[vmu_id][0];
|
||||
for (int i = 0; i < ARRAY_SIZE(vmu_lcd_data[vmu_id]); i++, buffer++)
|
||||
*p++ = *buffer != 0 ? 0xFFFFFFFFu : 0xFF000000u;
|
||||
vmu_lcd_status[vmu_id] = true;
|
||||
}
|
||||
|
||||
static const int vmu_coords[8][2] = {
|
||||
{ 0 , 0 },
|
||||
{ 0 , 0 },
|
||||
{ 1 , 0 },
|
||||
{ 1 , 0 },
|
||||
{ 0 , 1 },
|
||||
{ 0 , 1 },
|
||||
{ 1 , 1 },
|
||||
{ 1 , 1 },
|
||||
};
|
||||
|
||||
static void display_vmus()
|
||||
{
|
||||
if (!game_started)
|
||||
return;
|
||||
ImGui::SetNextWindowBgAlpha(0);
|
||||
ImGui::SetNextWindowPos(ImVec2(0, 0));
|
||||
ImGui::SetNextWindowSize(ImVec2(screen_width, screen_height));
|
||||
|
||||
ImGui::Begin("vmu-window", NULL, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoInputs
|
||||
| ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoFocusOnAppearing);
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
if (!vmu_lcd_status[i])
|
||||
continue;
|
||||
|
||||
if (vmu_lcd_tex_ids[i] != (ImTextureID)0)
|
||||
ImGui_ImplOpenGL3_DeleteVmuTexture(vmu_lcd_tex_ids[i]);
|
||||
vmu_lcd_tex_ids[i] = ImGui_ImplOpenGL3_CreateVmuTexture(vmu_lcd_data[i]);
|
||||
|
||||
int x = vmu_coords[i][0];
|
||||
int y = vmu_coords[i][1];
|
||||
ImVec2 pos;
|
||||
if (x == 0)
|
||||
pos.x = VMU_PADDING;
|
||||
else
|
||||
pos.x = screen_width - VMU_WIDTH - VMU_PADDING;
|
||||
if (y == 0)
|
||||
{
|
||||
pos.y = VMU_PADDING;
|
||||
if (i & 1)
|
||||
pos.y += VMU_HEIGHT + VMU_PADDING;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos.y = screen_height - VMU_HEIGHT - VMU_PADDING;
|
||||
if (i & 1)
|
||||
pos.y -= VMU_HEIGHT + VMU_PADDING;
|
||||
}
|
||||
ImVec2 pos_b(pos.x + VMU_WIDTH, pos.y + VMU_HEIGHT);
|
||||
ImGui::GetWindowDrawList()->AddImage(vmu_lcd_tex_ids[i], pos, pos_b, ImVec2(0, 1), ImVec2(1, 0), 0xC0ffffff);
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
static void reset_vmus()
|
||||
{
|
||||
for (int i = 0; i < ARRAY_SIZE(vmu_lcd_status); i++)
|
||||
vmu_lcd_status[i] = false;
|
||||
}
|
||||
|
||||
static void term_vmus()
|
||||
{
|
||||
for (int i = 0; i < ARRAY_SIZE(vmu_lcd_status); i++)
|
||||
{
|
||||
if (vmu_lcd_tex_ids[i] != (ImTextureID)0)
|
||||
{
|
||||
ImGui_ImplOpenGL3_DeleteVmuTexture(vmu_lcd_tex_ids[i]);
|
||||
vmu_lcd_tex_ids[i] = (ImTextureID)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ void select_directory_popup(const char *prompt, float scaling, StringCallback ca
|
|||
}
|
||||
|
||||
ImGui::Text("%s", error_message.empty() ? select_current_directory.c_str() : error_message.c_str());
|
||||
ImGui::BeginChild(ImGui::GetID("dir_list"), ImVec2(0, -ImGui::CalcTextSize("Cancel").y - ImGui::GetStyle().FramePadding. y * 2 - ImGui::GetStyle().ItemSpacing.y), true);
|
||||
ImGui::BeginChild(ImGui::GetID("dir_list"), ImVec2(0, - 30 * scaling - ImGui::GetStyle().ItemSpacing.y), true);
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(8 * scaling, 20 * scaling)); // from 8, 4
|
||||
|
||||
|
@ -245,14 +245,14 @@ void select_directory_popup(const char *prompt, float scaling, StringCallback ca
|
|||
}
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::EndChild();
|
||||
if (ImGui::Button("Select Current Directory"))
|
||||
if (ImGui::Button("Select Current Directory", ImVec2(0, 30 * scaling)))
|
||||
{
|
||||
subfolders_read = false;
|
||||
callback(false, select_current_directory);
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Cancel"))
|
||||
if (ImGui::Button("Cancel", ImVec2(0, 30 * scaling)))
|
||||
{
|
||||
subfolders_read = false;
|
||||
callback(true, "");
|
||||
|
|
|
@ -50,6 +50,13 @@ public:
|
|||
_name = SDL_JoystickName(sdl_joystick);
|
||||
sdl_joystick_instance = SDL_JoystickInstanceID(sdl_joystick);
|
||||
printf("SDL: Opened joystick on port %d: '%s' ", maple_port, _name.c_str());
|
||||
SDL_JoystickGUID guid = SDL_JoystickGetGUID(sdl_joystick);
|
||||
char buf[33];
|
||||
SDL_JoystickGetGUIDString(guid, buf, sizeof(buf));
|
||||
_unique_id = buf;
|
||||
if (_unique_id.empty())
|
||||
_unique_id = _name;
|
||||
|
||||
if (!find_mapping())
|
||||
{
|
||||
if (_name == "Microsoft X-Box 360 pad")
|
||||
|
@ -175,6 +182,7 @@ public:
|
|||
SDLKbGamepadDevice(int maple_port) : GamepadDevice(maple_port, "SDL")
|
||||
{
|
||||
_name = "Keyboard";
|
||||
_unique_id = "sdl_keyboard;
|
||||
if (!find_mapping())
|
||||
input_mapper = new KbInputMapping();
|
||||
}
|
||||
|
@ -201,6 +209,7 @@ public:
|
|||
SDLMouseGamepadDevice(int maple_port) : GamepadDevice(maple_port, "SDL")
|
||||
{
|
||||
_name = "Mouse";
|
||||
_unique_id = "sdl_mouse";
|
||||
if (!find_mapping())
|
||||
input_mapper = new MouseInputMapping();
|
||||
}
|
||||
|
|
|
@ -36,6 +36,9 @@ public:
|
|||
XInputGamepadDevice(int maple_port, int xinput_port)
|
||||
: GamepadDevice(maple_port, "xinput"), _xinput_port(xinput_port)
|
||||
{
|
||||
char buf[32];
|
||||
sprintf(buf, "xinput-%d", xinput_port + 1);
|
||||
_unique_id = buf;
|
||||
}
|
||||
|
||||
void ReadInput()
|
||||
|
@ -231,6 +234,7 @@ public:
|
|||
WinKbGamepadDevice(int maple_port) : GamepadDevice(maple_port, "win32")
|
||||
{
|
||||
_name = "Keyboard";
|
||||
_unique_id = "win_keyboard";
|
||||
if (!find_mapping())
|
||||
input_mapper = new KbInputMapping();
|
||||
}
|
||||
|
@ -257,6 +261,7 @@ public:
|
|||
WinMouseGamepadDevice(int maple_port) : GamepadDevice(maple_port, "win32")
|
||||
{
|
||||
_name = "Mouse";
|
||||
_unique_id = "win_mouse";
|
||||
if (!find_mapping())
|
||||
input_mapper = new MouseInputMapping();
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public final class InputDeviceManager implements InputManager.InputDeviceListene
|
|||
{
|
||||
maple_port = 0;
|
||||
if (applicationContext.getPackageManager().hasSystemFeature("android.hardware.touchscreen"))
|
||||
joystickAdded(VIRTUAL_GAMEPAD_ID, "Virtual Gamepad", maple_port == 3 ? 3 : maple_port++);
|
||||
joystickAdded(VIRTUAL_GAMEPAD_ID, "Virtual Gamepad", maple_port == 3 ? 3 : maple_port++, "virtual_gamepad_uid");
|
||||
int[] ids = InputDevice.getDeviceIds();
|
||||
for (int id : ids)
|
||||
onInputDeviceAdded(id);
|
||||
|
@ -49,7 +49,7 @@ public final class InputDeviceManager implements InputManager.InputDeviceListene
|
|||
if ((device.getSources() & InputDevice.SOURCE_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK) {
|
||||
port = this.maple_port == 3 ? 3 : this.maple_port++;
|
||||
}
|
||||
joystickAdded(i, device.getName(), port);
|
||||
joystickAdded(i, device.getName(), port, device.getDescriptor());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,6 +96,6 @@ public final class InputDeviceManager implements InputManager.InputDeviceListene
|
|||
public native boolean joystickButtonEvent(int id, int button, boolean pressed);
|
||||
public native boolean joystickAxisEvent(int id, int button, int value);
|
||||
public native void mouseEvent(int xpos, int ypos, int buttons);
|
||||
private native void joystickAdded(int id, String name, int maple_port);
|
||||
private native void joystickAdded(int id, String name, int maple_port, String uniqueId);
|
||||
private native void joystickRemoved(int id);
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ JNIEXPORT jboolean JNICALL Java_com_reicast_emulator_emu_JNIdc_guiIsOpen(JNIEnv
|
|||
JNIEXPORT jboolean JNICALL Java_com_reicast_emulator_emu_JNIdc_guiIsContentBrowser(JNIEnv *env,jobject obj) __attribute__((visibility("default")));
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_reicast_emulator_periph_InputDeviceManager_init(JNIEnv *env, jobject obj) __attribute__((visibility("default")));
|
||||
JNIEXPORT void JNICALL Java_com_reicast_emulator_periph_InputDeviceManager_joystickAdded(JNIEnv *env, jobject obj, jint id, jstring name, jint maple_port) __attribute__((visibility("default")));
|
||||
JNIEXPORT void JNICALL Java_com_reicast_emulator_periph_InputDeviceManager_joystickAdded(JNIEnv *env, jobject obj, jint id, jstring name, jint maple_port, jstring junique_id) __attribute__((visibility("default")));
|
||||
JNIEXPORT void JNICALL Java_com_reicast_emulator_periph_InputDeviceManager_joystickRemoved(JNIEnv *env, jobject obj, jint id) __attribute__((visibility("default")));
|
||||
JNIEXPORT void JNICALL Java_com_reicast_emulator_periph_InputDeviceManager_virtualGamepadEvent(JNIEnv *env, jobject obj, jint kcode, jint joyx, jint joyy, jint lt, jint rt) __attribute__((visibility("default")));
|
||||
JNIEXPORT jboolean JNICALL Java_com_reicast_emulator_periph_InputDeviceManager_joystickButtonEvent(JNIEnv *env, jobject obj, jint id, jint key, jboolean pressed) __attribute__((visibility("default")));
|
||||
|
@ -315,10 +315,6 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_diskSwap(JNIEnv *env,
|
|||
//stuff for microphone
|
||||
jobject sipemu;
|
||||
jmethodID getmicdata;
|
||||
//stuff for vmu lcd
|
||||
jobject vmulcd = NULL;
|
||||
jbyteArray jpix = NULL;
|
||||
jmethodID updatevmuscreen;
|
||||
extern bool game_started;
|
||||
|
||||
//stuff for audio
|
||||
|
@ -333,12 +329,6 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_setupMic(JNIEnv *env,
|
|||
getmicdata = env->GetMethodID(env->GetObjectClass(sipemu),"getData","()[B");
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_setupVmu(JNIEnv *env,jobject obj,jobject vmu)
|
||||
{
|
||||
vmulcd = env->NewGlobalRef(vmu);
|
||||
updatevmuscreen = env->GetMethodID(env->GetObjectClass(vmu),"updateBytes","([B)V");
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_pause(JNIEnv *env,jobject obj)
|
||||
{
|
||||
if (game_started)
|
||||
|
@ -362,18 +352,6 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_destroy(JNIEnv *env,j
|
|||
dc_term();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_vmuSwap(JNIEnv *env,jobject obj)
|
||||
{
|
||||
maple_device* olda = MapleDevices[0][0];
|
||||
maple_device* oldb = MapleDevices[0][1];
|
||||
MapleDevices[0][0] = NULL;
|
||||
MapleDevices[0][1] = NULL;
|
||||
usleep(50000);//50 ms, wait for host to detect disconnect
|
||||
|
||||
MapleDevices[0][0] = oldb;
|
||||
MapleDevices[0][1] = olda;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_reicast_emulator_emu_JNIdc_send(JNIEnv *env,jobject obj,jint cmd, jint param)
|
||||
{
|
||||
if (cmd==0)
|
||||
|
@ -584,19 +562,6 @@ int get_mic_data(u8* buffer)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int push_vmu_screen(u8* buffer)
|
||||
{
|
||||
if(vmulcd==NULL){
|
||||
return 0;
|
||||
}
|
||||
if(jpix==NULL){
|
||||
jpix = jvm_attacher.getEnv()->NewByteArray(1536);
|
||||
}
|
||||
jvm_attacher.getEnv()->SetByteArrayRegion(jpix, 0, 1536, (jbyte*)buffer);
|
||||
jvm_attacher.getEnv()->CallVoidMethod(vmulcd, updatevmuscreen, jpix);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void os_DebugBreak()
|
||||
{
|
||||
// TODO: notify the parent thread about it ...
|
||||
|
@ -622,13 +587,14 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_periph_InputDeviceManager_init(
|
|||
input_device_manager_rumble = env->GetMethodID(env->GetObjectClass(obj), "rumble", "(IFFI)Z");
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_reicast_emulator_periph_InputDeviceManager_joystickAdded(JNIEnv *env, jobject obj, jint id, jstring name, jint maple_port)
|
||||
JNIEXPORT void JNICALL Java_com_reicast_emulator_periph_InputDeviceManager_joystickAdded(JNIEnv *env, jobject obj, jint id, jstring name, jint maple_port, jstring junique_id)
|
||||
{
|
||||
const char* joyname = env->GetStringUTFChars(name,0);
|
||||
std::shared_ptr<AndroidGamepadDevice> gamepad = std::make_shared<AndroidGamepadDevice>(maple_port, id, joyname);
|
||||
const char* unique_id = env->GetStringUTFChars(junique_id, 0);
|
||||
std::shared_ptr<AndroidGamepadDevice> gamepad = std::make_shared<AndroidGamepadDevice>(maple_port, id, joyname, unique_id);
|
||||
AndroidGamepadDevice::AddAndroidGamepad(gamepad);
|
||||
env->ReleaseStringUTFChars(name, joyname);
|
||||
|
||||
env->ReleaseStringUTFChars(name, unique_id);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_com_reicast_emulator_periph_InputDeviceManager_joystickRemoved(JNIEnv *env, jobject obj, jint id)
|
||||
{
|
||||
|
|
|
@ -87,10 +87,12 @@ public:
|
|||
class AndroidGamepadDevice : public GamepadDevice
|
||||
{
|
||||
public:
|
||||
AndroidGamepadDevice(int maple_port, int id, const char *name) : GamepadDevice(maple_port, "Android", id != VIRTUAL_GAMEPAD_ID), android_id(id)
|
||||
AndroidGamepadDevice(int maple_port, int id, const char *name, const char *unique_id)
|
||||
: GamepadDevice(maple_port, "Android", id != VIRTUAL_GAMEPAD_ID), android_id(id)
|
||||
{
|
||||
_name = name;
|
||||
printf("Android: Opened joystick %d on port %d: '%s' ", id, maple_port, _name.c_str());
|
||||
_unique_id = unique_id;
|
||||
printf("Android: Opened joystick %d on port %d: '%s' descriptor '%s'", id, maple_port, _name.c_str(), _unique_id.c_str());
|
||||
if (id == VIRTUAL_GAMEPAD_ID)
|
||||
{
|
||||
input_mapper = new IdentityInputMapping();
|
||||
|
@ -213,6 +215,7 @@ public:
|
|||
AndroidMouseGamepadDevice(int maple_port) : GamepadDevice(maple_port, "Android")
|
||||
{
|
||||
_name = "Mouse";
|
||||
_unique_id = "android_mouse";
|
||||
if (!find_mapping())
|
||||
input_mapper = new MouseInputMapping();
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
OSXKbGamepadDevice(int maple_port) : GamepadDevice(maple_port, "OSX")
|
||||
{
|
||||
_name = "Keyboard";
|
||||
_unique_id = "osx_keyboard";
|
||||
if (!find_mapping())
|
||||
input_mapper = new KbInputMapping();
|
||||
}
|
||||
|
@ -61,6 +62,7 @@ public:
|
|||
OSXMouseGamepadDevice(int maple_port) : GamepadDevice(maple_port, "OSX")
|
||||
{
|
||||
_name = "Mouse";
|
||||
_unique_id = "osx_mouse";
|
||||
if (!find_mapping())
|
||||
input_mapper = new MouseInputMapping();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue