Merge pull request #15990 from rraallvv/colemak_layout_2.1
Add Colemak layout (branch 2.1)
This commit is contained in:
commit
69da799e49
@ -435,6 +435,7 @@ String _OS::get_latin_keyboard_variant() const {
|
||||
case OS::LATIN_KEYBOARD_QZERTY: return "QZERTY";
|
||||
case OS::LATIN_KEYBOARD_DVORAK: return "DVORAK";
|
||||
case OS::LATIN_KEYBOARD_NEO: return "NEO";
|
||||
case OS::LATIN_KEYBOARD_COLEMAK: return "COLEMAK";
|
||||
default: return "ERROR";
|
||||
}
|
||||
}
|
||||
|
@ -507,6 +507,27 @@ static const _KeyCodeReplace _keycode_replace_neo[] = {
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static const _KeyCodeReplace _keycode_replace_colemak[] = {
|
||||
{ KEY_E, KEY_F },
|
||||
{ KEY_R, KEY_P },
|
||||
{ KEY_T, KEY_G },
|
||||
{ KEY_Y, KEY_J },
|
||||
{ KEY_U, KEY_L },
|
||||
{ KEY_I, KEY_U },
|
||||
{ KEY_O, KEY_Y },
|
||||
{ KEY_P, KEY_SEMICOLON },
|
||||
{ KEY_S, KEY_R },
|
||||
{ KEY_D, KEY_S },
|
||||
{ KEY_F, KEY_T },
|
||||
{ KEY_G, KEY_D },
|
||||
{ KEY_J, KEY_N },
|
||||
{ KEY_K, KEY_E },
|
||||
{ KEY_L, KEY_I },
|
||||
{ KEY_SEMICOLON, KEY_O },
|
||||
{ KEY_N, KEY_K },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int latin_keyboard_keycode_convert(int p_keycode) {
|
||||
|
||||
const _KeyCodeReplace *kcr = NULL;
|
||||
|
@ -314,8 +314,8 @@ public:
|
||||
virtual void hide_virtual_keyboard();
|
||||
|
||||
virtual void set_cursor_shape(CursorShape p_shape) = 0;
|
||||
virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) = 0;
|
||||
|
||||
virtual void set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) = 0;
|
||||
|
||||
virtual bool get_swap_ok_cancel() { return false; }
|
||||
virtual void dump_memory_to_file(const char *p_file);
|
||||
virtual void dump_resources_to_file(const char *p_file);
|
||||
@ -405,6 +405,7 @@ public:
|
||||
LATIN_KEYBOARD_QZERTY,
|
||||
LATIN_KEYBOARD_DVORAK,
|
||||
LATIN_KEYBOARD_NEO,
|
||||
LATIN_KEYBOARD_COLEMAK,
|
||||
};
|
||||
|
||||
virtual LatinKeyboardVariant get_latin_keyboard_variant() const;
|
||||
|
@ -23422,7 +23422,7 @@
|
||||
</return>
|
||||
<description>
|
||||
Returns the current latin keyboard variant as a String.
|
||||
Possible return values are: "QWERTY", "AZERTY", "QZERTY", "DVORAK", "NEO" or "ERROR"
|
||||
Possible return values are: "QWERTY", "AZERTY", "QZERTY", "DVORAK", "NEO", "COLEMAK" or "ERROR"
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_locale" qualifiers="const">
|
||||
|
@ -34,11 +34,11 @@
|
||||
#include "main/main.h"
|
||||
#include "os/keyboard.h"
|
||||
#include "print_string.h"
|
||||
#include "scene/resources/texture.h"
|
||||
#include "sem_osx.h"
|
||||
#include "servers/physics/physics_server_sw.h"
|
||||
#include "servers/visual/visual_server_raster.h"
|
||||
#include "servers/visual/visual_server_wrap_mt.h"
|
||||
#include "scene/resources/texture.h"
|
||||
|
||||
#include <Carbon/Carbon.h>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
@ -502,9 +502,10 @@ static void _mouseDownEvent(NSEvent *event, int index, int mask, bool pressed) {
|
||||
if (OS_OSX::singleton->main_loop && OS_OSX::singleton->mouse_mode != OS::MOUSE_MODE_CAPTURED)
|
||||
OS_OSX::singleton->main_loop->notification(MainLoop::NOTIFICATION_WM_MOUSE_ENTER);
|
||||
|
||||
if (OS_OSX::singleton->input)
|
||||
if (OS_OSX::singleton->input) {
|
||||
OS_OSX::singleton->cursor_shape = OS::CURSOR_MAX;
|
||||
OS_OSX::singleton->set_cursor_shape(OS::CURSOR_ARROW);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewDidChangeBackingProperties {
|
||||
@ -1193,7 +1194,7 @@ void OS_OSX::set_cursor_shape(CursorShape p_shape) {
|
||||
cursor_shape = p_shape;
|
||||
}
|
||||
|
||||
void OS_OSX::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot){
|
||||
void OS_OSX::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
|
||||
if (p_cursor.is_valid()) {
|
||||
Ref<ImageTexture> texture = p_cursor;
|
||||
Image image = texture->get_data();
|
||||
@ -1203,16 +1204,16 @@ void OS_OSX::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c
|
||||
ERR_FAIL_COND(texture->get_width() != 32 || texture->get_height() != 32);
|
||||
|
||||
NSBitmapImageRep *imgrep = [[[NSBitmapImageRep alloc]
|
||||
initWithBitmapDataPlanes:NULL
|
||||
pixelsWide:image.get_width()
|
||||
pixelsHigh:image.get_height()
|
||||
bitsPerSample:8
|
||||
samplesPerPixel:4
|
||||
hasAlpha:YES
|
||||
isPlanar:NO
|
||||
colorSpaceName:NSDeviceRGBColorSpace
|
||||
bytesPerRow:image.get_width() * 4
|
||||
bitsPerPixel:32] autorelease];
|
||||
initWithBitmapDataPlanes:NULL
|
||||
pixelsWide:image.get_width()
|
||||
pixelsHigh:image.get_height()
|
||||
bitsPerSample:8
|
||||
samplesPerPixel:4
|
||||
hasAlpha:YES
|
||||
isPlanar:NO
|
||||
colorSpaceName:NSDeviceRGBColorSpace
|
||||
bytesPerRow:image.get_width() * 4
|
||||
bitsPerPixel:32] autorelease];
|
||||
ERR_FAIL_COND(imgrep == nil);
|
||||
uint8_t *pixels = [imgrep bitmapData];
|
||||
|
||||
@ -1229,10 +1230,10 @@ void OS_OSX::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c
|
||||
pixels[i * 4 + 3] = alpha;
|
||||
}
|
||||
|
||||
NSImage * nsimage = [[[NSImage alloc] initWithSize: NSMakeSize(image.get_width(), image.get_height())] autorelease];
|
||||
[nsimage addRepresentation: imgrep];
|
||||
|
||||
NSCursor *cursor = [[NSCursor alloc] initWithImage: nsimage hotSpot: NSMakePoint(p_hotspot.x, p_hotspot.y)];
|
||||
NSImage *nsimage = [[[NSImage alloc] initWithSize:NSMakeSize(image.get_width(), image.get_height())] autorelease];
|
||||
[nsimage addRepresentation:imgrep];
|
||||
|
||||
NSCursor *cursor = [[NSCursor alloc] initWithImage:nsimage hotSpot:NSMakePoint(p_hotspot.x, p_hotspot.y)];
|
||||
|
||||
cursors[p_shape] = cursor;
|
||||
|
||||
@ -1816,6 +1817,8 @@ OS::LatinKeyboardVariant OS_OSX::get_latin_keyboard_variant() const {
|
||||
layout = LATIN_KEYBOARD_DVORAK;
|
||||
} else if ([test isEqualToString:@"xvlcwk"]) {
|
||||
layout = LATIN_KEYBOARD_NEO;
|
||||
} else if ([test isEqualToString:@"qwfpgj"]) {
|
||||
layout = LATIN_KEYBOARD_COLEMAK;
|
||||
}
|
||||
|
||||
[test release];
|
||||
|
@ -68,6 +68,8 @@
|
||||
|
||||
#undef CursorShape
|
||||
|
||||
#include <X11/XKBlib.h>
|
||||
|
||||
int OS_X11::get_video_driver_count() const {
|
||||
return 1;
|
||||
}
|
||||
@ -2201,6 +2203,38 @@ void OS_X11::set_context(int p_context) {
|
||||
}
|
||||
}
|
||||
|
||||
OS::LatinKeyboardVariant OS_X11::get_latin_keyboard_variant() const {
|
||||
|
||||
XkbDescRec *xkbdesc = XkbAllocKeyboard();
|
||||
ERR_FAIL_COND_V(!xkbdesc, LATIN_KEYBOARD_QWERTY);
|
||||
|
||||
XkbGetNames(x11_display, XkbSymbolsNameMask, xkbdesc);
|
||||
ERR_FAIL_COND_V(!xkbdesc->names, LATIN_KEYBOARD_QWERTY);
|
||||
ERR_FAIL_COND_V(!xkbdesc->names->symbols, LATIN_KEYBOARD_QWERTY);
|
||||
|
||||
char *layout = XGetAtomName(x11_display, xkbdesc->names->symbols);
|
||||
ERR_FAIL_COND_V(!layout, LATIN_KEYBOARD_QWERTY);
|
||||
|
||||
Vector<String> info = String(layout).split("+");
|
||||
ERR_FAIL_INDEX_V(1, info.size(), LATIN_KEYBOARD_QWERTY);
|
||||
|
||||
if (info[1].find("colemak") != -1) {
|
||||
return LATIN_KEYBOARD_COLEMAK;
|
||||
} else if (info[1].find("qwertz") != -1) {
|
||||
return LATIN_KEYBOARD_QWERTZ;
|
||||
} else if (info[1].find("azerty") != -1) {
|
||||
return LATIN_KEYBOARD_AZERTY;
|
||||
} else if (info[1].find("qzerty") != -1) {
|
||||
return LATIN_KEYBOARD_QZERTY;
|
||||
} else if (info[1].find("dvorak") != -1) {
|
||||
return LATIN_KEYBOARD_DVORAK;
|
||||
} else if (info[1].find("neo") != -1) {
|
||||
return LATIN_KEYBOARD_NEO;
|
||||
}
|
||||
|
||||
return LATIN_KEYBOARD_QWERTY;
|
||||
}
|
||||
|
||||
OS_X11::OS_X11() {
|
||||
|
||||
#ifdef RTAUDIO_ENABLED
|
||||
|
@ -285,6 +285,8 @@ public:
|
||||
void disable_crash_handler();
|
||||
bool is_disable_crash_handler() const;
|
||||
|
||||
virtual LatinKeyboardVariant get_latin_keyboard_variant() const;
|
||||
|
||||
OS_X11();
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user