⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wince_input.c

📁 这个是延伸mame的在wince平台下的游戏模拟器的代码
💻 C
字号:
/* PocketCultMAME - MAME Emulator for PocketPC
   (c) Copyright 2006 Manuel Castrillo Mart韓ez

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include "driver.h"
#include "vidsys.h"

#include "wince_input.h"
#include "wince_events.h"
#include "wince_cfg.h"

extern VidSysInfo VideoInfo;
extern cfgStruct GameConfig;

PadMappingStruct PadMapping;
PadMappingStruct rotatedPadMapping;
PadMappingStruct PadStatus;

int AutofireSpeeds[] = { 1, 4, 8 };
int AutofireCount = 0;
extern int frameCount;  // one shot per frame
int oldFrameCount;

int checkKey( int code )
{

	if( PadStatus.Up == code ) return(code);
	if( PadStatus.Down == code ) return(code);
	if( PadStatus.Left == code ) return(code);
	if( PadStatus.Right == code ) return(code);
	if( PadStatus.KeyA == code ) return(code);
	if( PadStatus.KeyB == code ) return(code);
	if( PadStatus.KeyC == code ) return(code);
	if( PadStatus.KeyD == code ) return(code);
	if( PadStatus.KeyE == code ) return(code);
	if( PadStatus.KeyF == code ) return(code);
	if( PadStatus.KeyG == code ) return(code);
	if( PadStatus.OnscreenRed == code ) return(code);
	if( PadStatus.OnscreenGreen == code ) return(code);
	if( PadStatus.OnscreenYellow == code ) return(code);

	return(0);
}


int osd_key_pressed(int keycode)
{
	return( checkKey(keycode) );
}

int osd_joy_pressed(int joycode)
{
	
	// Checks autofire if is FIRE_A pressed and the key requested

	if( joycode == OSD_JOY_FIRE1 && checkKey(OSD_JOY_FIRE1) && GameConfig.inpAutofire != AUTOFIRE_DISABLED )
	{
		if( oldFrameCount != frameCount )
		{
			oldFrameCount = frameCount;

			if( AutofireCount > 0 )
			{
				AutofireCount--;
				return(0);
			}
			else
			{
				AutofireCount = AutofireSpeeds[ GameConfig.inpAutofire ];
				return(joycode);
			}
		}
	}

	// Checks requested keypress

	return( checkKey(joycode) );

}

void osd_led_w(int led,int on)
{
}

void osd_trak_read(int *deltax,int *deltay)
{
	if ( GameConfig.inpAnalogControls != ANALOG_TRACKSTYLUS ) *deltax = *deltay = 0;
	else stylusMovement(deltax,deltay);
}

void osd_analogjoy_read(int *analog_x, int *analog_y)
{
	switch( GameConfig.inpAnalogControls )
	{
		case ANALOG_JOYPAD :
			*analog_x = 0;
			*analog_y = 0;
			if( checkKey( OSD_JOY_RIGHT ) ) *analog_x = 128;
			if( checkKey( OSD_JOY_LEFT ) ) *analog_x = -128;
			if( checkKey( OSD_JOY_UP ) ) *analog_y = -128;
			if( checkKey( OSD_JOY_DOWN ) ) *analog_y = 128;
			break;

		case ANALOG_JOYSTYLUS :
			stylusJoystick( analog_x, analog_y );
			break;

		default :
			*analog_x = 0;
			*analog_y = 0;
			break;
	}
}

void osd_poll_joystick(void)
{
}

void RotatePadMapping(void)
{
    
	switch( VideoInfo.Rotation )
	{
		case ROTATION_0 :
			rotatedPadMapping.Up    = PadMapping.Up;
			rotatedPadMapping.Down  = PadMapping.Down;
			rotatedPadMapping.Left  = PadMapping.Left;
			rotatedPadMapping.Right = PadMapping.Right;
			break;

		case ROTATION_CW90 :
			rotatedPadMapping.Up    = PadMapping.Left;
			rotatedPadMapping.Down  = PadMapping.Right;
			rotatedPadMapping.Left  = PadMapping.Down;
			rotatedPadMapping.Right = PadMapping.Up;
			break;

		case ROTATION_ACW90 :
			rotatedPadMapping.Up    = PadMapping.Right;
			rotatedPadMapping.Down  = PadMapping.Left;
			rotatedPadMapping.Left  = PadMapping.Up;
			rotatedPadMapping.Right = PadMapping.Down;
			break;
	}

	rotatedPadMapping.KeyA  = PadMapping.KeyA;
	rotatedPadMapping.KeyB  = PadMapping.KeyB;
	rotatedPadMapping.KeyC  = PadMapping.KeyC;
	rotatedPadMapping.KeyD  = PadMapping.KeyD;
	rotatedPadMapping.KeyE  = PadMapping.KeyE;
	rotatedPadMapping.KeyF  = PadMapping.KeyF;
	rotatedPadMapping.KeyG  = PadMapping.KeyG;

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -