MCPcopy Create free account
hub / github.com/TASEmulators/fceux / KeyboardUpdateState

Function KeyboardUpdateState

src/drivers/win/keyboard.cpp:43–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41extern ButtConfig autoHoldKeys, autoHoldClearKeys;
42int ctr=0;
43void KeyboardUpdateState(void)
44{
45 unsigned char tk[256];
46
47 ddrval=IDirectInputDevice7_GetDeviceState(lpdid,256,tk);
48 if (tk[0]) tk[0] = 0; //adelikat: HACK. If a keyboard key is recognized as this, the effect is that all non assigned hotkeys are run. This prevents the key from being used, but also prevent "hotkey explosion". Also, they essentially couldn't use it anyway since FCEUX doesn't know it is a shift key, and it can't be assigned in the hotkeys
49 // HACK because DirectInput is totally wacky about recognizing the PAUSE/BREAK key
50 if(GetAsyncKeyState(VK_PAUSE)) // normally this should have & 0x8000, but apparently this key is too special for that to work
51 tk[0xC5] = 0x80;
52
53 switch(ddrval)
54 {
55 case DI_OK: //memcpy(keys,tk,256);break;
56 break;
57
58 //mbg 10/8/2008
59 //previously only these two cases were handled. this made dwedit's laptop volume keys freak out.
60 //we're trying this instead
61 default:
62 //case DIERR_INPUTLOST:
63 //case DIERR_NOTACQUIRED:
64 memset(tk,0,256);
65 IDirectInputDevice7_Acquire(lpdid);
66 break;
67 }
68
69 //process keys
70 extern int soundoptions;
71#define SO_OLDUP 32
72
73 extern int soundo;
74 extern int32 fps_scale;
75 int notAlternateThrottle = !(soundoptions&SO_OLDUP) && soundo && ((NoWaiting&1)?(256*16):fps_scale) >= 64;
76#define KEY_REPEAT_INITIAL_DELAY ((!notAlternateThrottle) ? (16) : (64)) // must be >= 0 and <= 255
77#define KEY_REPEAT_REPEATING_DELAY (6) // must be >= 1 and <= 255
78#define KEY_JUST_DOWN_DURATION (1) // must be >= 1 and <= 255 // AnS: changed to 1 to disallow unwanted hits of e.g. F1 after pressing Shift+F1 and quickly releasing Shift
79
80 for(int i = 0 ; i < 256 ; i++)
81 if(tk[i])
82 if(keys_nr[i] < 255)
83 keys_nr[i]++; // activate key, and count up for repeat
84 else
85 keys_nr[i] = 255 - KEY_REPEAT_REPEATING_DELAY; // oscillate for repeat
86 else
87 keys_nr[i] = 0; // deactivate key
88
89 memcpy(keys,keys_nr,sizeof(keys));
90
91 // key-down detection
92 for(int i = 0 ; i < 256 ; i++)
93 if(!keys_nr[i])
94 {
95 keys_jd[i] = 0;
96 keys_jd_lock[i] = 0;
97 }
98 else if(keys_jd_lock[i])
99 {}
100 else if(keys_jd[i]

Callers 2

UpdateRawInputAndHotkeysFunction · 0.85
DWBCallBFunction · 0.85

Calls 1

DTestButtonFunction · 0.70

Tested by

no test coverage detected