Skip to content

Commit a237eeb

Browse files
committed
Dx/Sdl: Add KeyMapChanged event
1 parent 3a7d4af commit a237eeb

File tree

6 files changed

+24
-3
lines changed

6 files changed

+24
-3
lines changed

libs/directx/dx/Driver.hx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,10 +749,12 @@ class Driver {
749749
static function dxDebugPrint( str : hl.Bytes ) {
750750
}
751751

752+
@:deprecated("dx.Driver.detectKeyboardLayout is deprecated. Use dx.Window.detectKeyboardLayout instead.")
752753
public static function detectKeyboardLayout() @:privateAccess {
753754
return String.fromUTF8( dxDetectKeyboardLayout() );
754755
}
755756

757+
@:deprecated("dx.Driver.dxDetectKeyboardLayout is deprecated. Use dx.Window.dxDetectKeyboardLayout instead.")
756758
@:hlNative("directx", "detect_keyboard_layout")
757759
static function dxDetectKeyboardLayout() : hl.Bytes {
758760
return null;

libs/directx/dx/Event.hx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ enum abstract EventType(Int) {
3434
var DropStart = 10;
3535
var DropFile = 11;
3636
var DropEnd = 12;
37+
var KeyMapChanged = 13;
3738
}
3839

3940
enum abstract WindowStateChange(Int) {

libs/directx/dx/Window.hx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,4 +368,13 @@ class Window {
368368
static function winSetDragAcceptFiles( win : WinPtr, enable: Bool ) : Void {
369369
}
370370

371-
}
371+
public static function detectKeyboardLayout() @:privateAccess {
372+
return String.fromUTF8( dxDetectKeyboardLayout() );
373+
}
374+
375+
@:hlNative("directx", "detect_keyboard_layout")
376+
static function dxDetectKeyboardLayout() : hl.Bytes {
377+
return null;
378+
}
379+
380+
}

libs/directx/window.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ typedef enum {
1717
DropStart = 10,
1818
DropFile = 11,
1919
DropEnd = 12,
20+
KeyMapChanged = 13,
2021
} EventType;
2122

2223
typedef enum {
@@ -513,6 +514,9 @@ static LRESULT CALLBACK WndProc( HWND wnd, UINT umsg, WPARAM wparam, LPARAM lpar
513514
DragFinish(drop);
514515
break;
515516
}
517+
case WM_INPUTLANGCHANGE:
518+
e = addEvent(wnd,KeyMapChanged);
519+
break;
516520
case WM_CLOSE:
517521
addState(Close);
518522
return 0;

libs/sdl/sdl.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ typedef enum {
6161
DropFile,
6262
DropText,
6363
DropEnd,
64+
KeyMapChanged = 500,
6465
} event_type;
6566

6667
typedef enum {
@@ -373,6 +374,9 @@ HL_PRIM bool HL_NAME(event_loop)( event_data *event ) {
373374
event->type = DropEnd;
374375
event->window = e.drop.windowID;
375376
break;
377+
case SDL_KEYMAPCHANGED:
378+
event->type = KeyMapChanged;
379+
break;
376380
default:
377381
//printf("Unknown event type 0x%X\\n", e.type);
378382
continue;
@@ -523,7 +527,7 @@ HL_PRIM SDL_Window *HL_NAME(win_create_ex)(int x, int y, int width, int height,
523527
// force window to match device resolution on mobile
524528
if ((sdlFlags & (
525529
#ifdef HL_MAC
526-
SDL_WINDOW_METAL |
530+
SDL_WINDOW_METAL |
527531
#endif
528532
SDL_WINDOW_VULKAN )) == 0) {
529533
sdlFlags |= SDL_WINDOW_OPENGL;

libs/sdl/sdl/Event.hx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ package sdl;
2525
inline function get_controller() return reference;
2626
inline function get_joystick() return reference;
2727
inline function get_fingerId() return reference;
28-
28+
2929
public function new() {
3030
}
3131
}
@@ -60,6 +60,7 @@ enum abstract EventType(Int) {
6060
var DropFile = 401;
6161
var DropText = 402;
6262
var DropEnd = 403;
63+
var KeyMapChanged = 500;
6364
}
6465

6566
enum abstract WindowStateChange(Int) {

0 commit comments

Comments
 (0)