Subversion Repositories HelenOS

Rev

Rev 4327 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4327 Rev 4581
Line 26... Line 26...
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
/**
29
/**
30
 * @addtogroup kbdgen generic
30
 * @addtogroup kbdgen generic
31
 * @brief   HelenOS generic uspace keyboard handler.
31
 * @brief HelenOS generic uspace keyboard handler.
32
 * @ingroup  kbd
32
 * @ingroup kbd
33
 * @{
33
 * @{
34
 */
34
 */
35
/** @file
35
/** @file
36
 */
36
 */
37
 
37
 
38
#include <ipc/ipc.h>
38
#include <ipc/ipc.h>
39
#include <ipc/services.h>
39
#include <ipc/services.h>
Line 43... Line 43...
43
#include <stdlib.h>
43
#include <stdlib.h>
44
#include <stdio.h>
44
#include <stdio.h>
45
#include <ipc/ns.h>
45
#include <ipc/ns.h>
46
#include <async.h>
46
#include <async.h>
47
#include <errno.h>
47
#include <errno.h>
48
#include <libadt/fifo.h>
48
#include <adt/fifo.h>
49
#include <kbd/kbd.h>
49
#include <io/console.h>
50
#include <kbd/keycode.h>
50
#include <io/keycode.h>
51
 
51
 
52
#include <kbd.h>
52
#include <kbd.h>
53
#include <key_buffer.h>
53
#include <keybuffer.h>
54
#include <kbd_port.h>
54
#include <kbd_port.h>
55
#include <kbd_ctl.h>
55
#include <kbd_ctl.h>
56
#include <layout.h>
56
#include <layout.h>
57
 
57
 
58
#define NAME "kbd"
58
#define NAME "kbd"
Line 86... Line 86...
86
    kbd_ctl_parse_scancode(scancode);
86
    kbd_ctl_parse_scancode(scancode);
87
}
87
}
88
 
88
 
89
void kbd_push_ev(int type, unsigned int key)
89
void kbd_push_ev(int type, unsigned int key)
90
{
90
{
91
    kbd_event_t ev;
91
    console_event_t ev;
92
    unsigned mod_mask;
92
    unsigned mod_mask;
93
 
93
 
94
    switch (key) {
94
    switch (key) {
95
    case KC_LCTRL: mod_mask = KM_LCTRL; break;
95
    case KC_LCTRL: mod_mask = KM_LCTRL; break;
96
    case KC_RCTRL: mod_mask = KM_RCTRL; break;
96
    case KC_RCTRL: mod_mask = KM_RCTRL; break;
Line 100... Line 100...
100
    case KC_RALT: mod_mask = KM_RALT; break;
100
    case KC_RALT: mod_mask = KM_RALT; break;
101
    default: mod_mask = 0; break;
101
    default: mod_mask = 0; break;
102
    }
102
    }
103
 
103
 
104
    if (mod_mask != 0) {
104
    if (mod_mask != 0) {
105
        if (type == KE_PRESS)
105
        if (type == KEY_PRESS)
106
            mods = mods | mod_mask;
106
            mods = mods | mod_mask;
107
        else
107
        else
108
            mods = mods & ~mod_mask;
108
            mods = mods & ~mod_mask;
109
    }
109
    }
110
 
110
 
Line 114... Line 114...
114
    case KC_SCROLL_LOCK: mod_mask = KM_SCROLL_LOCK; break;
114
    case KC_SCROLL_LOCK: mod_mask = KM_SCROLL_LOCK; break;
115
    default: mod_mask = 0; break;
115
    default: mod_mask = 0; break;
116
    }
116
    }
117
 
117
 
118
    if (mod_mask != 0) {
118
    if (mod_mask != 0) {
119
        if (type == KE_PRESS) {
119
        if (type == KEY_PRESS) {
120
            /*
120
            /*
121
             * Only change lock state on transition from released
121
             * Only change lock state on transition from released
122
             * to pressed. This prevents autorepeat from messing
122
             * to pressed. This prevents autorepeat from messing
123
             * up the lock state.
123
             * up the lock state.
124
             */
124
             */
Line 131... Line 131...
131
/*
131
/*
132
    printf("type: %d\n", type);
132
    printf("type: %d\n", type);
133
    printf("mods: 0x%x\n", mods);
133
    printf("mods: 0x%x\n", mods);
134
    printf("keycode: %u\n", key);
134
    printf("keycode: %u\n", key);
135
*/
135
*/
136
    if (type == KE_PRESS && (mods & KM_LCTRL) &&
136
    if (type == KEY_PRESS && (mods & KM_LCTRL) &&
137
        key == KC_F1) {
137
        key == KC_F1) {
138
        active_layout = 0;
138
        active_layout = 0;
139
        layout[active_layout]->reset();
139
        layout[active_layout]->reset();
140
        return;
140
        return;
141
    }
141
    }
142
 
142
 
143
    if (type == KE_PRESS && (mods & KM_LCTRL) &&
143
    if (type == KEY_PRESS && (mods & KM_LCTRL) &&
144
        key == KC_F2) {
144
        key == KC_F2) {
145
        active_layout = 1;
145
        active_layout = 1;
146
        layout[active_layout]->reset();
146
        layout[active_layout]->reset();
147
        return;
147
        return;
148
    }
148
    }
149
 
149
 
150
    if (type == KE_PRESS && (mods & KM_LCTRL) &&
150
    if (type == KEY_PRESS && (mods & KM_LCTRL) &&
151
        key == KC_F3) {
151
        key == KC_F3) {
152
        active_layout = 2;
152
        active_layout = 2;
153
        layout[active_layout]->reset();
153
        layout[active_layout]->reset();
154
        return;
154
        return;
155
    }
155
    }
Line 191... Line 191...
191
                break;
191
                break;
192
            }
192
            }
193
            phone2cons = IPC_GET_ARG5(call);
193
            phone2cons = IPC_GET_ARG5(call);
194
            retval = 0;
194
            retval = 0;
195
            break;
195
            break;
-
 
196
        case KBD_YIELD:
-
 
197
            kbd_port_yield();
-
 
198
            retval = 0;
-
 
199
            break;
-
 
200
        case KBD_RECLAIM:
-
 
201
            kbd_port_reclaim();
-
 
202
            retval = 0;
-
 
203
            break;
196
        default:
204
        default:
197
            retval = EINVAL;
205
            retval = EINVAL;
198
        }
206
        }
199
        ipc_answer_0(callid, retval);
207
        ipc_answer_0(callid, retval);
200
    }  
208
    }