General fixes
This commit is contained in:
parent
b2c7c42d9b
commit
2f5bd49837
6 changed files with 3 additions and 124 deletions
|
@ -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))
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#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
|
|
@ -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()");
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
#include <windows.h>
|
||||
#include <GdiPlus.h>
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue