-
Notifications
You must be signed in to change notification settings - Fork 13
Polling of input states
FPL supports manual polling of input states for Keyboard/Gamepad/Mouse as well.
If you only use polling to get your input states, you should disable the input-events entirely.
This is done by simply setting the fplInputSettings::disabledEvents to "1" in your fplSettings structure.
Use fplPollKeyboardState to poll the current keyboard state.
This state contains all the raw/mapped button states and the modifier states.
keyboardState;
if ((&keyboardState)) {
if (keyboardState.[] >= ) {
// Spacebar pressed
}
}See fplKeyboardState for more details.
Use fplPollGamepadStates to poll the current states for all connected game controllers.
This state contains all the buttons, digital-pad, the left/right stick position + trigger, etc.
gamepadStates;
if ((&gamepadStates)) {
for (int index = 0; index < (gamepadStates.); ++index) {
*gamepadState = gamepadStates. + index;
// ... do something with the gamepad state
}
}See fplGamepadStates for more details.
Note: use
fplGamepadState::isConnected to check if the gamepad is connected or not.
Use fplPollMouseState to poll the current mouse state.
This state contains the state of all the buttons (Left, Right, Middle) and the position in pixels coordinates.
mouseState;
if ((&mouseState)) {
int mousePosX = mouseState.;
int mousePosY = mouseState.;
if (mouseState.[] >= fplButtonState_Pressed) {
// Left mouse button down
}
}See fplMouseState for more details.
Note: You can always use all those polling functions, regardless of the
When the application runs without a window (FPL_NO_WINDOW or fplInputSettings::detachFromWindow), the input subsystem is not driven by a window event loop. Call fplUpdateInputDevices once per frame to refresh cached state and dispatch gamepad connect/disconnect events. fplPollEvent and fplPollEvents also work in this mode and drive the input subsystem internally.
See Using input without a window for a full example.
- Assertion & Debug
- Atomic operations
- Audio functions
- Clipboard functions
- Console functions
- Constants
- Display/Monitor functions
- Dynamic library loading
- Error Handling
- Files/IO functions
- Function macros
- Hardware Infos
- Input types and functions
- Localization functions
- Logging
- Memory Macros
- Memory functions
- Operating system Infos
- Path functions
- Platform functions
- Session Infos
- Settings & Configurations
- Storage class identifiers
- String functions
- Threading and synchronizations routines
- Timing functions
- Video functions
- Window events
- Window functions
- fplARMCPUCapabilities
- fplAudioChannelMap
- fplAudioDeviceID
- fplAudioDeviceInfo
- fplAudioFormat
- fplAudioSettings
- fplColor32
- fplConditionVariable
- fplConsoleSettings
- fplCPUCapabilities
- fplCPUIDLeaf
- fplDateTime
- fplDateTimeCreationResult
- fplDateTimeResult
- fplDisplayInfo
- fplDisplayMode
- fplDynamicLibraryHandle
- fplEndianess
- fplEvent
- fplFileEntry
- fplFileHandle
- fplFilePermissions
- fplFileTimeStamps
- fplGamepadButton
- fplGamepadData
- fplGamepadEvent
- fplGamepadInfo
- fplGamepadInputBinding
- fplGamepadMapping
- fplGamepadSettings
- fplGamepadState
- fplGamepadStates
- fplGraphicsApiSettings
- fplImageSource
- fplInputBackendMask
- fplInputBackendSupport
- fplInputDevice
- fplInputDeviceGuid
- fplInputSettings
- fplInternalConditionVariable
- fplInternalDynamicLibraryHandle
- fplInternalFileEntryHandle
- fplInternalFileHandle
- fplInternalFileRootInfo
- fplInternalMutexHandle
- fplInternalSemaphoreHandle
- fplInternalSignalHandle
- fplInternalThreadHandle
- fplKeyboardEvent
- fplKeyboardState
- fplLogSettings
- fplLogWriter
- fplLogWriterConsole
- fplLogWriterCustom
- fplMemoryAllocationSettings
- fplMemoryBlock
- fplMemoryInfos
- fplMemorySettings
- fplMouseEvent
- fplMouseState
- fplMutexHandle
- fplOpenGLSettings
- fplOSVersionInfos
- fplSemaphoreHandle
- fplSettings
- fplSignalHandle
- fplSpecificAudioSettings
- fplThreadHandle
- fplThreadParameters
- fplTimestamp
- fplVersionInfo
- fplVideoBackBuffer
- fplVideoRect
- fplVideoRequirements
- fplVideoRequirementsVulkan
- fplVideoSettings
- fplVideoSurface
- fplVideoSurfaceOpenGL
- fplVideoSurfaceVulkan
- fplVideoWindow
- fplVulkanSettings
- fplWindowCallbacks
- fplWindowDropFiles
- fplWindowEvent
- fplWindowPosition
- fplWindowSettings
- fplWindowSize
- fplX86CPUCapabilities