Moved some code around and cleaned things a bit.

This commit is contained in:
2021-02-22 08:08:12 +11:00
parent 424577f835
commit adc7f5e208
14 changed files with 405 additions and 77 deletions

52
src/platform/platform.h Normal file
View 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);

View 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;
}

View 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"