Changeset 04803bf in mainline for uspace/srv/hid/kbd/generic/kbd.c
- Timestamp:
- 2011-03-21T22:00:17Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 143932e3
- Parents:
- b50b5af2 (diff), 7308e84 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 moved
-
uspace/srv/hid/kbd/generic/kbd.c (moved) (moved from uspace/srv/kbd/generic/kbd.c ) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/kbd/generic/kbd.c
rb50b5af2 r04803bf 36 36 */ 37 37 38 #include <ipc/ipc.h>39 38 #include <ipc/services.h> 40 39 #include <ipc/kbd.h> … … 50 49 #include <io/console.h> 51 50 #include <io/keycode.h> 51 #include <devmap.h> 52 52 53 53 #include <kbd.h> … … 56 56 #include <layout.h> 57 57 58 #define NAME "kbd"59 60 int cons_connected = 0; 61 int phone2cons= -1;58 #define NAME "kbd" 59 #define NAMESPACE "hid_in" 60 61 int client_phone = -1; 62 62 63 63 /** Currently active modifiers. */ … … 163 163 ev.c = layout[active_layout]->parse_ev(&ev); 164 164 165 async_msg_4( phone2cons, KBD_EVENT, ev.type, ev.key, ev.mods, ev.c);166 } 167 168 static void c onsole_connection(ipc_callid_t iid, ipc_call_t *icall)165 async_msg_4(client_phone, KBD_EVENT, ev.type, ev.key, ev.mods, ev.c); 166 } 167 168 static void client_connection(ipc_callid_t iid, ipc_call_t *icall) 169 169 { 170 170 ipc_callid_t callid; … … 172 172 int retval; 173 173 174 if (cons_connected) { 175 ipc_answer_0(iid, ELIMIT); 176 return; 177 } 178 cons_connected = 1; 179 ipc_answer_0(iid, EOK); 174 async_answer_0(iid, EOK); 180 175 181 176 while (1) { 182 177 callid = async_get_call(&call); 183 switch (IPC_GET_ METHOD(call)) {178 switch (IPC_GET_IMETHOD(call)) { 184 179 case IPC_M_PHONE_HUNGUP: 185 cons_connected = 0; 186 ipc_hangup(phone2cons); 187 phone2cons = -1; 188 ipc_answer_0(callid, EOK); 180 if (client_phone != -1) { 181 async_hangup(client_phone); 182 client_phone = -1; 183 } 184 185 async_answer_0(callid, EOK); 189 186 return; 190 187 case IPC_M_CONNECT_TO_ME: 191 if ( phone2cons!= -1) {188 if (client_phone != -1) { 192 189 retval = ELIMIT; 193 190 break; 194 191 } 195 phone2cons= IPC_GET_ARG5(call);192 client_phone = IPC_GET_ARG5(call); 196 193 retval = 0; 197 194 break; … … 207 204 retval = EINVAL; 208 205 } 209 ipc_answer_0(callid, retval);206 async_answer_0(callid, retval); 210 207 } 211 208 } … … 214 211 int main(int argc, char **argv) 215 212 { 216 printf(NAME ": HelenOS Keyboard service\n"); 217 218 ipcarg_t phonead; 219 220 if (sysinfo_value("kbd.cir.fhc") == 1) 213 printf("%s: HelenOS Keyboard service\n", NAME); 214 215 sysarg_t fhc; 216 sysarg_t obio; 217 218 if ((sysinfo_get_value("kbd.cir.fhc", &fhc) == EOK) && (fhc)) 221 219 cir_service = SERVICE_FHC; 222 else if ( sysinfo_value("kbd.cir.obio") == 1)220 else if ((sysinfo_get_value("kbd.cir.obio", &obio) == EOK) && (obio)) 223 221 cir_service = SERVICE_OBIO; 224 222 225 223 if (cir_service) { 226 while (cir_phone < 0) { 227 cir_phone = ipc_connect_me_to_blocking(PHONE_NS, cir_service, 228 0, 0); 229 } 224 while (cir_phone < 0) 225 cir_phone = service_connect_blocking(cir_service, 0, 0); 230 226 } 231 227 … … 241 237 layout[active_layout]->reset(); 242 238 243 async_set_client_connection(console_connection); 244 245 /* Register service at nameserver. */ 246 if (ipc_connect_to_me(PHONE_NS, SERVICE_KEYBOARD, 0, 0, &phonead) != 0) 247 return -1; 248 239 /* Register driver */ 240 int rc = devmap_driver_register(NAME, client_connection); 241 if (rc < 0) { 242 printf("%s: Unable to register driver (%d)\n", NAME, rc); 243 return -1; 244 } 245 246 char kbd[DEVMAP_NAME_MAXLEN + 1]; 247 snprintf(kbd, DEVMAP_NAME_MAXLEN, "%s/%s", NAMESPACE, NAME); 248 249 devmap_handle_t devmap_handle; 250 if (devmap_device_register(kbd, &devmap_handle) != EOK) { 251 printf("%s: Unable to register device %s\n", NAME, kbd); 252 return -1; 253 } 254 249 255 printf(NAME ": Accepting connections\n"); 250 256 async_manager();
Note:
See TracChangeset
for help on using the changeset viewer.
