Skip to content

Commit 3f3a00c

Browse files
authored
Merge pull request #17 from Animeshz/node-js
Quick Fix for #16 and fix unintended JS floating number errors (received non-int from Napi).
2 parents 19b1070 + 84c7a00 commit 3f3a00c

6 files changed

Lines changed: 8 additions & 8 deletions

File tree

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44

55
allprojects {
66
this.group = "com.github.animeshz"
7-
this.version = "0.3.1"
7+
this.version = "0.3.2"
88

99
repositories {
1010
mavenCentral()

keyboard-kt/src/jsMain/cpp/linux/JsKeyboardHandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ TSFN ts_callback;
2020

2121
void Send(const Napi::CallbackInfo& info) {
2222
int scanCode = info[0].As<Napi::Number>().Int32Value();
23-
bool isPressed = info[0].As<Napi::Boolean>().Value();
23+
bool isPressed = info[1].As<Napi::Boolean>().Value();
2424

2525
LinuxKeyboardHandler::getInstance()->sendEvent(scanCode, isPressed);
2626
}

keyboard-kt/src/jsMain/cpp/windows/JsKeyboardHandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ TSFN ts_callback;
2020

2121
void Send(const Napi::CallbackInfo& info) {
2222
int scanCode = info[0].As<Napi::Number>().Int32Value();
23-
bool isPressed = info[0].As<Napi::Boolean>().Value();
23+
bool isPressed = info[1].As<Napi::Boolean>().Value();
2424

2525
WindowsKeyboardHandler::getInstance()->sendEvent(scanCode, isPressed);
2626
}

keyboard-kt/src/jsMain/kotlin/com/github/animeshz/keyboard/JsKeyboardHandler.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import kotlinx.coroutines.flow.onEach
1111
@ExperimentalKeyIO
1212
internal object KotlinJsKeyboardHandler : NativeKeyboardHandlerBase() {
1313
init {
14-
if (NApiNativeHandler.init() != 0) {
14+
if (NApiNativeHandler.init().toInt() != 0) {
1515
error("Native initialization failed")
1616
}
1717
}
@@ -34,7 +34,7 @@ internal object KotlinJsKeyboardHandler : NativeKeyboardHandlerBase() {
3434
eventsInternal.tryEmit(KeyEvent(Key.fromKeyCode(scanCode), isPressed.toKeyState()))
3535
}
3636

37-
if (code != 0) {
37+
if (code.toInt() != 0) {
3838
error("Unable to set native hook. Error code: $code")
3939
}
4040
}

keyboard-kt/src/jsMain/kotlin/com/github/animeshz/keyboard/NativeUtils.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ internal external interface INApiNativeHandler {
2727
fun isNumLockOn(): Boolean
2828
fun isScrollLockOn(): Boolean
2929

30-
fun init(): Int
31-
fun startReadingEvents(handler: (scanCode: Int, isPressed: Boolean) -> Unit): Int
30+
fun init(): Number
31+
fun startReadingEvents(handler: (scanCode: Int, isPressed: Boolean) -> Unit): Number
3232
fun stopReadingEvents()
3333
}

keyboard-kt/src/jsMain/package.template.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"email": "animeshsahu19@yahoo.com"
3434
},
3535
"repository": {
36-
"url": "https://animeshz.github.io/keyboard-mouse-kt"
36+
"url": "https://github.com/animeshz/keyboard-mouse-kt"
3737
},
3838
"bugs": {
3939
"url": "https://animeshz.github.io/keyboard-mouse-kt/issues"

0 commit comments

Comments
 (0)