Update for latest compilers and libraries

This commit is contained in:
CTurt 2015-07-25 22:42:55 +01:00
parent f826941fda
commit da319963b6
4 changed files with 117 additions and 14 deletions

View File

@ -1,6 +1,19 @@
#pragma once
#include <windows.h>
#include <winable.h>
#include <winuser.h>
// For some reason, these are not defined in winuser.h like they used to be...
#ifndef VK_OEM_MINUS
#define VK_OEM_MINUS 0xBD
#endif
#ifndef VK_OEM_COMMA
#define VK_OEM_COMMA 0xBC
#endif
#ifndef KEYEVENTF_SCANCODE
#define KEYEVENTF_SCANCODE 0x08
#endif
#define MAPVK_VK_TO_VSC 0

View File

@ -1,4 +1,37 @@
#pragma once
/*++
Copyright (c) Shaul Eizikovich. All rights reserved.
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
PURPOSE.
Module Name:
public.h
Abstract:
Public header file for the vJoy project
Developpers that need to interface with vJoy need to include this file
Author:
Environment:
kernel mode and User mode
Notes:
Revision History:
--*/
#ifndef _PUBLIC_H
#define _PUBLIC_H
// Compilation directives
#define PPJOY_MODE
@ -10,10 +43,6 @@
#include <INITGUID.H> // Definitions for controlling GUID initialization
// Sideband comunication with vJoy Device
//{781EF630-72B2-11d2-B852-00C04FAD5101}
DEFINE_GUID(GUID_DEVINTERFACE_VJOY, 0x781EF630, 0x72B2, 0x11d2, 0xB8, 0x52, 0x00, 0xC0, 0x4F, 0xAD, 0x51, 0x01);
//
// Usage example:
// CreateFile(TEXT("\\\\.\\vJoy"), GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
@ -31,7 +60,7 @@ DEFINE_GUID(GUID_DEVINTERFACE_VJOY, 0x781EF630, 0x72B2, 0x11d2, 0xB8, 0x52, 0x00
#define VER_X_ 0
#define VER_H_ 2
#define VER_M_ 0
#define VER_L_ 4
#define VER_L_ 5
#define STRINGIFY_1(x) #x
#define STRINGIFY(x) STRINGIFY_1(x)
@ -51,15 +80,34 @@ DEFINE_GUID(GUID_DEVINTERFACE_VJOY, 0x781EF630, 0x72B2, 0x11d2, 0xB8, 0x52, 0x00
#define SERIALNUMBER_STR MAKEWIDE(STRINGIFY(VER_H_)) L"." MAKEWIDE(STRINGIFY(VER_M_)) L"." MAKEWIDE(STRINGIFY(VER_L_))
// Function codes;
#define LOAD_POSITIONS 0x910
#define GETATTRIB 0x911
//#define LOAD_POSITIONS 0x910
//#define GETATTRIB 0x911
// #define GET_FFB_DATA 0x00222912 // METHOD_OUT_DIRECT + FILE_DEVICE_UNKNOWN + FILE_ANY_ACCESS
//#define SET_FFB_STAT 0x913 // METHOD_NEITHER
//#define GET_FFB_STAT 0x916
#define F_LOAD_POSITIONS 0x910
#define F_GETATTRIB 0x911
#define F_GET_FFB_DATA 0x912
#define F_SET_FFB_STAT 0x913
#define F_GET_FFB_STAT 0x916
#define F_GET_DEV_INFO 0x917
// IO Device Control codes;
#define IOCTL_VJOY_GET_ATTRIB CTL_CODE (FILE_DEVICE_UNKNOWN, GETATTRIB, METHOD_BUFFERED, FILE_WRITE_ACCESS)
#define IOCTL_VJOY_GET_ATTRIB CTL_CODE (FILE_DEVICE_UNKNOWN, GETATTRIB, METHOD_BUFFERED, FILE_WRITE_ACCESS)
#define LOAD_POSITIONS CTL_CODE (FILE_DEVICE_UNKNOWN, F_LOAD_POSITIONS, METHOD_BUFFERED, FILE_WRITE_ACCESS)
#define GET_FFB_DATA CTL_CODE (FILE_DEVICE_UNKNOWN, F_GET_FFB_DATA, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
#define SET_FFB_STAT CTL_CODE (FILE_DEVICE_UNKNOWN, F_SET_FFB_STAT, METHOD_NEITHER, FILE_ANY_ACCESS)
#define GET_FFB_STAT CTL_CODE (FILE_DEVICE_UNKNOWN, F_GET_FFB_STAT, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define GET_DEV_INFO CTL_CODE (FILE_DEVICE_UNKNOWN, F_GET_DEV_INFO, METHOD_BUFFERED, FILE_ANY_ACCESS)
#ifndef __HIDPORT_H__
// Copied from hidport.h
#define IOCTL_HID_SET_FEATURE 0xB0191
#define IOCTL_HID_WRITE_REPORT 0xB000F
#define MAX_N_DEVICES 16 // Maximum number of vJoy devices
typedef struct _HID_DEVICE_ATTRIBUTES {
ULONG Size;
@ -153,12 +201,14 @@ typedef struct _JOYSTICK_POSITION_V2
DWORD bHatsEx1; // Lower 4 bits: HAT switch or 16-bit of continuous HAT switch
DWORD bHatsEx2; // Lower 4 bits: HAT switch or 16-bit of continuous HAT switch
DWORD bHatsEx3; // Lower 4 bits: HAT switch or 16-bit of continuous HAT switch LONG lButtonsEx1; // Buttons 33-64
/// JOYSTICK_POSITION_V2 Extenssion
LONG lButtonsEx1; // Buttons 33-64
LONG lButtonsEx2; // Buttons 65-96
LONG lButtonsEx3; // Buttons 97-128
LONG lButtonsEx1; // Buttons 33-64
LONG lButtonsEx2; // Buttons 65-96
LONG lButtonsEx3; // Buttons 97-128
} JOYSTICK_POSITION_V2, *PJOYSTICK_POSITION_V2;
// HID Descriptor definitions
#define HID_USAGE_X 0x30
#define HID_USAGE_Y 0x31
@ -170,3 +220,8 @@ typedef struct _JOYSTICK_POSITION_V2
#define HID_USAGE_SL1 0x37
#define HID_USAGE_WHL 0x38
#define HID_USAGE_POV 0x39
#endif

View File

@ -21,6 +21,35 @@ enum VjdStat /* Declares an enumeration data type called BOOLEAN */
VJD_STAT_MISS, // The vJoy Device is missing. It either does not exist or the driver is down.
VJD_STAT_UNKN // Unknown
};
/* Error codes for some of the functions */
#define NO_HANDLE_BY_INDEX -1
#define BAD_PREPARSED_DATA -2
#define NO_CAPS -3
#define BAD_N_BTN_CAPS -4
#define BAD_CALLOC -5
#define BAD_BTN_CAPS -6
#define BAD_BTN_RANGE -7
#define BAD_N_VAL_CAPS -8
#define BAD_ID_RANGE -9
#define NO_SUCH_AXIS -10
/* Environment Variables */
#define INTERFACE_LOG_LEVEL "VJOYINTERFACELOGLEVEL"
#define INTERFACE_LOG_FILE "VJOYINTERFACELOGFILE"
#define INTERFACE_DEF_LOG_FILE "vJoyInterface.log"
struct DEV_INFO {
BYTE DeviceID; // Device ID: Valid values are 1-16
BYTE nImplemented; // Number of implemented device: Valid values are 1-16
BYTE isImplemented; // Is this device implemented?
BYTE MaxDevices; // Maximum number of devices that may be implemented (16)
BYTE DriverFFB; // Does this driver support FFB (False)
BYTE DeviceFFB; // Does this device support FFB (False)
} ;
typedef void (CALLBACK *RemovalCB)(BOOL, BOOL, PVOID);
#endif
///////////////////////////// vJoy device (collection) Control interface /////////////////////////////////
/*
@ -40,6 +69,8 @@ VJOYINTERFACE_API BOOL __cdecl vJoyEnabled(void);
VJOYINTERFACE_API PVOID __cdecl GetvJoyProductString(void);
VJOYINTERFACE_API PVOID __cdecl GetvJoyManufacturerString(void);
VJOYINTERFACE_API PVOID __cdecl GetvJoySerialNumberString(void);
VJOYINTERFACE_API BOOL __cdecl DriverMatch(WORD * DllVer, WORD * DrvVer);
VJOYINTERFACE_API VOID __cdecl RegisterRemovalCB(RemovalCB cb, PVOID data);
///// vJoy Device properties
@ -70,4 +101,4 @@ VJOYINTERFACE_API BOOL __cdecl ResetPovs(UINT rID); // Reset all POV Switches
VJOYINTERFACE_API BOOL __cdecl SetAxis(LONG Value, UINT rID, UINT Axis); // Write Value to a given axis defined in the specified VDJ
VJOYINTERFACE_API BOOL __cdecl SetBtn(BOOL Value, UINT rID, UCHAR nBtn); // Write Value to a given button defined in the specified VDJ
VJOYINTERFACE_API BOOL __cdecl SetDiscPov(int Value, UINT rID, UCHAR nPov); // Write Value to a given descrete POV defined in the specified VDJ
VJOYINTERFACE_API BOOL __cdecl SetContPov(DWORD Value, UINT rID, UCHAR nPov); // Write Value to a given continuous POV defined in the specified VDJ
VJOYINTERFACE_API BOOL __cdecl SetContPov(DWORD Value, UINT rID, UCHAR nPov); // Write Value to a given continuous POV defined in the specified VDJ

View File

@ -1,5 +1,9 @@
#include "keys.h"
// Sideband comunication with vJoy Device
//{781EF630-72B2-11d2-B852-00C04FAD5101}
DEFINE_GUID(GUID_DEVINTERFACE_VJOY, 0x781EF630, 0x72B2, 0x11d2, 0xB8, 0x52, 0x00, 0xC0, 0x4F, 0xAD, 0x51, 0x01);
unsigned int lastKeys;
unsigned int currentKeys;