Skip to content

Commit fc58879

Browse files
committed
Merge branch 'develop' into 8.3.0-Dev
2 parents 30b77eb + 05591eb commit fc58879

File tree

5 files changed

+75
-16
lines changed

5 files changed

+75
-16
lines changed

project/src/ExternalInterface.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,28 +2490,28 @@ namespace lime {
24902490
}
24912491

24922492

2493-
float lime_key_code_from_scan_code (float scanCode) {
2493+
int lime_key_code_from_scan_code (int scanCode) {
24942494

24952495
return KeyCode::FromScanCode (scanCode);
24962496

24972497
}
24982498

24992499

2500-
HL_PRIM float HL_NAME(hl_key_code_from_scan_code) (float scanCode) {
2500+
HL_PRIM int HL_NAME(hl_key_code_from_scan_code) (int scanCode) {
25012501

25022502
return KeyCode::FromScanCode (scanCode);
25032503

25042504
}
25052505

25062506

2507-
float lime_key_code_to_scan_code (float keyCode) {
2507+
int lime_key_code_to_scan_code (int keyCode) {
25082508

25092509
return KeyCode::ToScanCode (keyCode);
25102510

25112511
}
25122512

25132513

2514-
HL_PRIM float HL_NAME(hl_key_code_to_scan_code) (float keyCode) {
2514+
HL_PRIM int HL_NAME(hl_key_code_to_scan_code) (int keyCode) {
25152515

25162516
return KeyCode::ToScanCode (keyCode);
25172517

@@ -4300,8 +4300,8 @@ namespace lime {
43004300
DEFINE_HL_PRIM (_I32, hl_joystick_get_num_hats, _I32);
43014301
DEFINE_HL_PRIM (_TIMAGEBUFFER, hl_jpeg_decode_bytes, _TBYTES _BOOL _TIMAGEBUFFER);
43024302
DEFINE_HL_PRIM (_TIMAGEBUFFER, hl_jpeg_decode_file, _STRING _BOOL _TIMAGEBUFFER);
4303-
DEFINE_HL_PRIM (_F32, hl_key_code_from_scan_code, _F32);
4304-
DEFINE_HL_PRIM (_F32, hl_key_code_to_scan_code, _F32);
4303+
DEFINE_HL_PRIM (_I32, hl_key_code_from_scan_code, _I32);
4304+
DEFINE_HL_PRIM (_I32, hl_key_code_to_scan_code, _I32);
43054305
DEFINE_HL_PRIM (_VOID, hl_key_event_manager_register, _FUN (_VOID, _NO_ARG) _TKEY_EVENT);
43064306
DEFINE_HL_PRIM (_BYTES, hl_locale_get_system_locale, _NO_ARG);
43074307
DEFINE_HL_PRIM (_TBYTES, hl_lzma_compress, _TBYTES _TBYTES);

src/lime/_internal/backend/native/NativeCFFI.hx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,9 @@ class NativeCFFI
225225

226226
@:cffi private static function lime_jpeg_decode_file(path:String, decodeData:Bool, buffer:Dynamic):Dynamic;
227227

228-
@:cffi private static function lime_key_code_from_scan_code(scanCode:Float32):Float32;
228+
@:cffi private static function lime_key_code_from_scan_code(scanCode:Int):Int;
229229

230-
@:cffi private static function lime_key_code_to_scan_code(keyCode:Float32):Float32;
230+
@:cffi private static function lime_key_code_to_scan_code(keyCode:Int):Int;
231231

232232
@:cffi private static function lime_key_event_manager_register(callback:Dynamic, eventObject:Dynamic):Void;
233233

@@ -515,10 +515,10 @@ class NativeCFFI
515515
"lime_jpeg_decode_bytes", "oboo", false));
516516
private static var lime_jpeg_decode_file = new cpp.Callable<String->Bool->cpp.Object->cpp.Object>(cpp.Prime._loadPrime("lime", "lime_jpeg_decode_file",
517517
"sboo", false));
518-
private static var lime_key_code_from_scan_code = new cpp.Callable<cpp.Float32->cpp.Float32>(cpp.Prime._loadPrime("lime", "lime_key_code_from_scan_code",
519-
"ff", false));
520-
private static var lime_key_code_to_scan_code = new cpp.Callable<cpp.Float32->cpp.Float32>(cpp.Prime._loadPrime("lime", "lime_key_code_to_scan_code",
521-
"ff", false));
518+
private static var lime_key_code_from_scan_code = new cpp.Callable<Int->Int>(cpp.Prime._loadPrime("lime", "lime_key_code_from_scan_code",
519+
"ii", false));
520+
private static var lime_key_code_to_scan_code = new cpp.Callable<Int->Int>(cpp.Prime._loadPrime("lime", "lime_key_code_to_scan_code",
521+
"ii", false));
522522
private static var lime_key_event_manager_register = new cpp.Callable<cpp.Object->cpp.Object->cpp.Void>(cpp.Prime._loadPrime("lime",
523523
"lime_key_event_manager_register", "oov", false));
524524
private static var lime_lzma_compress = new cpp.Callable<cpp.Object->cpp.Object->cpp.Object>(cpp.Prime._loadPrime("lime", "lime_lzma_compress", "ooo",
@@ -1157,12 +1157,12 @@ class NativeCFFI
11571157
return null;
11581158
}
11591159

1160-
@:hlNative("lime", "hl_key_code_from_scan_code") private static function lime_key_code_from_scan_code(scanCode:hl.F32):hl.F32
1160+
@:hlNative("lime", "hl_key_code_from_scan_code") private static function lime_key_code_from_scan_code(scanCode:Int):Int
11611161
{
11621162
return 0;
11631163
}
11641164

1165-
@:hlNative("lime", "hl_key_code_to_scan_code") private static function lime_key_code_to_scan_code(keyCode:hl.F32):hl.F32
1165+
@:hlNative("lime", "hl_key_code_to_scan_code") private static function lime_key_code_to_scan_code(keyCode:Int):Int
11661166
{
11671167
return 0;
11681168
}

src/lime/ui/KeyCode.hx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ package lime.ui;
22

33
import lime._internal.backend.native.NativeCFFI;
44

5+
/**
6+
Used by keyboard event listeners to identify which key was pressed
7+
down or released.
8+
9+
@see `lime.ui.Window.onKeyDown`
10+
@see `lime.ui.Window.onKeyUp`
11+
@see `lime.ui.ScanCode`
12+
**/
513
@:access(lime._internal.backend.native.NativeCFFI)
614
#if (haxe_ver >= 4.0) enum #else @:enum #end abstract KeyCode(Int) from Int to Int from UInt to UInt
715
{
@@ -246,7 +254,7 @@ import lime._internal.backend.native.NativeCFFI;
246254
{
247255
#if (lime_cffi && !macro)
248256
var code:Int = scanCode;
249-
return Std.int(NativeCFFI.lime_key_code_from_scan_code(code));
257+
return NativeCFFI.lime_key_code_from_scan_code(code);
250258
#else
251259
return KeyCode.UNKNOWN;
252260
#end
@@ -256,7 +264,7 @@ import lime._internal.backend.native.NativeCFFI;
256264
{
257265
#if (lime_cffi && !macro)
258266
var code:Int = keyCode;
259-
return Std.int(NativeCFFI.lime_key_code_to_scan_code(code));
267+
return NativeCFFI.lime_key_code_to_scan_code(code);
260268
#else
261269
return ScanCode.UNKNOWN;
262270
#end

src/lime/ui/ScanCode.hx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ package lime.ui;
22

33
import lime._internal.backend.native.NativeCFFI;
44

5+
/**
6+
May be used to identify the scan code associated with the `KeyCode` passed
7+
to keyboard event listeners.
8+
9+
@see `lime.ui.Window.onKeyDown`
10+
@see `lime.ui.Window.onKeyUp`
11+
@see `lime.ui.KeyCode`
12+
**/
513
@:access(lime._internal.backend.native.NativeCFFI)
614
@:access(lime.ui.KeyCode)
715
#if (haxe_ver >= 4.0) enum #else @:enum #end abstract ScanCode(Int) from Int to Int from UInt to UInt

src/lime/ui/Window.hx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,25 +67,68 @@ class Window
6767
public var onFocusOut(default, null) = new Event<Void->Void>();
6868
public var onFullscreen(default, null) = new Event<Void->Void>();
6969
public var onHide(default, null) = new Event<Void->Void>();
70+
71+
/**
72+
Fired when the user presses a key down when this window has focus.
73+
**/
7074
public var onKeyDown(default, null) = new Event<KeyCode->KeyModifier->Void>();
75+
76+
/**
77+
Fired when the user releases a key that was down.
78+
**/
7179
public var onKeyUp(default, null) = new Event<KeyCode->KeyModifier->Void>();
80+
7281
public var onLeave(default, null) = new Event<Void->Void>();
82+
83+
/**
84+
Fired when the window is maximized.
85+
**/
7386
public var onMaximize(default, null) = new Event<Void->Void>();
87+
88+
/**
89+
Fired when the window is minimized.
90+
**/
7491
public var onMinimize(default, null) = new Event<Void->Void>();
92+
93+
/**
94+
Fired when the user pressed a mouse button down.
95+
**/
7596
public var onMouseDown(default, null) = new Event<Float->Float->MouseButton->Void>();
97+
98+
/**
99+
Fired when the mouse is moved over the window.
100+
**/
76101
public var onMouseMove(default, null) = new Event<Float->Float->Void>();
77102
public var onMouseMoveRelative(default, null) = new Event<Float->Float->Void>();
103+
104+
/**
105+
Fired when the user releases a mouse button that was pressed down.
106+
**/
78107
public var onMouseUp(default, null) = new Event<Float->Float->Int->Void>();
108+
109+
/**
110+
Fired when the user interacts with the mouse wheel.
111+
**/
79112
public var onMouseWheel(default, null) = new Event<Float->Float->MouseWheelMode->Void>();
113+
114+
/**
115+
Fired when the window is moved to a new position.
116+
**/
80117
public var onMove(default, null) = new Event<Float->Float->Void>();
81118
public var onRender(default, null) = new Event<RenderContext->Void>();
82119
public var onRenderContextLost(default, null) = new Event<Void->Void>();
83120
public var onRenderContextRestored(default, null) = new Event<RenderContext->Void>();
121+
122+
/**
123+
Fired when the window is resized with new dimensions.
124+
**/
84125
public var onResize(default, null) = new Event<Int->Int->Void>();
126+
85127
public var onRestore(default, null) = new Event<Void->Void>();
86128
public var onShow(default, null) = new Event<Void->Void>();
87129
public var onTextEdit(default, null) = new Event<String->Int->Int->Void>();
88130
public var onTextInput(default, null) = new Event<String->Void>();
131+
89132
public var opacity(get, set):Float;
90133
public var parameters:Dynamic;
91134
public var resizable(get, set):Bool;

0 commit comments

Comments
 (0)