mirror of
https://github.com/micsthepick/dsi2key.git
synced 2025-06-18 16:55:33 -04:00
server updates - probably broke windows builds
This commit is contained in:
parent
4067f46a1e
commit
d7abe2e4e8
52
server/Makefile
Normal file
52
server/Makefile
Normal file
@ -0,0 +1,52 @@
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CXX)),)
|
||||
$(error "Please set CXX in your environment. export CXX=g++")
|
||||
endif
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# all directories are relative to this makefile
|
||||
#---------------------------------------------------------------------------------
|
||||
CPPFILES :=
|
||||
CPPDIRS := core ../common .
|
||||
CDIRS := ../common/iniparser/src
|
||||
INCLUDES := -I..
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
CFLAGS :=
|
||||
CXXFLAGS := -std=c++11
|
||||
DEFINES := -DEMULATOR=0 -DD2KSERVER -DNULL_VALUE=0
|
||||
LDFLAGS := -lX11 -lXtst
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
export OUTPUTFILE := ds2key
|
||||
VPATH := $(CPPDIRS) $(CDIRS)
|
||||
|
||||
CFILES := $(foreach dir,$(CDIRS),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(filter-out vjoy.cpp, $(foreach dir,$(CPPDIRS),$(notdir $(wildcard $(dir)/*.cpp))))
|
||||
|
||||
OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CXX)
|
||||
|
||||
.PHONY: all clean build
|
||||
|
||||
all: $(OUTPUTFILE)
|
||||
|
||||
$(OUTPUTFILE) : $(OFILES)
|
||||
$(LD) $(DEFINES) $(OFILES) $(LDFLAGS) -o $@
|
||||
|
||||
%.o: %.c
|
||||
$(CXX) $(DEFINES) $(INCLUDES) $(CFLAGS) -c $< -o $@
|
||||
|
||||
%.o: %.cpp
|
||||
$(CXX) $(DEFINES) $(INCLUDES) $(CXXFLAGS) -c $< -o $@
|
||||
|
||||
build: $(OUTPUTFILE)
|
||||
|
||||
clean:
|
||||
rm -rf $(OFILES) $(OUTPUTFILE)
|
@ -3,12 +3,17 @@
|
||||
#include "client.h"
|
||||
#include "common/key.h"
|
||||
#include "common/misc.h"
|
||||
#include "common/screen_size.h"
|
||||
#include <sstream> // std::stringstream
|
||||
#if defined(__linux__)
|
||||
#if defined(__linux__) && !defined(_NDS) && !defined(__3DS__)
|
||||
#include <arpa/inet.h>
|
||||
#include <X11/Xlib.h>
|
||||
#endif
|
||||
|
||||
#if defined(__3DS__)
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
namespace D2K {
|
||||
|
||||
Client* g_client_array[CLIENT_MAX]{};
|
||||
@ -389,7 +394,7 @@ Client::Client()
|
||||
#if WIN32
|
||||
screen_width = (int) GetSystemMetrics(SM_CXSCREEN);
|
||||
screen_height = (int) GetSystemMetrics(SM_CYSCREEN);
|
||||
#else
|
||||
#elif defined(__linux__)
|
||||
Display* disp = XOpenDisplay(NULL);
|
||||
Screen* scrn = DefaultScreenOfDisplay(disp);
|
||||
screen_width = scrn->width;
|
||||
@ -472,17 +477,25 @@ void Client::SetIP(uint32_t ip_address)
|
||||
m_profile_data->m_ip_address = ip_address;
|
||||
}
|
||||
|
||||
long Client::GetOffsetX(int mult)
|
||||
long Client::GetOffsetX()
|
||||
{
|
||||
return std::min(m_profile_data->m_absolute_top_left_x, m_profile_data->m_absolute_bot_right_x) * mult / screen_width;
|
||||
#ifdef _WIN32
|
||||
return std::min(m_profile_data->m_absolute_top_left_x, m_profile_data->m_absolute_bot_right_x)*25565 / screen_width;
|
||||
#elif defined(__linux__)
|
||||
return std::min(m_profile_data->m_absolute_top_left_x, m_profile_data->m_absolute_bot_right_x);
|
||||
#endif
|
||||
}
|
||||
|
||||
long Client::GetOffsetY(int mult)
|
||||
long Client::GetOffsetY()
|
||||
{
|
||||
return std::min(m_profile_data->m_absolute_top_left_y, m_profile_data->m_absolute_bot_right_y) * mult / screen_height;
|
||||
#ifdef _WIN32
|
||||
return std::min(m_profile_data->m_absolute_top_left_y, m_profile_data->m_absolute_bot_right_y)*25565 / screen_height;
|
||||
#elif defined(__linux__)
|
||||
return std::min(m_profile_data->m_absolute_top_left_y, m_profile_data->m_absolute_bot_right_y);
|
||||
#endif
|
||||
}
|
||||
|
||||
int Client::GetDX(int mult)
|
||||
int Client::GetDX()
|
||||
{
|
||||
auto sm = m_profile_data->m_absolute_top_left_x;
|
||||
auto la = m_profile_data->m_absolute_bot_right_x;
|
||||
@ -493,12 +506,20 @@ int Client::GetDX(int mult)
|
||||
}
|
||||
if (sm == la)
|
||||
{
|
||||
return mult * (screen_width - sm) / screen_width / screen_width;
|
||||
#ifdef _WIN32
|
||||
return (screen_width - sm)*25565 / screen_width;
|
||||
#elif defined(__linux__)
|
||||
return (screen_width - sm);
|
||||
#endif
|
||||
}
|
||||
return mult * (la - sm) / screen_width;
|
||||
#ifdef _WIN32
|
||||
return (la - sm)*25565 / screen_width;
|
||||
#elif defined(__linux__)
|
||||
return (la - sm);
|
||||
#endif
|
||||
}
|
||||
|
||||
int Client::GetDY(int mult)
|
||||
int Client::GetDY()
|
||||
{
|
||||
auto sm = m_profile_data->m_absolute_top_left_y;
|
||||
auto la = m_profile_data->m_absolute_bot_right_y;
|
||||
@ -509,9 +530,17 @@ int Client::GetDY(int mult)
|
||||
}
|
||||
if (sm == la)
|
||||
{
|
||||
return mult * (screen_height - sm) / screen_height / screen_height;
|
||||
#ifdef _WIN32
|
||||
return (screen_height - sm)*25565 / screen_height;
|
||||
#elif defined(__linux__)
|
||||
return (screen_height - sm);
|
||||
#endif
|
||||
}
|
||||
return mult * (la - sm) / screen_height;
|
||||
#ifdef _WIN32
|
||||
return (la - sm)*25565 / screen_height;
|
||||
#elif defined(__linux__)
|
||||
return (la - sm);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint16_t Client::GetX()
|
||||
|
@ -197,16 +197,16 @@ public:
|
||||
void SetIP(uint32_t ip_address);
|
||||
|
||||
// gets the width of the absolute touch surface
|
||||
int GetDX(int mult);
|
||||
int GetDX();
|
||||
|
||||
// gets the height of the absolute touch surface
|
||||
int GetDY(int mult);
|
||||
int GetDY();
|
||||
|
||||
// gets the X offset of a point
|
||||
long GetOffsetX(int mult);
|
||||
long GetOffsetX();
|
||||
|
||||
// gets the Y offset of a point
|
||||
long GetOffsetY(int mult);
|
||||
long GetOffsetY();
|
||||
|
||||
// return: Stylus current X Position. Values range 0-255(NDS), 0-319(3DS)
|
||||
uint16_t GetX();
|
||||
|
@ -96,12 +96,12 @@ void NewProfile(ProfileData* profile_data, uint8_t profile_number)
|
||||
profile_data->SetVirtualKey(KEYS::CPAD_DOWN, Key::KEY_END);
|
||||
profile_data->SetVirtualKey(KEYS::CPAD_LEFT, Key::KEY_DELETE);
|
||||
profile_data->SetVirtualKey(KEYS::CPAD_RIGHT, Key::KEY_NEXT);
|
||||
|
||||
#ifdef COLOR_KEYS
|
||||
profile_data->SetVirtualKey(KEYS::BLUE, Key::KEY_NUMPAD1);
|
||||
profile_data->SetVirtualKey(KEYS::YELLOW, Key::KEY_NUMPAD3);
|
||||
profile_data->SetVirtualKey(KEYS::RED, Key::KEY_NUMPAD7);
|
||||
profile_data->SetVirtualKey(KEYS::GREEN, Key::KEY_NUMPAD9);
|
||||
|
||||
#endif
|
||||
profile_data->SetVirtualKey(KEYS::SLIDER_VOLUME, Key::KEY_NUMPAD1);
|
||||
profile_data->SetVirtualKey(KEYS::SLIDER_3D, Key::KEY_NUMPAD3);
|
||||
|
||||
@ -201,12 +201,12 @@ int LoadProfile(ProfileData* profile_data, uint8_t profile_number)
|
||||
profile_data->SetValue(KEYS::CPAD_DOWN, iniParser::getstring(ini, "profile:cpaddown", "Key_None"));
|
||||
profile_data->SetValue(KEYS::CPAD_LEFT, iniParser::getstring(ini, "profile:cpadleft", "Key_None"));
|
||||
profile_data->SetValue(KEYS::CPAD_RIGHT, iniParser::getstring(ini, "profile:cpadright", "Key_None"));
|
||||
|
||||
#ifdef COLOR_KEYS
|
||||
profile_data->SetValue(KEYS::BLUE, iniParser::getstring(ini, "profile:blue", "Key_None"));
|
||||
profile_data->SetValue(KEYS::YELLOW, iniParser::getstring(ini, "profile:yellow", "Key_None"));
|
||||
profile_data->SetValue(KEYS::RED, iniParser::getstring(ini, "profile:red", "Key_None"));
|
||||
profile_data->SetValue(KEYS::GREEN, iniParser::getstring(ini, "profile:green", "Key_None"));
|
||||
|
||||
#endif
|
||||
profile_data->SetValue(KEYS::SLIDER_VOLUME, iniParser::getstring(ini, "profile:slidervolume", "Key_None"));
|
||||
profile_data->SetValue(KEYS::SLIDER_3D, iniParser::getstring(ini, "profile:slider3d", "Key_None"));
|
||||
|
||||
@ -350,12 +350,12 @@ int SaveProfile(ProfileData* Profile, uint8_t profileNumber)
|
||||
fprintf(file, "CPadDown=%s\n", Profile->GetButtonString(KEYS::CPAD_DOWN).c_str());
|
||||
fprintf(file, "CPadLeft=%s\n", Profile->GetButtonString(KEYS::CPAD_LEFT).c_str());
|
||||
fprintf(file, "CPadRight=%s\n", Profile->GetButtonString(KEYS::CPAD_RIGHT).c_str());
|
||||
|
||||
#ifdef COLOR_KEYS
|
||||
fprintf(file, "Blue=%s\n", Profile->GetButtonString(KEYS::BLUE).c_str());
|
||||
fprintf(file, "Yellow=%s\n", Profile->GetButtonString(KEYS::YELLOW).c_str());
|
||||
fprintf(file, "Red=%s\n", Profile->GetButtonString(KEYS::RED).c_str());
|
||||
fprintf(file, "Green=%s\n", Profile->GetButtonString(KEYS::GREEN).c_str());
|
||||
|
||||
#endif
|
||||
fprintf(file, "SliderVolume=%s\n", Profile->GetButtonString(KEYS::SLIDER_VOLUME).c_str());
|
||||
fprintf(file, "Slider3D=%s\n", Profile->GetButtonString(KEYS::SLIDER_3D).c_str());
|
||||
|
||||
|
@ -337,7 +337,9 @@ void ProcessButtons(D2K::Client* client)
|
||||
ExecuteCommand(command);
|
||||
}
|
||||
}
|
||||
#ifdef _WIN32
|
||||
D2K::Input::Joystick::Update(joystick);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ProcessTouchScreen(D2K::Client* client)
|
||||
@ -372,54 +374,45 @@ void ProcessTouchScreen(D2K::Client* client)
|
||||
last_screen_touched = true;
|
||||
}
|
||||
|
||||
// check that we've moved
|
||||
if(true/*!((x - last_x < -s_ignore)
|
||||
|| (x - last_x > s_ignore)
|
||||
|| (y - last_y < -s_ignore)
|
||||
|| (y - last_y > s_ignore))*/)
|
||||
// relative movement
|
||||
if(moveType == "Relative")
|
||||
{
|
||||
// relative movement
|
||||
if(moveType == "Relative")
|
||||
{
|
||||
Input::Move((x - last_x) * s_sensitivity, (y - last_y) * s_sensitivity);
|
||||
}
|
||||
// absolute movement
|
||||
else if(moveType == "Absolute")
|
||||
{
|
||||
int temporary_x = x;
|
||||
int temporary_y = y;
|
||||
|
||||
if(temporary_x < s_deadzone)
|
||||
temporary_x = s_deadzone;
|
||||
if(temporary_x > 255 - s_deadzone)
|
||||
temporary_x = 255 - s_deadzone;
|
||||
if(temporary_y < s_deadzone)
|
||||
temporary_y = s_deadzone;
|
||||
if(temporary_y > 191 - s_deadzone)
|
||||
temporary_y = 191 - s_deadzone;
|
||||
|
||||
temporary_x -= s_deadzone;
|
||||
temporary_y -= s_deadzone;
|
||||
|
||||
auto old_width = 255 - s_deadzone - s_deadzone;
|
||||
auto new_width = client->GetDX(65535);
|
||||
|
||||
auto old_height = 191 - s_deadzone - s_deadzone;
|
||||
auto new_height = client->GetDY(65535);
|
||||
|
||||
Input::MoveAbsolute(
|
||||
temporary_x * new_width / old_width + client->GetOffsetX(65535),
|
||||
temporary_y * new_height / old_height + client->GetOffsetY(65535));
|
||||
}
|
||||
else
|
||||
{
|
||||
int temporary_x = x * 100 / 255;
|
||||
int temporary_y = y * 100 / 191;
|
||||
Input::MoveJoystick(clamp(temporary_x, 0, 100), clamp(temporary_y, 0, 100));
|
||||
}
|
||||
last_x = x;
|
||||
last_y = y;
|
||||
Input::Move((x - last_x) * s_sensitivity, (y - last_y) * s_sensitivity);
|
||||
}
|
||||
// absolute movement
|
||||
else if(moveType == "Absolute")
|
||||
{
|
||||
int temporary_x = x * client->GetDX() / 255 + client->GetOffsetX();
|
||||
int temporary_y = y * client->GetDY() / 191 + client->GetOffsetY();
|
||||
|
||||
// if(temporary_x < s_deadzone)
|
||||
// temporary_x = s_deadzone;
|
||||
// if(temporary_x > 255 - s_deadzone)
|
||||
// temporary_x = 255 - s_deadzone;
|
||||
// if(temporary_y < s_deadzone)
|
||||
// temporary_y = s_deadzone;
|
||||
// if(temporary_y > 191 - s_deadzone)
|
||||
// temporary_y = 191 - s_deadzone;
|
||||
|
||||
// temporary_x -= s_deadzone;
|
||||
// temporary_y -= s_deadzone;
|
||||
|
||||
// auto old_width = 255 - s_deadzone - s_deadzone;
|
||||
// auto new_width = client->GetDX(65535);
|
||||
|
||||
// auto old_height = 191 - s_deadzone - s_deadzone;
|
||||
// auto new_height = client->GetDY(65535);
|
||||
|
||||
Input::MoveAbsolute(temporary_x, temporary_y);
|
||||
}
|
||||
// joystick
|
||||
else {
|
||||
int temporary_x = x * 100 / 255;
|
||||
int temporary_y = y * 100 / 191;
|
||||
Input::MoveJoystick(clamp(temporary_x, 0, 100), clamp(temporary_y, 0, 100));
|
||||
}
|
||||
last_x = x;
|
||||
last_y = y;
|
||||
}
|
||||
// If newly released
|
||||
else if(last_screen_touched == true)
|
||||
@ -496,8 +489,9 @@ void ReleaseDeadClient(D2K::Client* client)
|
||||
&& client->Held(ds_button_bit))
|
||||
Input::Release(pc_key, joystick);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
D2K::Input::Joystick::DeInit(joystick);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CheckForDeadClients()
|
||||
|
@ -158,7 +158,20 @@ void Keyboard(uint16_t key, KeyState state)
|
||||
|
||||
SendInput(1, (LPINPUT)&input, sizeof(INPUT));
|
||||
#elif defined(__linux__)
|
||||
unsigned long int code = XKeysymToKeycode(g_display, key);
|
||||
unsigned long int code;
|
||||
if (key >= 0x8001 && key <= 0x8003) {
|
||||
code = (key & 0x3);
|
||||
//LOG(TRACE) << "XTestFakeButtonEvent:: code: " << code << ", state: " << state;
|
||||
XTestFakeButtonEvent(g_display, code, !state, 0);
|
||||
XFlush(g_display);
|
||||
return;
|
||||
}
|
||||
|
||||
code = XKeysymToKeycode(g_display, key);
|
||||
if (code == 0) {
|
||||
LOG(ERROR) << "XKeysymToKeycode returned 0 (NULL)" << std::endl;
|
||||
return;
|
||||
}
|
||||
XTestFakeKeyEvent(g_display, code, !state, 0);
|
||||
XFlush(g_display);
|
||||
#endif
|
||||
@ -172,8 +185,8 @@ void Mouse(MouseMovement type, signed long int x, signed long int y)
|
||||
INPUT input{};
|
||||
|
||||
input.type = INPUT_MOUSE;
|
||||
input.mi.dx = x; // -16 border
|
||||
input.mi.dy = y; // -16 border
|
||||
input.mi.dx = x;
|
||||
input.mi.dy = y;
|
||||
input.mi.dwFlags = (type ? MOUSEEVENTF_ABSOLUTE : 0) | MOUSEEVENTF_MOVE;
|
||||
input.mi.dwExtraInfo = 0;
|
||||
input.mi.mouseData = 0;
|
||||
@ -190,10 +203,13 @@ void Mouse(MouseMovement type, signed long int x, signed long int y)
|
||||
|
||||
if(XGetGeometry(g_display, rootwindow, &dummyWin, &dummySignedInt, &dummySignedInt, &width, &height, &dummyInt, &dummyInt))
|
||||
{
|
||||
//LOG(DEBUG) << x << ", " << y << std::endl;
|
||||
//return;
|
||||
if(type)
|
||||
XTestFakeMotionEvent(g_display, screen, (x * width) / 65535, (y * height) / 65535, 0);
|
||||
XTestFakeMotionEvent(g_display, screen, x, y, 0);
|
||||
else
|
||||
XTestFakeRelativeMotionEvent(g_display, x, y, 0);
|
||||
XFlush(g_display);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance,
|
||||
#include <chrono>
|
||||
namespace D2K {
|
||||
|
||||
#if 0
|
||||
void ExecuteCommand(const std::string& Command);
|
||||
void SendClient()
|
||||
{
|
||||
@ -32,6 +33,7 @@ void SendClient()
|
||||
time_previous = time_current;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@ -51,7 +53,6 @@ int main(int argc, char* argv[])
|
||||
|
||||
#ifdef WIN32GUI
|
||||
D2K::GUI::MainWindow::TrayIcon->Delete();
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user