txori / picobook Goto Github PK
View Code? Open in Web Editor NEWLaunch Picotron by Lexaloffle at the correct screen resolution on the Chuwi Minibook X, then switch back to the original resolution upon exit.
Launch Picotron by Lexaloffle at the correct screen resolution on the Chuwi Minibook X, then switch back to the original resolution upon exit.
There are two 40 black pixels at the top and bottom of the screen. The mouse cursor can go there.
I tried to restrain the mouse cursor to the Picotron without success, using cpp ClipCursor:
#include <iostream>
#include <windows.h>
// Screen resolution of the Chuwi Minibook X
constexpr int SCREEN_WIDTH = 1440;
constexpr int SCREEN_HEIGHT = 900;
// Screen resolution of the Picotron 480x270 (x3)
constexpr int PICOTRON_WIDTH = 1440;
constexpr int PICOTRON_HEIGHT = 810;
// Function prototypes
bool ChangeResolution(int width, int height);
void RestoreResolution();
void ClipMouseToRect(RECT rect);
int main() {
// Change the screen resolution
if (!ChangeResolution(SCREEN_WIDTH, SCREEN_HEIGHT)) {
std::cerr << "Failed to change screen resolution." << std::endl;
return 1; // Exit if resolution change failed
}
// Calculate the rectangle to clip the mouse cursor
RECT clipRect;
clipRect.left = 0;
clipRect.top = (SCREEN_HEIGHT - PICOTRON_HEIGHT) / 2; // Adjust to center vertically
clipRect.right = PICOTRON_WIDTH;
clipRect.bottom = clipRect.top + PICOTRON_HEIGHT;
// Clip the mouse cursor to the specified rectangle
ClipMouseToRect(clipRect);
// Run the program
if (system("picotron.exe") != 0) {
std::cerr << "Failed to execute picotron.exe." << std::endl;
RestoreResolution(); // Restore resolution before exiting
return 1;
}
// Restore the original screen resolution
RestoreResolution();
// Release the mouse cursor from the clipped rectangle
ClipCursor(NULL);
return 0;
}
// Function to change the screen resolution
bool ChangeResolution(int width, int height) {
DEVMODE devMode = {};
devMode.dmSize = sizeof(DEVMODE);
devMode.dmPelsWidth = width;
devMode.dmPelsHeight = height;
devMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
return ChangeDisplaySettings(&devMode, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL;
}
// Function to restore the original screen resolution
void RestoreResolution() {
ChangeDisplaySettings(NULL, 0);
}
// Function to clip the mouse cursor to a specified rectangle
void ClipMouseToRect(RECT rect) {
ClipCursor(&rect);
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.