Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Silversircel

Pages: [1]
1
Calculator C / nSDL showCursor
« on: September 26, 2014, 10:03:59 am »
Hi,

i need to display the mouse cursor in my app.
But it seem "SDL_ShowCursor(SDL_ENABLE)" does not do the job.

quick example:
Code: [Select]
int main()
{
    SDL_Surface *screen;
    bool run = true;
    SDL_Rect rect;
    Uint32 color;
   
    rect.w = 320;
    rect.h = 240;
    rect.x = 0;
    rect.y = 0;
   
    //Show Cursor
    SDL_ShowCursor(SDL_ENABLE);
   
    SDL_Init(SDL_INIT_VIDEO);
    screen = SDL_SetVideoMode(320, 240, has_colors ? 16 : 8, SDL_SWSURFACE);
   
   
    color = SDL_MapRGB(screen->format, 255, 0, 0);
   
    while(run)
    {
        SDL_Event event;
        if(SDL_PollEvent (&event))
        {
            switch(event.type)
            {
                case (SDL_QUIT):
                {
                    run = false;
                }break;

                case(SDL_KEYDOWN):
                {
                    switch(event.key.keysym.sym)
                    {
                        case(SDLK_ESCAPE):
                        {
                            run = false;
                        }break;
                    }
                }break;
            }
        }
       
        SDL_FillRect(screen, &rect, color);
        SDL_Flip(screen);
    }
}
Cursor is not shown. Does anybody knows how to enable the cursor?

Thanks ^^

2
Calculator C / Re: NspireIO - undefined reference problem- ndless-sdk
« on: March 13, 2014, 08:59:44 am »

Problem solved^^
cant use c routine in c++


But I have another question
Is it possible to read single chars from console without tip enter each time? (unbuffered read)


nio examples show:
Code: [Select]

c << "unitbuf test. Press any key" << nio::endl;
c.unsetf(console::unitbuf);
c << "Key pressed!" << nio::endl;
wait_key_pressed();


How do i capture which key was pressed?


Thanks

3
Calculator C / NspireIO - undefined reference problem- ndless-sdk
« on: March 11, 2014, 06:30:58 pm »
Hi everyone,


i'm working on a project that organize my mathematical formula.[/size]Therfor i have to print text on screen.
[/size]If i use nspireIO like the example shows everything works
[/size]
Code: [Select]
console c;

c << "Print Text" << endl;
return 0;

But if i try to use the functions in "nspireio.h", i get the message:
Screen.cpp:(.text+0x64): undefined reference to `nio_fprintf(...)
I'm using "ndless-v3.1-beta-r914-sdk" to build the code. The "libnspireio.a" is located in the .../ndless/lib folder
My code: part of header-file
Code: [Select]

#include <os.h>
#include <nspireio/console.hpp>
#include <nspireio/uart.hpp>
#include <nspireio/nspireio.h>
#include <string.h>



class Screen
{
private:
    static bool instanceFlag;
    static Screen *screen;


    Screen() { //private constructor
}


//Member Var
nio_console c;


public:
    static Screen* getInstance();


    ~Screen()
    {
        instanceFlag = false;
    }


//Member Func
void print(char *cString);
        //...

part of cpp:
Code: [Select]

void Screen::print(char *cString)
{
nio_fprintf(&c, cString);
}

I would like to read single chars from keyboard. After one char has been tipped a searchList() function will search for matches and display them. Next received char will be added to the first one and search,display repeat...
Does anyone knows how to solve the undefined reference problem?
Thanks

4
Nspire I/O / Re: Nspire I/O - Now with C++ support
« on: December 16, 2013, 05:09:18 pm »
Hi ,
every time i pass some variables to nspireio the programm crahes if i try to execute it.
I've no idea whats wrong.
I basicely only modified the exampel to display a cstring and a string. but it doesn't
work...
The programm crahes if i pass the variables with << operator.
Code: [Select]
#include <nspireio/console.hpp>
#include <nspireio/uart.hpp>
#include <string.h>
#include <string>
#include <iostream>

#ifndef NIO_TEST_UART
#define NIO_TEST_UART 0
#endif

using namespace std;
using namespace nio;

int main(void)
{
clrscr();
#if NIO_TEST_UART == 1
nio::uart u;
#endif
nio::console c;

int num = 123;
char cString[] = "Test";
string cppString = "Text";

c.foreground_color(COLOR_BLACK);
c << cString << endl;
c << cppString.c_str() << endl;

wait_key_pressed();
return 0;
}

Does anyone have a clue?
Thanks

Pages: [1]