Moved some code around and cleaned things a bit.
This commit is contained in:
52
src/platform/platform.h
Normal file
52
src/platform/platform.h
Normal file
@ -0,0 +1,52 @@
|
||||
// Copyright (c) 2021 Dominic Msters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include <malloc.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef void platforminputsource_t;
|
||||
|
||||
/**
|
||||
* Platform stuct, contains information about the device/method that is running
|
||||
* the program that the game itself is running on, typically this will be either
|
||||
* the operating system, or perhaps the specific device information.
|
||||
*/
|
||||
typedef struct {
|
||||
/** Internal name of the platform */
|
||||
char *name;
|
||||
|
||||
/** List of known input sources */
|
||||
platforminputsource_t **inputSources;
|
||||
/** Count of known input source */
|
||||
uint32_t *inputSourceCount;
|
||||
/** State of the input sources, updated by the platform. */
|
||||
float *inputStates;
|
||||
} platform_t;
|
||||
|
||||
/**
|
||||
* Initialize the current platform context. The platform itself is responsible
|
||||
* for deciding how this method is implemented.
|
||||
*
|
||||
* @return The context information for the platform.
|
||||
*/
|
||||
platform_t * platformInit();
|
||||
|
||||
/**
|
||||
* Cleanup a previously created platform instance.
|
||||
*
|
||||
* @param platform The platform instance to cleanse.
|
||||
*/
|
||||
void platformDispose(platform_t *platform);
|
||||
|
||||
/**
|
||||
* Method will be polled for each known input source to request the current
|
||||
* state from the device. Values returned will be defined within the 0 to 1
|
||||
* range.
|
||||
*
|
||||
* @param source The input source.
|
||||
* @return Input state between 0 and 1.
|
||||
*/
|
||||
float platformInputGetState(platforminputsource_t *source);
|
26
src/platform/win32/win32platform.c
Normal file
26
src/platform/win32/win32platform.c
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright (c) 2021 Dominic Msters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "win32platform.h"
|
||||
|
||||
platform_t * platformInit() {
|
||||
platform_t *platform = malloc(sizeof(platform_t));
|
||||
|
||||
platform->name = WIN32_NAME;
|
||||
|
||||
platform->inputSourceCount = 0;
|
||||
platform->inputSources = NULL;
|
||||
platform->inputStates = NULL;
|
||||
|
||||
return platform;
|
||||
}
|
||||
|
||||
void platformDispose(platform_t *platform) {
|
||||
free(platform);
|
||||
}
|
||||
|
||||
float platformInputGetState(platforminputsource_t *source) {
|
||||
return 0;
|
||||
}
|
9
src/platform/win32/win32platform.h
Normal file
9
src/platform/win32/win32platform.h
Normal file
@ -0,0 +1,9 @@
|
||||
// Copyright (c) 2021 Dominic Msters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "../platform.h"
|
||||
|
||||
#define WIN32_NAME "Win32"
|
Reference in New Issue
Block a user