mirror of https://gitlab.com/nakst/essence
more mouse settings
This commit is contained in:
parent
7163761f39
commit
dbc595a344
|
@ -1130,9 +1130,7 @@ extern "C" void _start(EsProcessStartupInformation *_startupInformation) {
|
||||||
NodeAddMountPoint(EsLiteral("|Themes:"), node.handle, false);
|
NodeAddMountPoint(EsLiteral("|Themes:"), node.handle, false);
|
||||||
EsHeapFree(path);
|
EsHeapFree(path);
|
||||||
|
|
||||||
api.global->clickChainTimeoutMs = EsSystemConfigurationReadInteger(EsLiteral("general"), EsLiteral("click_chain_timeout_ms"));
|
SettingsUpdateGlobalAndWindowManager();
|
||||||
api.global->swapLeftAndRightButtons = EsSystemConfigurationReadInteger(EsLiteral("general"), EsLiteral("swap_left_and_right_buttons"));
|
|
||||||
api.global->showCursorShadow = EsSystemConfigurationReadInteger(EsLiteral("general"), EsLiteral("show_cursor_shadow"));
|
|
||||||
} else {
|
} else {
|
||||||
EsHandle initialMountPointsBuffer = EsSyscall(ES_SYSCALL_PROCESS_GET_CREATION_ARGUMENT, ES_CURRENT_PROCESS, CREATION_ARGUMENT_INITIAL_MOUNT_POINTS, 0, 0);
|
EsHandle initialMountPointsBuffer = EsSyscall(ES_SYSCALL_PROCESS_GET_CREATION_ARGUMENT, ES_CURRENT_PROCESS, CREATION_ARGUMENT_INITIAL_MOUNT_POINTS, 0, 0);
|
||||||
size_t initialMountPointCount = EsConstantBufferGetSize(initialMountPointsBuffer) / sizeof(EsMountPoint);
|
size_t initialMountPointCount = EsConstantBufferGetSize(initialMountPointsBuffer) / sizeof(EsMountPoint);
|
||||||
|
|
|
@ -789,6 +789,7 @@ enum EsSyscallType {
|
||||||
|
|
||||||
ES_SYSCALL_CURSOR_POSITION_GET
|
ES_SYSCALL_CURSOR_POSITION_GET
|
||||||
ES_SYSCALL_CURSOR_POSITION_SET
|
ES_SYSCALL_CURSOR_POSITION_SET
|
||||||
|
ES_SYSCALL_CURSOR_PROPERTIES_SET
|
||||||
ES_SYSCALL_GAME_CONTROLLER_STATE_POLL
|
ES_SYSCALL_GAME_CONTROLLER_STATE_POLL
|
||||||
ES_SYSCALL_EYEDROP_START
|
ES_SYSCALL_EYEDROP_START
|
||||||
|
|
||||||
|
|
|
@ -291,6 +291,10 @@ struct BundleFile {
|
||||||
#define WINDOW_SET_BITS_SCROLL_VERTICAL (2)
|
#define WINDOW_SET_BITS_SCROLL_VERTICAL (2)
|
||||||
#define WINDOW_SET_BITS_AFTER_RESIZE (3)
|
#define WINDOW_SET_BITS_AFTER_RESIZE (3)
|
||||||
|
|
||||||
|
#define CURSOR_USE_ACCELERATION (1 << 0)
|
||||||
|
#define CURSOR_USE_ALT_SLOW (1 << 1)
|
||||||
|
#define CURSOR_SPEED(x) ((x) >> 16)
|
||||||
|
|
||||||
#define SHUTDOWN_ACTION_POWER_OFF (1)
|
#define SHUTDOWN_ACTION_POWER_OFF (1)
|
||||||
#define SHUTDOWN_ACTION_RESTART (2)
|
#define SHUTDOWN_ACTION_RESTART (2)
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,9 @@ struct SettingsControl {
|
||||||
#define SETTINGS_CONTROL_NUMBER (2)
|
#define SETTINGS_CONTROL_NUMBER (2)
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
bool originalValueBool;
|
bool originalValueBool;
|
||||||
bool *globalPointerBool;
|
|
||||||
int32_t originalValueInt;
|
int32_t originalValueInt;
|
||||||
int32_t *globalPointerInt;
|
|
||||||
int32_t minimumValue, maximumValue;
|
int32_t minimumValue, maximumValue;
|
||||||
|
double dragSpeed, dragValue;
|
||||||
const char *suffix;
|
const char *suffix;
|
||||||
size_t suffixBytes;
|
size_t suffixBytes;
|
||||||
const char *cConfigurationSection;
|
const char *cConfigurationSection;
|
||||||
|
@ -102,6 +101,20 @@ const EsStyle styleSettingsButton = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void SettingsUpdateGlobalAndWindowManager() {
|
||||||
|
api.global->clickChainTimeoutMs = EsSystemConfigurationReadInteger(EsLiteral("general"), EsLiteral("click_chain_timeout_ms"));
|
||||||
|
api.global->swapLeftAndRightButtons = EsSystemConfigurationReadInteger(EsLiteral("general"), EsLiteral("swap_left_and_right_buttons"));
|
||||||
|
api.global->showCursorShadow = EsSystemConfigurationReadInteger(EsLiteral("general"), EsLiteral("show_cursor_shadow"));
|
||||||
|
|
||||||
|
uint32_t cursorProperties = 0;
|
||||||
|
if (EsSystemConfigurationReadInteger(EsLiteral("general"), EsLiteral("use_cursor_acceleration"))) cursorProperties |= CURSOR_USE_ACCELERATION;
|
||||||
|
if (EsSystemConfigurationReadInteger(EsLiteral("general"), EsLiteral("use_cursor_alt_slow"))) cursorProperties |= CURSOR_USE_ALT_SLOW;
|
||||||
|
int32_t cursorSpeed = EsSystemConfigurationReadInteger(EsLiteral("general"), EsLiteral("cursor_speed"));
|
||||||
|
double cursorSpeedFactor = EsCRTexp2(0.25 * cursorSpeed /* -20 to 20, 0 is default */) /* 1/32 to 32, 1 is default */;
|
||||||
|
cursorProperties |= (uint32_t) (cursorSpeedFactor * 0x100) << 16; // Speed.
|
||||||
|
EsSyscall(ES_SYSCALL_CURSOR_PROPERTIES_SET, cursorProperties, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
void SettingsBackButton(EsInstance *_instance, EsElement *, EsCommand *) {
|
void SettingsBackButton(EsInstance *_instance, EsElement *, EsCommand *) {
|
||||||
SettingsInstance *instance = (SettingsInstance *) _instance;
|
SettingsInstance *instance = (SettingsInstance *) _instance;
|
||||||
instance->undoButton = nullptr;
|
instance->undoButton = nullptr;
|
||||||
|
@ -116,7 +129,7 @@ void SettingsNumberBoxSetValue(EsElement *element, int32_t newValue) {
|
||||||
|
|
||||||
newValue = ClampInteger(control->minimumValue, control->maximumValue, newValue);
|
newValue = ClampInteger(control->minimumValue, control->maximumValue, newValue);
|
||||||
char buffer[64];
|
char buffer[64];
|
||||||
size_t bytes = EsStringFormat(buffer, sizeof(buffer), "%d%s", newValue, control->suffixBytes, control->suffix);
|
size_t bytes = EsStringFormat(buffer, sizeof(buffer), "%i%s", newValue, control->suffixBytes, control->suffix);
|
||||||
EsTextboxSelectAll(textbox);
|
EsTextboxSelectAll(textbox);
|
||||||
EsTextboxInsert(textbox, buffer, bytes);
|
EsTextboxInsert(textbox, buffer, bytes);
|
||||||
|
|
||||||
|
@ -130,7 +143,7 @@ void SettingsNumberBoxSetValue(EsElement *element, int32_t newValue) {
|
||||||
EsMutexRelease(&api.systemConfigurationMutex);
|
EsMutexRelease(&api.systemConfigurationMutex);
|
||||||
|
|
||||||
if (oldValue != newValue) {
|
if (oldValue != newValue) {
|
||||||
if (control->globalPointerInt) *control->globalPointerInt = newValue;
|
SettingsUpdateGlobalAndWindowManager();
|
||||||
EsElementSetDisabled(instance->undoButton, false);
|
EsElementSetDisabled(instance->undoButton, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -194,19 +207,18 @@ void SettingsCheckboxCommand(EsInstance *_instance, EsElement *element, EsComman
|
||||||
EsMutexRelease(&api.systemConfigurationMutex);
|
EsMutexRelease(&api.systemConfigurationMutex);
|
||||||
|
|
||||||
if (oldValue == newValue) return;
|
if (oldValue == newValue) return;
|
||||||
if (control->globalPointerBool) *control->globalPointerBool = newValue;
|
SettingsUpdateGlobalAndWindowManager();
|
||||||
EsElementSetDisabled(instance->undoButton, false);
|
EsElementSetDisabled(instance->undoButton, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsAddCheckbox(EsElement *table, const char *string, ptrdiff_t stringBytes, char accessKey,
|
void SettingsAddCheckbox(EsElement *table, const char *string, ptrdiff_t stringBytes, char accessKey,
|
||||||
const char *cConfigurationSection, const char *cConfigurationKey, bool *globalPointerBool) {
|
const char *cConfigurationSection, const char *cConfigurationKey) {
|
||||||
SettingsInstance *instance = (SettingsInstance *) table->instance;
|
SettingsInstance *instance = (SettingsInstance *) table->instance;
|
||||||
|
|
||||||
SettingsControl *control = (SettingsControl *) EsHeapAllocate(sizeof(SettingsControl), true);
|
SettingsControl *control = (SettingsControl *) EsHeapAllocate(sizeof(SettingsControl), true);
|
||||||
control->type = SETTINGS_CONTROL_CHECKBOX;
|
control->type = SETTINGS_CONTROL_CHECKBOX;
|
||||||
control->cConfigurationSection = cConfigurationSection;
|
control->cConfigurationSection = cConfigurationSection;
|
||||||
control->cConfigurationKey = cConfigurationKey;
|
control->cConfigurationKey = cConfigurationKey;
|
||||||
control->globalPointerBool = globalPointerBool;
|
|
||||||
control->originalValueBool = EsSystemConfigurationReadInteger(control->cConfigurationSection, -1, control->cConfigurationKey, -1);
|
control->originalValueBool = EsSystemConfigurationReadInteger(control->cConfigurationSection, -1, control->cConfigurationKey, -1);
|
||||||
|
|
||||||
EsButton *button = EsButtonCreate(table, ES_CELL_H_FILL | ES_BUTTON_CHECKBOX | ES_ELEMENT_FREE_USER_DATA | ES_ELEMENT_STICKY_ACCESS_KEY, 0, string, stringBytes);
|
EsButton *button = EsButtonCreate(table, ES_CELL_H_FILL | ES_BUTTON_CHECKBOX | ES_ELEMENT_FREE_USER_DATA | ES_ELEMENT_STICKY_ACCESS_KEY, 0, string, stringBytes);
|
||||||
|
@ -234,11 +246,14 @@ int SettingsNumberBoxMessage(EsElement *element, EsMessage *message) {
|
||||||
} else {
|
} else {
|
||||||
return ES_REJECTED;
|
return ES_REJECTED;
|
||||||
}
|
}
|
||||||
|
} else if (message->type == ES_MSG_TEXTBOX_NUMBER_DRAG_START) {
|
||||||
|
control->dragValue = EsTextboxGetContentsAsDouble(textbox);
|
||||||
} else if (message->type == ES_MSG_TEXTBOX_NUMBER_DRAG_DELTA) {
|
} else if (message->type == ES_MSG_TEXTBOX_NUMBER_DRAG_DELTA) {
|
||||||
int oldValue = EsTextboxGetContentsAsDouble(textbox);
|
double newValue = ClampDouble(control->minimumValue, control->maximumValue,
|
||||||
int newValue = ClampInteger(control->minimumValue, control->maximumValue, oldValue + message->numberDragDelta.delta * (message->numberDragDelta.fast ? 10 : 1));
|
control->dragValue + message->numberDragDelta.delta * (message->numberDragDelta.fast ? 10.0 : 1.0) * control->dragSpeed);
|
||||||
|
control->dragValue = newValue;
|
||||||
char buffer[64];
|
char buffer[64];
|
||||||
size_t bytes = EsStringFormat(buffer, sizeof(buffer), "%d%s", newValue, control->suffixBytes, control->suffix);
|
size_t bytes = EsStringFormat(buffer, sizeof(buffer), "%i%s", (int32_t) newValue, control->suffixBytes, control->suffix);
|
||||||
EsTextboxSelectAll(textbox);
|
EsTextboxSelectAll(textbox);
|
||||||
EsTextboxInsert(textbox, buffer, bytes);
|
EsTextboxInsert(textbox, buffer, bytes);
|
||||||
return ES_HANDLED;
|
return ES_HANDLED;
|
||||||
|
@ -248,8 +263,8 @@ int SettingsNumberBoxMessage(EsElement *element, EsMessage *message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsAddNumberBox(EsElement *table, const char *string, ptrdiff_t stringBytes, char accessKey,
|
void SettingsAddNumberBox(EsElement *table, const char *string, ptrdiff_t stringBytes, char accessKey,
|
||||||
const char *cConfigurationSection, const char *cConfigurationKey, int32_t *globalPointer,
|
const char *cConfigurationSection, const char *cConfigurationKey,
|
||||||
int32_t minimumValue, int32_t maximumValue, const char *suffix, ptrdiff_t suffixBytes) {
|
int32_t minimumValue, int32_t maximumValue, const char *suffix, ptrdiff_t suffixBytes, double dragSpeed) {
|
||||||
if (suffixBytes == -1) {
|
if (suffixBytes == -1) {
|
||||||
suffixBytes = EsCStringLength(suffix);
|
suffixBytes = EsCStringLength(suffix);
|
||||||
}
|
}
|
||||||
|
@ -260,12 +275,12 @@ void SettingsAddNumberBox(EsElement *table, const char *string, ptrdiff_t string
|
||||||
control->type = SETTINGS_CONTROL_NUMBER;
|
control->type = SETTINGS_CONTROL_NUMBER;
|
||||||
control->cConfigurationSection = cConfigurationSection;
|
control->cConfigurationSection = cConfigurationSection;
|
||||||
control->cConfigurationKey = cConfigurationKey;
|
control->cConfigurationKey = cConfigurationKey;
|
||||||
control->globalPointerInt = globalPointer;
|
|
||||||
control->originalValueInt = EsSystemConfigurationReadInteger(control->cConfigurationSection, -1, control->cConfigurationKey, -1);
|
control->originalValueInt = EsSystemConfigurationReadInteger(control->cConfigurationSection, -1, control->cConfigurationKey, -1);
|
||||||
control->suffix = suffix;
|
control->suffix = suffix;
|
||||||
control->suffixBytes = suffixBytes;
|
control->suffixBytes = suffixBytes;
|
||||||
control->minimumValue = minimumValue;
|
control->minimumValue = minimumValue;
|
||||||
control->maximumValue = maximumValue;
|
control->maximumValue = maximumValue;
|
||||||
|
control->dragSpeed = dragSpeed;
|
||||||
|
|
||||||
EsTextDisplayCreate(table, ES_CELL_H_RIGHT | ES_CELL_H_PUSH, 0, string, stringBytes);
|
EsTextDisplayCreate(table, ES_CELL_H_RIGHT | ES_CELL_H_PUSH, 0, string, stringBytes);
|
||||||
EsTextbox *textbox = EsTextboxCreate(table, ES_CELL_H_LEFT | ES_CELL_H_PUSH | ES_TEXTBOX_EDIT_BASED | ES_ELEMENT_FREE_USER_DATA, &styleSettingsNumberTextbox);
|
EsTextbox *textbox = EsTextboxCreate(table, ES_CELL_H_LEFT | ES_CELL_H_PUSH | ES_TEXTBOX_EDIT_BASED | ES_ELEMENT_FREE_USER_DATA, &styleSettingsNumberTextbox);
|
||||||
|
@ -275,7 +290,7 @@ void SettingsAddNumberBox(EsElement *table, const char *string, ptrdiff_t string
|
||||||
textbox->messageUser = SettingsNumberBoxMessage;
|
textbox->messageUser = SettingsNumberBoxMessage;
|
||||||
|
|
||||||
char buffer[64];
|
char buffer[64];
|
||||||
size_t bytes = EsStringFormat(buffer, sizeof(buffer), "%d%s", control->originalValueInt, suffixBytes, suffix);
|
size_t bytes = EsStringFormat(buffer, sizeof(buffer), "%i%s", control->originalValueInt, suffixBytes, suffix);
|
||||||
EsTextboxInsert(textbox, buffer, bytes);
|
EsTextboxInsert(textbox, buffer, bytes);
|
||||||
|
|
||||||
control->element = textbox;
|
control->element = textbox;
|
||||||
|
@ -306,40 +321,37 @@ void SettingsPageMouse(EsElement *element, SettingsPage *page) {
|
||||||
table = EsPanelCreate(container, ES_CELL_H_FILL | ES_PANEL_TABLE | ES_PANEL_HORIZONTAL, &styleSettingsTable);
|
table = EsPanelCreate(container, ES_CELL_H_FILL | ES_PANEL_TABLE | ES_PANEL_HORIZONTAL, &styleSettingsTable);
|
||||||
EsPanelSetBands(table, 2);
|
EsPanelSetBands(table, 2);
|
||||||
|
|
||||||
EsTextDisplayCreate(table, ES_CELL_H_RIGHT | ES_CELL_H_PUSH, 0, INTERFACE_STRING(DesktopSettingsMouseSpeed)); // TODO.
|
// TODO Use a slider instead?
|
||||||
textbox = EsTextboxCreate(table, ES_CELL_H_LEFT | ES_CELL_H_PUSH | ES_TEXTBOX_EDIT_BASED, &styleSettingsNumberTextbox);
|
SettingsAddNumberBox(table, INTERFACE_STRING(DesktopSettingsMouseSpeed), 'M', "general", "cursor_speed", -20, 20, nullptr, 0, 0.05);
|
||||||
textbox->accessKey = 'M';
|
|
||||||
EsTextboxUseNumberOverlay(textbox, false);
|
|
||||||
EsTextboxInsert(textbox, "50%");
|
|
||||||
|
|
||||||
EsTextDisplayCreate(table, ES_CELL_H_RIGHT | ES_CELL_H_PUSH, 0, INTERFACE_STRING(DesktopSettingsMouseCursorTrails)); // TODO.
|
// TODO Mouse trails.
|
||||||
|
EsTextDisplayCreate(table, ES_CELL_H_RIGHT | ES_CELL_H_PUSH, 0, INTERFACE_STRING(DesktopSettingsMouseCursorTrails));
|
||||||
textbox = EsTextboxCreate(table, ES_CELL_H_LEFT | ES_CELL_H_PUSH | ES_TEXTBOX_EDIT_BASED, &styleSettingsNumberTextbox);
|
textbox = EsTextboxCreate(table, ES_CELL_H_LEFT | ES_CELL_H_PUSH | ES_TEXTBOX_EDIT_BASED, &styleSettingsNumberTextbox);
|
||||||
textbox->accessKey = 'T';
|
textbox->accessKey = 'T';
|
||||||
EsTextboxUseNumberOverlay(textbox, false);
|
EsTextboxUseNumberOverlay(textbox, false);
|
||||||
EsTextboxInsert(textbox, "0");
|
EsTextboxInsert(textbox, "0");
|
||||||
|
|
||||||
EsTextDisplayCreate(table, ES_CELL_H_RIGHT | ES_CELL_H_PUSH, 0, INTERFACE_STRING(DesktopSettingsMouseLinesPerScrollNotch)); // TODO.
|
// TODO Scroll wheel.
|
||||||
|
EsTextDisplayCreate(table, ES_CELL_H_RIGHT | ES_CELL_H_PUSH, 0, INTERFACE_STRING(DesktopSettingsMouseLinesPerScrollNotch));
|
||||||
textbox = EsTextboxCreate(table, ES_CELL_H_LEFT | ES_CELL_H_PUSH | ES_TEXTBOX_EDIT_BASED, &styleSettingsNumberTextbox);
|
textbox = EsTextboxCreate(table, ES_CELL_H_LEFT | ES_CELL_H_PUSH | ES_TEXTBOX_EDIT_BASED, &styleSettingsNumberTextbox);
|
||||||
textbox->accessKey = 'S';
|
textbox->accessKey = 'S';
|
||||||
EsTextboxUseNumberOverlay(textbox, false);
|
EsTextboxUseNumberOverlay(textbox, false);
|
||||||
EsTextboxInsert(textbox, "3");
|
EsTextboxInsert(textbox, "3");
|
||||||
|
|
||||||
table = EsPanelCreate(container, ES_CELL_H_FILL, &styleSettingsCheckboxGroup);
|
table = EsPanelCreate(container, ES_CELL_H_FILL, &styleSettingsCheckboxGroup);
|
||||||
SettingsAddCheckbox(table, INTERFACE_STRING(DesktopSettingsMouseSwapLeftAndRightButtons), 'B',
|
SettingsAddCheckbox(table, INTERFACE_STRING(DesktopSettingsMouseSwapLeftAndRightButtons), 'B', "general", "swap_left_and_right_buttons");
|
||||||
"general", "swap_left_and_right_buttons", &api.global->swapLeftAndRightButtons);
|
SettingsAddCheckbox(table, INTERFACE_STRING(DesktopSettingsMouseShowShadow), 'W', "general", "show_cursor_shadow");
|
||||||
SettingsAddCheckbox(table, INTERFACE_STRING(DesktopSettingsMouseShowShadow), 'W',
|
SettingsAddCheckbox(table, INTERFACE_STRING(DesktopSettingsMouseLocateCursorOnCtrl), 'L', "general", "locate_cursor_on_ctrl");
|
||||||
"general", "show_cursor_shadow", &api.global->showCursorShadow);
|
SettingsAddCheckbox(table, INTERFACE_STRING(DesktopSettingsMouseUseAcceleration), 'C', "general", "use_cursor_acceleration");
|
||||||
SettingsAddCheckbox(table, INTERFACE_STRING(DesktopSettingsMouseLocateCursorOnCtrl), 'L',
|
SettingsAddCheckbox(table, INTERFACE_STRING(DesktopSettingsMouseSlowOnAlt), 'O', "general", "use_cursor_alt_slow");
|
||||||
"general", "locate_cursor_on_ctrl", nullptr);
|
|
||||||
|
|
||||||
EsSpacerCreate(container, ES_CELL_H_FILL, ES_STYLE_BUTTON_GROUP_SEPARATOR);
|
EsSpacerCreate(container, ES_CELL_H_FILL, ES_STYLE_BUTTON_GROUP_SEPARATOR);
|
||||||
|
|
||||||
table = EsPanelCreate(container, ES_CELL_H_FILL | ES_PANEL_TABLE | ES_PANEL_HORIZONTAL, &styleSettingsTable);
|
table = EsPanelCreate(container, ES_CELL_H_FILL | ES_PANEL_TABLE | ES_PANEL_HORIZONTAL, &styleSettingsTable);
|
||||||
EsPanelSetBands(table, 2);
|
EsPanelSetBands(table, 2);
|
||||||
|
|
||||||
SettingsAddNumberBox(table, INTERFACE_STRING(DesktopSettingsMouseDoubleClickSpeed), 'D',
|
SettingsAddNumberBox(table, INTERFACE_STRING(DesktopSettingsMouseDoubleClickSpeed), 'D', "general", "click_chain_timeout_ms",
|
||||||
"general", "click_chain_timeout_ms", &api.global->clickChainTimeoutMs,
|
100, 1500, INTERFACE_STRING(CommonUnitMilliseconds), 1.0);
|
||||||
100, 1500, INTERFACE_STRING(CommonUnitMilliseconds));
|
|
||||||
|
|
||||||
EsPanel *testBox = EsPanelCreate(container, ES_CELL_H_FILL);
|
EsPanel *testBox = EsPanelCreate(container, ES_CELL_H_FILL);
|
||||||
EsTextDisplayCreate(testBox, ES_CELL_H_FILL, ES_STYLE_TEXT_PARAGRAPH, INTERFACE_STRING(DesktopSettingsMouseTestDoubleClickIntroduction));
|
EsTextDisplayCreate(testBox, ES_CELL_H_FILL, ES_STYLE_TEXT_PARAGRAPH, INTERFACE_STRING(DesktopSettingsMouseTestDoubleClickIntroduction));
|
||||||
|
|
|
@ -198,7 +198,7 @@ uint16_t scancodeConversionTable2[] = {
|
||||||
|
|
||||||
void PS2MouseUpdated(EsGeneric _update) {
|
void PS2MouseUpdated(EsGeneric _update) {
|
||||||
PS2Update *update = (PS2Update *) _update.p;
|
PS2Update *update = (PS2Update *) _update.p;
|
||||||
KCursorUpdate(update->xMovement, update->yMovement, update->buttons);
|
KCursorUpdate(update->xMovement * K_CURSOR_MOVEMENT_SCALE, update->yMovement * K_CURSOR_MOVEMENT_SCALE, update->buttons);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PS2KeyboardUpdated(EsGeneric _update) {
|
void PS2KeyboardUpdated(EsGeneric _update) {
|
||||||
|
|
|
@ -559,7 +559,7 @@ void HIDDevice::ReportReceived(BitBuffer *buffer) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mouseEvent) KCursorUpdate(mouseXMovement, mouseYMovement, mouseButtons);
|
if (mouseEvent) KCursorUpdate(mouseXMovement * K_CURSOR_MOVEMENT_SCALE, mouseYMovement * K_CURSOR_MOVEMENT_SCALE, mouseButtons);
|
||||||
if (keyboardEvent) KKeyboardUpdate(keysDown, keysDownCount);
|
if (keyboardEvent) KKeyboardUpdate(keysDown, keysDownCount);
|
||||||
if (gameControllerEvent) KGameControllerUpdateState(&controllerState);
|
if (gameControllerEvent) KGameControllerUpdateState(&controllerState);
|
||||||
|
|
||||||
|
|
|
@ -365,9 +365,10 @@ void KTimerRemove(KTimer *timer); // Timers with callbacks cannot be removed (it
|
||||||
// Window manager.
|
// Window manager.
|
||||||
// ---------------------------------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
void KCursorUpdate(int xMovement, int yMovement, unsigned buttons);
|
#define K_CURSOR_MOVEMENT_SCALE (0x100)
|
||||||
|
void KCursorUpdate(int32_t xMovement, int32_t yMovement, uint32_t buttons);
|
||||||
void KKeyboardUpdate(uint16_t *keysDown, size_t keysDownCount);
|
void KKeyboardUpdate(uint16_t *keysDown, size_t keysDownCount);
|
||||||
void KKeyPress(unsigned scancode);
|
void KKeyPress(uint32_t scancode);
|
||||||
|
|
||||||
uint64_t KGameControllerConnect();
|
uint64_t KGameControllerConnect();
|
||||||
void KGameControllerDisconnect(uint64_t id);
|
void KGameControllerDisconnect(uint64_t id);
|
||||||
|
|
|
@ -1144,8 +1144,16 @@ SYSCALL_IMPLEMENT(ES_SYSCALL_CURSOR_POSITION_SET) {
|
||||||
KMutexAcquire(&windowManager.mutex);
|
KMutexAcquire(&windowManager.mutex);
|
||||||
windowManager.cursorX = argument0;
|
windowManager.cursorX = argument0;
|
||||||
windowManager.cursorY = argument1;
|
windowManager.cursorY = argument1;
|
||||||
windowManager.cursorXPrecise = argument0 * 10;
|
windowManager.cursorXPrecise = argument0 * K_CURSOR_MOVEMENT_SCALE;
|
||||||
windowManager.cursorYPrecise = argument1 * 10;
|
windowManager.cursorYPrecise = argument1 * K_CURSOR_MOVEMENT_SCALE;
|
||||||
|
KMutexRelease(&windowManager.mutex);
|
||||||
|
SYSCALL_RETURN(ES_SUCCESS, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
SYSCALL_IMPLEMENT(ES_SYSCALL_CURSOR_PROPERTIES_SET) {
|
||||||
|
SYSCALL_PERMISSION(ES_PERMISSION_SCREEN_MODIFY);
|
||||||
|
KMutexAcquire(&windowManager.mutex);
|
||||||
|
windowManager.cursorProperties = argument0;
|
||||||
KMutexRelease(&windowManager.mutex);
|
KMutexRelease(&windowManager.mutex);
|
||||||
SYSCALL_RETURN(ES_SUCCESS, false);
|
SYSCALL_RETURN(ES_SUCCESS, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ struct WindowManager {
|
||||||
|
|
||||||
void Initialise();
|
void Initialise();
|
||||||
|
|
||||||
void MoveCursor(int xMovement, int yMovement);
|
void MoveCursor(int64_t xMovement, int64_t yMovement);
|
||||||
void ClickCursor(unsigned buttons);
|
void ClickCursor(unsigned buttons);
|
||||||
void UpdateCursor(int xMovement, int yMovement, unsigned buttons);
|
void UpdateCursor(int xMovement, int yMovement, unsigned buttons);
|
||||||
void PressKey(unsigned scancode);
|
void PressKey(unsigned scancode);
|
||||||
|
@ -96,8 +96,8 @@ struct WindowManager {
|
||||||
// Cursor:
|
// Cursor:
|
||||||
|
|
||||||
int cursorX, cursorY;
|
int cursorX, cursorY;
|
||||||
int cursorXPrecise, cursorYPrecise; // Scaled up by a factor of 10.
|
int cursorXPrecise, cursorYPrecise; // Scaled up by a factor of K_CURSOR_MOVEMENT_SCALE.
|
||||||
unsigned lastButtons;
|
uint32_t lastButtons;
|
||||||
|
|
||||||
Surface cursorSurface, cursorSwap, cursorTemporary;
|
Surface cursorSurface, cursorSwap, cursorTemporary;
|
||||||
int cursorImageOffsetX, cursorImageOffsetY;
|
int cursorImageOffsetX, cursorImageOffsetY;
|
||||||
|
@ -105,6 +105,8 @@ struct WindowManager {
|
||||||
bool cursorXOR, cursorShadow;
|
bool cursorXOR, cursorShadow;
|
||||||
bool changedCursorImage;
|
bool changedCursorImage;
|
||||||
|
|
||||||
|
uint32_t cursorProperties;
|
||||||
|
|
||||||
// Keyboard:
|
// Keyboard:
|
||||||
|
|
||||||
bool shift, alt, ctrl, flag;
|
bool shift, alt, ctrl, flag;
|
||||||
|
@ -597,41 +599,29 @@ void WindowManager::ClickCursor(unsigned buttons) {
|
||||||
KMutexRelease(&mutex);
|
KMutexRelease(&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::MoveCursor(int xMovement, int yMovement) {
|
void WindowManager::MoveCursor(int64_t xMovement, int64_t yMovement) {
|
||||||
KMutexAssertLocked(&mutex);
|
KMutexAssertLocked(&mutex);
|
||||||
|
|
||||||
xMovement *= alt ? 2 : 10;
|
if ((xMovement * xMovement + yMovement * yMovement > 50 * K_CURSOR_MOVEMENT_SCALE * K_CURSOR_MOVEMENT_SCALE) && (cursorProperties & CURSOR_USE_ACCELERATION)) {
|
||||||
yMovement *= alt ? 2 : 10;
|
// Apply cursor acceleration.
|
||||||
|
xMovement *= 2;
|
||||||
|
yMovement *= 2;
|
||||||
|
}
|
||||||
|
|
||||||
int oldCursorX = cursorXPrecise;
|
// Apply cursor speed. Introduces another factor of K_CURSOR_MOVEMENT_SCALE.
|
||||||
int oldCursorY = cursorYPrecise;
|
xMovement *= CURSOR_SPEED(cursorProperties);
|
||||||
int _cursorX = oldCursorX + xMovement;
|
yMovement *= CURSOR_SPEED(cursorProperties);
|
||||||
int _cursorY = oldCursorY + yMovement;
|
|
||||||
|
|
||||||
// if (!lastButtons) {
|
if (alt && (cursorProperties & CURSOR_USE_ALT_SLOW)) {
|
||||||
if (_cursorX < 0) {
|
// Apply cursor slowdown.
|
||||||
_cursorX = 0;
|
xMovement /= 5, yMovement /= 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_cursorY < 0) {
|
// Update cursor position.
|
||||||
_cursorY = 0;
|
cursorXPrecise = ClampInteger(0, graphics.width * K_CURSOR_MOVEMENT_SCALE - 1, cursorXPrecise + xMovement / K_CURSOR_MOVEMENT_SCALE);
|
||||||
}
|
cursorYPrecise = ClampInteger(0, graphics.height * K_CURSOR_MOVEMENT_SCALE - 1, cursorYPrecise + yMovement / K_CURSOR_MOVEMENT_SCALE);
|
||||||
|
cursorX = cursorXPrecise / K_CURSOR_MOVEMENT_SCALE;
|
||||||
if (_cursorX >= (int) graphics.width * 10) {
|
cursorY = cursorYPrecise / K_CURSOR_MOVEMENT_SCALE;
|
||||||
_cursorX = graphics.width * 10 - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_cursorY >= (int) graphics.height * 10) {
|
|
||||||
_cursorY = graphics.height * 10 - 1;
|
|
||||||
}
|
|
||||||
// }
|
|
||||||
|
|
||||||
cursorXPrecise = _cursorX;
|
|
||||||
cursorYPrecise = _cursorY;
|
|
||||||
cursorX = _cursorX / 10;
|
|
||||||
cursorY = _cursorY / 10;
|
|
||||||
oldCursorX /= 10;
|
|
||||||
oldCursorY /= 10;
|
|
||||||
|
|
||||||
if (eyedropping) {
|
if (eyedropping) {
|
||||||
EsMessage m = { ES_MSG_EYEDROP_REPORT };
|
EsMessage m = { ES_MSG_EYEDROP_REPORT };
|
||||||
|
@ -713,10 +703,11 @@ void _CloseWindows(uintptr_t) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::Initialise() {
|
void WindowManager::Initialise() {
|
||||||
windowManager.windowsToCloseEvent.autoReset = true;
|
windowsToCloseEvent.autoReset = true;
|
||||||
|
cursorProperties = K_CURSOR_MOVEMENT_SCALE << 16;
|
||||||
KThreadCreate("CloseWindows", _CloseWindows);
|
KThreadCreate("CloseWindows", _CloseWindows);
|
||||||
KMutexAcquire(&mutex);
|
KMutexAcquire(&mutex);
|
||||||
MoveCursor(graphics.width / 2, graphics.height / 2);
|
MoveCursor(graphics.width / 2 * K_CURSOR_MOVEMENT_SCALE, graphics.height / 2 * K_CURSOR_MOVEMENT_SCALE);
|
||||||
GraphicsUpdateScreen();
|
GraphicsUpdateScreen();
|
||||||
initialised = true;
|
initialised = true;
|
||||||
KMutexRelease(&mutex);
|
KMutexRelease(&mutex);
|
||||||
|
|
|
@ -9,6 +9,7 @@ default_user_documents_path=0:/
|
||||||
installation_state=0
|
installation_state=0
|
||||||
click_chain_timeout_ms=500
|
click_chain_timeout_ms=500
|
||||||
show_cursor_shadow=1
|
show_cursor_shadow=1
|
||||||
|
use_cursor_alt_slow=1
|
||||||
|
|
||||||
[ui]
|
[ui]
|
||||||
; User interface settings that are accessible by all applications.
|
; User interface settings that are accessible by all applications.
|
||||||
|
|
|
@ -33,6 +33,12 @@ inline int ClampInteger(int low, int high, int integer) {
|
||||||
return integer;
|
return integer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline double ClampDouble(double low, double high, double x) {
|
||||||
|
if (x < low) return low;
|
||||||
|
if (x > high) return high;
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
inline intptr_t ClampIntptr(intptr_t low, intptr_t high, intptr_t integer) {
|
inline intptr_t ClampIntptr(intptr_t low, intptr_t high, intptr_t integer) {
|
||||||
if (integer < low) return low;
|
if (integer < low) return low;
|
||||||
if (integer > high) return high;
|
if (integer > high) return high;
|
||||||
|
|
|
@ -117,6 +117,8 @@ DEFINE_INTERFACE_STRING(DesktopSettingsMouseSwapLeftAndRightButtons, "Swap left
|
||||||
DEFINE_INTERFACE_STRING(DesktopSettingsMouseShowShadow, "Show shadow below cursor");
|
DEFINE_INTERFACE_STRING(DesktopSettingsMouseShowShadow, "Show shadow below cursor");
|
||||||
DEFINE_INTERFACE_STRING(DesktopSettingsMouseLocateCursorOnCtrl, "Highlight cursor location when Ctrl is pressed");
|
DEFINE_INTERFACE_STRING(DesktopSettingsMouseLocateCursorOnCtrl, "Highlight cursor location when Ctrl is pressed");
|
||||||
DEFINE_INTERFACE_STRING(DesktopSettingsMouseTestDoubleClickIntroduction, "Double click the circle below to try your setting. If it does not change color, increase the double click time.");
|
DEFINE_INTERFACE_STRING(DesktopSettingsMouseTestDoubleClickIntroduction, "Double click the circle below to try your setting. If it does not change color, increase the double click time.");
|
||||||
|
DEFINE_INTERFACE_STRING(DesktopSettingsMouseUseAcceleration, "Move cursor faster when mouse is moved quickly");
|
||||||
|
DEFINE_INTERFACE_STRING(DesktopSettingsMouseSlowOnAlt, "Move cursor slower when Alt is held");
|
||||||
|
|
||||||
// File operations.
|
// File operations.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue