Switches to SDL2

This commit is contained in:
mkwong98 2015-01-14 00:38:38 +08:00
parent 29bdcedf5c
commit c2255e0696
8 changed files with 81 additions and 78 deletions

View file

@ -13,7 +13,7 @@ fraHDNesImp::fraHDNesImp():fraHDNes(NULL){
wxInitAllImageHandlers();
screenTileCache = NULL;
for(int i = SDLK_FIRST; i < SDLK_LAST; i++){
for(int i = 0; i < SDL_NUM_SCANCODES; i++){
keycodes[i] = i;
}
@ -87,16 +87,16 @@ void fraHDNesImp::refreshGUI(){
void fraHDNesImp::addKeyCode(wxChoice* cbobox){
string keyname;
for(int i = SDLK_FIRST; i < SDLK_LAST; i++){
keyname = string(SDL_GetKeyName((SDLKey)i));
if(keyname.compare("unknown key") != 0){
for(int i = 0; i < SDL_NUM_SCANCODES; i++){
keyname = string(SDL_GetScancodeName((SDL_Scancode)i));
if(keyname.compare("") != 0){
cbobox->Append(wxString(keyname.c_str(), wxConvUTF8), &(keycodes[i]));
}
}
}
void fraHDNesImp::showKeyCode(wxChoice* cbobox, SDLKey key){
cbobox->SetSelection(cbobox->FindString(wxString(SDL_GetKeyName(key), wxConvUTF8)));
void fraHDNesImp::showKeyCode(wxChoice* cbobox, SDL_Scancode key){
cbobox->SetSelection(cbobox->FindString(wxString(SDL_GetScancodeName(key), wxConvUTF8)));
}
@ -255,99 +255,99 @@ void fraHDNesImp::powerButtonClicked( wxCommandEvent& event ) {
}
void fraHDNesImp::input1UP( wxCommandEvent& event ){
inputCore->controller[0][BUTTON_UP].assignedKey = (*(SDLKey*)(cbo1UP->GetClientData(cbo1UP->GetCurrentSelection())));
inputCore->controller[0][BUTTON_UP].assignedKey = (*(SDL_Scancode*)(cbo1UP->GetClientData(cbo1UP->GetCurrentSelection())));
}
void fraHDNesImp::input1DOWN( wxCommandEvent& event ){
inputCore->controller[0][BUTTON_DOWN].assignedKey = (*(SDLKey*)(cbo1DOWN->GetClientData(cbo1DOWN->GetCurrentSelection())));
inputCore->controller[0][BUTTON_DOWN].assignedKey = (*(SDL_Scancode*)(cbo1DOWN->GetClientData(cbo1DOWN->GetCurrentSelection())));
}
void fraHDNesImp::input1LEFT( wxCommandEvent& event ){
inputCore->controller[0][BUTTON_LEFT].assignedKey = (*(SDLKey*)(cbo1LEFT->GetClientData(cbo1LEFT->GetCurrentSelection())));
inputCore->controller[0][BUTTON_LEFT].assignedKey = (*(SDL_Scancode*)(cbo1LEFT->GetClientData(cbo1LEFT->GetCurrentSelection())));
}
void fraHDNesImp::input1RIGHT( wxCommandEvent& event ){
inputCore->controller[0][BUTTON_RIGHT].assignedKey = (*(SDLKey*)(cbo1RIGHT->GetClientData(cbo1RIGHT->GetCurrentSelection())));
inputCore->controller[0][BUTTON_RIGHT].assignedKey = (*(SDL_Scancode*)(cbo1RIGHT->GetClientData(cbo1RIGHT->GetCurrentSelection())));
}
void fraHDNesImp::input1A( wxCommandEvent& event ){
inputCore->controller[0][BUTTON_A].assignedKey = (*(SDLKey*)(cbo1A->GetClientData(cbo1A->GetCurrentSelection())));
inputCore->controller[0][BUTTON_A].assignedKey = (*(SDL_Scancode*)(cbo1A->GetClientData(cbo1A->GetCurrentSelection())));
}
void fraHDNesImp::input1B( wxCommandEvent& event ){
inputCore->controller[0][BUTTON_B].assignedKey = (*(SDLKey*)(cbo1B->GetClientData(cbo1B->GetCurrentSelection())));
inputCore->controller[0][BUTTON_B].assignedKey = (*(SDL_Scancode*)(cbo1B->GetClientData(cbo1B->GetCurrentSelection())));
}
void fraHDNesImp::input1SELECT( wxCommandEvent& event ){
inputCore->controller[0][BUTTON_SELECT].assignedKey = (*(SDLKey*)(cbo1SELECT->GetClientData(cbo1SELECT->GetCurrentSelection())));
inputCore->controller[0][BUTTON_SELECT].assignedKey = (*(SDL_Scancode*)(cbo1SELECT->GetClientData(cbo1SELECT->GetCurrentSelection())));
}
void fraHDNesImp::input1START( wxCommandEvent& event ){
inputCore->controller[0][BUTTON_START].assignedKey = (*(SDLKey*)(cbo1START->GetClientData(cbo1START->GetCurrentSelection())));
inputCore->controller[0][BUTTON_START].assignedKey = (*(SDL_Scancode*)(cbo1START->GetClientData(cbo1START->GetCurrentSelection())));
}
void fraHDNesImp::input2UP( wxCommandEvent& event ){
inputCore->controller[1][BUTTON_UP].assignedKey = (*(SDLKey*)(cbo2UP->GetClientData(cbo2UP->GetCurrentSelection())));
inputCore->controller[1][BUTTON_UP].assignedKey = (*(SDL_Scancode*)(cbo2UP->GetClientData(cbo2UP->GetCurrentSelection())));
}
void fraHDNesImp::input2DOWN( wxCommandEvent& event ){
inputCore->controller[1][BUTTON_DOWN].assignedKey = (*(SDLKey*)(cbo2DOWN->GetClientData(cbo2DOWN->GetCurrentSelection())));
inputCore->controller[1][BUTTON_DOWN].assignedKey = (*(SDL_Scancode*)(cbo2DOWN->GetClientData(cbo2DOWN->GetCurrentSelection())));
}
void fraHDNesImp::input2LEFT( wxCommandEvent& event ){
inputCore->controller[1][BUTTON_LEFT].assignedKey = (*(SDLKey*)(cbo2LEFT->GetClientData(cbo2LEFT->GetCurrentSelection())));
inputCore->controller[1][BUTTON_LEFT].assignedKey = (*(SDL_Scancode*)(cbo2LEFT->GetClientData(cbo2LEFT->GetCurrentSelection())));
}
void fraHDNesImp::input2RIGHT( wxCommandEvent& event ){
inputCore->controller[1][BUTTON_RIGHT].assignedKey = (*(SDLKey*)(cbo2RIGHT->GetClientData(cbo2RIGHT->GetCurrentSelection())));
inputCore->controller[1][BUTTON_RIGHT].assignedKey = (*(SDL_Scancode*)(cbo2RIGHT->GetClientData(cbo2RIGHT->GetCurrentSelection())));
}
void fraHDNesImp::input2A( wxCommandEvent& event ){
inputCore->controller[1][BUTTON_A].assignedKey = (*(SDLKey*)(cbo2A->GetClientData(cbo2A->GetCurrentSelection())));
inputCore->controller[1][BUTTON_A].assignedKey = (*(SDL_Scancode*)(cbo2A->GetClientData(cbo2A->GetCurrentSelection())));
}
void fraHDNesImp::input2B( wxCommandEvent& event ){
inputCore->controller[1][BUTTON_B].assignedKey = (*(SDLKey*)(cbo2B->GetClientData(cbo2B->GetCurrentSelection())));
inputCore->controller[1][BUTTON_B].assignedKey = (*(SDL_Scancode*)(cbo2B->GetClientData(cbo2B->GetCurrentSelection())));
}
void fraHDNesImp::input2SELECT( wxCommandEvent& event ){
inputCore->controller[1][BUTTON_SELECT].assignedKey = (*(SDLKey*)(cbo2SELECT->GetClientData(cbo2SELECT->GetCurrentSelection())));
inputCore->controller[1][BUTTON_SELECT].assignedKey = (*(SDL_Scancode*)(cbo2SELECT->GetClientData(cbo2SELECT->GetCurrentSelection())));
}
void fraHDNesImp::input2START( wxCommandEvent& event ){
inputCore->controller[1][BUTTON_START].assignedKey = (*(SDLKey*)(cbo2START->GetClientData(cbo2START->GetCurrentSelection())));
inputCore->controller[1][BUTTON_START].assignedKey = (*(SDL_Scancode*)(cbo2START->GetClientData(cbo2START->GetCurrentSelection())));
}
void fraHDNesImp::inputEndGame( wxCommandEvent& event ){
inputCore->setting[SETTING_END_EMU].assignedKey = (*(SDLKey*)(cboEndGame->GetClientData(cboEndGame->GetCurrentSelection())));
inputCore->setting[SETTING_END_EMU].assignedKey = (*(SDL_Scancode*)(cboEndGame->GetClientData(cboEndGame->GetCurrentSelection())));
}
void fraHDNesImp::inputSaveState( wxCommandEvent& event ){
inputCore->setting[SETTING_SAVE_STATE].assignedKey = (*(SDLKey*)(cboSaveState->GetClientData(cboSaveState->GetCurrentSelection())));
inputCore->setting[SETTING_SAVE_STATE].assignedKey = (*(SDL_Scancode*)(cboSaveState->GetClientData(cboSaveState->GetCurrentSelection())));
}
void fraHDNesImp::inputLoadState( wxCommandEvent& event ){
inputCore->setting[SETTING_LOAD_STATE].assignedKey = (*(SDLKey*)(cboLoadState->GetClientData(cboLoadState->GetCurrentSelection())));
inputCore->setting[SETTING_LOAD_STATE].assignedKey = (*(SDL_Scancode*)(cboLoadState->GetClientData(cboLoadState->GetCurrentSelection())));
}
void fraHDNesImp::inputScreenCap( wxCommandEvent& event ){
inputCore->setting[SETTING_SCREENCAP].assignedKey = (*(SDLKey*)(cboScreenCap->GetClientData(cboScreenCap->GetCurrentSelection())));
inputCore->setting[SETTING_SCREENCAP].assignedKey = (*(SDL_Scancode*)(cboScreenCap->GetClientData(cboScreenCap->GetCurrentSelection())));
}
void fraHDNesImp::inputDataCap( wxCommandEvent& event ){
inputCore->setting[SETTING_CAP_DATA].assignedKey = (*(SDLKey*)(cboDataCap->GetClientData(cboDataCap->GetCurrentSelection())));
inputCore->setting[SETTING_CAP_DATA].assignedKey = (*(SDL_Scancode*)(cboDataCap->GetClientData(cboDataCap->GetCurrentSelection())));
}
void fraHDNesImp::inputPause( wxCommandEvent& event ){
inputCore->setting[SETTING_PAUSE].assignedKey = (*(SDLKey*)(cboPause->GetClientData(cboPause->GetCurrentSelection())));
inputCore->setting[SETTING_PAUSE].assignedKey = (*(SDL_Scancode*)(cboPause->GetClientData(cboPause->GetCurrentSelection())));
}
void fraHDNesImp::inputRunFrame( wxCommandEvent& event ){
inputCore->setting[SETTING_RUN_FRAME].assignedKey = (*(SDLKey*)(cboRunFrame->GetClientData(cboRunFrame->GetCurrentSelection())));
inputCore->setting[SETTING_RUN_FRAME].assignedKey = (*(SDL_Scancode*)(cboRunFrame->GetClientData(cboRunFrame->GetCurrentSelection())));
}
void fraHDNesImp::inputContCap( wxCommandEvent& event ){
inputCore->setting[SETTING_CONT_CAP].assignedKey = (*(SDLKey*)(cboContCap->GetClientData(cboContCap->GetCurrentSelection())));
inputCore->setting[SETTING_CONT_CAP].assignedKey = (*(SDL_Scancode*)(cboContCap->GetClientData(cboContCap->GetCurrentSelection())));
}
void fraHDNesImp::capRateChange( wxSpinEvent& event ) {

View file

@ -86,9 +86,9 @@ protected:
public:
fraHDNesImp();
~fraHDNesImp();
int keycodes[SDLK_LAST];
int keycodes[SDL_NUM_SCANCODES];
void addKeyCode(wxChoice* cbobox);
void showKeyCode(wxChoice* cbobox, SDLKey key);
void showKeyCode(wxChoice* cbobox, SDL_Scancode key);
void refreshGUI();
void refreshInputGUI();
void refreshVideoGUI();

View file

@ -40,13 +40,13 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>C:\Users\mkwong98\Documents\Visual Studio 2010\common include;$(IncludePath)</IncludePath>
<LibraryPath>C:\Users\mkwong98\Documents\Visual Studio 2010\SDL_mixer\lib\x86;C:\Users\mkwong98\Documents\Visual Studio 2010\glew-1.6.0\lib;C:\SourceCode\Libraries\wxWidgets2.8\lib\vc_lib;C:\Users\mkwong98\Documents\Visual Studio 2010\SDL_image-1.2.12\lib\x86;C:\Users\mkwong98\Documents\Visual Studio 2010\SDL-1.2.14\lib;$(LibraryPath)</LibraryPath>
<LibraryPath>C:\Users\mkwong98\Documents\Visual Studio 2010\glew-1.6.0\lib;C:\SourceCode\Libraries\wxWidgets2.8\lib\vc_lib;C:\Users\mkwong98\Documents\Visual Studio 2010\SDL2_image-2.0.0\lib\x86;C:\Users\mkwong98\Documents\Visual Studio 2010\SDL2_mixer-2.0.0\lib\x86;C:\Users\mkwong98\Documents\Visual Studio 2010\SDL2-2.0.3\lib\x86;$(LibraryPath)</LibraryPath>
<SourcePath>C:\Users\mkwong98\Documents\Visual Studio 2010\Projects\hdnes\wxwidget;$(SourcePath)</SourcePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>C:\Users\mkwong98\Documents\Visual Studio 2010\common include;$(IncludePath)</IncludePath>
<LibraryPath>C:\Users\mkwong98\Documents\Visual Studio 2010\SDL_image-1.2.12\lib\x86;C:\Users\mkwong98\Documents\Visual Studio 2010\glew-1.6.0\lib;C:\SourceCode\Libraries\wxWidgets2.8\lib\vc_lib;C:\Users\mkwong98\Documents\Visual Studio 2010\SDL_mixer\lib\x86;C:\Users\mkwong98\Documents\Visual Studio 2010\SDL-1.2.14\lib;$(LibraryPath)</LibraryPath>
<LibraryPath>C:\Users\mkwong98\Documents\Visual Studio 2010\glew-1.6.0\lib;C:\SourceCode\Libraries\wxWidgets2.8\lib\vc_lib;C:\Users\mkwong98\Documents\Visual Studio 2010\SDL2_image-2.0.0\lib\x86;C:\Users\mkwong98\Documents\Visual Studio 2010\SDL2_mixer-2.0.0\lib\x86;C:\Users\mkwong98\Documents\Visual Studio 2010\SDL2-2.0.3\lib\x86;$(LibraryPath)</LibraryPath>
<SourcePath>C:\Users\mkwong98\Documents\Visual Studio 2010\Projects\hdnes\wxwidget;$(SourcePath)</SourcePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
@ -67,7 +67,7 @@
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>sdl.lib;sdlmain.lib;opengl32.lib;glew32.lib;glu32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;comctl32.lib;rpcrt4.lib;wsock32.lib;winmm.lib;wxmsw28ud_core.lib;wxbase28ud.lib;Shlwapi.lib;SDL_image.lib;wxpngd.lib;wxtiffd.lib;wxzlibd.lib;wxjpegd.lib;SDL_mixer.lib</AdditionalDependencies>
<AdditionalDependencies>sdl2.lib;sdl2main.lib;opengl32.lib;glew32.lib;glu32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;comctl32.lib;rpcrt4.lib;wsock32.lib;winmm.lib;wxmsw28ud_core.lib;wxbase28ud.lib;Shlwapi.lib;SDL2_image.lib;wxpngd.lib;wxtiffd.lib;wxzlibd.lib;wxjpegd.lib;SDL2_mixer.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>C:\SourceCode\Libraries\wxWidgets2.8\contrib\lib;C:\SourceCode\Libraries\wxWidgets2.8\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<LinkTimeCodeGeneration>PGOptimization</LinkTimeCodeGeneration>
@ -94,7 +94,7 @@
<GenerateDebugInformation>false</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>sdl.lib;sdlmain.lib;opengl32.lib;glew32.lib;glu32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;comctl32.lib;rpcrt4.lib;wsock32.lib;winmm.lib;wxmsw28u_core.lib;wxbase28u.lib;Shlwapi.lib;SDL_image.lib;wxpngd.lib;wxtiffd.lib;wxzlibd.lib;wxjpegd.lib;SDL_mixer.lib</AdditionalDependencies>
<AdditionalDependencies>sdl2.lib;sdl2main.lib;opengl32.lib;glew32.lib;glu32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;comctl32.lib;rpcrt4.lib;wsock32.lib;winmm.lib;wxmsw28u_core.lib;wxbase28u.lib;Shlwapi.lib;SDL2_image.lib;wxpngd.lib;wxtiffd.lib;wxzlibd.lib;wxjpegd.lib;SDL2_mixer.lib</AdditionalDependencies>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<IgnoreSpecificDefaultLibraries>libcd.lib;libcid.lib;msvcrt.lib;LIBCMTD.lib</IgnoreSpecificDefaultLibraries>
<AdditionalLibraryDirectories>C:\SourceCode\Libraries\wxWidgets2.8\contrib\lib;C:\SourceCode\Libraries\wxWidgets2.8\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>

View file

@ -4,33 +4,33 @@
input::input(void)
{
controller[0][BUTTON_A].assignedKey = SDLK_z;
controller[0][BUTTON_B].assignedKey = SDLK_x;
controller[0][BUTTON_SELECT].assignedKey = SDLK_a;
controller[0][BUTTON_START].assignedKey = SDLK_s;
controller[0][BUTTON_UP].assignedKey = SDLK_UP;
controller[0][BUTTON_DOWN].assignedKey = SDLK_DOWN;
controller[0][BUTTON_LEFT].assignedKey = SDLK_LEFT;
controller[0][BUTTON_RIGHT].assignedKey = SDLK_RIGHT;
controller[0][BUTTON_A].assignedKey = SDL_SCANCODE_Z;
controller[0][BUTTON_B].assignedKey = SDL_SCANCODE_X;
controller[0][BUTTON_SELECT].assignedKey = SDL_SCANCODE_A;
controller[0][BUTTON_START].assignedKey = SDL_SCANCODE_S;
controller[0][BUTTON_UP].assignedKey = SDL_SCANCODE_UP;
controller[0][BUTTON_DOWN].assignedKey = SDL_SCANCODE_DOWN;
controller[0][BUTTON_LEFT].assignedKey = SDL_SCANCODE_LEFT;
controller[0][BUTTON_RIGHT].assignedKey = SDL_SCANCODE_RIGHT;
controller[1][BUTTON_A].assignedKey = SDLK_UNKNOWN;
controller[1][BUTTON_B].assignedKey = SDLK_UNKNOWN;
controller[1][BUTTON_SELECT].assignedKey = SDLK_UNKNOWN;
controller[1][BUTTON_START].assignedKey = SDLK_UNKNOWN;
controller[1][BUTTON_UP].assignedKey = SDLK_UNKNOWN;
controller[1][BUTTON_DOWN].assignedKey = SDLK_UNKNOWN;
controller[1][BUTTON_LEFT].assignedKey = SDLK_UNKNOWN;
controller[1][BUTTON_RIGHT].assignedKey = SDLK_UNKNOWN;
controller[1][BUTTON_A].assignedKey = SDL_SCANCODE_UNKNOWN;
controller[1][BUTTON_B].assignedKey = SDL_SCANCODE_UNKNOWN;
controller[1][BUTTON_SELECT].assignedKey = SDL_SCANCODE_UNKNOWN;
controller[1][BUTTON_START].assignedKey = SDL_SCANCODE_UNKNOWN;
controller[1][BUTTON_UP].assignedKey = SDL_SCANCODE_UNKNOWN;
controller[1][BUTTON_DOWN].assignedKey = SDL_SCANCODE_UNKNOWN;
controller[1][BUTTON_LEFT].assignedKey = SDL_SCANCODE_UNKNOWN;
controller[1][BUTTON_RIGHT].assignedKey = SDL_SCANCODE_UNKNOWN;
setting[SETTING_SCREENCAP].assignedKey = SDLK_PRINT;
setting[SETTING_END_EMU].assignedKey = SDLK_ESCAPE;
setting[SETTING_SAVE_STATE].assignedKey = SDLK_F1;
setting[SETTING_LOAD_STATE].assignedKey = SDLK_F2;
setting[SETTING_SCREENCAP].assignedKey = SDL_SCANCODE_PRINTSCREEN;
setting[SETTING_END_EMU].assignedKey = SDL_SCANCODE_ESCAPE;
setting[SETTING_SAVE_STATE].assignedKey = SDL_SCANCODE_F1;
setting[SETTING_LOAD_STATE].assignedKey = SDL_SCANCODE_F2;
setting[SETTING_PAUSE].assignedKey = SDLK_F3;
setting[SETTING_RUN_FRAME].assignedKey = SDLK_F4;
setting[SETTING_CAP_DATA].assignedKey = SDLK_F5;
setting[SETTING_CONT_CAP].assignedKey = SDLK_F6;
setting[SETTING_PAUSE].assignedKey = SDL_SCANCODE_F3;
setting[SETTING_RUN_FRAME].assignedKey = SDL_SCANCODE_F4;
setting[SETTING_CAP_DATA].assignedKey = SDL_SCANCODE_F5;
setting[SETTING_CONT_CAP].assignedKey = SDL_SCANCODE_F6;
}
@ -42,7 +42,7 @@ void input::Init(){
SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
SDL_EventState(SDL_MOUSEBUTTONDOWN, SDL_IGNORE);
SDL_EventState(SDL_MOUSEBUTTONUP, SDL_IGNORE);
SDL_EventState(SDL_ACTIVEEVENT, SDL_IGNORE);
SDL_EventState(SDL_WINDOWEVENT, SDL_IGNORE);
for(Uint8 i = 0; i < BUTTON_COUNT; ++i){
controller[0][i].currentState = false;
@ -61,13 +61,13 @@ void input::handleEvent(SDL_Event event){
switch( event.type ){
case SDL_KEYDOWN:
//find if controller key pressed
eventButton = findKeyButton(event.key.keysym.sym);
eventButton = findKeyButton(event.key.keysym.scancode);
if(eventButton != NULL) {
eventButton->currentState = true;
}
//find setting key pressed
settingKey = findSettingButton(event.key.keysym.sym);
settingKey = findSettingButton(event.key.keysym.scancode);
if(settingKey != -1) {
switch (settingKey) {
case SETTING_SCREENCAP:
@ -104,7 +104,7 @@ void input::handleEvent(SDL_Event event){
break;
case SDL_KEYUP:
eventButton = findKeyButton(event.key.keysym.sym);
eventButton = findKeyButton(event.key.keysym.scancode);
if(eventButton != NULL) eventButton->currentState = false;
break;
case SDL_QUIT:
@ -117,7 +117,7 @@ void input::handleEvent(SDL_Event event){
}
button* input::findKeyButton(SDLKey key){
button* input::findKeyButton(SDL_Scancode key){
for(Uint8 i = 0; i < BUTTON_COUNT; ++i){
for(Uint8 j = 0; j < 2; ++j){
if(controller[j][i].assignedKey == key)
@ -127,7 +127,7 @@ button* input::findKeyButton(SDLKey key){
return NULL;
}
int input::findSettingButton(SDLKey key){
int input::findSettingButton(SDL_Scancode key){
for(int i = 0; i < SETTING_COUNT; ++i){
if(setting[i].assignedKey == key) return i;
}
@ -172,10 +172,10 @@ void input::readConfig(string value){
split(value, ',', lineTokens);
if (lineTokens[0].compare("controller") == 0) {
controller[stoi(lineTokens[1])][stoi(lineTokens[2])].assignedKey = (SDLKey)stoi(lineTokens[3]);
controller[stoi(lineTokens[1])][stoi(lineTokens[2])].assignedKey = (SDL_Scancode)stoi(lineTokens[3]);
}
if (lineTokens[0].compare("setting") == 0) {
setting[stoi(lineTokens[1])].assignedKey = (SDLKey)stoi(lineTokens[2]);
setting[stoi(lineTokens[1])].assignedKey = (SDL_Scancode)stoi(lineTokens[2]);
}
}

View file

@ -26,7 +26,7 @@
struct button{
bool recordedState;
bool currentState;
SDLKey assignedKey;
SDL_Scancode assignedKey;
};
class input
@ -42,8 +42,8 @@ public:
~input(void);
void Init();
void handleEvent(SDL_Event event);
button* findKeyButton(SDLKey key);
int findSettingButton(SDLKey key);
button* findKeyButton(SDL_Scancode key);
int findSettingButton(SDL_Scancode key);
Uint8 readReg(Uint8 address);
void writeReg(Uint8 address, Uint8 data);

View file

@ -10,8 +10,8 @@
#include <stdio.h>
#include <tchar.h>
#include <time.h>
#include "SDL/SDL.h"
#include "SDL/SDL_mixer.h"
#include "SDL2/SDL.h"
#include "SDL2/SDL_mixer.h"
#include <GL\glew.h>
#include <gl/gl.h>
#include <gl/glu.h>

View file

@ -54,12 +54,12 @@ void video::init(){
break;
}
if((Surf_Display = SDL_SetVideoMode(screenSizeWidth, screenSizeHeight, 32, SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER | SDL_OPENGL)) == NULL) {
if((Surf_Display = SDL_CreateWindow("HDNes", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, screenSizeWidth, screenSizeHeight, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL)) == NULL) {
initState = false;
writeLog("Cannot create display surface with SDL_SetVideoMode");
return;
}
SDL_WM_SetCaption("HDNes", 0);
glcontext = SDL_GL_CreateContext(Surf_Display);
glewInit();
//init resource
@ -141,6 +141,8 @@ video::~video(void){
}
void video::cleanUp(){
SDL_GL_DeleteContext(glcontext);
SDL_DestroyWindow(Surf_Display);
Surf_Display = NULL;
glDeleteTextures(1, &bgTextureRef);
glDeleteTextures(1, &spTextureRef);
@ -289,7 +291,7 @@ void video::displayFrame(){
capScreen(true);
}
SDL_GL_SwapBuffers();
SDL_GL_SwapWindow(Surf_Display);
//capScreen(false);
}
@ -1799,7 +1801,7 @@ void video::saveScreenToPath(string path, bool useNative){
capScreenQueue.push_back(path);
SDL_Thread* gh;
gh = SDL_CreateThread(video::convertScreenCapToPNG, NULL);
gh = SDL_CreateThread(video::convertScreenCapToPNG, NULL, NULL);
}
else{

View file

@ -156,7 +156,8 @@ struct screenTile{
class video
{
public:
SDL_Surface* Surf_Display;
SDL_Window * Surf_Display;
SDL_GLContext glcontext;
bool initState;
int screenSizeOption;