|
coastline 0.0.4
|
The control bindings and the DirectInput devices of the PC port. More...
#include <windows.h>#include <dinput.h>#include "common/emulatedclock.h"#include "common/inputbinding.h"#include "common/inputpoll.h"
Go to the source code of this file.
Classes | |
| class | MouseDevice |
| The mouse of the game. More... | |
| struct | MouseMenuState |
| The state of the menus the mouse and the arrows of the keyboard move. More... | |
| struct | MouseInputState |
| Mouse axes, accumulated movement, and buttons from input polling. More... | |
| struct | InputControlName |
| A control and its label in the menus. More... | |
Macros | |
| #define | DIRECTINPUT_VERSION 0x0500 |
| Select the DirectInput 5 declarations used by Boss Rally. | |
| #define | KEYBOARD_KEY_COUNT 256 |
| The number of keys of the state of a keyboard. | |
| #define | MOUSE_BUTTON_COUNT 4 |
| The number of buttons of the mouse the game reads. | |
| #define | JOYSTICK_CONTROL_BUTTON 0x100 |
| The control of a button of a game controller GetPressedJoystickControl() reports. | |
| #define | JOYSTICK_CONTROL_X_NEGATIVE 0x8000 |
| The control of the left of the X axis of a game controller. | |
| #define | JOYSTICK_CONTROL_X_POSITIVE 0x8100 |
| The control of the right of the X axis of a game controller. | |
| #define | JOYSTICK_CONTROL_Y_NEGATIVE 0x8200 |
| The control of the top of the Y axis of a game controller. | |
| #define | JOYSTICK_CONTROL_Y_POSITIVE 0x8300 |
| The control of the bottom of the Y axis of a game controller. | |
| #define | JOYSTICK_NAME_COUNT_A 10 |
| The number of entries of g_aJoystickButtonNamesA. | |
| #define | JOYSTICK_NAME_COUNT_B 134 |
| The number of entries of g_aJoystickButtonNamesB. | |
| #define | KEYBOARD_CONTROL_NAME_COUNT 120 |
| The number of keyboard control labels. | |
Functions | |
| void | UpdateMouseInput (void) |
| Read the mouse for the main window. | |
| int | ShowInfoMessageBox (HWND hWnd, HRESULT hResult, const char *pszText) |
| Show a message of the input with the caption of string 0xaa. | |
| bool | InitializeDirectInput (void) |
| Add a user of DirectInput. | |
| bool | TryAcquireJoystickDevice (void) |
| Acquire the DirectInput device of the game controller. | |
| HRESULT | SetJoystickPropertyDword (IDirectInputDevice2A *pDevice, REFGUID guidProperty, DWORD dwObject, DWORD dwHow, DWORD dwData) |
| Set a property of a DIPROPDWORD on a DirectInput device. | |
| HRESULT | SetJoystickAxisRange (IDirectInputDevice2A *pDevice, REFGUID guidProperty, DWORD dwObject, DWORD dwHow, LONG lMin, LONG lMax) |
| Set a property of a DIPROPRANGE on a DirectInput device. | |
| void | ReleaseKeyboardDevice (void) |
| Drop a user of the keyboard device. | |
| bool | ShutdownDirectInput (void) |
| Drop a user of DirectInput. | |
| unsigned char | IsInputBindingPressed (int nBinding) |
| Read rising edges of an active binding and its keyboard alternatives. | |
| unsigned char | IsInputBindingHeld (int nBinding) |
| Read an active binding and its keyboard alternatives. | |
| void | UpdateMouseButtonEdges (void) |
| Find the buttons of the mouse that went down since the mouse was read before. | |
| void | PollInputAndUpdateEdges (void) |
| Refresh keyboard and mouse button transitions for menu input. | |
| bool WINAPI | ResetMouseCursorToCenter (HWND hWnd) |
| Put the cursor of the mouse in the centre of the screen and clear g_MouseMenuState. | |
| int | FindControlNameIndex (int nTable, int nCode) |
| Find a control code in the keyboard or joystick label table. | |
| void | InitJoystickBindingNames (void) |
| Fill the names of the controls of a game controller. | |
| int | GetPressedMouseButton (void) |
| Read the buttons of the mouse and find the first one that went down. | |
| int | GetPressedJoystickControl (unsigned *pwControl) |
| Read the game controller and find a control that is pressed, to bind it. | |
| bool | InitializeKeyboardDevice (void) |
| Add a user of the keyboard. | |
| HRESULT | ReadKeyboardState (unsigned char *pabState) |
| Read the state of the keyboard, acquiring the device again and reading once more when the input was lost. | |
| void | ClearKeyboardStateBuffers (void) |
| Clear the state of the keyboard. | |
| void | UpdateKeyboardEdgeState (void) |
| Find the keys that went down since the keyboard was read before. | |
| void | SetForceFeedbackMagnitude (LONG lMagnitude) |
| Set both coefficients of the first spring of g_DiConditionEffect, and give the effect its new parameters when it exists. | |
| HRESULT | CreateForceFeedbackEffects (int nCoefficientX, int nCoefficientY) |
| Create the condition effect, a spring on X and Y that lasts until it stops, and the jolt effect, a square wave, of force feedback of the game controller. | |
| BOOL CALLBACK | EnumJoysticksCallback_CreateDevice (const DIDEVICEINSTANCEA *pInstance, void *pContext) |
| Create the device of the first attached game controller DirectInput enumerates, as its second interface, with the cooperation the enumeration passes and the format of DIJOYSTATE2. | |
| void | ProbeJoystickDevice (void) |
| Create and release the first game controller with force feedback on, to find whether one is attached. | |
| void | PollKeyboardState (void) |
| Read the keyboard into g_abKeyboardState and find the keys that went down. | |
| int | GetFirstPressedKeyIndex (char *pszKeyName=nullptr) |
| The first key of g_adwKeyPressedEdge pressed in this frame. | |
| bool | IsInputOrEventActive (void) |
| Whether a button of the mouse was pressed or, outside the setup of the car of network play, Return, Enter of the keypad, Left, or Right was pressed in this frame. | |
| bool | CheckForUserInput (void) |
| Whether a key or a button of the mouse was pressed in this frame. | |
Variables | |
| int | g_fHostWindowActive |
| Whether the game window has focus and can receive input. | |
| int | g_fCharInputSuppressed |
| Whether the input of characters is held back, which stops the poll of the mouse. | |
| short | g_dwMouseScrollDirection |
| The direction the hover of a menu moved last, -1 up and 1 down. | |
| unsigned short | g_wMenuHoverIndex |
| The item of a menu under the hover. | |
| DWORD | g_dwLastInputActivityTime |
| The time of the last change of the mouse, in milliseconds. | |
| MouseDevice * | g_pMousePosition |
| The mouse that was read last. | |
| MouseDevice * | g_pMouseDevice |
| The mouse, created with DirectInput. | |
| int | g_anMouseAxisRanges [8] |
| Movement ranges for the eight mouse sensitivity settings. | |
| unsigned char | g_abKeyboardState [KEYBOARD_KEY_COUNT] |
| The keys of the keyboard the game read last, as DirectInput reports them. | |
| int | g_adwKeyPressedEdge [KEYBOARD_KEY_COUNT] |
| Whether each key went down since the keyboard was read before. | |
| int | g_adwMouseButtonRaw [MOUSE_BUTTON_COUNT] |
| Whether each button of the mouse is down. | |
| int | g_adwMouseButtonPressed [MOUSE_BUTTON_COUNT] |
| Whether each button of the mouse went down since the mouse was read before. | |
| InputControlName | g_aJoystickButtonNamesA [JOYSTICK_NAME_COUNT_A] |
| The names of four buttons and six axes of a game controller. | |
| InputControlName | g_aJoystickButtonNamesB [JOYSTICK_NAME_COUNT_B] |
| The names of 128 buttons and six axes of a game controller. | |
| InputControlName | g_aKeyboardControlNames [KEYBOARD_CONTROL_NAME_COUNT] |
| The labels of the keyboard controls available for binding. | |
| int | g_bForceFeedbackAvailable |
| Whether the game controller has force feedback. | |
| LONG | g_adwForceFeedbackDirection [2] |
| The direction of the jolt, along the negative X axis. | |
The control bindings and the DirectInput devices of the PC port.
| #define DIRECTINPUT_VERSION 0x0500 |
Select the DirectInput 5 declarations used by Boss Rally.
| #define KEYBOARD_KEY_COUNT 256 |
The number of keys of the state of a keyboard.
| #define MOUSE_BUTTON_COUNT 4 |
The number of buttons of the mouse the game reads.
| #define JOYSTICK_CONTROL_BUTTON 0x100 |
The control of a button of a game controller GetPressedJoystickControl() reports.
| #define JOYSTICK_CONTROL_X_NEGATIVE 0x8000 |
The control of the left of the X axis of a game controller.
| #define JOYSTICK_CONTROL_X_POSITIVE 0x8100 |
The control of the right of the X axis of a game controller.
| #define JOYSTICK_CONTROL_Y_NEGATIVE 0x8200 |
The control of the top of the Y axis of a game controller.
| #define JOYSTICK_CONTROL_Y_POSITIVE 0x8300 |
The control of the bottom of the Y axis of a game controller.
| #define JOYSTICK_NAME_COUNT_A 10 |
The number of entries of g_aJoystickButtonNamesA.
| #define JOYSTICK_NAME_COUNT_B 134 |
The number of entries of g_aJoystickButtonNamesB.
| #define KEYBOARD_CONTROL_NAME_COUNT 120 |
The number of keyboard control labels.
| void UpdateMouseInput | ( | void | ) |
Read the mouse for the main window.
Show a message of the input with the caption of string 0xaa.
| hWnd | The window that owns the message. |
| hResult | Not read. |
| pszText | The message. |
| bool InitializeDirectInput | ( | void | ) |
Add a user of DirectInput.
The first user creates DirectInput, version 5, and the mouse, and a DirectInput that is not created shows a message.
| bool TryAcquireJoystickDevice | ( | void | ) |
Acquire the DirectInput device of the game controller.
| HRESULT SetJoystickPropertyDword | ( | IDirectInputDevice2A * | pDevice, |
| REFGUID | guidProperty, | ||
| DWORD | dwObject, | ||
| DWORD | dwHow, | ||
| DWORD | dwData ) |
Set a property of a DIPROPDWORD on a DirectInput device.
| pDevice | The device. |
| guidProperty | The property. |
| dwObject | The object of the device, or 0 for the device. |
| dwHow | How dwObject is read. |
| dwData | The value. |
| HRESULT SetJoystickAxisRange | ( | IDirectInputDevice2A * | pDevice, |
| REFGUID | guidProperty, | ||
| DWORD | dwObject, | ||
| DWORD | dwHow, | ||
| LONG | lMin, | ||
| LONG | lMax ) |
Set a property of a DIPROPRANGE on a DirectInput device.
| pDevice | The device. |
| guidProperty | The property. |
| dwObject | The object of the device, or 0 for the device. |
| dwHow | How dwObject is read. |
| lMin | The low end of the range. |
| lMax | The high end of the range. |
| void ReleaseKeyboardDevice | ( | void | ) |
Drop a user of the keyboard device.
The last user releases the device. A count that falls below 0 is set back to 0.
| bool ShutdownDirectInput | ( | void | ) |
Drop a user of DirectInput.
The last user frees the mouse and releases DirectInput.
| unsigned char IsInputBindingPressed | ( | int | nBinding | ) |
Read rising edges of an active binding and its keyboard alternatives.
| nBinding | Binding index. |
| unsigned char IsInputBindingHeld | ( | int | nBinding | ) |
Read an active binding and its keyboard alternatives.
| nBinding | Binding index. |
| void UpdateMouseButtonEdges | ( | void | ) |
Find the buttons of the mouse that went down since the mouse was read before.
| void PollInputAndUpdateEdges | ( | void | ) |
Refresh keyboard and mouse button transitions for menu input.
Put the cursor of the mouse in the centre of the screen and clear g_MouseMenuState.
| hWnd | The main window. It is not read. |
| int FindControlNameIndex | ( | int | nTable, |
| int | nCode ) |
Find a control code in the keyboard or joystick label table.
| nTable | Zero for keyboard labels, one or two for joystick table B, or three for table A. |
| nCode | The control code to locate. |
| void InitJoystickBindingNames | ( | void | ) |
Fill the names of the controls of a game controller.
A button is named with its number in the format of string 0xc3, and the axes take strings 0xc4 to 0xc9. Only the first bytes of the tables are cleared before, as in the original.
| int GetPressedMouseButton | ( | void | ) |
Read the buttons of the mouse and find the first one that went down.
| int GetPressedJoystickControl | ( | unsigned * | pwControl | ) |
Read the game controller and find a control that is pressed, to bind it.
A game controller that does not exist is created as the first one.
| pwControl | Receives JOYSTICK_CONTROL_BUTTON for a button, or the control of an axis pushed past 50. |
| bool InitializeKeyboardDevice | ( | void | ) |
Add a user of the keyboard.
The first user clears the states of the keyboard, the game controller, and the mouse, and creates and acquires the device of the system keyboard for the main window, shared in the foreground.
| HRESULT ReadKeyboardState | ( | unsigned char * | pabState | ) |
Read the state of the keyboard, acquiring the device again and reading once more when the input was lost.
| pabState | Receives the state of each key. |
| void ClearKeyboardStateBuffers | ( | void | ) |
Clear the state of the keyboard.
Only the first 64 entries of g_adwKeyPressedEdge and g_adwKeyPrevDown are cleared, as in the original.
| void UpdateKeyboardEdgeState | ( | void | ) |
Find the keys that went down since the keyboard was read before.
| void SetForceFeedbackMagnitude | ( | LONG | lMagnitude | ) |
Set both coefficients of the first spring of g_DiConditionEffect, and give the effect its new parameters when it exists.
| lMagnitude | The coefficient. |
| HRESULT CreateForceFeedbackEffects | ( | int | nCoefficientX, |
| int | nCoefficientY ) |
Create the condition effect, a spring on X and Y that lasts until it stops, and the jolt effect, a square wave, of force feedback of the game controller.
| nCoefficientX | The strength of the spring of X, 1000 as the game passes it. |
| nCoefficientY | The strength of the spring of Y, 8000 as the game passes it. |
| BOOL CALLBACK EnumJoysticksCallback_CreateDevice | ( | const DIDEVICEINSTANCEA * | pInstance, |
| void * | pContext ) |
Create the device of the first attached game controller DirectInput enumerates, as its second interface, with the cooperation the enumeration passes and the format of DIJOYSTATE2.
A step that fails is written to the debugger and releases the device.
| pInstance | The game controller. |
| pContext | The flags of cooperation. |
| void ProbeJoystickDevice | ( | void | ) |
Create and release the first game controller with force feedback on, to find whether one is attached.
The type of the input device, its bindings, and force feedback are restored after.
| void PollKeyboardState | ( | void | ) |
Read the keyboard into g_abKeyboardState and find the keys that went down.
| int GetFirstPressedKeyIndex | ( | char * | pszKeyName = nullptr | ) |
The first key of g_adwKeyPressedEdge pressed in this frame.
| pszKeyName | Not read. PollKeyCapture() passes a buffer of 256 bytes, and CheckForUserInput() passes nothing in the binaries. |
| bool IsInputOrEventActive | ( | void | ) |
Whether a button of the mouse was pressed or, outside the setup of the car of network play, Return, Enter of the keypad, Left, or Right was pressed in this frame.
| bool CheckForUserInput | ( | void | ) |
Whether a key or a button of the mouse was pressed in this frame.
|
extern |
Whether the game window has focus and can receive input.
|
extern |
Whether the input of characters is held back, which stops the poll of the mouse.
|
extern |
The direction the hover of a menu moved last, -1 up and 1 down.
|
extern |
The item of a menu under the hover.
|
extern |
The time of the last change of the mouse, in milliseconds.
|
extern |
The mouse that was read last.
|
extern |
The mouse, created with DirectInput.
|
extern |
Movement ranges for the eight mouse sensitivity settings.
|
extern |
The keys of the keyboard the game read last, as DirectInput reports them.
|
extern |
Whether each key went down since the keyboard was read before.
|
extern |
Whether each button of the mouse is down.
|
extern |
Whether each button of the mouse went down since the mouse was read before.
|
extern |
The names of four buttons and six axes of a game controller.
Its use is not recovered yet.
|
extern |
The names of 128 buttons and six axes of a game controller.
Its use is not recovered yet.
|
extern |
The labels of the keyboard controls available for binding.
|
extern |
Whether the game controller has force feedback.
|
extern |
The direction of the jolt, along the negative X axis.