Skip to content

Commit eef10d3

Browse files
committed
Update InputEvent
1 parent dce8bdd commit eef10d3

1 file changed

Lines changed: 22 additions & 10 deletions

File tree

Sources/AndroidInput/InputEvent.swift

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public extension InputEvent {
153153
///
154154
/// Only valid for key events.
155155
var keyAction: KeyAction {
156-
KeyAction(rawValue: AKeyEvent_getAction(pointer))
156+
KeyAction(AKeyEvent_getAction(pointer))
157157
}
158158

159159
/// Get the key event flags.
@@ -167,7 +167,7 @@ public extension InputEvent {
167167
///
168168
/// Only valid for key events.
169169
var keyCode: KeyCode {
170-
KeyCode(rawValue: AKeyEvent_getKeyCode(pointer))
170+
KeyCode(AKeyEvent_getKeyCode(pointer))
171171
}
172172

173173
/// Get the hardware key id of this key event.
@@ -210,11 +210,15 @@ public extension InputEvent {
210210

211211
public struct KeyAction: RawRepresentable, Equatable, Hashable, Sendable {
212212

213-
public let rawValue: Int32
213+
public let rawValue: Int
214214

215-
public init(rawValue: Int32) {
215+
public init(rawValue: Int) {
216216
self.rawValue = rawValue
217217
}
218+
219+
internal init(_ rawValue: Int32) {
220+
self.rawValue = Int(rawValue)
221+
}
218222

219223
/// Key down action.
220224
public static let down = KeyAction(rawValue: AKEY_EVENT_ACTION_DOWN)
@@ -234,7 +238,7 @@ public extension InputEvent {
234238
///
235239
/// Only valid for motion events.
236240
var motionAction: MotionAction {
237-
MotionAction(rawValue: AMotionEvent_getAction(pointer))
241+
MotionAction(AMotionEvent_getAction(pointer))
238242
}
239243

240244
/// Get the motion event flags.
@@ -338,7 +342,7 @@ public extension InputEvent {
338342
/// - Parameter pointerIndex: The index of the pointer for which to retrieve the tool type.
339343
/// - Returns: The tool type.
340344
func getToolType(at pointerIndex: Int) -> ToolType {
341-
ToolType(rawValue: AMotionEvent_getToolType(pointer, pointerIndex))
345+
ToolType(AMotionEvent_getToolType(pointer, pointerIndex))
342346
}
343347

344348
/// Get the original raw X coordinate of this event.
@@ -499,11 +503,15 @@ public extension InputEvent {
499503

500504
public struct MotionAction: RawRepresentable, Equatable, Hashable, Sendable {
501505

502-
public let rawValue: Int32
506+
public let rawValue: Int
503507

504-
public init(rawValue: Int32) {
508+
public init(rawValue: Int) {
505509
self.rawValue = rawValue
506510
}
511+
512+
internal init(_ rawValue: Int32) {
513+
self.rawValue = Int(rawValue)
514+
}
507515

508516
/// Motion action down.
509517
public static let down = MotionAction(rawValue: AMOTION_EVENT_ACTION_DOWN)
@@ -549,11 +557,15 @@ public struct MotionAction: RawRepresentable, Equatable, Hashable, Sendable {
549557

550558
public struct ToolType: RawRepresentable, Equatable, Hashable, Sendable {
551559

552-
public let rawValue: Int32
560+
public let rawValue: Int
553561

554-
public init(rawValue: Int32) {
562+
public init(rawValue: Int) {
555563
self.rawValue = rawValue
556564
}
565+
566+
internal init(_ rawValue: Int32) {
567+
self.rawValue = Int(rawValue)
568+
}
557569

558570
/// Unknown tool type.
559571
public static let unknown = ToolType(rawValue: AMOTION_EVENT_TOOL_TYPE_UNKNOWN)

0 commit comments

Comments
 (0)