summaryrefslogtreecommitdiffstats
path: root/private/mvdm/softpc.new/host/src/nt_input.c
blob: 3b89d83d340abf0a0604343de75732a35bf091db (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
 * SoftPC Revision 3.0
 *
 * Title		:	Win32 Input Module.
 *
 * Description	:	This module contains data and functions to
 *			implement the SoftPC keyboard/mouse input subsystem.
 *
 * Author	:	D.A.Bartlett (based on X_input.c)
 *
 * Notes	:	HELP!!!!!!
 * Mods		:	Tim May 28, 92. Yoda break now on F11 if set YODA=1.
 */

/*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Include files */

#include <nt.h>
#include <ntrtl.h>
#include <nturtl.h>
#include <windows.h>
#include <ntddkbd.h>

#include "insignia.h"
#include "host_def.h"
#include "xt.h"
#include "keyboard.h"
#include "keyba.h"
#include "ica.h"
#include "error.h"
#include "config.h"
#include "keyba.h"
#include "gmi.h"
#include "nt_uis.h"
#include "sas.h"
#include <stdio.h>
#include "trace.h"
#include "video.h"
#include "debug.h"
#include "nt_event.h"
#include "nt_reset.h"
#include "bios.h"
#include CpuH

#include "host.h"
#include "host_hfx.h"
#include "host_nls.h"
#include "spcfile.h"


// The command bits for the kbd light (same as real hardware)
#define CAPS_LOCK       0x04
#define NUM_LOCK 	0x02
#define SCROLL_LOCK     0x01

// functions available thru the keyb functions table
void nt_kb_prepare(void) {}


#if NOTUSEDNOTUSED
void nt_kb_light_off IFN1(half_word, kyLight) {}
void nt_kb_restore(void) {}
#endif

void nt_kb_light_on(UCHAR);
void nt_kb_init(void);
void nt_kb_shutdown(void);


// the keyb functions table
KEYBDFUNCS nt_keybd_funcs = {nt_kb_prepare,   // not implemented
                             nt_kb_prepare,   // not implemented
                             nt_kb_prepare,   // not implemented
                             nt_kb_prepare,   // not implemented
                             nt_kb_light_on,
                             nt_kb_light_on   // not implemented
                             };


/*
 *   nt_kb_light_on
 *
 *   This code gets called whenever kbdhdw  tries to change the kbd leds.
 *   We cannot allow changes to the real leds because this would get us
 *   out of sync with user32 physical keyboard state. So what we do is
 *   to send fake keys to the kbd hdw to reset the state to what the
 *   the latest state is according to the console input
 *
 *   Caller should hold the kbd mutex
 */
void nt_kb_light_on (unsigned char kyLight)
{
   DWORD KeyState;
   unsigned char ChangeBits;

   ChangeBits = kyLight >> 4;

   KeyState = (ToggleKeyState & ~(CAPSLOCK_ON | NUMLOCK_ON | SCROLLLOCK_ON));

   if(ChangeBits & CAPS_LOCK) {
      if (kyLight & CAPS_LOCK)
          KeyState |= CAPSLOCK_ON;
      }
   else {
      KeyState |= ToggleKeyState & CAPSLOCK_ON;
      }

   if(ChangeBits & NUM_LOCK) {
      if(kyLight & NUM_LOCK)
         KeyState |= NUMLOCK_ON;
      }
   else {
      KeyState |= ToggleKeyState & NUMLOCK_ON;
      }


   if(ChangeBits & SCROLL_LOCK) {
      if(kyLight & SCROLL_LOCK)
         KeyState |= SCROLLLOCK_ON;
      }
   else {
      KeyState |= ToggleKeyState & SCROLLLOCK_ON;
      }

   if (ToggleKeyState != KeyState) {
       SyncToggleKeys( 0, KeyState);
       }

}