From 52ffb97b687bb2d006d715ffafcdcdd61364aa10 Mon Sep 17 00:00:00 2001 From: CTurt Date: Sun, 6 Sep 2015 18:38:49 +0100 Subject: [PATCH] General fixes --- PC/Makefile | 2 +- PC/include/keys.h | 2 + PC/include/screenshot.h | 16 -------- PC/source/main.c | 5 --- PC/source/screenshot.cpp | 80 ---------------------------------------- PC/source/wireless.c | 22 ----------- 6 files changed, 3 insertions(+), 124 deletions(-) delete mode 100644 PC/include/screenshot.h delete mode 100644 PC/source/screenshot.cpp diff --git a/PC/Makefile b/PC/Makefile index 33f12ab..4581eca 100644 --- a/PC/Makefile +++ b/PC/Makefile @@ -6,7 +6,7 @@ SDIR := source IDIR := include LDIR := lib CFLAGS := -I$(IDIR) -fms-extensions -O2 -Wall -LFLAGS := -L$(LDIR) -lvJoyInterface -lws2_32 -lGdi32 -lgdiplus -static-libgcc -static-libstdc++ +LFLAGS := $(LDIR)/vJoyInterface.lib -lws2_32 -lGdi32 -lgdiplus -static-libgcc CFILES := $(wildcard $(SDIR)/*.c) CPPFILES := $(wildcard $(SDIR)/*.cpp) OBJS := $(patsubst $(SDIR)/%.c, build/%.o, $(wildcard $(SDIR)/*.c)) diff --git a/PC/include/keys.h b/PC/include/keys.h index f362629..7ba9136 100644 --- a/PC/include/keys.h +++ b/PC/include/keys.h @@ -15,7 +15,9 @@ #define KEYEVENTF_SCANCODE 0x08 #endif +#ifndef MAPVK_VK_TO_VSC #define MAPVK_VK_TO_VSC 0 +#endif #define newpress(key) ((currentKeys & key) && !(lastKeys & key)) #define release(key) (!(currentKeys & key) && (lastKeys & key)) diff --git a/PC/include/screenshot.h b/PC/include/screenshot.h deleted file mode 100644 index a530517..0000000 --- a/PC/include/screenshot.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define SCREENSHOT_NAME "tempScreen.jpg" -#define SCREENSHOT_NAMEL L"tempScreen.jpg" - -void screenshot(const WCHAR *filename, BOOL fullscreen, int windowedX, int windowedY, ULONG quality); - -#ifdef __cplusplus -} -#endif diff --git a/PC/source/main.c b/PC/source/main.c index f0b5378..835f5d2 100644 --- a/PC/source/main.c +++ b/PC/source/main.c @@ -12,7 +12,6 @@ #include "joystick.h" #include "settings.h" #include "keyboard.h" -#include "screenshot.h" int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow) { printf("3DS Controller Server %.1f\n", VERSION); @@ -23,8 +22,6 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow) double widthMultiplier = screenWidth / 320.0; double heightMultiplier = screenHeight / 240.0; - //screenshot(SCREENSHOT_NAMEL, TRUE, 0, 0, 18); - bool vJoy = true; UINT iInterface = 1; @@ -221,8 +218,6 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmd, int nShow) } if(vJoy) updateJoystick(); - - //sendScreenshot(); } error("accept()"); diff --git a/PC/source/screenshot.cpp b/PC/source/screenshot.cpp deleted file mode 100644 index 029a863..0000000 --- a/PC/source/screenshot.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include -#include - -#include "screenshot.h" - -extern "C" { - -int GetEncoderClsid(const WCHAR *format, CLSID *pClsid) { - using namespace Gdiplus; - UINT num = 0; // number of image encoders - UINT size = 0; // size of the image encoder array in bytes - - ImageCodecInfo *pImageCodecInfo = NULL; - - GetImageEncodersSize(&num, &size); - if(size == 0) - return -1; // Failure - - pImageCodecInfo = (ImageCodecInfo *)(malloc(size)); - if(pImageCodecInfo == NULL) - return -1; // Failure - - GetImageEncoders(num, size, pImageCodecInfo); - - UINT j; - for(j = 0; j < num; j++) { - if(wcscmp(pImageCodecInfo[j].MimeType, format) == 0) { - *pClsid = pImageCodecInfo[j].Clsid; - free(pImageCodecInfo); - return j; // Success - } - } - - free(pImageCodecInfo); - return 0; -} - -void screenshot(const WCHAR *filename, BOOL fullscreen, int windowedX, int windowedY, ULONG quality) { - using namespace Gdiplus; - GdiplusStartupInput gdiplusStartupInput; - ULONG_PTR gdiplusToken; - GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); - - { - HDC scrdc, memdc; - HBITMAP membit; - scrdc = ::GetDC(0); - memdc = CreateCompatibleDC(scrdc); - membit = CreateCompatibleBitmap(scrdc, 400, 240); - HBITMAP hOldBitmap = (HBITMAP) SelectObject(memdc, membit); - - EncoderParameters encoderParams; - encoderParams.Count = 1; - encoderParams.Parameter[0].NumberOfValues = 1; - encoderParams.Parameter[0].Guid = EncoderQuality; - encoderParams.Parameter[0].Type = EncoderParameterValueTypeLong; - encoderParams.Parameter[0].Value = &quality; - - if(fullscreen) { - StretchBlt(memdc, 0, 0, 400, 240, scrdc, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SRCCOPY); - } - else { - BitBlt(memdc, 0, 0, 400, 240, scrdc, windowedX, windowedY, SRCCOPY); - } - - Gdiplus::Bitmap bitmap(membit, NULL); - CLSID clsid; - GetEncoderClsid(L"image/jpeg", &clsid); - bitmap.Save(filename, &clsid, &encoderParams); - - SelectObject(memdc, hOldBitmap); - DeleteObject(memdc); - DeleteObject(membit); - ::ReleaseDC(0, scrdc); - } - - GdiplusShutdown(gdiplusToken); -} - -} diff --git a/PC/source/wireless.c b/PC/source/wireless.c index 9100878..389989a 100644 --- a/PC/source/wireless.c +++ b/PC/source/wireless.c @@ -3,7 +3,6 @@ #include "general.h" #include "settings.h" -#include "screenshot.h" #include "wireless.h" @@ -79,24 +78,3 @@ void sendBuffer(int length) { int receiveBuffer(int length) { return recvfrom(listener, (char *)&buffer, length, 0, (struct sockaddr *)&client_in, &sockaddr_in_sizePtr); } - -void sendScreenshot(void) { - FILE *f = fopen(SCREENSHOT_NAME, "rb"); - fseek(f, 0, SEEK_END); - size_t len = ftell(f); - unsigned char *screenshotData = malloc(len); - rewind(f); - fread(screenshotData, len, 1, f); - fclose(f); - - buffer.command = SCREENSHOT; - - while(1) { - int tl = len - buffer.offset > SCREENSHOT_CHUNK ? SCREENSHOT_CHUNK : len - buffer.offset; - memcpy(buffer.data, screenshotData + buffer.offset, tl); - sendBuffer(tl + offsetof(struct packet, screenshotPacket)); - if(tl < SCREENSHOT_CHUNK) break; - } - - free(screenshotData); -}