3
3
4
4
with Ada.Unchecked_Conversion ;
5
5
with Interfaces ; use Interfaces;
6
+ with System ;
6
7
with System.Address_To_Access_Conversions ;
7
8
8
9
package Uinput is
@@ -18,82 +19,90 @@ package Uinput is
18
19
type K_Size_T is new Unsigned_64;
19
20
type K_SSize_T is new Integer_64;
20
21
type K_File_ID_T is new Integer_32;
21
- type K_Ioctl_ID_T is new Integer_32 ;
22
+ type K_Ioctl_ID_T is new Unsigned_32 ;
22
23
type K_Dummy_T is new Integer_32;
23
24
25
+ UINPUT_IOCTL_BASE : constant Integer_32 := 85 ; -- ASCII 'U'
26
+
24
27
Uinput_Max_Name_Size : constant Integer := 80 ;
28
+ BUS_USB : constant K_U16_T := 3 ;
25
29
26
30
type K_Input_ID_T is record
27
31
K_Bustype,
28
32
K_Vendor,
29
33
K_Product,
30
34
K_Version : K_U16_T;
31
35
end record ;
36
+ pragma Convention (C, K_Input_ID_T);
32
37
33
38
type K_Uinput_Setup_T is record
34
39
ID : K_Input_ID_T;
35
40
Name : String (1 .. Uinput_Max_Name_Size);
36
- FF_Effects_Max : K_U32_T;
41
+ FF_Effects_Max : K_U32_T := 0 ;
37
42
end record ;
43
+ pragma Convention (C, K_Uinput_Setup_T);
44
+
45
+ UI_SET_EVBIT : constant Unsigned_32 := 100 ;
46
+ UI_SET_KEYBIT : constant Unsigned_32 := 101 ;
38
47
39
- package Uinput_Setup_Pointers is new System.Address_To_Access_Conversions (K_Uinput_Setup_T);
48
+ UI_DEV_SETUP : constant Unsigned_32 := 3 ;
49
+ UI_DEV_CREATE : constant Unsigned_32 := 1 ;
50
+ UI_DEV_DESTROY : constant Unsigned_32 := 2 ;
40
51
41
52
type K_Timeval_T is record
42
53
TV_Sec : K_Int_T := 0 ;
43
54
TV_USec : K_Long_T := 0 ;
44
55
end record ;
45
56
46
57
-- The Event Types we need...
47
- EV_SYN : constant K_Int_T := 0 ;
48
- EV_KEY : constant K_Int_T := 1 ;
49
- EV_REL : constant K_Int_T := 2 ;
58
+ EV_SYN : constant K_U16_T := 0 ;
59
+ EV_KEY : constant K_U16_T := 1 ;
60
+ EV_REL : constant K_U16_T := 2 ;
50
61
51
62
type K_Input_Event_T is record
52
63
Time : K_Timeval_T;
53
- IE_Type : K_Int_T ;
54
- IE_Code : K_Int_T ;
64
+ IE_Type : K_U16_T ;
65
+ IE_Code : K_U16_T ;
55
66
IE_Value : K_Int_T;
56
67
end record ;
68
+ pragma Convention (C, K_Input_Event_T);
57
69
58
70
K_Input_Event_Size : constant K_Size_T := K_Input_Event_T'Size;
59
71
60
72
package IE_Pointers is new System.Address_To_Access_Conversions (K_Input_Event_T);
61
73
62
74
-- The short-form 2 arg (i.e. 1 parameter) ioctl call
63
- procedure K_IOCTL_2_Arg (Result : out K_Int_T ;
64
- FID : K_File_ID_T ;
65
- IOCTL_ID : K_Ioctl_ID_T;
66
- Ignored : K_Dummy_T) ;
75
+ function K_IOCTL_2_Arg (FID : K_File_ID_T ;
76
+ IOCTL_ID : K_Ioctl_ID_T ;
77
+ Ignored : K_Dummy_T := 0
78
+ ) return K_Int_T ;
67
79
pragma Import (C, K_IOCTL_2_Arg, " ioctl" );
68
- pragma Import_Valued_Procedure (K_IOCTL_2_Arg);
69
80
70
81
-- The long-form 3 arg (i.e. 2 parameters) ioctl call
71
82
-- with a simple (int) 3rd argument
72
- procedure K_IOCTL_3_Arg (Result : out K_Int_T ;
73
- FID : K_File_ID_T ;
74
- IOCTL_ID : K_Ioctl_ID_T;
75
- IOCTL_Arg : K_Int_T) ;
83
+ function K_IOCTL_3_Arg (FID : K_File_ID_T ;
84
+ IOCTL_ID : K_Ioctl_ID_T ;
85
+ IOCTL_Arg : K_Long_T
86
+ ) return K_Int_T;
76
87
pragma Import (C, K_IOCTL_3_Arg, " ioctl" );
77
- pragma Import_Valued_Procedure (K_IOCTL_3_Arg);
78
88
79
89
-- The long-form 3 arg (i.e. 2 parameters) ioctl call
80
90
-- with an (address of) Uinput_Setup 3rd argument
81
- procedure K_IOCTL_Uinput_Setup (Result : out K_Int_T ;
82
- FID : K_File_ID_T ;
83
- IOCTL_ID : K_Ioctl_ID_T;
84
- Uinput_Setup_Addr : Uinput_Setup_Pointers.Object_Pointer) ;
91
+ function K_IOCTL_Uinput_Setup (FID : K_File_ID_T ;
92
+ IOCTL_ID : K_Ioctl_ID_T ;
93
+ Usetup : K_Uinput_Setup_T
94
+ ) return K_Int_T ;
85
95
pragma Import (C, K_IOCTL_Uinput_Setup, " ioctl" );
86
- pragma Import_Valued_Procedure (K_IOCTL_Uinput_Setup);
96
+
97
+ procedure C_Perror (Msg : String);
98
+ pragma Import (C, C_Perror, " perror" );
87
99
88
100
O_WRONLY : constant K_Int_T := 1 ;
89
101
O_NONBLOCK : constant K_Int_T := 2048 ;
90
102
91
- -- System file open call
92
- procedure K_Open (FID : out K_File_ID_T;
93
- Path : String;
94
- Flags : K_Int_T);
103
+ function K_Open (Path : String;
104
+ Flags : K_Int_T) return K_File_ID_T;
95
105
pragma Import (C, K_Open, " open" );
96
- pragma Import_Valued_Procedure (K_Open);
97
106
98
107
-- System file write call
99
108
procedure K_Write_IE (Written : out K_SSize_T;
@@ -110,12 +119,18 @@ package Uinput is
110
119
pragma Import_Valued_Procedure (K_Close);
111
120
112
121
-- The special Event Code we need...
113
- SYN_REPORT : constant K_Int_T := 0 ;
122
+ SYN_REPORT : constant K_U16_T := 0 ;
114
123
115
- function Char_To_K_Int is new Ada.Unchecked_Conversion (Character, K_Int_T);
124
+ pragma Warnings (Off, " types for unchecked conversion have different sizes" );
125
+ function Char_To_K_U16 is new Ada.Unchecked_Conversion (Character, K_U16_T);
126
+ pragma Warnings (On, " types for unchecked conversion have different sizes" );
116
127
117
- Cannot_Open, Cannot_Write : exception ;
128
+ Cannot_Open,
129
+ Cannot_Write,
130
+ IOCTL_Error : exception ;
118
131
119
- procedure Emit (FID : K_File_ID_T; E_Type, E_Code, E_Val : K_Int_T);
132
+ procedure Emit (FID : K_File_ID_T;
133
+ E_Type, E_Code : K_U16_T;
134
+ E_Val : K_Int_T);
120
135
121
136
end Uinput ;
0 commit comments