Skip to content

Commit

Permalink
Merge pull request #17 from Animeshz/node-js
Browse files Browse the repository at this point in the history
Quick Fix for #16 and fix unintended JS floating number errors (received non-int from Napi).
  • Loading branch information
Animeshz committed Feb 14, 2021
2 parents 19b1070 + 84c7a00 commit 3f3a00c
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {

allprojects {
this.group = "com.github.animeshz"
this.version = "0.3.1"
this.version = "0.3.2"

repositories {
mavenCentral()
Expand Down
2 changes: 1 addition & 1 deletion keyboard-kt/src/jsMain/cpp/linux/JsKeyboardHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ TSFN ts_callback;

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

LinuxKeyboardHandler::getInstance()->sendEvent(scanCode, isPressed);
}
Expand Down
2 changes: 1 addition & 1 deletion keyboard-kt/src/jsMain/cpp/windows/JsKeyboardHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ TSFN ts_callback;

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

WindowsKeyboardHandler::getInstance()->sendEvent(scanCode, isPressed);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import kotlinx.coroutines.flow.onEach
@ExperimentalKeyIO
internal object KotlinJsKeyboardHandler : NativeKeyboardHandlerBase() {
init {
if (NApiNativeHandler.init() != 0) {
if (NApiNativeHandler.init().toInt() != 0) {
error("Native initialization failed")
}
}
Expand All @@ -34,7 +34,7 @@ internal object KotlinJsKeyboardHandler : NativeKeyboardHandlerBase() {
eventsInternal.tryEmit(KeyEvent(Key.fromKeyCode(scanCode), isPressed.toKeyState()))
}

if (code != 0) {
if (code.toInt() != 0) {
error("Unable to set native hook. Error code: $code")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal external interface INApiNativeHandler {
fun isNumLockOn(): Boolean
fun isScrollLockOn(): Boolean

fun init(): Int
fun startReadingEvents(handler: (scanCode: Int, isPressed: Boolean) -> Unit): Int
fun init(): Number
fun startReadingEvents(handler: (scanCode: Int, isPressed: Boolean) -> Unit): Number
fun stopReadingEvents()
}
2 changes: 1 addition & 1 deletion keyboard-kt/src/jsMain/package.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"email": "[email protected]"
},
"repository": {
"url": "https://animeshz.github.io/keyboard-mouse-kt"
"url": "https://github.com/animeshz/keyboard-mouse-kt"
},
"bugs": {
"url": "https://animeshz.github.io/keyboard-mouse-kt/issues"
Expand Down

0 comments on commit 3f3a00c

Please sign in to comment.